@styled/typescript-styled-plugin
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -9,3 +9,3 @@ "use strict"; | ||
const vscode_css_languageservice_1 = require("vscode-css-languageservice"); | ||
const vscode_emmet_helper_1 = require("vscode-emmet-helper"); | ||
const emmet_helper_1 = require("@vscode/emmet-helper"); | ||
const vscode = require("vscode-languageserver-types"); | ||
@@ -29,6 +29,7 @@ const config = require("./_config"); | ||
getCached(context, position) { | ||
if (this._completions | ||
&& context.fileName === this._cachedCompletionsFile | ||
&& this._cachedCompletionsPosition && arePositionsEqual(position, this._cachedCompletionsPosition) | ||
&& context.text === this._cachedCompletionsContent) { | ||
if (this._completions && | ||
context.fileName === this._cachedCompletionsFile && | ||
this._cachedCompletionsPosition && | ||
arePositionsEqual(position, this._cachedCompletionsPosition) && | ||
context.text === this._cachedCompletionsContent) { | ||
return this._completions; | ||
@@ -83,3 +84,3 @@ } | ||
getCompletionEntryDetails(context, position, name) { | ||
const item = this.getCompletionItems(context, position).items.find(x => x.label === name); | ||
const item = this.getCompletionItems(context, position).items.find((x) => x.label === name); | ||
if (!item) { | ||
@@ -109,3 +110,3 @@ return { | ||
const stylesheet = this.scssLanguageService.parseStylesheet(doc); | ||
return this.translateDiagnostics(this.scssLanguageService.doValidation(doc, stylesheet), doc, context, context.text).filter(x => !!x); | ||
return this.translateDiagnostics(this.scssLanguageService.doValidation(doc, stylesheet), doc, context, context.text).filter((x) => !!x); | ||
} | ||
@@ -115,8 +116,12 @@ getSupportedCodeFixes() { | ||
} | ||
getCodeFixesAtPosition(context, start, end) { | ||
getCodeFixesAtPosition(context, start, end | ||
// _errorCodes: number[], | ||
// _format: ts.FormatCodeSettings | ||
) { | ||
const doc = this.virtualDocumentFactory.createVirtualDocument(context); | ||
const stylesheet = this.scssLanguageService.parseStylesheet(doc); | ||
const range = this.toVsRange(context, start, end); | ||
const diagnostics = this.scssLanguageService.doValidation(doc, stylesheet) | ||
.filter(diagnostic => overlaps(diagnostic.range, range)); | ||
const diagnostics = this.scssLanguageService | ||
.doValidation(doc, stylesheet) | ||
.filter((diagnostic) => overlaps(diagnostic.range, range)); | ||
return this.translateCodeActions(context, this.scssLanguageService.doCodeActions(doc, range, { diagnostics }, stylesheet)); | ||
@@ -128,3 +133,3 @@ } | ||
return ranges | ||
.filter(range => { | ||
.filter((range) => { | ||
// Filter out ranges outside on last line | ||
@@ -137,3 +142,3 @@ const end = context.toOffset({ | ||
}) | ||
.map(range => this.translateOutliningSpan(context, range)); | ||
.map((range) => this.translateOutliningSpan(context, range)); | ||
} | ||
@@ -170,3 +175,3 @@ toVsRange(context, start, end) { | ||
this.cssLanguageService.setCompletionParticipants([]); | ||
const emmetResults = (0, vscode_emmet_helper_1.doComplete)(doc, virtualPosition, 'css', this.configurationManager.config.emmet) || emptyCompletionList; | ||
const emmetResults = (0, emmet_helper_1.doComplete)(doc, virtualPosition, 'css', this.configurationManager.config.emmet) || emptyCompletionList; | ||
const completionsCss = this.cssLanguageService.doComplete(doc, virtualPosition, stylesheet) || emptyCompletionList; | ||
@@ -185,9 +190,9 @@ const completionsScss = this.scssLanguageService.doComplete(doc, virtualPosition, stylesheet) || emptyCompletionList; | ||
const sourceFile = context.node.getSourceFile(); | ||
return diagnostics.map(diag => this.translateDiagnostic(diag, sourceFile, doc, context, content)); | ||
return diagnostics.map((diag) => this.translateDiagnostic(diag, sourceFile, doc, context, content)); | ||
} | ||
translateDiagnostic(diagnostic, file, doc, context, content) { | ||
// Make sure returned error is within the real document | ||
if (diagnostic.range.start.line === 0 | ||
|| diagnostic.range.start.line > doc.lineCount | ||
|| diagnostic.range.start.character >= content.length) { | ||
if (diagnostic.range.start.line === 0 || | ||
diagnostic.range.start.line > doc.lineCount || | ||
diagnostic.range.start.character >= content.length) { | ||
return undefined; | ||
@@ -228,3 +233,5 @@ } | ||
start, | ||
length: hover.range ? context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition(hover.range.end)) - start : 1, | ||
length: hover.range | ||
? context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition(hover.range.end)) - start | ||
: 1, | ||
}, | ||
@@ -246,3 +253,3 @@ displayParts: [], | ||
description: vsAction.title, | ||
changes: edits.map(edit => this.translateTextEditToFileTextChange(context, edit)), | ||
changes: edits.map((edit) => this.translateTextEditToFileTextChange(context, edit)), | ||
}); | ||
@@ -258,3 +265,4 @@ } | ||
fileName: context.fileName, | ||
textChanges: [{ | ||
textChanges: [ | ||
{ | ||
newText: textEdit.newText, | ||
@@ -265,8 +273,15 @@ span: { | ||
}, | ||
}], | ||
}, | ||
], | ||
}; | ||
} | ||
translateOutliningSpan(context, range) { | ||
const startOffset = context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition({ line: range.startLine, character: range.startCharacter || 0 })); | ||
const endOffset = context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition({ line: range.endLine, character: range.endCharacter || 0 })); | ||
const startOffset = context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition({ | ||
line: range.startLine, | ||
character: range.startCharacter || 0, | ||
})); | ||
const endOffset = context.toOffset(this.virtualDocumentFactory.fromVirtualDocPosition({ | ||
line: range.endLine, | ||
character: range.endCharacter || 0, | ||
})); | ||
const span = { | ||
@@ -287,3 +302,3 @@ start: startOffset, | ||
function filterScssCompletionItems(items) { | ||
return items.filter(item => (item.kind === vscode.CompletionItemKind.Function && item.label.substr(0, 1) === ':')); | ||
return items.filter((item) => item.kind === vscode.CompletionItemKind.Function && item.label.substr(0, 1) === ':'); | ||
} | ||
@@ -298,3 +313,3 @@ function translateCompletionItemsToCompletionInfo(typescript, items, doc, wrapper) { | ||
isNewIdentifierLocation: false, | ||
entries: items.items.map(x => translateCompetionEntry(typescript, x, doc, wrapper)), | ||
entries: items.items.map((x) => translateCompetionEntry(typescript, x, doc, wrapper)), | ||
}; | ||
@@ -385,7 +400,9 @@ } | ||
} | ||
return [{ | ||
return [ | ||
{ | ||
kind: 'text', | ||
text: typeof text === 'string' ? text : text.value, | ||
}]; | ||
}, | ||
]; | ||
} | ||
//# sourceMappingURL=_language-service.js.map |
import { Logger } from 'typescript-template-language-service-decorator'; | ||
import * as ts from 'typescript/lib/tsserverlibrary'; | ||
export declare class LanguageServiceLogger implements Logger { | ||
@@ -3,0 +4,0 @@ private readonly info; |
@@ -37,3 +37,5 @@ "use strict"; | ||
return { | ||
get tags() { return configManager.config.tags; }, | ||
get tags() { | ||
return configManager.config.tags; | ||
}, | ||
enableForStringWithSubstitutions: true, | ||
@@ -40,0 +42,0 @@ getSubstitutions(templateString, spans) { |
import { TemplateContext } from 'typescript-template-language-service-decorator'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
import * as ts from 'typescript/lib/tsserverlibrary'; | ||
/** | ||
@@ -4,0 +5,0 @@ * Handles mapping between template contents to virtual documents. |
@@ -50,3 +50,5 @@ "use strict"; | ||
const tag = (_b = (_a = context.node.parent) === null || _a === void 0 ? void 0 : _a.tag) === null || _b === void 0 ? void 0 : _b.escapedText; | ||
return tag === 'keyframes' ? StyledVirtualDocumentFactory.wrapperPreKeyframes : StyledVirtualDocumentFactory.wrapperPreRoot; | ||
return tag === 'keyframes' | ||
? StyledVirtualDocumentFactory.wrapperPreKeyframes | ||
: StyledVirtualDocumentFactory.wrapperPreRoot; | ||
} | ||
@@ -53,0 +55,0 @@ } |
{ | ||
"name": "@styled/typescript-styled-plugin", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "TypeScript language service plugin that adds IntelliSense for styled components", | ||
@@ -23,5 +23,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@vscode/emmet-helper": "^2.8.4", | ||
"typescript-template-language-service-decorator": "^2.3.1", | ||
"vscode-css-languageservice": "^6.2.1", | ||
"vscode-emmet-helper": "^2.6.4", | ||
"vscode-languageserver-textdocument": "^1.0.7", | ||
@@ -28,0 +28,0 @@ "vscode-languageserver-types": "^3.17.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81061
946
+ Added@vscode/emmet-helper@^2.8.4
+ Added@vscode/emmet-helper@2.10.0(transitive)
- Removedvscode-emmet-helper@^2.6.4
- Removedvscode-emmet-helper@2.6.4(transitive)
- Removedvscode-nls@5.2.0(transitive)
- Removedvscode-uri@2.1.2(transitive)