use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class HyperlinkXpectMethod method getTargetDescription.
private String getTargetDescription(XtextResource resource, IHyperlink hyperlink) {
final StringBuffer sb = new StringBuffer();
// append hyperlink text. Only consider the element name and ignore the qualified part.
String hyperlinkText = hyperlink.getHyperlinkText();
hyperlinkText = hyperlinkText.substring(hyperlinkText.lastIndexOf('.') + 1);
if (hyperlinkText != null)
sb.append(hyperlinkText);
else
sb.append("<no hyperlink text>");
// append description of target element (path from the element to the root of the AST)
final EObject target = getTarget(resource, hyperlink);
if (target != null) {
// build chain of ancestor AST elements
sb.append(": ");
final int startLen = sb.length();
EObject currTarget = target;
while (currTarget != null) {
if (currTarget instanceof NamedElement || currTarget instanceof IdentifiableElement) {
if (sb.length() > startLen)
sb.append(" in ");
String name = currTarget instanceof NamedElement ? ((NamedElement) currTarget).getName() : ((IdentifiableElement) currTarget).getName();
if (name == null || name.trim().length() == 0)
name = "<unnamed>";
else
name = "\"" + name + "\"";
sb.append(name + "(" + currTarget.eClass().getName() + ")");
}
currTarget = currTarget.eContainer();
}
// add URI of resource
final URI targetResURI = target.eResource() != null ? target.eResource().getURI() : null;
final String fname = targetResURI != null ? targetResURI.lastSegment() : null;
if (fname != null && fname.trim().length() > 0) {
sb.append(" in file ");
sb.append(fname);
}
}
return sb.toString();
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class ScopeXpectMethod method binding.
/**
* Checks that a given element is bound to something identified by (simple) qualified name. The check is designed as
* simple as possible. That is, simply the next following expression is tested, and within that we expect a property
* access or a direct identifiable element. The compared name is the simple qualified name, that is container (type)
* followed by elements name, without URIs of modules etc.
*/
@Xpect
@ParameterParser(syntax = "('at' arg1=OFFSET)?")
public //
void binding(//
@CommaSeparatedValuesExpectation ICommaSeparatedValuesExpectation expectation, //
ICrossEReferenceAndEObject arg1) {
EObject eobj = arg1.getEObject();
ParameterizedPropertyAccessExpression ppae = EcoreUtil2.getContainerOfType(eobj, ParameterizedPropertyAccessExpression.class);
IdentifiableElement element;
if (ppae != null) {
element = ppae.getProperty();
} else if (eobj instanceof IdentifiableElement) {
element = (IdentifiableElement) eobj;
} else {
throw new IllegalArgumentException("Cannot check binding for " + (eobj == null ? "null" : eobj.eClass().getName()));
}
String container = "";
if (element instanceof TMember) {
container = ((TMember) element).getContainingType().getName() + ".";
}
final String qn = container + element.getName();
// URI uri = eobj == null ? null : eobj.eResource() == null ? null : eobj.eResource().getURI();
expectation.assertEquals(Collections.singleton(qn));
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class ParameterizedPropertyAccessExpressionImpl method setProperty.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setProperty(IdentifiableElement newProperty) {
IdentifiableElement oldProperty = property;
property = newProperty;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY, oldProperty, property));
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class JSXPropertyAttributeImpl method setProperty.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setProperty(IdentifiableElement newProperty) {
IdentifiableElement oldProperty = property;
property = newProperty;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.JSX_PROPERTY_ATTRIBUTE__PROPERTY, oldProperty, property));
}
use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.
the class N4ClassDeclarationImpl method getExportedName.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getExportedName() {
boolean _isExported = this.isExported();
if (_isExported) {
EObject _eContainer = this.eContainer();
final ExportDeclaration exportDecl = ((ExportDeclaration) _eContainer);
boolean _isDefaultExport = exportDecl.isDefaultExport();
if (_isDefaultExport) {
return "default";
}
final ExportableElement me = this;
String _switchResult = null;
boolean _matched = false;
if (me instanceof NamedElement) {
_matched = true;
_switchResult = ((NamedElement) me).getName();
}
if (!_matched) {
if (me instanceof IdentifiableElement) {
_matched = true;
_switchResult = ((IdentifiableElement) me).getName();
}
}
return _switchResult;
}
return null;
}
Aggregations