Java Code Examples for org.eclipse.xtext.resource.XtextResourceSet#getClasspathURIContext()
The following examples show how to use
org.eclipse.xtext.resource.XtextResourceSet#getClasspathURIContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClasspathTypeProviderFactory.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public ClassLoader getClassLoader(ResourceSet resourceSet) { if (resourceSet instanceof XtextResourceSet) { XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet; Object ctx = xtextResourceSet.getClasspathURIContext(); if (ctx != null) { if (ctx instanceof Class<?>) { return ((Class<?>)ctx).getClassLoader(); } if (!(ctx instanceof ClassLoader)) { return ctx.getClass().getClassLoader(); } return (ClassLoader) ctx; } } return classLoader; }
Example 2
Source File: ReflectionTypeProviderFactory.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public ClassLoader getClassLoader(ResourceSet resourceSet) { if (resourceSet instanceof XtextResourceSet) { XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet; Object ctx = xtextResourceSet.getClasspathURIContext(); if (ctx != null) { if (ctx instanceof Class<?>) { return ((Class<?>)ctx).getClassLoader(); } if (!(ctx instanceof ClassLoader)) { return ctx.getClass().getClassLoader(); } return (ClassLoader) ctx; } } return classLoader; }
Example 3
Source File: DomainmodelHyperlinkHelper.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) { super.createHyperlinksByOffset(resource, offset, acceptor); EObject eObject = getEObjectAtOffsetHelper().resolveElementAt(resource, offset); if (eObject instanceof Entity) { List<INode> nodes = NodeModelUtils.findNodesForFeature(eObject, DomainmodelPackage.Literals.ABSTRACT_ELEMENT__NAME); if (!nodes.isEmpty()) { INode node = nodes.get(0); if (node.getOffset() <= offset && node.getOffset() + node.getLength() > offset) { String qualifiedJavaName = qualifiedNameConverter.toString(qualifiedNameProvider.getFullyQualifiedName(eObject)); if (resource.getResourceSet() instanceof XtextResourceSet) { XtextResourceSet resourceSet = (XtextResourceSet) resource.getResourceSet(); Object uriContext = resourceSet.getClasspathURIContext(); if (uriContext instanceof IJavaProject) { IJavaProject javaProject = (IJavaProject) uriContext; try { IType type = javaProject.findType(qualifiedJavaName); if (type != null) { JdtHyperlink hyperlink = jdtHyperlinkProvider.get(); hyperlink.setJavaElement(type); hyperlink.setTypeLabel("Navigate to generated source code."); hyperlink.setHyperlinkText("Go to type " + qualifiedJavaName); hyperlink.setHyperlinkRegion((IRegion) new Region(node.getOffset(), node.getLength())); acceptor.accept(hyperlink); } } catch(JavaModelException e) { logger.error(e.getMessage(), e); } } } } } } }
Example 4
Source File: XtextResourceSetBasedProjectProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IJavaProject getJavaProject(ResourceSet resourceSet) { if (resourceSet instanceof XtextResourceSet) { XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet; Object context = xtextResourceSet.getClasspathURIContext(); if (context instanceof IJavaProject) return (IJavaProject) context; } return null; }
Example 5
Source File: JdtBasedProcessorProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public ClassLoader getClassLoader(final EObject ctx) { ResourceSet _resourceSet = ctx.eResource().getResourceSet(); final XtextResourceSet rs = ((XtextResourceSet) _resourceSet); final boolean isBuilder = ResourceSetContext.get(rs).isBuilder(); final boolean isEditor = ResourceSetContext.get(rs).isEditor(); if (isBuilder) { final ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter adapter = IterableExtensions.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>head(Iterables.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>filter(rs.eAdapters(), ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter.class)); if ((adapter != null)) { return adapter.getClassLoader(); } } if (isEditor) { final ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter adapter_1 = IterableExtensions.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>head(Iterables.<ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter>filter(this.getEditorResource(ctx).eAdapters(), ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter.class)); if ((adapter_1 != null)) { ClassLoader _classLoader = adapter_1.getClassLoader(); boolean _tripleEquals = (_classLoader == null); if (_tripleEquals) { this.getEditorResource(ctx).eAdapters().remove(adapter_1); } else { return adapter_1.getClassLoader(); } } } Object _classpathURIContext = rs.getClasspathURIContext(); final IJavaProject project = ((IJavaProject) _classpathURIContext); final URLClassLoader classloader = this.createClassLoaderForJavaProject(project); if (isBuilder) { EList<Adapter> _eAdapters = rs.eAdapters(); ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter _processorClassloaderAdapter = new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(classloader); _eAdapters.add(_processorClassloaderAdapter); } if (isEditor) { EList<Adapter> _eAdapters_1 = this.getEditorResource(ctx).eAdapters(); ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter _processorClassloaderAdapter_1 = new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(classloader); _eAdapters_1.add(_processorClassloaderAdapter_1); } return classloader; }