Try parsing signatures only if node is callable, see #149; Minor refactoring

This commit is contained in:
dcodeIO
2018-06-24 01:04:24 +02:00
parent 7a8995b18b
commit 188b4e48ce
14 changed files with 933 additions and 813 deletions

View File

@ -9,7 +9,7 @@ import {
STATIC_DELIMITER,
INSTANCE_DELIMITER,
LIBRARY_PREFIX
} from "./program";
} from "./common";
import {
Token,
@ -110,6 +110,26 @@ export function nodeIsConstantValue(kind: NodeKind): bool {
return false;
}
/** Checks if a node might be callable. */
export function nodeIsCallable(kind: NodeKind): bool {
switch (kind) {
case NodeKind.IDENTIFIER:
case NodeKind.CALL:
case NodeKind.ELEMENTACCESS:
case NodeKind.PROPERTYACCESS: return true;
}
return false;
}
/** Checks if a node might be callable with generic arguments. */
export function nodeIsGenericCallable(kind: NodeKind): bool {
switch (kind) {
case NodeKind.IDENTIFIER:
case NodeKind.PROPERTYACCESS: return true;
}
return false;
}
/** Base class of all nodes. */
export abstract class Node {