Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into refactor_findallrefs
  • Loading branch information
Andy Hanson committed Mar 1, 2017
commit aac3d80fc4c46ee72964ba89d8317d884b091552
49 changes: 31 additions & 18 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,37 @@ namespace ts {
return node ? getContextualType(node) : undefined;
},
getFullyQualifiedName,
getResolvedSignature,
getConstantValue,
isValidPropertyAccess,
getSignatureFromDeclaration,
isImplementationOfOverload,
getImmediateAliasedSymbol,
getResolvedSignature: (node, candidatesOutArray?) => {
node = getParseTreeNode(node, isCallLikeExpression);
return node ? getResolvedSignature(node, candidatesOutArray) : undefined;
},
getConstantValue: node => {
node = getParseTreeNode(node, canHaveConstantValue);
return node ? getConstantValue(node) : undefined;
},
isValidPropertyAccess: (node, propertyName) => {
node = getParseTreeNode(node, isPropertyAccessOrQualifiedName);
return node ? isValidPropertyAccess(node, propertyName) : false;
},
getSignatureFromDeclaration: declaration => {
declaration = getParseTreeNode(declaration, isFunctionLike);
return declaration ? getSignatureFromDeclaration(declaration) : undefined;
},
isImplementationOfOverload: node => {
node = getParseTreeNode(node, isFunctionLike);
return node ? isImplementationOfOverload(node) : undefined;
},
getImmediateAliasedSymbol: symbol => {
Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here.");
const links = getSymbolLinks(symbol);
if (!links.immediateTarget) {
const node = getDeclarationOfAliasSymbol(symbol);
Debug.assert(!!node);
links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/true);
}

return links.immediateTarget;
},
getAliasedSymbol: resolveAlias,
getEmitResolver,
getExportsOfModule: getExportsOfModuleAsArray,
Expand Down Expand Up @@ -1363,18 +1388,6 @@ namespace ts {
return shouldResolve ? resolveAlias(symbol) : symbol;
}

function getImmediateAliasedSymbol(symbol: Symbol): Symbol {
Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here.");
const links = getSymbolLinks(symbol);
if (!links.immediateTarget) {
const node = getDeclarationOfAliasSymbol(symbol);
Debug.assert(!!node);
links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/true);
}

return links.immediateTarget;
}

function resolveAlias(symbol: Symbol): Symbol {
Debug.assert((symbol.flags & SymbolFlags.Alias) !== 0, "Should only get Alias here.");
const links = getSymbolLinks(symbol);
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/fourslash/findAllRefsForDefaultExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a";
/////*ref*/[|g|]();

// @Filename: c.ts
////import { f } from "./a";

const ranges = test.ranges();
const [r0, r1, r2] = ranges;
verify.referenceGroups(r0, [
Expand All @@ -15,4 +18,5 @@ verify.referenceGroups(r0, [
]);
verify.referenceGroups(r1, [{ definition: "import g", ranges: [r1, r2] }]);
verify.referenceGroups(r2, [{ definition: "(alias) g(): void\nimport g", ranges: [r1, r2] }]);

verify.goToDefinition("ref", "def");
5 changes: 2 additions & 3 deletions tests/cases/fourslash/renameJsPropertyAssignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
////function bar() {
////}
////bar.[|foo|] = "foo";
////console.log(bar./**/[|foo|]);
////console.log(bar.[|foo|]);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
verify.rangesAreRenameLocations();
5 changes: 2 additions & 3 deletions tests/cases/fourslash/renameJsPropertyAssignment2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
////class Minimatch {
////}
////Minimatch.[|staticProperty|] = "string";
////console.log(Minimatch./**/[|staticProperty|]);
////console.log(Minimatch.[|staticProperty|]);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
verify.rangesAreRenameLocations();
5 changes: 2 additions & 3 deletions tests/cases/fourslash/renameJsPropertyAssignment3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
////var C = class {
////}
////C.[|staticProperty|] = "string";
////console.log(C./**/[|staticProperty|]);
////console.log(C.[|staticProperty|]);

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
verify.rangesAreRenameLocations();
6 changes: 3 additions & 3 deletions tests/cases/fourslash/renameJsSpecialAssignmentRhs1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//// this._x = x;
//// },
//// copy: function ([|x|]) {
//// this._x = /**/[|x|].prop;
//// this._x = [|x|].prop;
//// }
////};
goTo.marker();
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);

verify.rangesAreRenameLocations();
6 changes: 3 additions & 3 deletions tests/cases/fourslash/renameJsSpecialAssignmentRhs2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//// set: function (x) {
//// this._x = x;
//// },
//// copy: function (/**/[|x|]) {
//// copy: function ([|x|]) {
//// this._x = [|x|].prop;
//// }
////};
goTo.marker();
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);

verify.rangesAreRenameLocations();
5 changes: 2 additions & 3 deletions tests/cases/fourslash/renameJsThisProperty05.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
////}
////C.prototype.[|z|] = 1;
////var t = new C(12);
////t./**/[|z|] = 11;
////t.[|z|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
verify.rangesAreRenameLocations();
5 changes: 2 additions & 3 deletions tests/cases/fourslash/renameJsThisProperty06.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
////}
////C.prototype.[|z|] = 1;
////var t = new C(12);
////t./**/[|z|] = 11;
////t.[|z|] = 11;

goTo.marker();
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
verify.rangesAreRenameLocations();
You are viewing a condensed version of this merge commit. You can view the full changes here.