Search in sources :

Example 1 with AbstractElementImpl

use of org.eclipse.xtend.core.macro.declaration.AbstractElementImpl in project xtext-xtend by eclipse.

the class ProblemSupportImpl method getResourceAndEObject.

private Pair<Resource, EObject> getResourceAndEObject(final Element element) {
    this.checkCanceled();
    boolean _matched = false;
    if (element instanceof CompilationUnitImpl) {
        boolean _equals = Objects.equal(element, this.compilationUnit);
        if (_equals) {
            _matched = true;
            Resource _eResource = this.compilationUnit.getXtendFile().eResource();
            XtendFile _xtendFile = this.compilationUnit.getXtendFile();
            return Pair.<Resource, EObject>of(_eResource, _xtendFile);
        }
    }
    if (!_matched) {
        if (element instanceof AbstractElementImpl) {
            _matched = true;
            final Resource resource = ((AbstractElementImpl<? extends EObject>) element).getDelegate().eResource();
            Resource _eResource = this.compilationUnit.getXtendFile().eResource();
            boolean _equals = Objects.equal(resource, _eResource);
            if (_equals) {
                final EObject eobject = this.compilationUnit.getJvmModelAssociations().getPrimarySourceElement(((AbstractElementImpl<? extends EObject>) element).getDelegate());
                if ((eobject == null)) {
                    EObject _delegate = ((AbstractElementImpl<? extends EObject>) element).getDelegate();
                    return Pair.<Resource, EObject>of(resource, _delegate);
                }
                return Pair.<Resource, EObject>of(resource, eobject);
            }
        }
    }
    throw new IllegalArgumentException("You can only add issues on locally declared elements.");
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) AbstractElementImpl(org.eclipse.xtend.core.macro.declaration.AbstractElementImpl) CompilationUnitImpl(org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 2 with AbstractElementImpl

use of org.eclipse.xtend.core.macro.declaration.AbstractElementImpl in project xtext-xtend by eclipse.

the class AssociatorImpl method setPrimarySourceElement.

@Override
public void setPrimarySourceElement(final MutableElement javaElement, final Element sourceElement) {
    final Element primarySourceElement = this.unit.getTracability().getPrimarySourceElement(sourceElement);
    EObject _switchResult = null;
    boolean _matched = false;
    if (primarySourceElement instanceof TypeReferenceImpl) {
        _matched = true;
        _switchResult = ((TypeReferenceImpl) primarySourceElement).getSource();
    }
    if (!_matched) {
        if (primarySourceElement instanceof AbstractElementImpl) {
            _matched = true;
            _switchResult = ((AbstractElementImpl<?>) primarySourceElement).getDelegate();
        }
    }
    final EObject delegate = _switchResult;
    this.unit.getJvmModelAssociator().associate(delegate, ((AbstractElementImpl<?>) javaElement).getDelegate());
}
Also used : AbstractElementImpl(org.eclipse.xtend.core.macro.declaration.AbstractElementImpl) TypeReferenceImpl(org.eclipse.xtend.core.macro.declaration.TypeReferenceImpl) MutableElement(org.eclipse.xtend.lib.macro.declaration.MutableElement) Element(org.eclipse.xtend.lib.macro.declaration.Element) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 AbstractElementImpl (org.eclipse.xtend.core.macro.declaration.AbstractElementImpl)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)1 TypeReferenceImpl (org.eclipse.xtend.core.macro.declaration.TypeReferenceImpl)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 Element (org.eclipse.xtend.lib.macro.declaration.Element)1 MutableElement (org.eclipse.xtend.lib.macro.declaration.MutableElement)1