@Override public boolean isPlatformResource() { return uri.isPlatformResource(); }
@Override public boolean canHandle(URI uri) { return uri.isPlatformResource(); }
@Override public boolean canHandle(URI uri) { return uri.isPlatformResource(); }
@Override public boolean isPlatformResource() { return internalUri.isPlatformResource(); }
@Override public boolean isPlatformResource() { return base.isPlatformResource(); }
/** * @since 2.9 */ protected boolean isProjectLocal(URI uri, final String encodedProjectName) { if (uri == null || uri.segmentCount() < 2 || !uri.isPlatformResource()) return false; else return !uri.segment(1).equals(encodedProjectName); }
public CharSequence wrapWithTraceData(CharSequence sequence, URI originResourceURI, int originOffset, int originLength, int originLineNumber, int originEndLineNumber) { if (!originResourceURI.isPlatformResource()) { throw new IllegalArgumentException("URI has to be a platform resource uri but was: " + originResourceURI+ ". Use #wrapWithTraceData(CharSequence, URI, String, int, int) instead."); } return wrapWithTraceData(sequence, originResourceURI, originResourceURI.segment(1), originOffset, originLength, originLineNumber, originEndLineNumber); }
@SuppressWarnings("unchecked") public <T> T getAdapter(Class<T> adapterType) { URI uri = resource.getURI(); if ((adapterType == IFile.class || adapterType == IResource.class) && uri.isPlatformResource()) { return (T) ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true))); } return null; }
public static void validateFile(URI modelPath) { if (modelPath.isPlatformResource()) { IFile file; try { file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modelPath.toPlatformString(true))); } catch (Exception e) { throw new RuntimeException(format("The model file '%s' does not exist.", modelPath)); } if (file == null || !file.exists()) { throw new RuntimeException(format("The model file '%s' does not exist.", modelPath)); } if (file.getType() != IResource.FILE) { throw new RuntimeException(format("The '%s' path is not a file.", modelPath)); } } }
private File getOutletFolder(URI uri) { if (uri.isPlatformResource()) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFolder folder = root.getFolder((IPath) toPath(uri)); return new File(folder.getLocationURI()); } return new File(uri.toFileString()); }
protected String toRelativePath(URI uri) { String relativePath = null; if (uri.isPlatformResource()) { IFolder folder = EcorePlugin.getWorkspaceRoot().getFolder((IPath) toPath(uri)); relativePath = folder.getProjectRelativePath().toString() + File.separator; } else { relativePath = new File(getConfiguration().getProjectFolder().toFileString()).toURI().relativize( new File(uri.toFileString()).toURI()).getPath(); relativePath = relativePath + File.separator; } return relativePath; }
/** * Returns whether to expect that the resource corresponding to the given URI form will be read only. * @deprecated this method is no longer called by {@link #isReadOnly(Resource)} */ @Deprecated protected boolean isReadOnlyURI(URI uri) { if (uri.isArchive()) { return isReadOnlyURI(URI.createURI(uri.authority())); } return !uri.isPlatformResource() && (uri.isRelative() || !uri.isFile()); }
private Outlet createOutlet(String name, URI uri, boolean overwrite, boolean required, PostProcessor postProcessor) { Outlet outlet = null; if (uri.isPlatformResource()) { outlet = createResourceOutlet(name, uri, overwrite, required); } else if (uri.isFile()) { outlet = createOutlet(name, uri, overwrite, required); } if (outlet != null && postProcessor != null) { outlet.addPostprocessor(postProcessor); } return outlet; }
@Override public boolean isStandaloneFileURI(EObject context, URI uri) { if (uri.isPlatformResource() && context.eResource() != null) { IProjectConfig project = projectConfigurationProvider.getProjectConfig(context.eResource().getResourceSet()); if (project != null) { return project.findSourceFolderContaining(uri) == null; } } return true; } }
private IProject getProject(Resource resource) { URI uri = resource.getURI(); if (uri.isPlatformResource()) { final IProject project = getWorkspaceRoot().getProject(uri.segment(1)); if (project.isAccessible()) return project; } return null; }
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) { if (!uri.isPlatformResource()) { // support storage lookup by absolute file URI as it is possibly resolved by importURI references if (uri.isFile()) { IPath path = new Path(uri.toFileString()); if (path.isAbsolute()) { IFile file = getWorkspaceRoot().getFileForLocation(path); return getStorages(file); } } return emptySet(); } IFile file = getWorkspaceRoot().getFile(new Path(uri.toPlatformString(true))); return getStorages(file); }
protected boolean isValidTargetFile(Resource resource, StatusWrapper status) { IFile targetFile = projectUtil.findFileStorage(resource.getURI(), true); if (targetFile != null) return true; String path = (resource.getURI().isPlatformResource()) ? resource.getURI().toPlatformString(true) : resource.getURI().toString(); status.add(FATAL, "Rename target file '" + path + "' cannot be accessed", resource.getURI()); return false; }
private File getProjectDirectoryFile() { if (projectDirectory == null) { if (getConfiguration().getProjectFolder().isPlatformResource()) { IProject project = EcorePlugin.getWorkspaceRoot().getProject( getConfiguration().getProjectFolder().lastSegment()); projectDirectory = new File(project.getLocationURI()); } else { projectDirectory = new File(getConfiguration().getProjectFolder().toFileString()); } } return projectDirectory; }
/** * @return the resources uri in the normalized form or as is if it is a platform:/resource URI. * @since 2.4 */ public static URI getPlatformResourceOrNormalizedURI(Resource resource) { URI rawURI = resource.getURI(); if (rawURI.isPlatformResource()) { return rawURI; } if(resource.getResourceSet() != null) { return resource.getResourceSet().getURIConverter().normalize(rawURI); } else { return URIConverter.INSTANCE.normalize(rawURI); } }
/** * Produces hyperlinks for the given {@code region} that point to the referenced {@code target}. */ public void createHyperlinksTo(XtextResource from, Region region, EObject target, IHyperlinkAcceptor acceptor) { final URIConverter uriConverter = from.getResourceSet().getURIConverter(); final String hyperlinkText = labelProvider.getText(target); final URI uri = EcoreUtil.getURI(target); final URI normalized = uri.isPlatformResource() ? uri : uriConverter.normalize(uri); XtextHyperlink result = hyperlinkProvider.get(); result.setHyperlinkRegion(region); result.setURI(normalized); result.setHyperlinkText(hyperlinkText); acceptor.accept(result); }