org.eclipse.xtext.generator.trace.AbsoluteURI Java Examples
The following examples show how to use
org.eclipse.xtext.generator.trace.AbsoluteURI.
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: JarEntryAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected AbsoluteURI resolvePath(IJavaProject javaProject, SourceRelativeURI path) { try { for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { IResource resource = root.getResource(); if (resource instanceof IFolder) { IFolder folder = (IFolder) resource; String decodedPath = URI.decode(path.toString()); IResource candidate = folder.findMember(decodedPath); if (candidate != null && candidate.exists()) return new AbsoluteURI(URI.createPlatformResourceURI(resource.getFullPath() + "/" + decodedPath, true)); } } } catch (JavaModelException e) { log.error("Error resolving path", e); } return null; }
Example #2
Source File: AbstractLocationInResource.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public AbsoluteURI getAbsoluteResourceURI() { if (absoluteURI == null) { absoluteURI = trace.resolvePath(getSrcRelativeResourceURI()); } return absoluteURI; }
Example #3
Source File: JarEntryAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected AbsoluteURI resolvePath(IJarEntryResource jarEntry, SourceRelativeURI path) { IPackageFragmentRoot packageFragmentRoot = jarEntry.getPackageFragmentRoot(); try { Pair<URI, URI> pair = uriMapperExtensions.getURIMapping(packageFragmentRoot); if (pair != null) { URI first = pair.getFirst(); if (first != null) return new AbsoluteURI(URI.createURI(first + "/" + path)); } } catch (JavaModelException e) { log.error("Error resolving path", e); } return null; }
Example #4
Source File: JarEntryAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public AbsoluteURI tryResolvePath(IStorage localStorage, SourceRelativeURI path) { if (localStorage instanceof IFile) { IProject project = ((IFile) localStorage).getProject(); if (project != null) { IJavaProject javaProject = JavaCore.create(project); if (javaProject != null && javaProject.exists()) return resolvePath(javaProject, path); return null; } } else if (localStorage instanceof IJarEntryResource) { return resolvePath((IJarEntryResource) localStorage, path); } return null; }
Example #5
Source File: StorageAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected IStorage findStorage(SourceRelativeURI uri, IProject project) { AbsoluteURI resolvePath = resolvePath(uri); Iterable<Pair<IStorage, IProject>> allStorages = getStorage2uriMapper().getStorages(resolvePath.getURI()); for (Pair<IStorage, IProject> storage : allStorages) { if (project.equals(storage.getSecond())) { return storage.getFirst(); } } return null; }
Example #6
Source File: StorageAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected AbsoluteURI resolvePath(IProject project, SourceRelativeURI path) { String decodedPath = URI.decode(path.getURI().toString()); IResource candidate = project.findMember(decodedPath); if (candidate != null && candidate.exists()) return new AbsoluteURI(URI.createPlatformResourceURI(project.getFullPath() + "/" + decodedPath, true)); return null; }
Example #7
Source File: ZipFileAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected AbsoluteURI resolvePath(SourceRelativeURI path) { IResource member = getWorkspace().getRoot().findMember(zipFilePath); if (member != null) { String uri = "archive:platform:/resource" + member.getFullPath().toString() + "!/" + path; return new AbsoluteURI(URI.createURI(uri)); } return new AbsoluteURI(URI.createURI("archive:file:" + zipFilePath.toString() + "!/" + path)); }
Example #8
Source File: ResourceStorageTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testDecodeURI() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("public def void foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IFile file = this.helper.createFile("mypack/MyClass Foo.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); final ResourceStorageTest.TestableStorageAwareTrace storageAwareTrace = new ResourceStorageTest.TestableStorageAwareTrace(); this.getInjector().injectMembers(storageAwareTrace); storageAwareTrace.setLocalStorage(file); URI _createURI = URI.createURI("mypack/MyClass%20Foo.xtend"); SourceRelativeURI _sourceRelativeURI = new SourceRelativeURI(_createURI); AbsoluteURI result = storageAwareTrace.resolvePath(_sourceRelativeURI); Assert.assertEquals("platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", result.toString()); IProject _project = this.helper.getProject(); URI _createURI_1 = URI.createURI("src/mypack/MyClass%20Foo.xtend"); SourceRelativeURI _sourceRelativeURI_1 = new SourceRelativeURI(_createURI_1); result = storageAwareTrace.resolvePath(_project, _sourceRelativeURI_1); Assert.assertEquals("platform:/resource/test.project/src/mypack/MyClass%20Foo.xtend", result.toString()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #9
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public ILocationInResource getBestAssociatedLocation(ITextRegion localRegion, AbsoluteURI uri) { IProjectConfig projectConfig = getLocalProjectConfig(); AbstractTraceRegion left = findTraceRegionAtLeftOffset(localRegion.getOffset()); left = findParentByURI(left, uri, projectConfig); AbstractTraceRegion right = findTraceRegionAtRightOffset(localRegion.getOffset() + localRegion.getLength()); right = findParentByURI(right, uri, projectConfig); return mergeRegions(left, right); }
Example #10
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected boolean isAssociatedWith(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project) { ITraceURIConverter traceURIConverter = getService(uri, ITraceURIConverter.class); if (traceURIConverter == null) { traceURIConverter = getService(getLocalURI(), ITraceURIConverter.class); } SourceRelativeURI convertedUri = traceURIConverter.getURIForTrace(project, uri); return convertedUri.equals(region.getAssociatedSrcRelativePath()); }
Example #11
Source File: AbstractEclipseTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected AbsoluteURI getURIForStorage(IStorage storage) { final URI uri = storage2uriMapper.getUri(storage); if (uri != null) { return new AbsoluteURI(uri); } return new AbsoluteURI(URI.createPlatformResourceURI(storage.getFullPath().toString(), true)); }
Example #12
Source File: TraceForStorageProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected IProjectConfig getProjectConfig(IFile sourceFile) { AbsoluteURI location = getAbsoluteLocation(sourceFile); IResourceServiceProvider resourceServiceProvider = getServiceProvider(location); if (resourceServiceProvider != null) { EclipseProjectConfigProvider projectConfigProvider = resourceServiceProvider.get(EclipseProjectConfigProvider.class); return projectConfigProvider.createProjectConfig(sourceFile.getProject()); } else { LOG.error("No trace available for source file "+sourceFile.getFullPath()+", since no resource service provider could be determined."); return null; } }
Example #13
Source File: TraceForStorageProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected IFile asFile(AbsoluteURI absoluteURI, IProjectConfig project) { URI uri = absoluteURI.getURI(); if (uri.isPlatformResource()) { IFile result = workspace.getRoot().getFile(new Path(uri.toPlatformString(true))); if (result.exists()) { return result; } } return null; }
Example #14
Source File: OriginalEditorSelector.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @param traceToSource */ protected IEditorDescriptor getXtextEditor(IEclipseTrace traceToSource) { if (traceToSource != null) { Iterator<? extends ILocationInEclipseResource> sourceInformationIterator = traceToSource.getAllAssociatedLocations().iterator(); if (sourceInformationIterator.hasNext()) { ILocationInEclipseResource sourceInformation = sourceInformationIterator.next(); AbsoluteURI absoluteURI = sourceInformation.getAbsoluteResourceURI(); if (absoluteURI != null) { URI uri = absoluteURI.getURI(); return getXtextEditor(uri); } } } return null; }
Example #15
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected SomeFile asFile(SourceRelativeURI srcRelativeDerivedResource, IProjectConfig project) { String[] pathSegments = srcRelativeDerivedResource.getURI().segments(); Set<? extends ISourceFolder> sourceFolders = project.getSourceFolders(); for(ISourceFolder folder: sourceFolders) { URI srcFolderPath = folder.getPath(); URI absoluteURI = srcFolderPath.appendSegments(pathSegments); SomeFile result = asFile(new AbsoluteURI(absoluteURI), project); if (result != null) { return result; } } URI fromRoot = project.getPath().appendSegments(pathSegments); return asFile(new AbsoluteURI(fromRoot), project); }
Example #16
Source File: IPlatformSpecificTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override Iterable<? extends Location> getAllAssociatedLocations(ITextRegion localRegion, AbsoluteURI uri);
Example #17
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Compute the location of the generated file from the given trace file. */ protected AbsoluteURI getGeneratedLocation(PersistedTrace trace) { AbsoluteURI path = trace.getPath(); String fileName = traceFileNameProvider.getJavaFromTrace(path.getURI().toString()); return new AbsoluteURI(fileName); }
Example #18
Source File: IPlatformSpecificTraceProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override Trace getTraceToSource(AbsoluteURI absoluteDerivedResource, IProjectConfig project);
Example #19
Source File: IPlatformSpecificTraceProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override Trace getTraceToTarget(AbsoluteURI absoluteSourceResource, IProjectConfig project);
Example #20
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IResourceServiceProvider getServiceProvider(final AbsoluteURI absoluteSourceResource) { return serviceRegistry.getResourceServiceProvider(absoluteSourceResource.getURI()); }
Example #21
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected SourceRelativeURI getGeneratedUriForTrace(IProjectConfig projectConfig, AbsoluteURI absoluteSourceResource, AbsoluteURI generatedFileURI, ITraceURIConverter traceURIConverter) { return traceURIConverter.getURIForTrace(projectConfig, generatedFileURI); }
Example #22
Source File: AbstractTraceForURIProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Trace getTraceToTarget(final AbsoluteURI absoluteSourceResource, IProjectConfig project) { final SomeFile sourceFile = asFile(absoluteSourceResource, project); return getTraceToTarget(sourceFile, absoluteSourceResource, getProjectConfig(sourceFile)); }
Example #23
Source File: IPlatformSpecificTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override Location getBestAssociatedLocation(ITextRegion localRegion, AbsoluteURI uri);
Example #24
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public abstract AbsoluteURI getLocalURI();
Example #25
Source File: IPlatformSpecificTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override Iterable<? extends Location> getAllAssociatedLocations(AbsoluteURI uri);
Example #26
Source File: NoTraces.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Trace getTraceToSource(AbsoluteURI absoluteDerivedResource, IProjectConfig project) { return null; }
Example #27
Source File: NoTraces.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Trace getTraceToTarget(AbsoluteURI absoluteSourceResource, IProjectConfig project) { return null; }
Example #28
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public TraceRegionsByURI(Iterable<? extends AbstractTraceRegion> allTraceRegions, AbsoluteURI uri, IProjectConfig projectConfig) { this.allTraceRegions = allTraceRegions; this.uri = uri; this.projectConfig = projectConfig; }
Example #29
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected AbsoluteURI resolvePath(SourceRelativeURI path) { return new AbsoluteURI(path.getURI().resolve(getLocalProjectConfig().getPath())); }
Example #30
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected AbstractTraceRegion findParentByURI(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project) { while(region != null && !isAssociatedWith(region, uri, project)) { region = region.getParent(); } return region; }