mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Import the semantic highlighter from typescript-vscode-sh-plugin (#39119)
* Initial import of the vscode semantic highlight code * Adds the ability to test modern semantic classification via strings instead of numbers * Adds existing tests * Port over the semantic classification tests * Update baselines * Update src/harness/fourslashImpl.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Handle feedback from #39119 * Consistent formatting in the 2020 classifier * Update baselines * Apply suggestions from code review Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> * Update src/harness/fourslashImpl.ts Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> * Reafactor after comments * Use 2020 everywhere * Handle feedback * WIP - don't provide a breaking change * Fix all build errors * Update baselines * Update src/services/classifier2020.ts Co-authored-by: Sheetal Nandi <shkamat@microsoft.com> * Addresses Ron's feedback Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
@@ -747,7 +747,7 @@ namespace ts.server {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications {
|
||||
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan, _format?: SemanticClassificationFormat): Classifications {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
|
||||
@@ -2492,7 +2492,49 @@ namespace FourSlash {
|
||||
Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos)!, "**"));
|
||||
}
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[], sourceFileText: string) {
|
||||
private classificationToIdentifier(classification: number){
|
||||
|
||||
const tokenTypes: string[] = [];
|
||||
tokenTypes[ts.classifier.v2020.TokenType.class] = "class";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.enum] = "enum";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.interface] = "interface";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.namespace] = "namespace";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.typeParameter] = "typeParameter";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.type] = "type";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.parameter] = "parameter";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.variable] = "variable";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.enumMember] = "enumMember";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.property] = "property";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.function] = "function";
|
||||
tokenTypes[ts.classifier.v2020.TokenType.member] = "member";
|
||||
|
||||
const tokenModifiers: string[] = [];
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.async] = "async";
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.declaration] = "declaration";
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.readonly] = "readonly";
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.static] = "static";
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.local] = "local";
|
||||
tokenModifiers[ts.classifier.v2020.TokenModifier.defaultLibrary] = "defaultLibrary";
|
||||
|
||||
|
||||
function getTokenTypeFromClassification(tsClassification: number): number | undefined {
|
||||
if (tsClassification > ts.classifier.v2020.TokenEncodingConsts.modifierMask) {
|
||||
return (tsClassification >> ts.classifier.v2020.TokenEncodingConsts.typeOffset) - 1;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTokenModifierFromClassification(tsClassification: number) {
|
||||
return tsClassification & ts.classifier.v2020.TokenEncodingConsts.modifierMask;
|
||||
}
|
||||
|
||||
const typeIdx = getTokenTypeFromClassification(classification) || 0;
|
||||
const modSet = getTokenModifierFromClassification(classification);
|
||||
|
||||
return [tokenTypes[typeIdx], ...tokenModifiers.filter((_, i) => modSet & 1 << i)].join(".");
|
||||
}
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string | number, text?: string; textSpan?: TextSpan }[], actual: (ts.ClassifiedSpan | ts.ClassifiedSpan2020)[] , sourceFileText: string) {
|
||||
if (actual.length !== expected.length) {
|
||||
this.raiseError("verifyClassifications failed - expected total classifications to be " + expected.length +
|
||||
", but was " + actual.length +
|
||||
@@ -2501,10 +2543,12 @@ namespace FourSlash {
|
||||
|
||||
ts.zipWith(expected, actual, (expectedClassification, actualClassification) => {
|
||||
const expectedType = expectedClassification.classificationType;
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
const actualType = typeof actualClassification.classificationType === "number" ? this.classificationToIdentifier(actualClassification.classificationType) : actualClassification.classificationType;
|
||||
|
||||
if (expectedType !== actualType) {
|
||||
this.raiseError("verifyClassifications failed - expected classifications type to be " +
|
||||
expectedType + ", but was " +
|
||||
actualClassification.classificationType +
|
||||
actualType +
|
||||
jsonMismatchString());
|
||||
}
|
||||
|
||||
@@ -2555,10 +2599,30 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) {
|
||||
public replaceWithSemanticClassifications(format: ts.SemanticClassificationFormat.TwentyTwenty) {
|
||||
const actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
|
||||
ts.createTextSpan(0, this.activeFile.content.length));
|
||||
ts.createTextSpan(0, this.activeFile.content.length), format);
|
||||
const replacement = [`const c2 = classification("2020");`,`verify.semanticClassificationsAre("2020",`];
|
||||
for (const a of actual) {
|
||||
const identifier = this.classificationToIdentifier(a.classificationType as number);
|
||||
const text = this.activeFile.content.slice(a.textSpan.start, a.textSpan.start + a.textSpan.length);
|
||||
replacement.push(` c2.semanticToken("${identifier}", "${text}"), `);
|
||||
};
|
||||
replacement.push(");");
|
||||
|
||||
throw new Error("You need to change the source code of fourslash test to use replaceWithSemanticClassifications");
|
||||
|
||||
// const fs = require("fs");
|
||||
// const testfilePath = this.originalInputFileName.slice(1);
|
||||
// const testfile = fs.readFileSync(testfilePath, "utf8");
|
||||
// const newfile = testfile.replace("verify.replaceWithSemanticClassifications(\"2020\")", replacement.join("\n"));
|
||||
// fs.writeFileSync(testfilePath, newfile);
|
||||
}
|
||||
|
||||
|
||||
public verifySemanticClassifications(format: ts.SemanticClassificationFormat, expected: { classificationType: string | number; text?: string }[]) {
|
||||
const actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
|
||||
ts.createTextSpan(0, this.activeFile.content.length), format);
|
||||
this.verifyClassifications(expected, actual, this.activeFile.content);
|
||||
}
|
||||
|
||||
@@ -3859,7 +3923,7 @@ namespace FourSlash {
|
||||
const cancellation = new FourSlashInterface.Cancellation(state);
|
||||
// eslint-disable-next-line no-eval
|
||||
const f = eval(wrappedCode);
|
||||
f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, FourSlashInterface.Completion, verifyOperationIsCancelled);
|
||||
f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.classification, FourSlashInterface.Completion, verifyOperationIsCancelled);
|
||||
}
|
||||
catch (err) {
|
||||
// ensure 'source-map-support' is triggered while we still have the handler attached by accessing `error.stack`.
|
||||
|
||||
@@ -524,8 +524,12 @@ namespace FourSlashInterface {
|
||||
/**
|
||||
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
|
||||
*/
|
||||
public semanticClassificationsAre(...classifications: Classification[]) {
|
||||
this.state.verifySemanticClassifications(classifications);
|
||||
public semanticClassificationsAre(format: ts.SemanticClassificationFormat, ...classifications: Classification[]) {
|
||||
this.state.verifySemanticClassifications(format, classifications);
|
||||
}
|
||||
|
||||
public replaceWithSemanticClassifications(format: ts.SemanticClassificationFormat.TwentyTwenty) {
|
||||
this.state.replaceWithSemanticClassifications(format);
|
||||
}
|
||||
|
||||
public renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, expectedRange?: FourSlash.Range, options?: ts.RenameInfoOptions) {
|
||||
@@ -768,101 +772,127 @@ namespace FourSlashInterface {
|
||||
}
|
||||
}
|
||||
|
||||
interface Classification {
|
||||
interface OlderClassification {
|
||||
classificationType: ts.ClassificationTypeNames;
|
||||
text: string;
|
||||
textSpan?: FourSlash.TextSpan;
|
||||
}
|
||||
export namespace Classification {
|
||||
export function comment(text: string, position?: number): Classification {
|
||||
|
||||
// The VS Code LSP
|
||||
interface ModernClassification {
|
||||
classificationType: string;
|
||||
text?: string;
|
||||
textSpan?: FourSlash.TextSpan;
|
||||
}
|
||||
|
||||
type Classification = OlderClassification | ModernClassification;
|
||||
|
||||
export function classification(format: ts.SemanticClassificationFormat) {
|
||||
|
||||
function semanticToken(identifier: string, text: string, _position: number): Classification {
|
||||
return {
|
||||
classificationType: identifier,
|
||||
text
|
||||
};
|
||||
}
|
||||
|
||||
if (format === ts.SemanticClassificationFormat.TwentyTwenty) {
|
||||
return {
|
||||
semanticToken
|
||||
};
|
||||
}
|
||||
|
||||
// Defaults to the previous semantic classifier factory functions
|
||||
|
||||
function comment(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.comment, text, position);
|
||||
}
|
||||
|
||||
export function identifier(text: string, position?: number): Classification {
|
||||
function identifier(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.identifier, text, position);
|
||||
}
|
||||
|
||||
export function keyword(text: string, position?: number): Classification {
|
||||
function keyword(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.keyword, text, position);
|
||||
}
|
||||
|
||||
export function numericLiteral(text: string, position?: number): Classification {
|
||||
function numericLiteral(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.numericLiteral, text, position);
|
||||
}
|
||||
|
||||
export function operator(text: string, position?: number): Classification {
|
||||
function operator(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.operator, text, position);
|
||||
}
|
||||
|
||||
export function stringLiteral(text: string, position?: number): Classification {
|
||||
function stringLiteral(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.stringLiteral, text, position);
|
||||
}
|
||||
|
||||
export function whiteSpace(text: string, position?: number): Classification {
|
||||
function whiteSpace(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.whiteSpace, text, position);
|
||||
}
|
||||
|
||||
export function text(text: string, position?: number): Classification {
|
||||
function text(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.text, text, position);
|
||||
}
|
||||
|
||||
export function punctuation(text: string, position?: number): Classification {
|
||||
function punctuation(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.punctuation, text, position);
|
||||
}
|
||||
|
||||
export function docCommentTagName(text: string, position?: number): Classification {
|
||||
function docCommentTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.docCommentTagName, text, position);
|
||||
}
|
||||
|
||||
export function className(text: string, position?: number): Classification {
|
||||
function className(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.className, text, position);
|
||||
}
|
||||
|
||||
export function enumName(text: string, position?: number): Classification {
|
||||
function enumName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.enumName, text, position);
|
||||
}
|
||||
|
||||
export function interfaceName(text: string, position?: number): Classification {
|
||||
function interfaceName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.interfaceName, text, position);
|
||||
}
|
||||
|
||||
export function moduleName(text: string, position?: number): Classification {
|
||||
function moduleName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.moduleName, text, position);
|
||||
}
|
||||
|
||||
export function typeParameterName(text: string, position?: number): Classification {
|
||||
function typeParameterName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.typeParameterName, text, position);
|
||||
}
|
||||
|
||||
export function parameterName(text: string, position?: number): Classification {
|
||||
function parameterName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.parameterName, text, position);
|
||||
}
|
||||
|
||||
export function typeAliasName(text: string, position?: number): Classification {
|
||||
function typeAliasName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.typeAliasName, text, position);
|
||||
}
|
||||
|
||||
export function jsxOpenTagName(text: string, position?: number): Classification {
|
||||
function jsxOpenTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxOpenTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxCloseTagName(text: string, position?: number): Classification {
|
||||
function jsxCloseTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxCloseTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxSelfClosingTagName(text: string, position?: number): Classification {
|
||||
function jsxSelfClosingTagName(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxSelfClosingTagName, text, position);
|
||||
}
|
||||
|
||||
export function jsxAttribute(text: string, position?: number): Classification {
|
||||
function jsxAttribute(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxAttribute, text, position);
|
||||
}
|
||||
|
||||
export function jsxText(text: string, position?: number): Classification {
|
||||
function jsxText(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxText, text, position);
|
||||
}
|
||||
|
||||
export function jsxAttributeStringLiteralValue(text: string, position?: number): Classification {
|
||||
function jsxAttributeStringLiteralValue(text: string, position?: number): Classification {
|
||||
return getClassification(ts.ClassificationTypeNames.jsxAttributeStringLiteralValue, text, position);
|
||||
}
|
||||
|
||||
@@ -870,7 +900,35 @@ namespace FourSlashInterface {
|
||||
const textSpan = position === undefined ? undefined : { start: position, end: position + text.length };
|
||||
return { classificationType, text, textSpan };
|
||||
}
|
||||
|
||||
return {
|
||||
comment,
|
||||
identifier,
|
||||
keyword,
|
||||
numericLiteral,
|
||||
operator,
|
||||
stringLiteral,
|
||||
whiteSpace,
|
||||
text,
|
||||
punctuation,
|
||||
docCommentTagName,
|
||||
className,
|
||||
enumName,
|
||||
interfaceName,
|
||||
moduleName,
|
||||
typeParameterName,
|
||||
parameterName,
|
||||
typeAliasName,
|
||||
jsxOpenTagName,
|
||||
jsxCloseTagName,
|
||||
jsxSelfClosingTagName,
|
||||
jsxAttribute,
|
||||
jsxText,
|
||||
jsxAttributeStringLiteralValue,
|
||||
getClassification
|
||||
};
|
||||
}
|
||||
|
||||
export namespace Completion {
|
||||
export import SortText = ts.Completions.SortText;
|
||||
export import CompletionSource = ts.Completions.CompletionSource;
|
||||
|
||||
@@ -461,14 +461,15 @@ namespace Harness.LanguageService {
|
||||
getSyntacticClassifications(fileName: string, span: ts.TextSpan): ts.ClassifiedSpan[] {
|
||||
return unwrapJSONCallResult(this.shim.getSyntacticClassifications(fileName, span.start, span.length));
|
||||
}
|
||||
getSemanticClassifications(fileName: string, span: ts.TextSpan): ts.ClassifiedSpan[] {
|
||||
return unwrapJSONCallResult(this.shim.getSemanticClassifications(fileName, span.start, span.length));
|
||||
getSemanticClassifications(fileName: string, span: ts.TextSpan, format?: ts.SemanticClassificationFormat): ts.ClassifiedSpan[] {
|
||||
return unwrapJSONCallResult(this.shim.getSemanticClassifications(fileName, span.start, span.length, format));
|
||||
}
|
||||
getEncodedSyntacticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications {
|
||||
return unwrapJSONCallResult(this.shim.getEncodedSyntacticClassifications(fileName, span.start, span.length));
|
||||
}
|
||||
getEncodedSemanticClassifications(fileName: string, span: ts.TextSpan): ts.Classifications {
|
||||
return unwrapJSONCallResult(this.shim.getEncodedSemanticClassifications(fileName, span.start, span.length));
|
||||
getEncodedSemanticClassifications(fileName: string, span: ts.TextSpan, format?: ts.SemanticClassificationFormat): ts.Classifications {
|
||||
const responseFormat = format || ts.SemanticClassificationFormat.Original;
|
||||
return unwrapJSONCallResult(this.shim.getEncodedSemanticClassifications(fileName, span.start, span.length, responseFormat));
|
||||
}
|
||||
getCompletionsAtPosition(fileName: string, position: number, preferences: ts.UserPreferences | undefined): ts.CompletionInfo {
|
||||
return unwrapJSONCallResult(this.shim.getCompletionsAtPosition(fileName, position, preferences));
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
/** @internal */
|
||||
namespace ts.classifier.v2020 {
|
||||
|
||||
export const enum TokenEncodingConsts {
|
||||
typeOffset = 8,
|
||||
modifierMask = (1 << typeOffset) - 1
|
||||
}
|
||||
|
||||
export const enum TokenType {
|
||||
class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member
|
||||
}
|
||||
|
||||
export const enum TokenModifier {
|
||||
declaration, static, async, readonly, defaultLibrary, local
|
||||
}
|
||||
|
||||
/** This is mainly used internally for testing */
|
||||
export function getSemanticClassifications(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan2020[] {
|
||||
const classifications = getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span);
|
||||
|
||||
Debug.assert(classifications.spans.length % 3 === 0);
|
||||
const dense = classifications.spans;
|
||||
const result: ClassifiedSpan2020[] = [];
|
||||
for (let i = 0; i < dense.length; i += 3) {
|
||||
result.push({
|
||||
textSpan: createTextSpan(dense[i], dense[i + 1]),
|
||||
classificationType: dense[i + 2]
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getEncodedSemanticClassifications(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications {
|
||||
return {
|
||||
spans: getSemanticTokens(program, sourceFile, span, cancellationToken),
|
||||
endOfLineState: EndOfLineState.None
|
||||
};
|
||||
}
|
||||
|
||||
function getSemanticTokens(program: Program, sourceFile: SourceFile, span: TextSpan, cancellationToken: CancellationToken): number[] {
|
||||
const resultTokens: number[] = [];
|
||||
|
||||
const collector = (node: Node, typeIdx: number, modifierSet: number) => {
|
||||
resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << TokenEncodingConsts.typeOffset) + modifierSet);
|
||||
};
|
||||
|
||||
if (program && sourceFile) {
|
||||
collectTokens(program, sourceFile, span, collector, cancellationToken);
|
||||
}
|
||||
return resultTokens;
|
||||
}
|
||||
|
||||
function collectTokens(program: Program, sourceFile: SourceFile, span: TextSpan, collector: (node: Node, tokenType: number, tokenModifier: number) => void, cancellationToken: CancellationToken) {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
|
||||
let inJSXElement = false;
|
||||
|
||||
function visit(node: Node) {
|
||||
switch(node.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
}
|
||||
|
||||
if (!node || !textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) {
|
||||
return;
|
||||
}
|
||||
const prevInJSXElement = inJSXElement;
|
||||
if (isJsxElement(node) || isJsxSelfClosingElement(node)) {
|
||||
inJSXElement = true;
|
||||
}
|
||||
if (isJsxExpression(node)) {
|
||||
inJSXElement = false;
|
||||
}
|
||||
|
||||
if (isIdentifier(node) && !inJSXElement && !inImportClause(node)) {
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
if (symbol) {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
symbol = typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
let typeIdx = classifySymbol(symbol, getMeaningFromLocation(node));
|
||||
if (typeIdx !== undefined) {
|
||||
let modifierSet = 0;
|
||||
if (node.parent) {
|
||||
const parentIsDeclaration = (isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx);
|
||||
if (parentIsDeclaration && (<NamedDeclaration>node.parent).name === node) {
|
||||
modifierSet = 1 << TokenModifier.declaration;
|
||||
}
|
||||
}
|
||||
|
||||
// property declaration in constructor
|
||||
if (typeIdx === TokenType.parameter && isRightSideOfQualifiedNameOrPropertyAccess(node)) {
|
||||
typeIdx = TokenType.property;
|
||||
}
|
||||
|
||||
typeIdx = reclassifyByType(typeChecker, node, typeIdx);
|
||||
|
||||
const decl = symbol.valueDeclaration;
|
||||
if (decl) {
|
||||
const modifiers = getCombinedModifierFlags(decl);
|
||||
const nodeFlags = getCombinedNodeFlags(decl);
|
||||
if (modifiers & ModifierFlags.Static) {
|
||||
modifierSet |= 1 << TokenModifier.static;
|
||||
}
|
||||
if (modifiers & ModifierFlags.Async) {
|
||||
modifierSet |= 1 << TokenModifier.async;
|
||||
}
|
||||
if (typeIdx !== TokenType.class && typeIdx !== TokenType.interface) {
|
||||
if ((modifiers & ModifierFlags.Readonly) || (nodeFlags & NodeFlags.Const) || (symbol.getFlags() & SymbolFlags.EnumMember)) {
|
||||
modifierSet |= 1 << TokenModifier.readonly;
|
||||
}
|
||||
}
|
||||
if ((typeIdx === TokenType.variable || typeIdx === TokenType.function) && isLocalDeclaration(decl, sourceFile)) {
|
||||
modifierSet |= 1 << TokenModifier.local;
|
||||
}
|
||||
if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) {
|
||||
modifierSet |= 1 << TokenModifier.defaultLibrary;
|
||||
}
|
||||
}
|
||||
else if (symbol.declarations && symbol.declarations.some(d => program.isSourceFileDefaultLibrary(d.getSourceFile()))) {
|
||||
modifierSet |= 1 << TokenModifier.defaultLibrary;
|
||||
}
|
||||
|
||||
collector(node, typeIdx, modifierSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
forEachChild(node, visit);
|
||||
|
||||
inJSXElement = prevInJSXElement;
|
||||
}
|
||||
visit(sourceFile);
|
||||
}
|
||||
|
||||
function classifySymbol(symbol: Symbol, meaning: SemanticMeaning): TokenType | undefined {
|
||||
const flags = symbol.getFlags();
|
||||
if (flags & SymbolFlags.Class) {
|
||||
return TokenType.class;
|
||||
}
|
||||
else if (flags & SymbolFlags.Enum) {
|
||||
return TokenType.enum;
|
||||
}
|
||||
else if (flags & SymbolFlags.TypeAlias) {
|
||||
return TokenType.type;
|
||||
}
|
||||
else if (flags & SymbolFlags.Interface) {
|
||||
if (meaning & SemanticMeaning.Type) {
|
||||
return TokenType.interface;
|
||||
}
|
||||
}
|
||||
else if (flags & SymbolFlags.TypeParameter) {
|
||||
return TokenType.typeParameter;
|
||||
}
|
||||
let decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
|
||||
if (decl && isBindingElement(decl)) {
|
||||
decl = getDeclarationForBindingElement(decl);
|
||||
}
|
||||
return decl && tokenFromDeclarationMapping.get(decl.kind);
|
||||
}
|
||||
|
||||
function reclassifyByType(typeChecker: TypeChecker, node: Node, typeIdx: TokenType): TokenType {
|
||||
// type based classifications
|
||||
if (typeIdx === TokenType.variable || typeIdx === TokenType.property || typeIdx === TokenType.parameter) {
|
||||
const type = typeChecker.getTypeAtLocation(node);
|
||||
if (type) {
|
||||
const test = (condition: (type: Type) => boolean) => {
|
||||
return condition(type) || type.isUnion() && type.types.some(condition);
|
||||
};
|
||||
if (typeIdx !== TokenType.parameter && test(t => t.getConstructSignatures().length > 0)) {
|
||||
return TokenType.class;
|
||||
}
|
||||
if (test(t => t.getCallSignatures().length > 0) && !test(t => t.getProperties().length > 0) || isExpressionInCallExpression(node)) {
|
||||
return typeIdx === TokenType.property ? TokenType.member : TokenType.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeIdx;
|
||||
}
|
||||
|
||||
function isLocalDeclaration(decl: Declaration, sourceFile: SourceFile): boolean {
|
||||
if (isBindingElement(decl)) {
|
||||
decl = getDeclarationForBindingElement(decl);
|
||||
}
|
||||
if (isVariableDeclaration(decl)) {
|
||||
return (!isSourceFile(decl.parent.parent.parent) || isCatchClause(decl.parent)) && decl.getSourceFile() === sourceFile;
|
||||
}
|
||||
else if (isFunctionDeclaration(decl)) {
|
||||
return !isSourceFile(decl.parent) && decl.getSourceFile() === sourceFile;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getDeclarationForBindingElement(element: BindingElement): VariableDeclaration | ParameterDeclaration {
|
||||
while (true) {
|
||||
if (isBindingElement(element.parent.parent)) {
|
||||
element = element.parent.parent;
|
||||
}
|
||||
else {
|
||||
return element.parent.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function inImportClause(node: Node): boolean {
|
||||
const parent = node.parent;
|
||||
return parent && (isImportClause(parent) || isImportSpecifier(parent) || isNamespaceImport(parent));
|
||||
}
|
||||
|
||||
function isExpressionInCallExpression(node: Node): boolean {
|
||||
while (isRightSideOfQualifiedNameOrPropertyAccess(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return isCallExpression(node.parent) && node.parent.expression === node;
|
||||
}
|
||||
|
||||
function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean {
|
||||
return (isQualifiedName(node.parent) && node.parent.right === node) || (isPropertyAccessExpression(node.parent) && node.parent.name === node);
|
||||
}
|
||||
|
||||
const tokenFromDeclarationMapping = new Map<SyntaxKind, TokenType>([
|
||||
[SyntaxKind.VariableDeclaration, TokenType.variable],
|
||||
[SyntaxKind.Parameter, TokenType.parameter],
|
||||
[SyntaxKind.PropertyDeclaration, TokenType.property],
|
||||
[SyntaxKind.ModuleDeclaration, TokenType.namespace],
|
||||
[SyntaxKind.EnumDeclaration, TokenType.enum],
|
||||
[SyntaxKind.EnumMember, TokenType.enumMember],
|
||||
[SyntaxKind.ClassDeclaration, TokenType.class],
|
||||
[SyntaxKind.MethodDeclaration, TokenType.member],
|
||||
[SyntaxKind.FunctionDeclaration, TokenType.function],
|
||||
[SyntaxKind.FunctionExpression, TokenType.function],
|
||||
[SyntaxKind.MethodSignature, TokenType.member],
|
||||
[SyntaxKind.GetAccessor, TokenType.property],
|
||||
[SyntaxKind.SetAccessor, TokenType.property],
|
||||
[SyntaxKind.PropertySignature, TokenType.property],
|
||||
[SyntaxKind.InterfaceDeclaration, TokenType.interface],
|
||||
[SyntaxKind.TypeAliasDeclaration, TokenType.type],
|
||||
[SyntaxKind.TypeParameter, TokenType.typeParameter],
|
||||
[SyntaxKind.PropertyAssignment, TokenType.property],
|
||||
[SyntaxKind.ShorthandPropertyAssignment, TokenType.property]
|
||||
]);
|
||||
}
|
||||
@@ -1827,22 +1827,37 @@ namespace ts {
|
||||
return kind === ScriptKind.TS || kind === ScriptKind.TSX;
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[] {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return [];
|
||||
}
|
||||
synchronizeHostData();
|
||||
return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
|
||||
const responseFormat = format || SemanticClassificationFormat.Original;
|
||||
if (responseFormat === SemanticClassificationFormat.TwentyTwenty) {
|
||||
return classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span);
|
||||
}
|
||||
else {
|
||||
return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
}
|
||||
}
|
||||
|
||||
function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications {
|
||||
function getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return { spans: [], endOfLineState: EndOfLineState.None };
|
||||
}
|
||||
synchronizeHostData();
|
||||
return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
|
||||
const responseFormat = format || SemanticClassificationFormat.Original;
|
||||
if (responseFormat === SemanticClassificationFormat.Original) {
|
||||
return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
}
|
||||
else {
|
||||
return classifier.v2020.getEncodedSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span);
|
||||
}
|
||||
}
|
||||
|
||||
function getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
|
||||
@@ -145,9 +145,9 @@ namespace ts {
|
||||
getCompilerOptionsDiagnostics(): string;
|
||||
|
||||
getSyntacticClassifications(fileName: string, start: number, length: number): string;
|
||||
getSemanticClassifications(fileName: string, start: number, length: number): string;
|
||||
getSemanticClassifications(fileName: string, start: number, length: number, format?: SemanticClassificationFormat): string;
|
||||
getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string;
|
||||
getEncodedSemanticClassifications(fileName: string, start: number, length: number): string;
|
||||
getEncodedSemanticClassifications(fileName: string, start: number, length: number, format?: SemanticClassificationFormat): string;
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number, preferences: UserPreferences | undefined): string;
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: string/*Services.FormatCodeOptions*/ | undefined, source: string | undefined, preferences: UserPreferences | undefined): string;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"types.ts",
|
||||
"utilities.ts",
|
||||
"classifier.ts",
|
||||
"classifier2020.ts",
|
||||
"stringCompletions.ts",
|
||||
"completions.ts",
|
||||
"documentHighlights.ts",
|
||||
|
||||
+24
-2
@@ -319,6 +319,11 @@ namespace ts {
|
||||
|
||||
export type WithMetadata<T> = T & { metadata?: unknown; };
|
||||
|
||||
export const enum SemanticClassificationFormat {
|
||||
Original = "original",
|
||||
TwentyTwenty = "2020"
|
||||
}
|
||||
|
||||
//
|
||||
// Public services of a language service instance associated
|
||||
// with a language service host instance
|
||||
@@ -382,13 +387,25 @@ namespace ts {
|
||||
|
||||
/** @deprecated Use getEncodedSyntacticClassifications instead. */
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
|
||||
/** @deprecated Use getEncodedSemanticClassifications instead. */
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSemanticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
|
||||
// Encoded as triples of [start, length, ClassificationType].
|
||||
/** Encoded as triples of [start, length, ClassificationType]. */
|
||||
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
|
||||
/**
|
||||
* Gets semantic highlights information for a particular file. Has two formats, an older
|
||||
* version used by VS and a format used by VS Code.
|
||||
*
|
||||
* @param fileName The path to the file
|
||||
* @param position A text span to return results within
|
||||
* @param format Which format to use, defaults to "original"
|
||||
* @returns a number array encoded as triples of [start, length, ClassificationType, ...].
|
||||
*/
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications;
|
||||
|
||||
/**
|
||||
* Gets completion entries at a particular position in a file.
|
||||
@@ -603,6 +620,11 @@ namespace ts {
|
||||
classificationType: ClassificationTypeNames;
|
||||
}
|
||||
|
||||
export interface ClassifiedSpan2020 {
|
||||
textSpan: TextSpan;
|
||||
classificationType: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation bar interface designed for visual studio's dual-column layout.
|
||||
* This does not form a proper tree.
|
||||
|
||||
+21
-1
@@ -5412,6 +5412,10 @@ declare namespace ts {
|
||||
type WithMetadata<T> = T & {
|
||||
metadata?: unknown;
|
||||
};
|
||||
enum SemanticClassificationFormat {
|
||||
Original = "original",
|
||||
TwentyTwenty = "2020"
|
||||
}
|
||||
interface LanguageService {
|
||||
/** This is used as a part of restarting the language service. */
|
||||
cleanupSemanticCache(): void;
|
||||
@@ -5463,10 +5467,22 @@ declare namespace ts {
|
||||
getCompilerOptionsDiagnostics(): Diagnostic[];
|
||||
/** @deprecated Use getEncodedSyntacticClassifications instead. */
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
/** @deprecated Use getEncodedSemanticClassifications instead. */
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSemanticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
/** Encoded as triples of [start, length, ClassificationType]. */
|
||||
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
/**
|
||||
* Gets semantic highlights information for a particular file. Has two formats, an older
|
||||
* version used by VS and a format used by VS Code.
|
||||
*
|
||||
* @param fileName The path to the file
|
||||
* @param position A text span to return results within
|
||||
* @param format Which format to use, defaults to "original"
|
||||
* @returns a number array encoded as triples of [start, length, ClassificationType, ...].
|
||||
*/
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications;
|
||||
/**
|
||||
* Gets completion entries at a particular position in a file.
|
||||
*
|
||||
@@ -5625,6 +5641,10 @@ declare namespace ts {
|
||||
textSpan: TextSpan;
|
||||
classificationType: ClassificationTypeNames;
|
||||
}
|
||||
interface ClassifiedSpan2020 {
|
||||
textSpan: TextSpan;
|
||||
classificationType: number;
|
||||
}
|
||||
/**
|
||||
* Navigation bar interface designed for visual studio's dual-column layout.
|
||||
* This does not form a proper tree.
|
||||
|
||||
+21
-1
@@ -5412,6 +5412,10 @@ declare namespace ts {
|
||||
type WithMetadata<T> = T & {
|
||||
metadata?: unknown;
|
||||
};
|
||||
enum SemanticClassificationFormat {
|
||||
Original = "original",
|
||||
TwentyTwenty = "2020"
|
||||
}
|
||||
interface LanguageService {
|
||||
/** This is used as a part of restarting the language service. */
|
||||
cleanupSemanticCache(): void;
|
||||
@@ -5463,10 +5467,22 @@ declare namespace ts {
|
||||
getCompilerOptionsDiagnostics(): Diagnostic[];
|
||||
/** @deprecated Use getEncodedSyntacticClassifications instead. */
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
/** @deprecated Use getEncodedSemanticClassifications instead. */
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
getSemanticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
|
||||
/** Encoded as triples of [start, length, ClassificationType]. */
|
||||
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
|
||||
/**
|
||||
* Gets semantic highlights information for a particular file. Has two formats, an older
|
||||
* version used by VS and a format used by VS Code.
|
||||
*
|
||||
* @param fileName The path to the file
|
||||
* @param position A text span to return results within
|
||||
* @param format Which format to use, defaults to "original"
|
||||
* @returns a number array encoded as triples of [start, length, ClassificationType, ...].
|
||||
*/
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications;
|
||||
/**
|
||||
* Gets completion entries at a particular position in a file.
|
||||
*
|
||||
@@ -5625,6 +5641,10 @@ declare namespace ts {
|
||||
textSpan: TextSpan;
|
||||
classificationType: ClassificationTypeNames;
|
||||
}
|
||||
interface ClassifiedSpan2020 {
|
||||
textSpan: TextSpan;
|
||||
classificationType: number;
|
||||
}
|
||||
/**
|
||||
* Navigation bar interface designed for visual studio's dual-column layout.
|
||||
* This does not form a proper tree.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
////function f(this){}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("function"),
|
||||
c.identifier("f"),
|
||||
|
||||
@@ -350,16 +350,18 @@ declare namespace FourSlashInterface {
|
||||
*/
|
||||
syntacticClassificationsAre(...classifications: {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
text?: string;
|
||||
}[]): void;
|
||||
/**
|
||||
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
|
||||
*/
|
||||
semanticClassificationsAre(...classifications: {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
semanticClassificationsAre(format: "original" | "2020", ...classifications: {
|
||||
classificationType: string | number;
|
||||
text?: string;
|
||||
textSpan?: TextSpan;
|
||||
}[]): void;
|
||||
/** Edits the current testfile and replaces with the semantic classifications */
|
||||
replaceWithSemanticClassifications(format: "2020")
|
||||
renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range, allowRenameOfImportPath?: boolean): void;
|
||||
renameInfoFailed(message?: string, allowRenameOfImportPath?: boolean): void;
|
||||
renameLocations(startRanges: ArrayOrSingle<Range>, options: RenameLocationsOptions): void;
|
||||
@@ -461,118 +463,123 @@ declare namespace FourSlashInterface {
|
||||
resetCancelled(): void;
|
||||
setCancelled(numberOfCalls?: number): void;
|
||||
}
|
||||
module classification {
|
||||
function comment(text: string, position?: number): {
|
||||
|
||||
interface ModernClassificationFactory {
|
||||
semanticToken(identifier: string, name: string)
|
||||
}
|
||||
|
||||
interface ClassificationFactory {
|
||||
comment(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function identifier(text: string, position?: number): {
|
||||
identifier(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function keyword(text: string, position?: number): {
|
||||
keyword(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function numericLiteral(text: string, position?: number): {
|
||||
numericLiteral(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function operator(text: string, position?: number): {
|
||||
operator(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function stringLiteral(text: string, position?: number): {
|
||||
stringLiteral(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function whiteSpace(text: string, position?: number): {
|
||||
whiteSpace(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function text(text: string, position?: number): {
|
||||
text(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function punctuation(text: string, position?: number): {
|
||||
punctuation(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function docCommentTagName(text: string, position?: number): {
|
||||
docCommentTagName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function className(text: string, position?: number): {
|
||||
className(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function enumName(text: string, position?: number): {
|
||||
enumName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function interfaceName(text: string, position?: number): {
|
||||
interfaceName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function moduleName(text: string, position?: number): {
|
||||
moduleName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function typeParameterName(text: string, position?: number): {
|
||||
typeParameterName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function parameterName(text: string, position?: number): {
|
||||
parameterName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function typeAliasName(text: string, position?: number): {
|
||||
typeAliasName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxOpenTagName(text: string, position?: number): {
|
||||
jsxOpenTagName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxCloseTagName(text: string, position?: number): {
|
||||
jsxCloseTagName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxSelfClosingTagName(text: string, position?: number): {
|
||||
jsxSelfClosingTagName(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxAttribute(text: string, position?: number): {
|
||||
jsxAttribute(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxText(text: string, position?: number): {
|
||||
jsxText(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
};
|
||||
function jsxAttributeStringLiteralValue(text: string, position?: number): {
|
||||
jsxAttributeStringLiteralValue(text: string, position?: number): {
|
||||
classificationType: string;
|
||||
text: string;
|
||||
textSpan?: TextSpan;
|
||||
@@ -757,7 +764,8 @@ declare var edit: FourSlashInterface.edit;
|
||||
declare var debug: FourSlashInterface.debug;
|
||||
declare var format: FourSlashInterface.format;
|
||||
declare var cancellation: FourSlashInterface.cancellation;
|
||||
declare var classification: typeof FourSlashInterface.classification;
|
||||
declare function classification(format: "original"): FourSlashInterface.ClassificationFactory;
|
||||
declare function classification(format: "2020"): FourSlashInterface.ModernClassificationFactory;
|
||||
declare namespace completion {
|
||||
type Entry = FourSlashInterface.ExpectedCompletionEntryObject;
|
||||
export const enum SortText {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//// * @param {Number} wid/*1*/
|
||||
goTo.marker('1');
|
||||
edit.insert("th\n@");
|
||||
const c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/**\n * Pad `str` to `width`.\n *\n * "),
|
||||
c.punctuation("@"),
|
||||
|
||||
@@ -6,10 +6,20 @@
|
||||
//// }
|
||||
//// interface /*2*/X extends /*3*/M./*4*/I { }
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.interfaceName("X", test.marker("2").position),
|
||||
c.moduleName("M", test.marker("3").position),
|
||||
c.interfaceName("I", test.marker("4").position));
|
||||
|
||||
var c2 = classification("2020")
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("interface.declaration", "X"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
)
|
||||
|
||||
|
||||
@@ -7,5 +7,14 @@
|
||||
//// var Thing = 0;
|
||||
//// Thing.toExponential();
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(c.interfaceName("Thing", test.marker("0").position));
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original", c.interfaceName("Thing", test.marker("0").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("interface.declaration", "Thing"),
|
||||
c2.semanticToken("member.declaration", "toExponential"),
|
||||
c2.semanticToken("variable.declaration", "Thing"),
|
||||
c2.semanticToken("variable", "Thing"),
|
||||
c2.semanticToken("member.defaultLibrary", "toExponential")
|
||||
);
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
goTo.file("/b.ts");
|
||||
|
||||
const [m0, m1, m2, m3] = test.markers();
|
||||
const c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.typeAliasName("x", m0.position),
|
||||
c.className("y", m1.position),
|
||||
c.typeAliasName("x", m2.position),
|
||||
c.className("y", m3.position),
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
|
||||
c2.semanticToken("variable.declaration.readonly", "v"),
|
||||
c2.semanticToken("type", "x"),
|
||||
c2.semanticToken("class", "y"),
|
||||
);
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
//// var x = class /*0*/C {}
|
||||
//// class /*1*/C {}
|
||||
//// class /*2*/D extends class /*3*/B{} { }
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.className("C", test.marker("0").position),
|
||||
c.className("C", test.marker("1").position),
|
||||
c.className("D", test.marker("2").position),
|
||||
c.className("B", test.marker("3").position)
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "x"),
|
||||
c2.semanticToken("class", "C"),
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("class.declaration", "D"),
|
||||
c2.semanticToken("class", "B"),
|
||||
);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
////}
|
||||
////`abcd${ /*3*/M./*4*/C.x + /*5*/M./*6*/E.E1}efg`
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.className("C", test.marker("1").position),
|
||||
c.enumName("E", test.marker("2").position),
|
||||
@@ -19,3 +19,18 @@ verify.semanticClassificationsAre(
|
||||
c.className("C", test.marker("4").position),
|
||||
c.moduleName("M", test.marker("5").position),
|
||||
c.enumName("E", test.marker("6").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("property.declaration.static", "x"),
|
||||
c2.semanticToken("enum.declaration", "E"),
|
||||
c2.semanticToken("enumMember.declaration.readonly", "E1"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("class", "C"),
|
||||
c2.semanticToken("property.static", "x"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("enum", "E"),
|
||||
c2.semanticToken("enumMember.readonly", "E1"),
|
||||
);
|
||||
|
||||
+18
-2
@@ -15,10 +15,26 @@
|
||||
////
|
||||
////var x = /*5*/M;
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.moduleName("M", test.marker("3").position),
|
||||
c.interfaceName("I", test.marker("4").position),
|
||||
c.moduleName("M", test.marker("5").position));
|
||||
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("variable.declaration.local", "x"),
|
||||
c2.semanticToken("variable.declaration", "M"),
|
||||
c2.semanticToken("property.declaration", "foo"),
|
||||
c2.semanticToken("property.declaration", "bar"),
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
);
|
||||
|
||||
+18
-2
@@ -18,11 +18,27 @@
|
||||
////
|
||||
////var x = /*6*/M;
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.moduleName("M", test.marker("2").position),
|
||||
c.moduleName("M", test.marker("4").position),
|
||||
c.interfaceName("I", test.marker("5").position),
|
||||
c.moduleName("M", test.marker("6").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("variable.declaration.local", "x"),
|
||||
c2.semanticToken("variable.declaration", "M"),
|
||||
c2.semanticToken("property.declaration", "foo"),
|
||||
c2.semanticToken("property.declaration", "bar"),
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
);
|
||||
|
||||
@@ -6,4 +6,6 @@
|
||||
//// let x = 1;
|
||||
|
||||
// no semantic classification in js file
|
||||
verify.semanticClassificationsAre();
|
||||
verify.semanticClassificationsAre("original", );
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,25 @@
|
||||
////var x: /*2*/M./*3*/I = /*4*/M.v;
|
||||
////var y = /*5*/M;
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.moduleName("M", test.marker("2").position),
|
||||
c.interfaceName("I", test.marker("3").position),
|
||||
c.moduleName("M", test.marker("4").position),
|
||||
c.moduleName("M", test.marker("5").position));
|
||||
c.moduleName("M", test.marker("5").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("variable.declaration.local", "v"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
c2.semanticToken("variable.local", "v"),
|
||||
c2.semanticToken("variable.declaration", "y"),
|
||||
c2.semanticToken("namespace", "M"),
|
||||
);
|
||||
|
||||
+12
-3
@@ -8,7 +8,16 @@
|
||||
////
|
||||
////var M = { I: 10 };
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position));
|
||||
c.interfaceName("I", test.marker("1").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("variable.declaration", "M"),
|
||||
c2.semanticToken("property.declaration", "I"),
|
||||
);
|
||||
|
||||
+17
-2
@@ -14,9 +14,24 @@
|
||||
////
|
||||
////var x = /*5*/M;
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.moduleName("M", test.marker("3").position),
|
||||
c.interfaceName("I", test.marker("4").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("variable.declaration", "M"),
|
||||
c2.semanticToken("property.declaration", "foo"),
|
||||
c2.semanticToken("property.declaration", "bar"),
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("variable", "M"),
|
||||
);
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
////var M: /*4*/M./*5*/I | /*6*/I | /*7*/C;
|
||||
////var I: typeof M | typeof /*8*/C;
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.interfaceName("I", test.marker("2").position),
|
||||
@@ -21,4 +21,20 @@ verify.semanticClassificationsAre(
|
||||
c.interfaceName("I", test.marker("5").position),
|
||||
c.interfaceName("I", test.marker("6").position),
|
||||
c.className("C", test.marker("7").position),
|
||||
c.className("C", test.marker("8").position));
|
||||
c.className("C", test.marker("8").position));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("variable.declaration", "M"),
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("interface", "I"),
|
||||
c2.semanticToken("class", "C"),
|
||||
c2.semanticToken("class.declaration", "I"),
|
||||
c2.semanticToken("variable", "M"),
|
||||
c2.semanticToken("class", "C"),
|
||||
);
|
||||
|
||||
@@ -5,11 +5,20 @@
|
||||
////module N {
|
||||
////}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
cancellation.setCancelled(1);
|
||||
verifyOperationIsCancelled(() => verify.semanticClassificationsAre());
|
||||
verifyOperationIsCancelled(() => verify.semanticClassificationsAre("original", ));
|
||||
cancellation.resetCancelled();
|
||||
|
||||
verify.semanticClassificationsAre(
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M"),
|
||||
c.moduleName("N"));
|
||||
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("namespace.declaration", "N"),
|
||||
);
|
||||
|
||||
|
||||
@@ -5,11 +5,24 @@
|
||||
////var y = </*2*/Alias>{};
|
||||
////function f(x: /*3*/Alias): /*4*/Alias { return undefined; }
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.typeAliasName("Alias", test.marker("0").position),
|
||||
c.typeAliasName("Alias", test.marker("1").position),
|
||||
c.typeAliasName("Alias", test.marker("2").position),
|
||||
c.typeAliasName("Alias", test.marker("3").position),
|
||||
c.typeAliasName("Alias", test.marker("4").position)
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("type.declaration", "Alias"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("type", "Alias"),
|
||||
c2.semanticToken("variable.declaration", "y"),
|
||||
c2.semanticToken("type", "Alias"),
|
||||
c2.semanticToken("function.declaration", "f"),
|
||||
c2.semanticToken("parameter.declaration", "x"),
|
||||
c2.semanticToken("type", "Alias"),
|
||||
c2.semanticToken("type", "Alias"),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// class A { onEvent: () => void; }
|
||||
//// const x = new A().onEvent;
|
||||
//// const match = (s: any) => x();
|
||||
//// const other = match;
|
||||
//// match({ other });
|
||||
//// interface B = { (): string; }; var b: B
|
||||
//// var s: String;
|
||||
//// var t: { (): string; foo: string};
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "A"),
|
||||
c2.semanticToken("member.declaration", "onEvent"),
|
||||
c2.semanticToken("function.declaration.readonly", "x"),
|
||||
c2.semanticToken("class", "A"),
|
||||
c2.semanticToken("member", "onEvent"),
|
||||
c2.semanticToken("function.declaration.readonly", "match"),
|
||||
c2.semanticToken("parameter.declaration", "s"),
|
||||
c2.semanticToken("function.readonly", "x"),
|
||||
c2.semanticToken("function.declaration.readonly", "other"),
|
||||
c2.semanticToken("function.readonly", "match"),
|
||||
c2.semanticToken("function.readonly", "match"),
|
||||
c2.semanticToken("member.declaration", "other"),
|
||||
c2.semanticToken("interface.declaration", "B"),
|
||||
c2.semanticToken("variable.declaration", "b"),
|
||||
c2.semanticToken("interface", "B"),
|
||||
c2.semanticToken("variable.declaration", "s"),
|
||||
c2.semanticToken("interface.defaultLibrary", "String"),
|
||||
c2.semanticToken("variable.declaration", "t"),
|
||||
c2.semanticToken("property.declaration", "foo"),
|
||||
);;
|
||||
@@ -0,0 +1,25 @@
|
||||
//// import "node";
|
||||
//// var fs = require("fs")
|
||||
//// require.resolve('react');
|
||||
//// require.resolve.paths;
|
||||
//// interface LanguageMode { getFoldingRanges?: (d: string) => number[]; };
|
||||
//// function (mode: LanguageMode | undefined) { if (mode && mode.getFoldingRanges) { return mode.getFoldingRanges('a'); }};
|
||||
//// function b(a: () => void) { a(); };
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "fs"),
|
||||
c2.semanticToken("interface.declaration", "LanguageMode"),
|
||||
c2.semanticToken("member.declaration", "getFoldingRanges"),
|
||||
c2.semanticToken("parameter.declaration", "d"),
|
||||
c2.semanticToken("parameter.declaration", "mode"),
|
||||
c2.semanticToken("interface", "LanguageMode"),
|
||||
c2.semanticToken("parameter", "mode"),
|
||||
c2.semanticToken("parameter", "mode"),
|
||||
c2.semanticToken("member", "getFoldingRanges"),
|
||||
c2.semanticToken("parameter", "mode"),
|
||||
c2.semanticToken("member", "getFoldingRanges"),
|
||||
c2.semanticToken("function.declaration", "b"),
|
||||
c2.semanticToken("function.declaration", "a"),
|
||||
c2.semanticToken("function", "a"),
|
||||
);;
|
||||
@@ -0,0 +1,21 @@
|
||||
//// class A {
|
||||
//// private y: number;
|
||||
//// constructor(public x : number, _y : number) { this.y = _y; }
|
||||
//// get z() : number { return this.x + this.y; }
|
||||
//// set a(v: number) { }
|
||||
//// }
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "A"),
|
||||
c2.semanticToken("property.declaration", "y"),
|
||||
c2.semanticToken("parameter.declaration", "x"),
|
||||
c2.semanticToken("parameter.declaration", "_y"),
|
||||
c2.semanticToken("property", "y"),
|
||||
c2.semanticToken("parameter", "_y"),
|
||||
c2.semanticToken("property.declaration", "z"),
|
||||
c2.semanticToken("property", "x"),
|
||||
c2.semanticToken("property", "y"),
|
||||
c2.semanticToken("property.declaration", "a"),
|
||||
c2.semanticToken("parameter.declaration", "v"),
|
||||
);;
|
||||
@@ -0,0 +1,13 @@
|
||||
//// Object.create(null);
|
||||
//// const x = Promise.resolve(Number.MAX_VALUE);
|
||||
//// if (x instanceof Promise) {}
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.defaultLibrary", "Object"),
|
||||
c2.semanticToken("member.defaultLibrary", "create"),
|
||||
c2.semanticToken("variable.declaration.readonly", "x"),
|
||||
c2.semanticToken("class.defaultLibrary", "Number"),
|
||||
c2.semanticToken("property.readonly.defaultLibrary", "MAX_VALUE"),
|
||||
c2.semanticToken("variable.readonly", "x"),
|
||||
);;
|
||||
@@ -0,0 +1,19 @@
|
||||
//// function foo(p1) {
|
||||
//// return foo(Math.abs(p1))
|
||||
//// }
|
||||
//// `/${window.location}`.split("/").forEach(s => foo(s));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("function.declaration", "foo"),
|
||||
c2.semanticToken("parameter.declaration", "p1"),
|
||||
c2.semanticToken("function", "foo"),
|
||||
c2.semanticToken("variable.defaultLibrary", "Math"),
|
||||
c2.semanticToken("member.defaultLibrary", "abs"),
|
||||
c2.semanticToken("parameter", "p1"),
|
||||
c2.semanticToken("member.defaultLibrary", "split"),
|
||||
c2.semanticToken("member.defaultLibrary", "forEach"),
|
||||
c2.semanticToken("parameter.declaration", "s"),
|
||||
c2.semanticToken("function", "foo"),
|
||||
c2.semanticToken("parameter", "s"),
|
||||
);;
|
||||
@@ -0,0 +1,21 @@
|
||||
//// interface Pos { x: number, y: number };
|
||||
//// const p = { x: 1, y: 2 } as Pos;
|
||||
//// const foo = (o: Pos) => o.x + o.y;
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("interface.declaration", "Pos"),
|
||||
c2.semanticToken("property.declaration", "x"),
|
||||
c2.semanticToken("property.declaration", "y"),
|
||||
c2.semanticToken("variable.declaration.readonly", "p"),
|
||||
c2.semanticToken("property.declaration", "x"),
|
||||
c2.semanticToken("property.declaration", "y"),
|
||||
c2.semanticToken("interface", "Pos"),
|
||||
c2.semanticToken("function.declaration.readonly", "foo"),
|
||||
c2.semanticToken("parameter.declaration", "o"),
|
||||
c2.semanticToken("interface", "Pos"),
|
||||
c2.semanticToken("parameter", "o"),
|
||||
c2.semanticToken("property", "x"),
|
||||
c2.semanticToken("parameter", "o"),
|
||||
c2.semanticToken("property", "y"),
|
||||
);;
|
||||
@@ -0,0 +1,24 @@
|
||||
//// class A {
|
||||
//// static x = 9;
|
||||
//// f = 9;
|
||||
//// async m() { return A.x + await this.m(); };
|
||||
//// get s() { return this.f;
|
||||
//// static t() { return new A().f; };
|
||||
//// constructor() {}
|
||||
//// }
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "A"),
|
||||
c2.semanticToken("property.declaration.static", "x"),
|
||||
c2.semanticToken("property.declaration", "f"),
|
||||
c2.semanticToken("member.declaration.async", "m"),
|
||||
c2.semanticToken("class", "A"),
|
||||
c2.semanticToken("property.static", "x"),
|
||||
c2.semanticToken("member.async", "m"),
|
||||
c2.semanticToken("property.declaration", "s"),
|
||||
c2.semanticToken("property", "f"),
|
||||
c2.semanticToken("member.declaration.static", "t"),
|
||||
c2.semanticToken("class", "A"),
|
||||
c2.semanticToken("property", "f"),
|
||||
);;
|
||||
@@ -0,0 +1,13 @@
|
||||
//// let x = 1, y = 1;
|
||||
//// const a1 = { e: 1 };
|
||||
//// var a2 = { x };
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("variable.declaration", "y"),
|
||||
c2.semanticToken("variable.declaration.readonly", "a1"),
|
||||
c2.semanticToken("property.declaration", "e"),
|
||||
c2.semanticToken("variable.declaration", "a2"),
|
||||
c2.semanticToken("property.declaration", "x"),
|
||||
);;
|
||||
@@ -0,0 +1,19 @@
|
||||
//// var x = 9, y1 = [x];
|
||||
//// try {
|
||||
//// for (const s of y1) { x = s }
|
||||
//// } catch (e) {
|
||||
//// throw y1;
|
||||
//// }
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("variable.declaration", "y1"),
|
||||
c2.semanticToken("variable", "x"),
|
||||
c2.semanticToken("variable.declaration.readonly.local", "s"),
|
||||
c2.semanticToken("variable", "y1"),
|
||||
c2.semanticToken("variable", "x"),
|
||||
c2.semanticToken("variable.readonly.local", "s"),
|
||||
c2.semanticToken("variable.declaration.local", "e"),
|
||||
c2.semanticToken("variable", "y1"),
|
||||
);;
|
||||
@@ -6,8 +6,8 @@
|
||||
//// }
|
||||
//// interface /*2*/X extends /*3*/M./*4*/I { }
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.interfaceName("X", test.marker("2").position),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//// }
|
||||
//// }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("// comment"),
|
||||
c.keyword("module"), c.moduleName("M"), c.punctuation("{"),
|
||||
@@ -32,4 +32,4 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation("}"),
|
||||
c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"),
|
||||
c.punctuation("}"),
|
||||
c.punctuation("}"));
|
||||
c.punctuation("}"));
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
//// }
|
||||
//// interface /*2*/X extends /*3*/M./*4*/I { }
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
const c = classification("original");
|
||||
verify.semanticClassificationsAre("original",
|
||||
c.moduleName("M", test.marker("0").position),
|
||||
c.interfaceName("I", test.marker("1").position),
|
||||
c.interfaceName("X", test.marker("2").position),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//// }
|
||||
//// }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("// comment"),
|
||||
c.keyword("module"), c.moduleName("M"), c.punctuation("{"),
|
||||
@@ -32,4 +32,4 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation("}"),
|
||||
c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"),
|
||||
c.punctuation("}"),
|
||||
c.punctuation("}"));
|
||||
c.punctuation("}"));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////function ident<T>: T {
|
||||
////}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/** "),
|
||||
c.punctuation("@"),
|
||||
@@ -20,3 +20,10 @@ verify.syntacticClassificationsAre(
|
||||
c.identifier("T"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("function.declaration", "ident"),
|
||||
c2.semanticToken("typeParameter.declaration", "T"),
|
||||
c2.semanticToken("typeParameter", "T"),
|
||||
);
|
||||
|
||||
@@ -5,10 +5,17 @@
|
||||
////}
|
||||
////c =
|
||||
|
||||
let c = classification
|
||||
const c = classification("original")
|
||||
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("class"), c.className("A"), c.punctuation("{"),
|
||||
c.identifier("a"), c.punctuation(":"),
|
||||
c.punctuation("}"),
|
||||
c.identifier("c"), c.operator("=")
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "A"),
|
||||
c2.semanticToken("property.declaration", "a"),
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//// }
|
||||
//// }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("// comment"),
|
||||
c.keyword("module"), c.moduleName("M"), c.punctuation("{"),
|
||||
@@ -32,4 +32,18 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation("}"),
|
||||
c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"),
|
||||
c.punctuation("}"),
|
||||
c.punctuation("}"));
|
||||
c.punctuation("}"));
|
||||
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("variable.declaration.local", "v"),
|
||||
c2.semanticToken("variable.declaration.local", "s"),
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("typeParameter.declaration", "T"),
|
||||
c2.semanticToken("enum.declaration", "E"),
|
||||
c2.semanticToken("interface.declaration", "I"),
|
||||
c2.semanticToken("namespace.declaration", "M1"),
|
||||
c2.semanticToken("namespace.declaration", "M2"),
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
////module N {
|
||||
////}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
cancellation.setCancelled(1);
|
||||
verifyOperationIsCancelled(() => verify.syntacticClassificationsAre());
|
||||
cancellation.resetCancelled();
|
||||
@@ -19,3 +19,9 @@ verify.syntacticClassificationsAre(
|
||||
c.moduleName("N"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("namespace.declaration", "M"),
|
||||
c2.semanticToken("namespace.declaration", "N"),
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
////>>>>>>> Branch - a
|
||||
////}
|
||||
|
||||
const c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"),
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
@@ -20,4 +20,10 @@ verify.syntacticClassificationsAre(
|
||||
c.comment("======="),
|
||||
c.identifier("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"),
|
||||
c.comment(">>>>>>> Branch - a"),
|
||||
c.punctuation("}"));
|
||||
c.punctuation("}"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("property.declaration", "v"),
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
////class D { }
|
||||
////>>>>>>> Branch - a
|
||||
|
||||
const c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"), c.punctuation("}"),
|
||||
@@ -16,4 +16,9 @@ verify.syntacticClassificationsAre(
|
||||
c.keyword("class"), c.identifier("E"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment("======="),
|
||||
c.keyword("class"), c.identifier("D"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment(">>>>>>> Branch - a"));
|
||||
c.comment(">>>>>>> Branch - a"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
////>>>>>>> Branch - a
|
||||
////}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"),
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
@@ -16,4 +16,10 @@ verify.syntacticClassificationsAre(
|
||||
c.comment("======="),
|
||||
c.identifier("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"),
|
||||
c.comment(">>>>>>> Branch - a"),
|
||||
c.punctuation("}"));
|
||||
c.punctuation("}"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
c2.semanticToken("property.declaration", "v"),
|
||||
);
|
||||
|
||||
@@ -6,10 +6,15 @@
|
||||
////class D { }
|
||||
////>>>>>>> Branch - a
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment("======="),
|
||||
c.keyword("class"), c.identifier("D"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment(">>>>>>> Branch - a"));
|
||||
c.comment(">>>>>>> Branch - a"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("class.declaration", "C"),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//// /** @type {number} */
|
||||
//// var v;
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/** "),
|
||||
c.punctuation("@"),
|
||||
@@ -15,3 +15,9 @@ verify.syntacticClassificationsAre(
|
||||
c.keyword("var"),
|
||||
c.identifier("v"),
|
||||
c.punctuation(";"));
|
||||
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//// var v;
|
||||
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/** "),
|
||||
c.punctuation("@"),
|
||||
@@ -24,3 +24,8 @@ verify.syntacticClassificationsAre(
|
||||
c.keyword("var"),
|
||||
c.identifier("v"),
|
||||
c.punctuation(";"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//// /** @param foo { number /* } */
|
||||
//// var v;
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/** "),
|
||||
c.punctuation("@"),
|
||||
@@ -17,3 +17,9 @@ verify.syntacticClassificationsAre(
|
||||
c.keyword("var"),
|
||||
c.identifier("v"),
|
||||
c.punctuation(";"));
|
||||
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//// /** @param {number} p1 */
|
||||
//// function foo(p1) {}
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/** "),
|
||||
c.punctuation("@"),
|
||||
@@ -22,3 +22,9 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation(")"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("function.declaration", "foo"),
|
||||
c2.semanticToken("parameter.declaration", "p1"),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// for (var of of of) { }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("for"),
|
||||
c.punctuation("("),
|
||||
@@ -13,4 +13,10 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation(")"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}")
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "of"),
|
||||
c2.semanticToken("variable", "of"),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// for (var of in of) { }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("for"),
|
||||
c.punctuation("("),
|
||||
@@ -13,4 +13,10 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation(")"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}")
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "of"),
|
||||
c2.semanticToken("variable", "of"),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// for (var of; of; of) { }
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("for"),
|
||||
c.punctuation("("),
|
||||
@@ -15,4 +15,11 @@ verify.syntacticClassificationsAre(
|
||||
c.punctuation(")"),
|
||||
c.punctuation("{"),
|
||||
c.punctuation("}")
|
||||
);
|
||||
);
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "of"),
|
||||
c2.semanticToken("variable", "of"),
|
||||
c2.semanticToken("variable", "of"),
|
||||
);
|
||||
|
||||
@@ -16,10 +16,20 @@ var firstCommentText =
|
||||
* There are many like it, but this one is mine.\n\
|
||||
*/";
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment(firstCommentText),
|
||||
c.keyword("function"), c.identifier("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"),
|
||||
c.keyword("var"), c.identifier("y"), c.operator("="), c.identifier("x"), c.operator("?"), c.identifier("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.identifier("x"), c.punctuation(";"),
|
||||
c.punctuation("}"),
|
||||
c.comment("// end of file"));
|
||||
c.comment("// end of file"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("function.declaration", "myFunction"),
|
||||
c2.semanticToken("parameter.declaration", "x"),
|
||||
c2.semanticToken("variable.declaration.local", "y"),
|
||||
c2.semanticToken("parameter", "x"),
|
||||
c2.semanticToken("parameter", "x"),
|
||||
c2.semanticToken("parameter", "x"),
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
////
|
||||
////let y = <element attr="123"/>
|
||||
|
||||
const c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("let"), c.identifier("x"), c.operator("="),
|
||||
c.punctuation("<"),
|
||||
@@ -24,4 +24,10 @@ verify.syntacticClassificationsAre(
|
||||
c.jsxSelfClosingTagName("element"),
|
||||
c.jsxAttribute("attr"), c.operator("="), c.jsxAttributeStringLiteralValue(`"123"`),
|
||||
c.punctuation("/"), c.punctuation(">")
|
||||
)
|
||||
)
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("variable.declaration", "y"),
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
////
|
||||
////let y = <element.name attr="123"/>
|
||||
|
||||
const c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("let"), c.identifier("x"), c.operator("="),
|
||||
c.punctuation("<"),
|
||||
@@ -24,4 +24,10 @@ verify.syntacticClassificationsAre(
|
||||
c.jsxSelfClosingTagName("element.name"),
|
||||
c.jsxAttribute("attr"), c.operator("="), c.jsxAttributeStringLiteralValue(`"123"`),
|
||||
c.punctuation("/"), c.punctuation(">")
|
||||
)
|
||||
)
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("variable.declaration", "y"),
|
||||
);
|
||||
|
||||
@@ -7,10 +7,14 @@
|
||||
//// >>>>>>> Feature
|
||||
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
c.stringLiteral("\"AAAA\""),
|
||||
c.comment("======="),
|
||||
c.stringLiteral("\"BBBB\""),
|
||||
c.comment(">>>>>>> Feature"));
|
||||
c.comment(">>>>>>> Feature"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//// v: v += v,
|
||||
////};
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"),
|
||||
c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"),
|
||||
@@ -22,4 +22,19 @@ verify.syntacticClassificationsAre(
|
||||
c.identifier("var"), c.punctuation(":"), c.numericLiteral("5"), c.punctuation(","),
|
||||
c.identifier("void"), c.punctuation(":"), c.keyword("void"), c.numericLiteral("0"), c.punctuation(","),
|
||||
c.identifier("v"), c.punctuation(":"), c.identifier("v"), c.operator("+="), c.identifier("v"), c.punctuation(","),
|
||||
c.punctuation("}"), c.punctuation(";"));
|
||||
c.punctuation("}"), c.punctuation(";"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("property.declaration", "p1"),
|
||||
c2.semanticToken("property.declaration", "p2"),
|
||||
c2.semanticToken("property.declaration", "any"),
|
||||
c2.semanticToken("property.declaration", "function"),
|
||||
c2.semanticToken("property.declaration", "var"),
|
||||
c2.semanticToken("property.declaration", "void"),
|
||||
c2.semanticToken("property.declaration", "v"),
|
||||
c2.semanticToken("variable", "v"),
|
||||
c2.semanticToken("variable", "v"),
|
||||
);
|
||||
|
||||
@@ -6,10 +6,18 @@
|
||||
//// p2: `goodbye ${0} cruel ${0} world`,
|
||||
////};
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"),
|
||||
c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"),
|
||||
c.identifier("p1"), c.punctuation(":"), c.stringLiteral("`hello world`"), c.punctuation(","),
|
||||
c.identifier("p2"), c.punctuation(":"), c.stringLiteral("`goodbye ${"), c.numericLiteral("0"), c.stringLiteral("} cruel ${"), c.numericLiteral("0"), c.stringLiteral("} world`"), c.punctuation(","),
|
||||
c.punctuation("}"), c.punctuation(";"));
|
||||
c.punctuation("}"), c.punctuation(";"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "v"),
|
||||
c2.semanticToken("variable.declaration", "x"),
|
||||
c2.semanticToken("property.declaration", "p1"),
|
||||
c2.semanticToken("property.declaration", "p2"),
|
||||
);
|
||||
|
||||
@@ -4,8 +4,13 @@
|
||||
////`goodbye "${ `hello world` }"
|
||||
////and ${ `good${ " " }riddance` }`;
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("var"), c.identifier("tiredOfCanonicalExamples"), c.operator("="),
|
||||
c.stringLiteral("`goodbye \"${"), c.stringLiteral("`hello world`"),
|
||||
c.stringLiteral("}\" \nand ${"), c.stringLiteral("`good${"), c.stringLiteral("\" \""), c.stringLiteral("}riddance`"), c.stringLiteral("}`"), c.punctuation(";"));
|
||||
c.stringLiteral("}\" \nand ${"), c.stringLiteral("`good${"), c.stringLiteral("\" \""), c.stringLiteral("}riddance`"), c.stringLiteral("}`"), c.punctuation(";"));
|
||||
|
||||
const c2 = classification("2020");
|
||||
verify.semanticClassificationsAre("2020",
|
||||
c2.semanticToken("variable.declaration", "tiredOfCanonicalExamples"),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts" />
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -12,4 +12,6 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"));
|
||||
c.punctuation("/>"));
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts"
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -10,4 +10,4 @@ verify.syntacticClassificationsAre(
|
||||
c.comment(" "),
|
||||
c.jsxAttribute("path"),
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""));
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts" /
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -12,4 +12,4 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
|
||||
c.comment(" "),
|
||||
c.comment("/"));
|
||||
c.comment("/"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts" bad types="node" />
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -16,4 +16,4 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"node\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"));
|
||||
c.punctuation("/>"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts" /> trailing
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -13,4 +13,4 @@ verify.syntacticClassificationsAre(
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"),
|
||||
c.comment(" trailing"));
|
||||
c.comment(" trailing"));
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
//// /// nonElement
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// nonElement"));
|
||||
c.comment("/// nonElement"));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//// /// <reference path="./module1.ts" />
|
||||
//// /// <reference path="./module2.ts" />
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -22,4 +22,4 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"./module2.ts\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"));
|
||||
c.punctuation("/>"));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//// /// <reference path="./module.ts" />
|
||||
//// 1
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -14,4 +14,4 @@ verify.syntacticClassificationsAre(
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"),
|
||||
c.numericLiteral("1"));
|
||||
c.numericLiteral("1"));
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
//// /// <summary>Text</summary>
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// <summary>Text</summary>"));
|
||||
c.comment("/// <summary>Text</summary>"));
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
//// /// <reference>Text</reference>
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// <reference>Text</reference>"));
|
||||
c.comment("/// <reference>Text</reference>"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// ///<reference path = "./module.ts"/>
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("///"),
|
||||
c.punctuation("<"),
|
||||
@@ -13,4 +13,6 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.comment(" "),
|
||||
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
|
||||
c.punctuation("/>"));
|
||||
c.punctuation("/>"));
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//// /// <reference path="./module.ts" types="node" />
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
@@ -16,4 +16,6 @@ verify.syntacticClassificationsAre(
|
||||
c.operator("="),
|
||||
c.jsxAttributeStringLiteralValue("\"node\""),
|
||||
c.comment(" "),
|
||||
c.punctuation("/>"));
|
||||
c.punctuation("/>"));
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
//// /// <
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// <")); // Don't classify until we recognize the element name
|
||||
c.comment("/// <")); // Don't classify until we recognize the element name
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
//// /// <reference
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
c.jsxSelfClosingTagName("reference"));
|
||||
c.jsxSelfClosingTagName("reference"));
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
//// /// <reference path
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
c.jsxSelfClosingTagName("reference"),
|
||||
c.comment(" path"));
|
||||
c.comment(" path"));
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
//// /// <reference path=
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
c.jsxSelfClosingTagName("reference"),
|
||||
c.comment(" path="));
|
||||
c.comment(" path="));
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
//// /// <reference path="
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
c.jsxSelfClosingTagName("reference"),
|
||||
c.comment(" path=\""));
|
||||
c.comment(" path=\""));
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
//// /// <reference path="./module.ts
|
||||
|
||||
var c = classification;
|
||||
const c = classification("original");
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("/// "),
|
||||
c.punctuation("<"),
|
||||
c.jsxSelfClosingTagName("reference"),
|
||||
c.comment(" path=\"./module.ts"));
|
||||
c.comment(" path=\"./module.ts"));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user