mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Merge branch 'master' into object-spread
This commit is contained in:
commit
f9fe01a6e3
361 files changed
+10154
-1320
No files matched your search
@@ -1,3 +1,5 @@
|
||||
/// <reference path='../compiler/utilities.ts' />
|
||||
|
||||
/* @internal */
|
||||
namespace ts.Completions {
|
||||
export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo {
|
||||
@@ -951,7 +953,6 @@ namespace ts.Completions {
|
||||
if (!tryGetGlobalSymbols()) {
|
||||
return undefined;
|
||||
}
|
||||
isGlobalCompletion = true;
|
||||
}
|
||||
|
||||
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
||||
@@ -1030,7 +1031,6 @@ namespace ts.Completions {
|
||||
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
|
||||
// Cursor is inside a JSX self-closing element or opening element
|
||||
attrsType = typeChecker.getJsxElementAttributesType(<JsxOpeningLikeElement>jsxContainer);
|
||||
isGlobalCompletion = false;
|
||||
|
||||
if (attrsType) {
|
||||
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (<JsxOpeningLikeElement>jsxContainer).attributes);
|
||||
@@ -1038,7 +1038,6 @@ namespace ts.Completions {
|
||||
isNewIdentifierLocation = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1079,6 +1078,13 @@ namespace ts.Completions {
|
||||
position;
|
||||
|
||||
const scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
||||
if (scopeNode) {
|
||||
isGlobalCompletion =
|
||||
scopeNode.kind === SyntaxKind.SourceFile ||
|
||||
scopeNode.kind === SyntaxKind.TemplateExpression ||
|
||||
scopeNode.kind === SyntaxKind.JsxExpression ||
|
||||
isStatement(scopeNode);
|
||||
}
|
||||
|
||||
/// TODO filter meaning based on the current context
|
||||
const symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
|
||||
|
||||
@@ -624,10 +624,11 @@ namespace ts.formatting {
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
if (isToken(child)) {
|
||||
// JSX text shouldn't affect indenting
|
||||
if (isToken(child) && child.kind !== SyntaxKind.JsxText) {
|
||||
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
|
||||
const tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
Debug.assert(tokenInfo.token.end === child.end);
|
||||
Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
|
||||
Debug.assert(scanner === undefined);
|
||||
Debug.assert(scanner === undefined, "Scanner should be undefined");
|
||||
scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner;
|
||||
|
||||
scanner.setText(sourceFile.text);
|
||||
@@ -62,7 +62,7 @@ namespace ts.formatting {
|
||||
};
|
||||
|
||||
function advance(): void {
|
||||
Debug.assert(scanner !== undefined);
|
||||
Debug.assert(scanner !== undefined, "Scanner should be present");
|
||||
|
||||
lastTokenInfo = undefined;
|
||||
const isStarted = scanner.getStartPos() !== startPos;
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
private GetRuleBucketIndex(row: number, column: number): number {
|
||||
Debug.assert(row <= SyntaxKind.LastKeyword && column <= SyntaxKind.LastKeyword, "Must compute formatting context from tokens");
|
||||
const rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
// Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
return rulesBucketIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ namespace ts.NavigateTo {
|
||||
const patternMatcher = createPatternMatcher(searchValue);
|
||||
let rawItems: RawNavigateToItem[] = [];
|
||||
|
||||
// This means "compare in a case insensitive manner."
|
||||
const baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
|
||||
|
||||
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -188,8 +185,8 @@ namespace ts.NavigateTo {
|
||||
// We first sort case insensitively. So "Aaa" will come before "bar".
|
||||
// Then we sort case sensitively, so "aaa" will come before "Aaa".
|
||||
return i1.matchKind - i2.matchKind ||
|
||||
i1.name.localeCompare(i2.name, undefined, baseSensitivity) ||
|
||||
i1.name.localeCompare(i2.name);
|
||||
ts.compareStringsCaseInsensitive(i1.name, i2.name) ||
|
||||
ts.compareStrings(i1.name, i2.name);
|
||||
}
|
||||
|
||||
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
|
||||
|
||||
@@ -330,10 +330,8 @@ namespace ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
|
||||
const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined;
|
||||
// Intl is missing in Safari, and node 0.10 treats "a" as greater than "B".
|
||||
const localeCompareIsCorrect = collator && collator.compare("a", "B") < 0;
|
||||
const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0;
|
||||
const localeCompareFix: (a: string, b: string) => number = localeCompareIsCorrect ? collator.compare : function(a, b) {
|
||||
// This isn't perfect, but it passes all of our tests.
|
||||
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
||||
@@ -344,7 +342,7 @@ namespace ts.NavigationBar {
|
||||
if (chA === "'" && chB === "\"") {
|
||||
return -1;
|
||||
}
|
||||
const cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase());
|
||||
const cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase());
|
||||
if (cmp !== 0) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[] {
|
||||
const pattern = getFileMatcherPatterns(path, extensions, exclude, include,
|
||||
const pattern = getFileMatcherPatterns(path, exclude, include,
|
||||
this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
|
||||
return JSON.parse(this.shimHost.readDirectory(
|
||||
path,
|
||||
@@ -509,7 +509,7 @@ namespace ts {
|
||||
// Wrap the API changes for 2.0 release. This try/catch
|
||||
// should be removed once TypeScript 2.0 has shipped.
|
||||
try {
|
||||
const pattern = getFileMatcherPatterns(rootDir, extensions, exclude, include,
|
||||
const pattern = getFileMatcherPatterns(rootDir, exclude, include,
|
||||
this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
|
||||
return JSON.parse(this.shimHost.readDirectory(
|
||||
rootDir,
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"sourceMap": true,
|
||||
"stripInternal": true,
|
||||
"noResolve": false,
|
||||
"declaration": true
|
||||
"declaration": true,
|
||||
"target": "es5"
|
||||
},
|
||||
"files": [
|
||||
"../compiler/core.ts",
|
||||
@@ -26,13 +27,15 @@
|
||||
"../compiler/transformers/ts.ts",
|
||||
"../compiler/transformers/jsx.ts",
|
||||
"../compiler/transformers/experimental.ts",
|
||||
"../compiler/transformers/es7.ts",
|
||||
"../compiler/transformers/es6.ts",
|
||||
"../compiler/transformers/es2017.ts",
|
||||
"../compiler/transformers/es2016.ts",
|
||||
"../compiler/transformers/es2015.ts",
|
||||
"../compiler/transformers/generators.ts",
|
||||
"../compiler/transformers/generators.ts",
|
||||
"../compiler/transformers/destructuring.ts",
|
||||
"../compiler/transformers/module/module.ts",
|
||||
"../compiler/transformers/module/system.ts",
|
||||
"../compiler/transformers/module/es6.ts",
|
||||
"../compiler/transformers/module/es2015.ts",
|
||||
"../compiler/transformer.ts",
|
||||
"../compiler/comments.ts",
|
||||
"../compiler/sourcemap.ts",
|
||||
|
||||
@@ -750,7 +750,7 @@ namespace ts {
|
||||
return find(startNode || sourceFile);
|
||||
|
||||
function findRightmostToken(n: Node): Node {
|
||||
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
|
||||
if (isToken(n)) {
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function find(n: Node): Node {
|
||||
if (isToken(n) || n.kind === SyntaxKind.JsxText) {
|
||||
if (isToken(n)) {
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -1339,7 +1339,7 @@ namespace ts {
|
||||
const options: TranspileOptions = {
|
||||
fileName: "config.js",
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ES6,
|
||||
target: ScriptTarget.ES2015,
|
||||
removeComments: true
|
||||
},
|
||||
reportDiagnostics: true
|
||||
|
||||
Reference in new issue
Block a user