Skip to content

Commit dc3c5c5

Browse files
author
Yui T
committed
Merge branch 'master' into refactorRefFilesPath
2 parents 35facf5 + d634ab8 commit dc3c5c5

7 files changed

+245
-23
lines changed

src/services/services.ts

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,25 @@ module ts {
352352
function isName(pos: number, end: number, sourceFile: SourceFile, name: string) {
353353
return pos + name.length < end &&
354354
sourceFile.text.substr(pos, name.length) === name &&
355-
isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length));
355+
(isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) ||
356+
isLineBreak(sourceFile.text.charCodeAt(pos + name.length)));
356357
}
357358

358359
function isParamTag(pos: number, end: number, sourceFile: SourceFile) {
359360
// If it is @param tag
360361
return isName(pos, end, sourceFile, paramTag);
361362
}
362363

364+
function pushDocCommentLineText(docComments: SymbolDisplayPart[], text: string, blankLineCount: number) {
365+
// Add the empty lines in between texts
366+
while (blankLineCount--) docComments.push(textPart(""));
367+
docComments.push(textPart(text));
368+
}
369+
363370
function getCleanedJsDocComment(pos: number, end: number, sourceFile: SourceFile) {
364371
var spacesToRemoveAfterAsterisk: number;
365372
var docComments: SymbolDisplayPart[] = [];
373+
var blankLineCount = 0;
366374
var isInParamTag = false;
367375

368376
while (pos < end) {
@@ -411,7 +419,12 @@ module ts {
411419
// Continue with next line
412420
pos = consumeLineBreaks(pos, end, sourceFile);
413421
if (docCommentTextOfLine) {
414-
docComments.push(textPart(docCommentTextOfLine));
422+
pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount);
423+
blankLineCount = 0;
424+
}
425+
else if (!isInParamTag && docComments.length) {
426+
// This is blank line when there is text already parsed
427+
blankLineCount++;
415428
}
416429
}
417430

@@ -423,6 +436,8 @@ module ts {
423436
var paramDocComments: SymbolDisplayPart[] = [];
424437
while (pos < end) {
425438
if (isParamTag(pos, end, sourceFile)) {
439+
var blankLineCount = 0;
440+
var recordedParamTag = false;
426441
// Consume leading spaces
427442
pos = consumeWhiteSpaces(pos + paramTag.length);
428443
if (pos >= end) {
@@ -484,8 +499,13 @@ module ts {
484499
// at line break, set this comment line text and go to next line
485500
if (isLineBreak(ch)) {
486501
if (paramHelpString) {
487-
paramDocComments.push(textPart(paramHelpString));
502+
pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount);
488503
paramHelpString = "";
504+
blankLineCount = 0;
505+
recordedParamTag = true;
506+
}
507+
else if (recordedParamTag) {
508+
blankLineCount++;
489509
}
490510

491511
// Get the pos after cleaning start of the line
@@ -506,7 +526,7 @@ module ts {
506526

507527
// If there is param help text, add it top the doc comments
508528
if (paramHelpString) {
509-
paramDocComments.push(textPart(paramHelpString));
529+
pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount);
510530
}
511531
paramHelpStringMargin = undefined;
512532
}
@@ -2682,6 +2702,7 @@ module ts {
26822702
case SyntaxKind.VarKeyword:
26832703
case SyntaxKind.GetKeyword:
26842704
case SyntaxKind.SetKeyword:
2705+
case SyntaxKind.ImportKeyword:
26852706
return true;
26862707
}
26872708

@@ -2852,10 +2873,10 @@ module ts {
28522873

28532874
if (flags & SymbolFlags.Property) {
28542875
if (flags & SymbolFlags.UnionProperty) {
2855-
// If union property is result of union of non method (property/accessors), it is labeled as property
2876+
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
28562877
var unionPropertyKind = forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
28572878
var rootSymbolFlags = rootSymbol.getFlags();
2858-
if (rootSymbolFlags & (SymbolFlags.Property | SymbolFlags.GetAccessor | SymbolFlags.SetAccessor)) {
2879+
if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) {
28592880
return ScriptElementKind.memberVariableElement;
28602881
}
28612882
Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method));
@@ -3129,21 +3150,26 @@ module ts {
31293150
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
31303151
displayParts.push(spacePart());
31313152
addFullSymbolName(symbol);
3132-
displayParts.push(spacePart());
3133-
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
3134-
displayParts.push(spacePart());
31353153
ts.forEach(symbol.declarations, declaration => {
31363154
if (declaration.kind === SyntaxKind.ImportDeclaration) {
31373155
var importDeclaration = <ImportDeclaration>declaration;
31383156
if (importDeclaration.externalModuleName) {
3157+
displayParts.push(spacePart());
3158+
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
3159+
displayParts.push(spacePart());
31393160
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
31403161
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
31413162
displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral));
31423163
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
31433164
}
31443165
else {
31453166
var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName);
3146-
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
3167+
if (internalAliasSymbol) {
3168+
displayParts.push(spacePart());
3169+
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
3170+
displayParts.push(spacePart());
3171+
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
3172+
}
31473173
}
31483174
return true;
31493175
}

src/services/shims.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,6 @@ module ts {
517517
};
518518
}
519519

520-
private realizeDiagnosticWithFileName(diagnostic: Diagnostic): { fileName: string; message: string; start: number; length: number; category: string; } {
521-
return {
522-
fileName: diagnostic.file.filename,
523-
message: diagnostic.messageText,
524-
start: diagnostic.start,
525-
length: diagnostic.length,
526-
/// TODO: no need for the tolowerCase call
527-
category: DiagnosticCategory[diagnostic.category].toLowerCase()
528-
};
529-
}
530-
531520
public getSyntacticClassifications(fileName: string, start: number, length: number): string {
532521
return this.forwardJSONCall(
533522
"getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")",
@@ -569,7 +558,7 @@ module ts {
569558
"getCompilerOptionsDiagnostics()",
570559
() => {
571560
var errors = this.languageService.getCompilerOptionsDiagnostics();
572-
return errors.map(d => this.realizeDiagnosticWithFileName(d))
561+
return errors.map(LanguageServiceShimObject.realizeDiagnostic)
573562
});
574563
}
575564

src/services/utilities.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ module ts {
224224
return nodeHasTokens((<ExpressionStatement>n).expression);
225225
}
226226

227-
if (n.kind === SyntaxKind.EndOfFileToken || n.kind === SyntaxKind.OmittedExpression || n.kind === SyntaxKind.Missing) {
227+
if (n.kind === SyntaxKind.EndOfFileToken ||
228+
n.kind === SyntaxKind.OmittedExpression ||
229+
n.kind === SyntaxKind.Missing ||
230+
n.kind === SyntaxKind.Unknown) {
228231
return false;
229232
}
230233

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** This is firstLine
4+
//// * This is second Line
5+
//// *
6+
//// * This is fourth Line
7+
//// */
8+
////var /*a*/a: string;
9+
/////**
10+
//// * This is firstLine
11+
//// * This is second Line
12+
//// *
13+
//// * This is fourth Line
14+
//// */
15+
////var /*b*/b: string;
16+
/////**
17+
//// * This is firstLine
18+
//// * This is second Line
19+
//// *
20+
//// * This is fourth Line
21+
//// *
22+
//// */
23+
////var /*c*/c: string;
24+
/////**
25+
//// * This is firstLine
26+
//// * This is second Line
27+
//// * @param param
28+
//// * @random tag This should be third line
29+
//// */
30+
////function /*d*/d(param: string) { /*1*/param = "hello"; }
31+
/////**
32+
//// * This is firstLine
33+
//// * This is second Line
34+
//// * @param param
35+
//// */
36+
////function /*e*/e(param: string) { /*2*/param = "hello"; }
37+
/////**
38+
//// * This is firstLine
39+
//// * This is second Line
40+
//// * @param param1 first line of param
41+
//// *
42+
//// * param information third line
43+
//// * @random tag This should be third line
44+
//// */
45+
////function /*f*/f(param1: string) { /*3*/param1 = "hello"; }
46+
/////**
47+
//// * This is firstLine
48+
//// * This is second Line
49+
//// * @param param1
50+
//// *
51+
//// * param information first line
52+
//// * @random tag This should be third line
53+
//// */
54+
////function /*g*/g(param1: string) { /*4*/param1 = "hello"; }
55+
/////**
56+
//// * This is firstLine
57+
//// * This is second Line
58+
//// * @param param1
59+
//// *
60+
//// * param information first line
61+
//// *
62+
//// * param information third line
63+
//// * @random tag This should be third line
64+
//// */
65+
////function /*h*/h(param1: string) { /*5*/param1 = "hello"; }
66+
/////**
67+
//// * This is firstLine
68+
//// * This is second Line
69+
//// * @param param1
70+
//// *
71+
//// * param information first line
72+
//// *
73+
//// * param information third line
74+
//// *
75+
//// */
76+
////function /*i*/i(param1: string) { /*6*/param1 = "hello"; }
77+
/////**
78+
//// * This is firstLine
79+
//// * This is second Line
80+
//// * @param param1
81+
//// *
82+
//// * param information first line
83+
//// *
84+
//// * param information third line
85+
//// */
86+
////function /*j*/j(param1: string) { /*7*/param1 = "hello"; }
87+
/////**
88+
//// * This is firstLine
89+
//// * This is second Line
90+
//// * @param param1 hello @randomtag
91+
//// *
92+
//// * random information first line
93+
//// *
94+
//// * random information third line
95+
//// */
96+
////function /*k*/k(param1: string) { /*8*/param1 = "hello"; }
97+
/////**
98+
//// * This is firstLine
99+
//// * This is second Line
100+
//// * @param param1 first Line text
101+
//// *
102+
//// * @param param1
103+
//// *
104+
//// * blank line that shouldnt be shown when starting this
105+
//// * second time information about the param again
106+
//// */
107+
////function /*l*/l(param1: string) { /*9*/param1 = "hello"; }
108+
109+
goTo.marker('a');
110+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
111+
112+
goTo.marker('b');
113+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
114+
115+
goTo.marker('c');
116+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
117+
118+
goTo.marker('d');
119+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
120+
goTo.marker('1');
121+
verify.quickInfoIs(undefined, "");
122+
123+
goTo.marker('e');
124+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
125+
goTo.marker('2');
126+
verify.quickInfoIs(undefined, "");
127+
128+
goTo.marker('f');
129+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
130+
goTo.marker('3');
131+
verify.quickInfoIs(undefined, "first line of param\n\nparam information third line");
132+
133+
goTo.marker('g');
134+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
135+
goTo.marker('4');
136+
verify.quickInfoIs(undefined, "param information first line");
137+
138+
goTo.marker('h');
139+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
140+
goTo.marker('5');
141+
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
142+
143+
goTo.marker('i');
144+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
145+
goTo.marker('6');
146+
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
147+
148+
goTo.marker('j');
149+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
150+
goTo.marker('7');
151+
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
152+
153+
goTo.marker('k');
154+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@randomtag \n\n random information first line\n\n random information third line");
155+
goTo.marker('8');
156+
verify.quickInfoIs(undefined, "hello ");
157+
158+
goTo.marker('l');
159+
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
160+
goTo.marker('9');
161+
verify.quickInfoIs(undefined, "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////@a/**/
4+
5+
goTo.marker();
6+
verify.not.completionListIsEmpty();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
///<reference path="fourslash.ts" />
2+
3+
////import /*1*/ /*2*/
4+
5+
goTo.marker('1');
6+
verify.completionListIsEmpty();
7+
edit.insert('q');
8+
verify.completionListIsEmpty();
9+
verifyIncompleteImportName();
10+
11+
goTo.marker('2');
12+
edit.insert(" = ");
13+
verifyIncompleteImportName();
14+
15+
goTo.marker("2");
16+
edit.moveRight(" = ".length);
17+
edit.insert("a.");
18+
verifyIncompleteImportName();
19+
20+
function verifyIncompleteImportName() {
21+
goTo.marker('1');
22+
verify.completionListIsEmpty();
23+
verify.quickInfoIs("import q");
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
///<reference path="fourslash.ts" />
2+
3+
////module E {
4+
//// export var n = 1;
5+
////}
6+
////module F {
7+
//// export var n = 1;
8+
////}
9+
////var q: typeof E | typeof F;
10+
////var j = q./*1*/
11+
12+
goTo.marker('1');
13+
verify.completionListContains('n', "(property) n: number");

0 commit comments

Comments
 (0)