Java Code Examples for org.eclipse.emf.common.util.URI#fileExtension()
The following examples show how to use
org.eclipse.emf.common.util.URI#fileExtension() .
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: HashedFileContent.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Create a fingerprint of the given file at the given location. */ public HashedFileContent(URI uri, File file) throws IOException { this.uri = uri; String ext = uri.fileExtension(); if (ext == null || "ts".equals(ext) || "js".equals(ext) || "jsx".equals(ext) || "map".equals(ext) || "md".equals(ext) || "hbs".equals(ext) || "json".equals(ext) && !"package.json".equals(uri.lastSegment())) { this.hash = file.length(); } else { try (InputStream s = new FileInputStream(file)) { Hasher hasher = hashFunction.newHasher(); s.transferTo(Funnels.asOutputStream(hasher)); this.hash = hasher.hash().asLong(); } } }
Example 2
Source File: N4JSTestHelper.java From n4js with Eclipse Public License 1.0 | 5 votes |
private Script parseWithFileExtensionFromURI(CharSequence text, URI uriToUse, ResourceSet resourceSetToUse) throws Exception { final String fileExtensionToUse = uriToUse.fileExtension(); if (fileExtensionToUse == null) { throw new IllegalArgumentException("given URI does not have a file extension"); } final String oldExtension = parseHelper.fileExtension; try { parseHelper.fileExtension = fileExtensionToUse; return parseHelper.parse(text, uriToUse, resourceSetToUse); } finally { parseHelper.fileExtension = oldExtension; } }
Example 3
Source File: ResourceLoadingStatistics.java From n4js with Eclipse Public License 1.0 | 5 votes |
private List<URI> collectURIsToInvestigate(IN4JSProject project) { final List<URI> urisToInvestigate = Lists.newArrayList(); for (IN4JSSourceContainer container : project.getSourceContainers()) { for (URI uri : container) { final String fileExtension = uri.fileExtension(); switch (fileExtension) { case "n4js": case "n4jsd": case "n4jsx": urisToInvestigate.add(uri); } } } return urisToInvestigate; }
Example 4
Source File: Index.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ @Override public String getSourceName() { final URI uri = delegate.getEObjectURI().trimFragment(); final String name = uri.lastSegment(); if (name != null) { final String extension = uri.fileExtension(); final String result = URI.decode(extension != null ? name + '.' + extension : name); return result.toUpperCase(Locale.getDefault()); } return null; }
Example 5
Source File: IFileExtensionResolver.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public String resolveExtension(final URI uri) { return uri.fileExtension(); }