(sourceFile, position, search, state, addReferencesHere)
| 138160 | return !!(ts.getMeaningFromLocation(referenceLocation) & state.searchMeaning); |
| 138161 | } |
| 138162 | function getReferencesAtLocation(sourceFile, position, search, state, addReferencesHere) { |
| 138163 | var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); |
| 138164 | if (!isValidReferencePosition(referenceLocation, search.text)) { |
| 138165 | // This wasn't the start of a token. Check to see if it might be a |
| 138166 | // match in a comment or string if that's what the caller is asking |
| 138167 | // for. |
| 138168 | if (!state.options.implementations && (state.options.findInStrings && ts.isInString(sourceFile, position) || state.options.findInComments && ts.isInNonReferenceComment(sourceFile, position))) { |
| 138169 | // In the case where we're looking inside comments/strings, we don't have |
| 138170 | // an actual definition. So just use 'undefined' here. Features like |
| 138171 | // 'Rename' won't care (as they ignore the definitions), and features like |
| 138172 | // 'FindReferences' will just filter out these results. |
| 138173 | state.addStringOrCommentReference(sourceFile.fileName, ts.createTextSpan(position, search.text.length)); |
| 138174 | } |
| 138175 | return; |
| 138176 | } |
| 138177 | if (!hasMatchingMeaning(referenceLocation, state)) |
| 138178 | return; |
| 138179 | var referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation); |
| 138180 | if (!referenceSymbol) { |
| 138181 | return; |
| 138182 | } |
| 138183 | var parent = referenceLocation.parent; |
| 138184 | if (ts.isImportSpecifier(parent) && parent.propertyName === referenceLocation) { |
| 138185 | // This is added through `singleReferences` in ImportsResult. If we happen to see it again, don't add it again. |
| 138186 | return; |
| 138187 | } |
| 138188 | if (ts.isExportSpecifier(parent)) { |
| 138189 | ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); |
| 138190 | getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); |
| 138191 | return; |
| 138192 | } |
| 138193 | var relatedSymbol = getRelatedSymbol(search, referenceSymbol, referenceLocation, state); |
| 138194 | if (!relatedSymbol) { |
| 138195 | getReferenceForShorthandProperty(referenceSymbol, search, state); |
| 138196 | return; |
| 138197 | } |
| 138198 | switch (state.specialSearchKind) { |
| 138199 | case 0 /* SpecialSearchKind.None */: |
| 138200 | if (addReferencesHere) |
| 138201 | addReference(referenceLocation, relatedSymbol, state); |
| 138202 | break; |
| 138203 | case 1 /* SpecialSearchKind.Constructor */: |
| 138204 | addConstructorReferences(referenceLocation, sourceFile, search, state); |
| 138205 | break; |
| 138206 | case 2 /* SpecialSearchKind.Class */: |
| 138207 | addClassStaticThisReferences(referenceLocation, search, state); |
| 138208 | break; |
| 138209 | default: |
| 138210 | ts.Debug.assertNever(state.specialSearchKind); |
| 138211 | } |
| 138212 | // Use the parent symbol if the location is commonjs require syntax on javascript files only. |
| 138213 | if (ts.isInJSFile(referenceLocation) |
| 138214 | && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ |
| 138215 | && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) { |
| 138216 | referenceSymbol = referenceLocation.parent.symbol; |
| 138217 | // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In |
| 138218 | // this case, just skip it, since the bound identifiers are not an alias of the import. |
| 138219 | if (!referenceSymbol) |
no test coverage detected