Search in sources :

Example 6 with IXtendOutlineContext

use of org.eclipse.xtend.ide.common.outline.IXtendOutlineContext in project xtext-xtend by eclipse.

the class XtendOutlineJvmTreeProvider method buildXtendNode.

@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
    IXtendOutlineContext resultedContext = super.buildXtendNode(modelElement, context);
    if (!context.isShowInherited()) {
        EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
        IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
        if (parentNode instanceof DocumentRootNode) {
            if (modelElement instanceof JvmDeclaredType) {
                JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) modelElement;
                String packageName = jvmDeclaredType.getPackageName();
                if (packageName != null) {
                    EObject rootElement = modelElement.eResource().getContents().get(0);
                    if (rootElement instanceof XtendFile) {
                        XtendFile xtendFile = (XtendFile) rootElement;
                        String primaryPackage = xtendFile.getPackage();
                        if (!packageName.equals(primaryPackage)) {
                            EObjectNode typeNode = (EObjectNode) ((EclipseXtendOutlineContext) resultedContext).getParentNode();
                            if (typeNode.getText() instanceof StyledString) {
                                typeNode.setText(((StyledString) typeNode.getText()).append(new StyledString(" - " + packageName, StyledString.QUALIFIER_STYLER)));
                            }
                        }
                    }
                }
            }
        }
    }
    return resultedContext;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) DocumentRootNode(org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) EObject(org.eclipse.emf.ecore.EObject) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) EObjectNode(org.eclipse.xtext.ui.editor.outline.impl.EObjectNode) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 7 with IXtendOutlineContext

use of org.eclipse.xtend.ide.common.outline.IXtendOutlineContext in project xtext-xtend by eclipse.

the class AbstractXtendOutlineTreeBuilder method buildFeature.

protected IXtendOutlineContext buildFeature(final JvmDeclaredType inferredType, final JvmFeature jvmFeature, final EObject semanticFeature, final IXtendOutlineContext context) {
    IXtendOutlineContext _xifexpression = null;
    boolean _isSynthetic = this._jvmTypeExtensions.isSynthetic(jvmFeature);
    boolean _not = (!_isSynthetic);
    if (_not) {
        _xifexpression = this.xtendOutlineNodeBuilder.buildFeatureNode(inferredType, semanticFeature, context);
    }
    return _xifexpression;
}
Also used : IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext)

Example 8 with IXtendOutlineContext

use of org.eclipse.xtend.ide.common.outline.IXtendOutlineContext in project xtext-xtend by eclipse.

the class AbstractXtendOutlineTreeBuilder method buildInheritedMembers.

protected void buildInheritedMembers(final JvmDeclaredType inferredType, final IXtendOutlineContext context) {
    ResourceSet _resourceSet = inferredType.eResource().getResourceSet();
    final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, _resourceSet);
    final LightweightTypeReference typeReference = owner.toLightweightTypeReference(inferredType);
    final List<LightweightTypeReference> superTypes = typeReference.getAllSuperTypes();
    IXtendOutlineContext superTypeContext = context;
    for (final LightweightTypeReference superTypeRef : superTypes) {
        {
            superTypeContext = superTypeContext.increaseInheritanceDepth();
            final ResolvedFeatures resolvedFeatures = new ResolvedFeatures(superTypeRef);
            List<IResolvedField> _declaredFields = resolvedFeatures.getDeclaredFields();
            for (final IResolvedField jvmField : _declaredFields) {
                boolean _skipFeature = this.skipFeature(jvmField.getDeclaration());
                boolean _not = (!_skipFeature);
                if (_not) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, jvmField, superTypeContext);
                }
            }
            List<IResolvedConstructor> _declaredConstructors = resolvedFeatures.getDeclaredConstructors();
            for (final IResolvedConstructor constructor : _declaredConstructors) {
                boolean _skipFeature_1 = this.skipFeature(constructor.getDeclaration());
                boolean _not_1 = (!_skipFeature_1);
                if (_not_1) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, constructor, superTypeContext);
                }
            }
            List<IResolvedOperation> _declaredOperations = resolvedFeatures.getDeclaredOperations();
            for (final IResolvedOperation operation : _declaredOperations) {
                if (((!this.skipFeature(operation.getDeclaration())) && (!superTypeContext.isProcessed(operation.getDeclaration())))) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, operation, superTypeContext);
                }
            }
            final JvmType declaredType = superTypeRef.getType();
            if ((declaredType instanceof JvmDeclaredType)) {
                final IXtendOutlineContext nestedTypeContext = superTypeContext.hideInherited();
                final Consumer<JvmDeclaredType> _function = (JvmDeclaredType it) -> {
                    this.buildJvmType(it, nestedTypeContext);
                };
                Iterables.<JvmDeclaredType>filter(((JvmDeclaredType) declaredType).getMembers(), JvmDeclaredType.class).forEach(_function);
            }
        }
    }
}
Also used : LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) ResolvedFeatures(org.eclipse.xtext.xbase.typesystem.override.ResolvedFeatures) IResolvedField(org.eclipse.xtext.xbase.typesystem.override.IResolvedField) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JvmType(org.eclipse.xtext.common.types.JvmType) IResolvedOperation(org.eclipse.xtext.xbase.typesystem.override.IResolvedOperation) IResolvedConstructor(org.eclipse.xtext.xbase.typesystem.override.IResolvedConstructor) Consumer(java.util.function.Consumer) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) EList(org.eclipse.emf.common.util.EList) List(java.util.List) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Example 9 with IXtendOutlineContext

use of org.eclipse.xtend.ide.common.outline.IXtendOutlineContext in project xtext-xtend by eclipse.

the class XtendOutlineSourceTreeBuilder method buildXtendType.

protected void buildXtendType(final XtendTypeDeclaration xtendType, final IXtendOutlineContext context) {
    final JvmDeclaredType inferredType = this._iXtendJvmAssociations.getInferredType(xtendType);
    final IXtendOutlineContext xtendTypeContext = this.xtendOutlineNodeBuilder.buildXtendNode(xtendType, context).markAsProcessed(inferredType);
    this.buildMembers(xtendType, inferredType, xtendTypeContext);
}
Also used : IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType)

Example 10 with IXtendOutlineContext

use of org.eclipse.xtend.ide.common.outline.IXtendOutlineContext in project xtext-xtend by eclipse.

the class XtendOutlineSourceTreeBuilder method buildMembers.

protected void buildMembers(final XtendTypeDeclaration xtendType, final JvmDeclaredType inferredType, final IXtendOutlineContext context) {
    if ((inferredType != null)) {
        final IXtendOutlineContext membersContext = context.newContext();
        this.buildMembers(xtendType, inferredType, inferredType, membersContext);
    } else {
        final Consumer<XtendMember> _function = (XtendMember it) -> {
            this.xtendOutlineNodeBuilder.buildEObjectNode(it, context);
        };
        xtendType.getMembers().forEach(_function);
    }
}
Also used : XtendMember(org.eclipse.xtend.core.xtend.XtendMember) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext)

Aggregations

IXtendOutlineContext (org.eclipse.xtend.ide.common.outline.IXtendOutlineContext)11 EObject (org.eclipse.emf.ecore.EObject)4 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)2 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 StyledString (org.eclipse.jface.viewers.StyledString)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)1 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)1 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)1 JvmFeature (org.eclipse.xtext.common.types.JvmFeature)1 JvmMember (org.eclipse.xtext.common.types.JvmMember)1 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1 JvmType (org.eclipse.xtext.common.types.JvmType)1 IOutlineNode (org.eclipse.xtext.ui.editor.outline.IOutlineNode)1 DocumentRootNode (org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode)1