mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Introduce a new HeritageClauseElment type.
This type represents the expression+type arguments you can get in a class or interface heritage clause section. For class-implements clauses, or interface-extends clauses, these expressions can only be identifiers or dotted names. For class extends clauses, these could be any expressions in the future. However, for now, we only support identifiers and dotted names.
This commit is contained in:
@@ -2932,7 +2932,7 @@ module ts {
|
||||
|
||||
function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
|
||||
let completionData = getCompletionData(fileName, position);
|
||||
if (!completionData) {
|
||||
return undefined;
|
||||
@@ -4887,7 +4887,7 @@ module ts {
|
||||
}
|
||||
return;
|
||||
|
||||
function getPropertySymbolFromTypeReference(typeReference: TypeReferenceNode) {
|
||||
function getPropertySymbolFromTypeReference(typeReference: HeritageClauseElement) {
|
||||
if (typeReference) {
|
||||
let type = typeInfoResolver.getTypeAtLocation(typeReference);
|
||||
if (type) {
|
||||
@@ -5144,19 +5144,44 @@ module ts {
|
||||
}
|
||||
|
||||
function isTypeReference(node: Node): boolean {
|
||||
if (isRightSideOfQualifiedName(node)) {
|
||||
if (isRightSideOfQualifiedNameOrPropertyAccess(node) ) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeReference;
|
||||
return node.parent.kind === SyntaxKind.TypeReference || node.parent.kind === SyntaxKind.HeritageClauseElement;
|
||||
}
|
||||
|
||||
function isNamespaceReference(node: Node): boolean {
|
||||
return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node);
|
||||
}
|
||||
|
||||
function isPropertyAccessNamespaceReference(node: Node): boolean {
|
||||
let root = node;
|
||||
let isLastClause = true;
|
||||
if (root.parent.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
while (root.parent && root.parent.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
root = root.parent;
|
||||
}
|
||||
|
||||
isLastClause = (<PropertyAccessExpression>root).name === node;
|
||||
}
|
||||
|
||||
if (!isLastClause && root.parent.kind === SyntaxKind.HeritageClauseElement && root.parent.parent.kind === SyntaxKind.HeritageClause) {
|
||||
let decl = root.parent.parent.parent;
|
||||
return (decl.kind === SyntaxKind.ClassDeclaration && (<HeritageClause>root.parent.parent).token === SyntaxKind.ImplementsKeyword) ||
|
||||
(decl.kind === SyntaxKind.InterfaceDeclaration && (<HeritageClause>root.parent.parent).token === SyntaxKind.ExtendsKeyword);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isQualifiedNameNamespaceReference(node: Node): boolean {
|
||||
let root = node;
|
||||
let isLastClause = true;
|
||||
if (root.parent.kind === SyntaxKind.QualifiedName) {
|
||||
while (root.parent && root.parent.kind === SyntaxKind.QualifiedName)
|
||||
while (root.parent && root.parent.kind === SyntaxKind.QualifiedName) {
|
||||
root = root.parent;
|
||||
}
|
||||
|
||||
isLastClause = (<QualifiedName>root).right === node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user