mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add isDefinition to ReferenceEntry
Clients can now easily tell if the reference is to a definition or a usage.
This commit is contained in:
@@ -376,6 +376,7 @@ namespace ts.server {
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: entry.isWriteAccess,
|
||||
isDefinition: entry.isDefinition,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -304,6 +304,11 @@ declare namespace ts.server.protocol {
|
||||
* True if reference is a write location, false otherwise.
|
||||
*/
|
||||
isWriteAccess: boolean;
|
||||
|
||||
/**
|
||||
* True if reference is a definition, false otherwise.
|
||||
*/
|
||||
isDefinition?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -379,7 +379,7 @@ namespace ts.server {
|
||||
start,
|
||||
end,
|
||||
file: fileName,
|
||||
isWriteAccess
|
||||
isWriteAccess,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -555,7 +555,8 @@ namespace ts.server {
|
||||
start: start,
|
||||
lineText: lineText,
|
||||
end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)),
|
||||
isWriteAccess: ref.isWriteAccess
|
||||
isWriteAccess: ref.isWriteAccess,
|
||||
isDefinition: ref.isDefinition
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1208,6 +1208,7 @@ namespace ts {
|
||||
textSpan: TextSpan;
|
||||
fileName: string;
|
||||
isWriteAccess: boolean;
|
||||
isDefinition?: boolean;
|
||||
}
|
||||
|
||||
export interface DocumentHighlights {
|
||||
@@ -6183,7 +6184,8 @@ namespace ts {
|
||||
references: [{
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan: createTextSpan(position, searchText.length),
|
||||
isWriteAccess: false
|
||||
isWriteAccess: false,
|
||||
isDefinition: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -6737,7 +6739,8 @@ namespace ts {
|
||||
return {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: isWriteAccess(node)
|
||||
isWriteAccess: isWriteAccess(node),
|
||||
isDefinition: isDeclarationName(node)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[]
|
||||
*/
|
||||
getReferencesAtPosition(fileName: string, position: number): string;
|
||||
|
||||
@@ -1141,4 +1141,4 @@ namespace TypeScript.Services {
|
||||
/* @internal */
|
||||
const toolsVersion = "1.9";
|
||||
|
||||
/* tslint:enable:no-unused-variable */
|
||||
/* tslint:enable:no-unused-variable */
|
||||
|
||||
Reference in New Issue
Block a user