Skip to content

Commit 2d64a23

Browse files
author
Andy Hanson
committed
Merge branch 'master' into services_modules_2
2 parents 4d6bd9d + c16ae3e commit 2d64a23

File tree

4 files changed

+63
-61
lines changed

4 files changed

+63
-61
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"ts-node": "latest",
7878
"tsd": "latest",
7979
"tslint": "next",
80-
"typescript": "next"
80+
"typescript": "2.1.0-dev.20160906"
8181
},
8282
"scripts": {
8383
"pretest": "jake tests",

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ namespace ts {
435435
TypeExcludesFlags = YieldContext | AwaitContext,
436436
}
437437

438+
export type ModifiersArray = NodeArray<Modifier>;
439+
438440
export const enum ModifierFlags {
439441
None = 0,
440442
Export = 1 << 0, // Declarations
@@ -480,7 +482,7 @@ namespace ts {
480482
/* @internal */ modifierFlagsCache?: ModifierFlags;
481483
/* @internal */ transformFlags?: TransformFlags;
482484
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
483-
modifiers?: NodeArray<Modifier>; // Array of modifiers
485+
modifiers?: ModifiersArray; // Array of modifiers
484486
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
485487
parent?: Node; // Parent node (initialized by binding)
486488
/* @internal */ original?: Node; // The original node if this is an updated node.

src/compiler/utilities.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -596,60 +596,6 @@ namespace ts {
596596
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
597597
}
598598

599-
function walkUpBindingElementsAndPatterns(node: Node): Node {
600-
while (node && (node.kind === SyntaxKind.BindingElement || isBindingPattern(node))) {
601-
node = node.parent;
602-
}
603-
604-
return node;
605-
}
606-
607-
export function getCombinedModifierFlags(node: Node): ModifierFlags {
608-
node = walkUpBindingElementsAndPatterns(node);
609-
let flags = getModifierFlags(node);
610-
if (node.kind === SyntaxKind.VariableDeclaration) {
611-
node = node.parent;
612-
}
613-
614-
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
615-
flags |= getModifierFlags(node);
616-
node = node.parent;
617-
}
618-
619-
if (node && node.kind === SyntaxKind.VariableStatement) {
620-
flags |= getModifierFlags(node);
621-
}
622-
623-
return flags;
624-
}
625-
626-
// Returns the node flags for this node and all relevant parent nodes. This is done so that
627-
// nodes like variable declarations and binding elements can returned a view of their flags
628-
// that includes the modifiers from their container. i.e. flags like export/declare aren't
629-
// stored on the variable declaration directly, but on the containing variable statement
630-
// (if it has one). Similarly, flags for let/const are store on the variable declaration
631-
// list. By calling this function, all those flags are combined so that the client can treat
632-
// the node as if it actually had those flags.
633-
export function getCombinedNodeFlags(node: Node): NodeFlags {
634-
node = walkUpBindingElementsAndPatterns(node);
635-
636-
let flags = node.flags;
637-
if (node.kind === SyntaxKind.VariableDeclaration) {
638-
node = node.parent;
639-
}
640-
641-
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
642-
flags |= node.flags;
643-
node = node.parent;
644-
}
645-
646-
if (node && node.kind === SyntaxKind.VariableStatement) {
647-
flags |= node.flags;
648-
}
649-
650-
return flags;
651-
}
652-
653599
export function isConst(node: Node): boolean {
654600
return !!(getCombinedNodeFlags(node) & NodeFlags.Const)
655601
|| !!(getCombinedModifierFlags(node) & ModifierFlags.Const);
@@ -4370,4 +4316,58 @@ namespace ts {
43704316
export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean {
43714317
return hasModifier(node, ModifierFlags.ParameterPropertyModifier) && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
43724318
}
4319+
4320+
function walkUpBindingElementsAndPatterns(node: Node): Node {
4321+
while (node && (node.kind === SyntaxKind.BindingElement || isBindingPattern(node))) {
4322+
node = node.parent;
4323+
}
4324+
4325+
return node;
4326+
}
4327+
4328+
export function getCombinedModifierFlags(node: Node): ModifierFlags {
4329+
node = walkUpBindingElementsAndPatterns(node);
4330+
let flags = getModifierFlags(node);
4331+
if (node.kind === SyntaxKind.VariableDeclaration) {
4332+
node = node.parent;
4333+
}
4334+
4335+
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
4336+
flags |= getModifierFlags(node);
4337+
node = node.parent;
4338+
}
4339+
4340+
if (node && node.kind === SyntaxKind.VariableStatement) {
4341+
flags |= getModifierFlags(node);
4342+
}
4343+
4344+
return flags;
4345+
}
4346+
4347+
// Returns the node flags for this node and all relevant parent nodes. This is done so that
4348+
// nodes like variable declarations and binding elements can returned a view of their flags
4349+
// that includes the modifiers from their container. i.e. flags like export/declare aren't
4350+
// stored on the variable declaration directly, but on the containing variable statement
4351+
// (if it has one). Similarly, flags for let/const are store on the variable declaration
4352+
// list. By calling this function, all those flags are combined so that the client can treat
4353+
// the node as if it actually had those flags.
4354+
export function getCombinedNodeFlags(node: Node): NodeFlags {
4355+
node = walkUpBindingElementsAndPatterns(node);
4356+
4357+
let flags = node.flags;
4358+
if (node.kind === SyntaxKind.VariableDeclaration) {
4359+
node = node.parent;
4360+
}
4361+
4362+
if (node && node.kind === SyntaxKind.VariableDeclarationList) {
4363+
flags |= node.flags;
4364+
node = node.parent;
4365+
}
4366+
4367+
if (node && node.kind === SyntaxKind.VariableStatement) {
4368+
flags |= node.flags;
4369+
}
4370+
4371+
return flags;
4372+
}
43734373
}

src/services/completions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ namespace ts.Completions {
578578

579579
if (host.getDirectories) {
580580
// Also get all @types typings installed in visible node_modules directories
581-
for (const package of findPackageJsons(scriptPath)) {
582-
const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types");
581+
for (const packageJson of findPackageJsons(scriptPath)) {
582+
const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types");
583583
getCompletionEntriesFromDirectories(host, options, typesDir, span, result);
584584
}
585585
}
@@ -625,8 +625,8 @@ namespace ts.Completions {
625625

626626
if (host.readFile && host.fileExists) {
627627
for (const packageJson of findPackageJsons(scriptPath)) {
628-
const package = tryReadingPackageJson(packageJson);
629-
if (!package) {
628+
const contents = tryReadingPackageJson(packageJson);
629+
if (!contents) {
630630
return;
631631
}
632632

@@ -635,7 +635,7 @@ namespace ts.Completions {
635635

636636
// Provide completions for all non @types dependencies
637637
for (const key of nodeModulesDependencyKeys) {
638-
addPotentialPackageNames(package[key], foundModuleNames);
638+
addPotentialPackageNames(contents[key], foundModuleNames);
639639
}
640640

641641
for (const moduleName of foundModuleNames) {

0 commit comments

Comments
 (0)