use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class IdentifierRefImpl method setId.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setId(IdentifiableElement newId) {
IdentifiableElement oldId = id;
id = newId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.IDENTIFIER_REF__ID, oldId, id));
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class N4JSCrossReferenceComputer method computeCrossRefs.
/*
* Browse all references type by the EClass of the given EObject ignoring References between AST element to its
* defined type and vice versa.
*/
private void computeCrossRefs(Resource resource, EObject from, IAcceptor<EObject> acceptor) {
EList<EReference> references = from.eClass().getEAllReferences();
for (EReference eReference : references) {
// We only follow cross references
if (!eReference.isContainment() && !eReference.isContainer()) {
// Ignore references between AST element and its defined type and vice versa
if (eReference != N4JSPackage.Literals.TYPE_DEFINING_ELEMENT__DEFINED_TYPE && eReference != TypesPackage.Literals.SYNTAX_RELATED_TELEMENT__AST_ELEMENT) {
if (from.eIsSet(eReference)) {
Object val = from.eGet(eReference);
// Handle both toOne and toMany cases
if (!eReference.isMany()) {
EObject to = (EObject) val;
handleReferenceObject(resource, acceptor, to);
} else {
@SuppressWarnings("unchecked") BasicEList<EObject> list = (BasicEList<EObject>) val;
// cases
if (TypesPackage.Literals.TYPE.isSuperTypeOf(eReference.getEReferenceType())) {
for (EObject to : list) {
handleType(resource, acceptor, (Type) to);
}
} else if (TypesPackage.Literals.IDENTIFIABLE_ELEMENT.isSuperTypeOf(eReference.getEReferenceType())) {
for (EObject to : list) {
handleIdentifiableElement(resource, acceptor, (IdentifiableElement) to);
}
} else {
// Handle all other cases
for (EObject to : list) {
handleReferenceObject(resource, acceptor, to);
}
}
}
}
}
}
}
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class SymbolTableEntryOriginalImpl method setOriginalTarget.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOriginalTarget(IdentifiableElement newOriginalTarget) {
IdentifiableElement oldOriginalTarget = originalTarget;
originalTarget = newOriginalTarget;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImPackage.SYMBOL_TABLE_ENTRY_ORIGINAL__ORIGINAL_TARGET, oldOriginalTarget, originalTarget));
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class AccessModifierXpectMethod method calculateActual.
private String calculateActual(EObject context) {
String actual = null;
if (context instanceof TMember) {
TMember tMember = (TMember) context;
actual = tMember.getMemberAccessModifier().getName();
} else {
FunctionDeclaration functionDeclaration = EcoreUtil2.getContainerOfType(context, FunctionDeclaration.class);
if (functionDeclaration != null) {
actual = functionDeclaration.getDefinedType().getTypeAccessModifier().getName();
} else {
VariableStatement variableStatement = EcoreUtil2.getContainerOfType(context, VariableStatement.class);
if (variableStatement != null) {
context = variableStatement.getVarDecl().get(0);
if (context instanceof ExportedVariableDeclaration) {
actual = ((ExportedVariableDeclaration) context).getDefinedVariable().getTypeAccessModifier().getName();
} else if (context instanceof VariableDeclaration) {
actual = "private";
}
} else if (context instanceof ExportDeclaration) {
context = ((ExportDeclaration) context).getExportedElement();
actual = calculateActual(context);
} else if (context instanceof ParameterizedPropertyAccessExpression) {
ParameterizedPropertyAccessExpression ppae = (ParameterizedPropertyAccessExpression) context;
IdentifiableElement ie = ppae.getProperty();
actual = calculateActual(ie);
} else if (context instanceof ParameterizedCallExpression) {
ParameterizedCallExpression pce = (ParameterizedCallExpression) context;
Expression targetExpr = pce.getTarget();
actual = calculateActual(targetExpr);
} else {
N4MemberDeclaration member = EcoreUtil2.getContainerOfType(context, N4MemberDeclaration.class);
N4TypeDeclaration type = EcoreUtil2.getContainerOfType(context, N4TypeDeclaration.class);
if (type == null && member == null) {
actual = "no element with access modifier found";
} else if (type != null && (member == null || EcoreUtil.isAncestor(member, type))) {
actual = type.getDefinedType().getTypeAccessModifier().getName();
} else {
actual = member.getDefinedTypeElement().getMemberAccessModifier().getName();
}
}
}
}
return actual;
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class SymbolOfIdentifierRef method getDeclaration.
@Override
public EObject getDeclaration() {
VariableDeclaration varDecl = null;
IdentifiableElement id = ir.getId();
if (id instanceof TVariable) {
TVariable tvar = (TVariable) id;
varDecl = (VariableDeclaration) tvar.getAstElement();
return varDecl;
} else {
// id instanceof VariableDeclaration
return id;
}
}
Aggregations