use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class MethodDeclarationImpl method getDefinedTypeElement.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TMember getDefinedTypeElement() {
TMember _xifexpression = null;
Type _definedType = this.getDefinedType();
boolean _tripleEquals = (_definedType == null);
if (_tripleEquals) {
_xifexpression = null;
} else {
TMember _xifexpression_1 = null;
Type _definedType_1 = this.getDefinedType();
if ((_definedType_1 instanceof TMember)) {
Type _definedType_2 = this.getDefinedType();
_xifexpression_1 = ((TMember) _definedType_2);
} else {
throw new IllegalArgumentException("");
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
use of org.eclipse.n4js.ts.types.TMember 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.TMember in project n4js by eclipse.
the class ProjectCompareHelper method createEntries.
// may be made public later
private ProjectComparisonEntry createEntries(ProjectComparisonEntry parent, int index, EObject api, EObject[] impls, final boolean includePolyfills) {
final ProjectComparisonEntry entry = new ProjectComparisonEntry(parent, index, api, impls);
final EObject[] childrenOfApi = computeChildren(api, false, false, includePolyfills);
final EObject[][] childrenOfImpls = computeChildren(impls, false, true, includePolyfills);
// STEP 1: create entries for children of the API
final Set<EObject> doneImpl = new HashSet<>();
for (EObject childApi : childrenOfApi) {
final EObject[] implsForChildApi = computeMatches(childApi, childrenOfImpls, doneImpl);
// special: for missing members on implementation side, try to find matches among inherited members
if (childApi instanceof TMember) {
for (int idxImpl = 0; idxImpl < impls.length; idxImpl++) {
if (implsForChildApi[idxImpl] == null) {
final EObject currImpl = impls[idxImpl];
if (currImpl instanceof ContainerType<?>) {
implsForChildApi[idxImpl] = computeMatch(childApi, computeChildren(currImpl, true, true, includePolyfills), doneImpl);
}
}
}
}
createEntries(entry, -1, childApi, implsForChildApi, includePolyfills);
}
// STEP 2: create missing entries for children of implementations that are not represented in the API
for (int idxImpl = 0; idxImpl < impls.length; idxImpl++) {
final EObject[] childrenOfCurrImpl = childrenOfImpls[idxImpl];
for (int idxChild = 0; idxChild < childrenOfCurrImpl.length; idxChild++) {
final EObject childImpl = childrenOfCurrImpl[idxChild];
if (!doneImpl.contains(childImpl)) {
// collect matches in other implementations
final EObject[] implsForChildImpl = computeMatches(childImpl, childrenOfImpls, doneImpl);
// look for neighbor EObject in childrenOfCurrImpl
final int idxSib = idxChild - 1;
final EObject siblingImpl = idxSib >= 0 ? childrenOfCurrImpl[idxSib] : null;
// look up neighbor Entry (i.e. entry with elementImpl == siblingImpl)
final ProjectComparisonEntry siblingEntry;
if (siblingImpl != null)
siblingEntry = entry.getChildForElementImpl(siblingImpl);
else
siblingEntry = null;
// add after neighbor OR at beginning if no neighbor found
final int insertIdx = siblingEntry != null ? entry.getChildIndex(siblingEntry) + 1 : 0;
// note: no API
createEntries(entry, insertIdx, null, implsForChildImpl, includePolyfills);
// element here!
}
}
}
return entry;
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class ConcreteSyntaxAwareReferenceFinder method referenceHasBeenFound.
private boolean referenceHasBeenFound(Predicate<URI> targetURIs, URI refURI, EObject instanceOrProxy) {
boolean result = false;
// If the EObject is a composed member, we compare the target URIs with the URIs of the constituent members.
if (instanceOrProxy instanceof TMember && ((TMember) instanceOrProxy).isComposed()) {
TMember member = (TMember) instanceOrProxy;
if (member.isComposed()) {
for (TMember constituentMember : member.getConstituentMembers()) {
URI constituentReffURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(constituentMember);
result = result || targetURIs.apply(constituentReffURI);
}
}
} else {
// Standard case
result = targetURIs.apply(refURI);
}
return result;
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class InferredElementsTargetURICollector method doAdd.
@Override
protected void doAdd(EObject primaryTarget, TargetURIs targetURIsAddHere) {
Resource resource = primaryTarget.eResource();
// If the target is not contained in a resource, we cannot do anything but return.
if (resource == null)
return;
EcoreUtil.resolveAll(primaryTarget.eResource());
// Special handling for composed members and TStructMember
if (primaryTarget instanceof TMember && ((TMember) primaryTarget).isComposed()) {
// In case of composed member, add the constituent members instead.
List<TMember> constituentMembers = ((TMember) primaryTarget).getConstituentMembers();
for (TMember constituentMember : constituentMembers) {
super.doAdd(constituentMember, targetURIsAddHere);
}
} else {
if (primaryTarget instanceof TStructMember) {
TStructMember crossRefStructMember = ((TStructMember) primaryTarget).getDefinedMember();
if (crossRefStructMember != null)
// If this TStructMember is an AST, also add the defined member located in the TModule
super.doAdd(((TStructMember) primaryTarget).getDefinedMember(), targetURIsAddHere);
}
super.doAdd(primaryTarget, targetURIsAddHere);
}
inferredElements.collectInferredElements(primaryTarget, (object) -> {
if (object != null) {
super.doAdd(object, targetURIsAddHere);
}
}, staticPolyfillHelper);
}
Aggregations