diff --git a/src/services/services.ts b/src/services/services.ts index bbd297a3940..0bfbd46f217 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -407,7 +407,7 @@ module ts { return pos + name.length < end && sourceFile.text.substr(pos, name.length) === name && (isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) || - isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); + isLineBreak(sourceFile.text.charCodeAt(pos + name.length))); } function isParamTag(pos: number, end: number, sourceFile: SourceFile) { @@ -798,7 +798,7 @@ module ts { if ((node).name) { namedDeclarations.push(node); } - // fall through + // fall through case SyntaxKind.Constructor: case SyntaxKind.VariableStatement: case SyntaxKind.VariableDeclarationList: @@ -819,7 +819,7 @@ module ts { if (!(node.flags & NodeFlags.AccessibilityModifier)) { break; } - // fall through + // fall through case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: if (isBindingPattern((node).name)) { @@ -852,13 +852,13 @@ module ts { // export interface LanguageServiceHost extends Logger { getCompilationSettings(): CompilerOptions; - getNewLine?(): string; + getNewLine? (): string; getScriptFileNames(): string[]; getScriptVersion(fileName: string): string; getScriptIsOpen(fileName: string): boolean; getScriptSnapshot(fileName: string): IScriptSnapshot; - getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getLocalizedDiagnosticMessages? (): any; + getCancellationToken? (): CancellationToken; getCurrentDirectory(): string; getDefaultLibFilename(options: CompilerOptions): string; } @@ -890,7 +890,7 @@ module ts { getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; @@ -913,7 +913,7 @@ module ts { dispose(): void; } - + export interface ClassifiedSpan { textSpan: TextSpan; classificationType: string; // ClassificationTypeNames @@ -1024,7 +1024,7 @@ module ts { text: string; kind: string; } - + export interface QuickInfo { kind: string; kindModifiers: string; @@ -1542,7 +1542,7 @@ module ts { sourceFile.version = version; sourceFile.isOpen = isOpen; sourceFile.scriptSnapshot = scriptSnapshot; - } + } export function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile { var sourceFile = createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents); @@ -1862,7 +1862,7 @@ module ts { // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment return position <= token.getStart(sourceFile) && (isInsideCommentRange(getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); + isInsideCommentRange(getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); function isInsideCommentRange(comments: CommentRange[]): boolean { return forEach(comments, comment => { @@ -1904,7 +1904,7 @@ module ts { } // A cache of completion entries for keywords, these do not change between sessions - var keywordCompletions:CompletionEntry[] = []; + var keywordCompletions: CompletionEntry[] = []; for (var i = SyntaxKind.FirstKeyword; i <= SyntaxKind.LastKeyword; i++) { keywordCompletions.push({ name: tokenToString(i), @@ -2372,8 +2372,6 @@ module ts { function isCompletionListBuilder(previousToken: Node): boolean { if (previousToken) { var containingNodeKind = previousToken.parent.kind; - // identifiers in method/function calls - // variable declarations switch (previousToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression @@ -2385,6 +2383,20 @@ module ts { return true; case SyntaxKind.DotToken: return containingNodeKind === SyntaxKind.ModuleDeclaration; + case SyntaxKind.OpenBraceToken: + return containingNodeKind === SyntaxKind.ClassDeclaration; + case SyntaxKind.PublicKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + return containingNodeKind === SyntaxKind.PropertyDeclaration; + } + + // Previous token may have been a keyword that was converted to an identifier. + switch (previousToken.getText()) { + case "public": + case "protected": + case "private": + return true; } } @@ -2457,16 +2469,16 @@ module ts { containingNodeKind === SyntaxKind.VariableStatement || containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | isFunction(containingNodeKind) || - containingNodeKind === SyntaxKind.ClassDeclaration || // class A 0 && !classifyKeywordsInGenerics) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts index cb1b7592518..10293c41a64 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts @@ -14,11 +14,13 @@ ////class bar6{ constructor(public a/*constructorParamter2*/ -////class bar7{ constructor(private a/*constructorParamter3*/ +////class bar7{ constructor(protected a/*constructorParamter3*/ -////class bar8{ constructor(.../*constructorParamter4*/ +////class bar8{ constructor(private a/*constructorParamter4*/ -////class bar9{ constructor(...a/*constructorParamter5*/ +////class bar9{ constructor(.../*constructorParamter5*/ + +////class bar10{ constructor(...a/*constructorParamter6*/ test.markers().forEach((m) => { diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts new file mode 100644 index 00000000000..f15868d2158 --- /dev/null +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts @@ -0,0 +1,38 @@ +/// + +////var aa = 1; + +////class A1 { +//// /*property1*/ +////} + +////class A2 { +//// p/*property2*/ +////} + +////class A3 { +//// public s/*property3*/ +////} + +////class A4 { +//// a/*property4*/ +////} + +////class A5 { +//// public a/*property5*/ +////} + +////class A6 { +//// protected a/*property6*/ +////} + +////class A7 { +//// private a/*property7*/ +////} + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + debugger; + verify.not.completionListIsEmpty(); + verify.completionListIsBuilder(); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListBuilderLocations_properties.ts b/tests/cases/fourslash/completionListBuilderLocations_properties.ts new file mode 100644 index 00000000000..287ffd6746b --- /dev/null +++ b/tests/cases/fourslash/completionListBuilderLocations_properties.ts @@ -0,0 +1,16 @@ +/// + +////var aa = 1; + +////class A1 { +//// public static /*property1*/ +////} + +////class A2 { +//// public static a/*property2*/ +////} + +test.markers().forEach((m) => { + goTo.position(m.position, m.fileName); + verify.completionListIsEmpty(); +}); \ No newline at end of file