summaryrefslogtreecommitdiff
path: root/tools/language-server/src/plugins/css/StyleAttributeDocument.ts
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-08-26 13:14:47 -0400
committerGravatar GitHub <noreply@github.com> 2021-08-26 13:14:47 -0400
commitc4cfc0d5fb26e39be7c10ba1ecdc32656870b10d (patch)
treee8dde32fb8ef88f6b9bd6276e5ca9194fb487ba9 /tools/language-server/src/plugins/css/StyleAttributeDocument.ts
parentc83d4817336f73348dbcedf493f2e5d2402e9e49 (diff)
downloadastro-c4cfc0d5fb26e39be7c10ba1ecdc32656870b10d.tar.gz
astro-c4cfc0d5fb26e39be7c10ba1ecdc32656870b10d.tar.zst
astro-c4cfc0d5fb26e39be7c10ba1ecdc32656870b10d.zip
Remove VSCode and Langauge Server from this monorepo (#1230)
* Remove VSCode and Langauge Server from this monorepo * Adds back in the syntax files
Diffstat (limited to 'tools/language-server/src/plugins/css/StyleAttributeDocument.ts')
-rw-r--r--tools/language-server/src/plugins/css/StyleAttributeDocument.ts72
1 files changed, 0 insertions, 72 deletions
diff --git a/tools/language-server/src/plugins/css/StyleAttributeDocument.ts b/tools/language-server/src/plugins/css/StyleAttributeDocument.ts
deleted file mode 100644
index e00398037..000000000
--- a/tools/language-server/src/plugins/css/StyleAttributeDocument.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { Stylesheet } from 'vscode-css-languageservice';
-import { Position } from 'vscode-languageserver';
-import { getLanguageService } from './service';
-import { Document, DocumentMapper, ReadableDocument } from '../../core/documents';
-
-const PREFIX = '__ {';
-const SUFFIX = '}';
-
-export class StyleAttributeDocument extends ReadableDocument implements DocumentMapper {
- readonly version = this.parent.version;
-
- public stylesheet: Stylesheet;
- public languageId = 'css';
-
- constructor(private readonly parent: Document, private readonly attrStart: number, private readonly attrEnd: number) {
- super();
-
- this.stylesheet = getLanguageService(this.languageId).parseStylesheet(this);
- }
-
- /**
- * Get the fragment position relative to the parent
- * @param pos Position in fragment
- */
- getOriginalPosition(pos: Position): Position {
- const parentOffset = this.attrStart + this.offsetAt(pos) - PREFIX.length;
- return this.parent.positionAt(parentOffset);
- }
-
- /**
- * Get the position relative to the start of the fragment
- * @param pos Position in parent
- */
- getGeneratedPosition(pos: Position): Position {
- const fragmentOffset = this.parent.offsetAt(pos) - this.attrStart + PREFIX.length;
- return this.positionAt(fragmentOffset);
- }
-
- /**
- * Returns true if the given parent position is inside of this fragment
- * @param pos Position in parent
- */
- isInGenerated(pos: Position): boolean {
- const offset = this.parent.offsetAt(pos);
- return offset >= this.attrStart && offset <= this.attrEnd;
- }
-
- /**
- * Get the fragment text from the parent
- */
- getText(): string {
- return PREFIX + this.parent.getText().slice(this.attrStart, this.attrEnd) + SUFFIX;
- }
-
- /**
- * Returns the length of the fragment as calculated from the start and end position
- */
- getTextLength(): number {
- return PREFIX.length + this.attrEnd - this.attrStart + SUFFIX.length;
- }
-
- /**
- * Return the parent file path
- */
- getFilePath(): string | null {
- return this.parent.getFilePath();
- }
-
- getURL() {
- return this.parent.getURL();
- }
-}