本文整理汇总了Java中org.eclipse.emf.common.util.URI.toFileString方法的典型用法代码示例。如果您正苦于以下问题:Java URI.toFileString方法的具体用法?Java URI.toFileString怎么用?Java URI.toFileString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.toFileString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSelection
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public IStructuredSelection findSelection(final IEditorInput input) {
final IStructuredSelection selection = super.findSelection(input);
if (null == selection || selection.isEmpty() && input instanceof XtextReadonlyEditorInput) {
try {
final IStorage storage = ((XtextReadonlyEditorInput) input).getStorage();
if (storage instanceof URIBasedStorage) {
final URI uri = ((URIBasedStorage) storage).getURI();
if (uri.isFile()) {
final File file = new File(uri.toFileString());
if (file.exists() && file.isFile()) {
final Node node = getResourceNode(file);
if (null != node) {
return new StructuredSelection(node);
}
}
}
}
} catch (final CoreException e) {
LOGGER.error("Error while extracting storage from read-only Xtext editor input.", e);
return EMPTY;
}
}
return selection;
}
示例2: tryFindProjectRecursivelyByManifest
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private URI tryFindProjectRecursivelyByManifest(URI location, Optional<URI> stopUri) {
URI nestedLocation = location;
int segmentCount = 0;
if (nestedLocation.isFile()) { // Here, unlike java.io.File, #isFile can mean directory as well.
File directory = new File(nestedLocation.toFileString());
while (directory != null) {
if (stopUri.isPresent() && stopUri.get().equals(nestedLocation)) {
break;
}
if (directory.isDirectory()) {
if (new File(directory, IN4JSProject.N4MF_MANIFEST).exists()) {
URI projectLocation = URI.createFileURI(directory.getAbsolutePath());
registerProject(projectLocation);
return projectLocation;
}
}
nestedLocation = nestedLocation.trimSegments(segmentCount++);
directory = directory.getParentFile();
}
}
return null;
}
示例3: load
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public Optional<Pair<ExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
if (null != rootLocation && rootLocation.isFile()) {
final File projectRoot = new File(rootLocation.toFileString());
if (projectRoot.exists() && projectRoot.isDirectory()) {
final URI manifestLocation = rootLocation.appendSegment(IN4JSProject.N4MF_MANIFEST);
final ProjectDescription projectDescription = packageManager.loadManifest(manifestLocation);
if (null != projectDescription) {
final ExternalProject project = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
return Optional.of(Tuples.create(project, projectDescription));
}
}
}
return Optional.absent();
}
示例4: assertResourceDescriptions
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Checks if expected list of stringified file locations matches
*
* @param expected
* collection of entries
* @param actual
* collection of entries
*/
public void assertResourceDescriptions(Collection<String> expected, Iterable<IResourceDescription> actual) {
Set<String> extraDescriptions = new HashSet<>();
Set<String> missingDescriptions = new HashSet<>(expected);
for (IResourceDescription iResourceDescription : actual) {
URI uri = iResourceDescription.getURI();
String stringUri = uri.isPlatform() ? uri.toPlatformString(false) : uri.toFileString();
if (!missingDescriptions.contains(stringUri)) {
extraDescriptions.add(stringUri);
} else {
missingDescriptions.remove(stringUri);
}
}
if (missingDescriptions.isEmpty() && extraDescriptions.isEmpty()) {
return;
}
StringBuilder msg = new StringBuilder("unexpected actual resources" + "\n");
if (!extraDescriptions.isEmpty()) {
msg.append("actual contains " + extraDescriptions.size() + " extra resources" + "\n");
}
if (!missingDescriptions.isEmpty()) {
msg.append("actual is missing " + missingDescriptions.size() + " expected resources" + "\n");
}
for (String extra : extraDescriptions) {
msg.append("[extra] " + extra + "\n");
}
for (String missing : missingDescriptions) {
msg.append("[missing] " + missing + "\n");
}
fail(msg.toString());
}
示例5: getFolderIterator
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public Iterator<URI> getFolderIterator(URI folderLocation) {
ensureInitialized();
final URI findProjectWith = findProjectWith(folderLocation);
if (null != findProjectWith) {
final String projectName = findProjectWith.lastSegment();
final ExternalProject project = getProjectMapping().get(projectName);
if (null != project) {
String projectPath = new File(project.getLocationURI()).getAbsolutePath();
String folderPath = folderLocation.toFileString();
final IContainer container = projectPath.equals(folderPath) ? project
: project.getFolder(folderPath.substring(projectPath.length() + 1));
final Collection<URI> result = Lists.newLinkedList();
try {
container.accept(resource -> {
if (resource instanceof IFile) {
final String path = new File(resource.getLocationURI()).getAbsolutePath();
result.add(URI.createFileURI(path));
}
return true;
});
return unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return unmodifiableIterator(result.iterator());
}
}
}
return emptyIterator();
}
示例6: findProjectWith
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI findProjectWith(URI nestedLocation) {
final String path = nestedLocation.toFileString();
if (null == path) {
return null;
}
final File nestedResource = new File(path);
if (!nestedResource.exists()) {
return null;
}
final Path nestedResourcePath = nestedResource.toPath();
final Iterable<URI> registeredProjectUris = projectCache.asMap().keySet();
for (final URI projectUri : registeredProjectUris) {
if (projectUri.isFile()) {
final File projectRoot = new File(projectUri.toFileString());
final Path projectRootPath = projectRoot.toPath();
if (nestedResourcePath.startsWith(projectRootPath)) {
return projectUri;
}
}
}
return null;
}
示例7: getManifestResourceNode
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/** Helper method to fake the manifest node if it is not in a source folder. Otherwise does nothing. */
private ResourceNode getManifestResourceNode() {
ResourceNode manifestNode = null;
// Does nothing if the project root is a source container as well.
if (!from(project.getSourceContainers()).transform(src -> src.getRelativeLocation()).toSet().contains("")) {
final URI manifestLocation = project.getManifestLocation().orNull();
if (null != manifestLocation) {
final File manifest = new File(manifestLocation.toFileString());
if (manifest.exists() && manifest.isFile()) {
manifestNode = ResourceNode.create(this, manifest);
}
}
}
return manifestNode;
}
示例8: getResource
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public IResource getResource(URI location) {
ensureInitialized();
final String path = location.toFileString();
if (null == path) {
return null;
}
final File nestedResource = new File(path);
if (nestedResource.exists()) {
final URI projectLocation = findProjectWith(location);
if (null != projectLocation) {
final String projectName = projectLocation.lastSegment();
final IProject project = getProject(projectName);
if (project instanceof ExternalProject) {
final File projectResource = new File(project.getLocationURI());
if (projectResource.exists() && projectResource.isDirectory()) {
final Path projectPath = projectResource.toPath();
final Path nestedPath = nestedResource.toPath();
if (projectPath.equals(nestedPath)) {
return project;
}
// TODO: project.getFile and project.getFolder don't check whether then given path is a file or
// a folder, and they should not?
final Path relativePath = projectPath.relativize(nestedPath);
final IFile file = project.getFile(relativePath.toString());
if (file.exists())
return file;
final IFolder folder = project.getFolder(relativePath.toString());
if (folder.exists())
return folder;
}
}
}
}
return null;
}
示例9: getLocationPath
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
protected String getLocationPath(URI location) {
return location.toFileString();
}