Java Code Examples for org.eclipse.emf.common.util.URI#appendSegment()
The following examples show how to use
org.eclipse.emf.common.util.URI#appendSegment() .
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: XStatefulIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
private boolean isResourceInOutputDirectory(Resource resource, IResourceServiceProvider serviceProvider) { XWorkspaceManager workspaceManager = serviceProvider.get(XWorkspaceManager.class); if (workspaceManager == null) { return false; } OutputConfigurationProvider outputConfProvider = serviceProvider.get(OutputConfigurationProvider.class); URI resourceUri = resource.getURI(); IProjectConfig projectConfig = workspaceManager.getProjectConfig(resourceUri); Set<OutputConfiguration> outputConfigurations = outputConfProvider.getOutputConfigurations(resource); URI projectBaseUri = projectConfig.getPath(); Path resourcePath = URIUtils.toPath(resourceUri); for (OutputConfiguration outputConf : outputConfigurations) { for (String outputDir : outputConf.getOutputDirectories()) { URI outputUri = projectBaseUri.appendSegment(outputDir); Path outputPath = URIUtils.toPath(outputUri); if (resourcePath.startsWith(outputPath)) { return true; } } } return false; }
Example 2
Source File: PackageJsonValidatorExtension.java From n4js with Eclipse Public License 1.0 | 6 votes |
private boolean isContainedOrEqual(URI uri, URI container) { if (uri.equals(container)) { return true; } if (!container.hasTrailingPathSeparator()) { container = container.appendSegment(""); } URI relative = uri.deresolve(container, true, true, false); if (relative != uri) { if (relative.isEmpty()) { return true; } if ("..".equals(relative.segment(0))) { return false; } return true; } return false; }
Example 3
Source File: SourceAttachmentPackageFragmentRootWalker.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Converts the physical URI to a logic URI based on the bundle symbolic name. */ protected URI getLogicalURI(URI uri, IStorage storage, TraversalState state) { if (bundleSymbolicName != null) { URI logicalURI = URI.createPlatformResourceURI(bundleSymbolicName, false); List<?> parents = state.getParents(); for (int i = 1; i < parents.size(); i++) { Object obj = parents.get(i); if (obj instanceof IPackageFragment) { logicalURI = logicalURI.appendSegments(((IPackageFragment) obj).getElementName().split("\\.")); } else if (obj instanceof IJarEntryResource) { logicalURI = logicalURI.appendSegment(((IJarEntryResource) obj).getName()); } else if (obj instanceof IFolder) { logicalURI = logicalURI.appendSegment(((IFolder) obj).getName()); } } return logicalURI.appendSegment(uri.lastSegment()); } return uri; }
Example 4
Source File: XProjectManager.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** @return list of output directories of this project */ public List<File> getOutputDirectories() { List<File> outputDirs = new ArrayList<>(); Set<OutputConfiguration> outputConfigurations = outputConfigProvider.getOutputConfigurations(resourceSet); URI projectBaseUri = projectConfig.getPath(); for (OutputConfiguration outputConf : outputConfigurations) { for (String outputDirName : outputConf.getOutputDirectories()) { URI outputUri = projectBaseUri.appendSegment(outputDirName); File outputDirectory = URIUtils.toFile(outputUri); outputDirs.add(outputDirectory); } } return outputDirs; }
Example 5
Source File: SolidityHyperlinkHelper.java From solidity-ide with Eclipse Public License 1.0 | 5 votes |
protected URI getFileURIOfImport (ImportDirective importElement) { URI fileURI = importElement.eResource().getURI().trimSegments(1); String importURI = importElement.getImportedNamespace(); while (importURI.startsWith("../")) { fileURI = fileURI.trimSegments(1); importURI = importURI.replaceFirst("../", ""); } String[] segments = importURI.split("/"); for (String segment : segments) { fileURI = fileURI.appendSegment(segment); } return fileURI; }
Example 6
Source File: FileSourceFolder.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public URI getPath() { final URI result = URI.createFileURI(name).resolve(parent.getPath()); if (result.hasTrailingPathSeparator()) { return result; } else { return result.appendSegment(""); } }
Example 7
Source File: UriUtil.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public static URI toFolderURI(URI uri) { if (uri.hasTrailingPathSeparator()) { return uri; } else { return uri.appendSegment(""); } }
Example 8
Source File: FormatLinkingService.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Creates a URI for given format name (equivalent to the grammar name). * * @param formatName * for which URI should be crated * @return URI of the {@code .format} file */ private URI buildExtendedFormatConfigurationURI(final String formatName) { URI formatURI = URI.createPlatformResourceURI(formatName, true); String[] formatSegments = formatName.split("\\."); formatURI = formatURI.trimFileExtension(); formatURI = formatURI.appendFileExtension("core"); formatURI = formatURI.appendSegment("src"); formatURI = formatURI.appendSegments(formatSegments); formatURI = formatURI.trimSegments(1); formatURI = formatURI.appendSegment("formatting"); formatURI = formatURI.appendSegment(formatSegments[formatSegments.length - 1]); formatURI = formatURI.appendFileExtension("format"); return formatURI; }