Search in sources :

Example 1 with IHierarchyBuilder

use of org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder in project xtext-eclipse by eclipse.

the class AbstractHierarchyBuilderTest method testBuildHierarchy.

protected void testBuildHierarchy(final Procedure1<? super AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration> configurator) {
    @Extension final AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration configuration = new AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration();
    configurator.apply(configuration);
    final ResourceSet resourceSet = this.createResourceSet(configuration);
    final IHierarchyBuilder hierarchyBuilder = configuration.hierarchyBuilderProvider.apply(resourceSet);
    String _xifexpression = null;
    if ((configuration.resourceURI == null)) {
        _xifexpression = IterableExtensions.<Pair<String, String>>last(configuration.models).getKey();
    } else {
        _xifexpression = configuration.resourceURI;
    }
    final String resourceURI = _xifexpression;
    Resource _resource = resourceSet.getResource(URI.createURI(resourceURI), false);
    final XtextResource resource = ((XtextResource) _resource);
    final URI rootURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(this._eObjectAtOffsetHelper.resolveElementAt(resource, configuration.index));
    final String actualHierarchy = this.toExpectation(rootURI, hierarchyBuilder);
    Assert.assertEquals(configuration.expectedHierarchy, actualHierarchy);
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResource(org.eclipse.xtext.resource.XtextResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) IHierarchyBuilder(org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder) URI(org.eclipse.emf.common.util.URI) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 2 with IHierarchyBuilder

use of org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder in project xtext-eclipse by eclipse.

the class AbstractHierarchyViewPart method getBuilder.

protected <T extends IHierarchyBuilder> T getBuilder(final Class<T> clazz) {
    boolean _isInstance = clazz.isInstance(this.builder);
    if (_isInstance) {
        return ((T) this.builder);
    }
    if ((this.builder instanceof DeferredHierarchyBuilder)) {
        final IHierarchyBuilder wrappedBuilder = ((DeferredHierarchyBuilder) this.builder).getHierarchyBuilder();
        boolean _isInstance_1 = clazz.isInstance(wrappedBuilder);
        if (_isInstance_1) {
            return ((T) wrappedBuilder);
        }
    }
    return null;
}
Also used : IHierarchyBuilder(org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder) DeferredHierarchyBuilder(org.eclipse.xtext.ui.editor.hierarchy.DeferredHierarchyBuilder)

Example 3 with IHierarchyBuilder

use of org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder in project xtext-eclipse by eclipse.

the class AbstractHierarchyBuilderTest method testBuildHierarchy.

protected void testBuildHierarchy(Procedure1<? super HierarchyBuilderTestConfiguration> configurator) {
    HierarchyBuilderTestConfiguration configuration = new HierarchyBuilderTestConfiguration();
    configurator.apply(configuration);
    ResourceSet resourceSet = createResourceSet(configuration);
    IHierarchyBuilder hierarchyBuilder = configuration.hierarchyBuilderProvider.apply(resourceSet);
    String resourceURI = null;
    if (configuration.resourceURI == null) {
        resourceURI = Iterables.getLast(configuration.models, null).getKey();
    } else {
        resourceURI = configuration.resourceURI;
    }
    XtextResource resource = (XtextResource) resourceSet.getResource(URI.createURI(resourceURI), false);
    URI rootURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(eObjectAtOffsetHelper.resolveElementAt(resource, configuration.index));
    String actualHierarchy = toExpectation(rootURI, hierarchyBuilder);
    Assert.assertEquals(configuration.expectedHierarchy, actualHierarchy);
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) IHierarchyBuilder(org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder) URI(org.eclipse.emf.common.util.URI)

Aggregations

IHierarchyBuilder (org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder)3 URI (org.eclipse.emf.common.util.URI)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 DeferredHierarchyBuilder (org.eclipse.xtext.ui.editor.hierarchy.DeferredHierarchyBuilder)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1