org.eclipse.xtext.mwe.NameBasedFilter Java Examples

The following examples show how to use org.eclipse.xtext.mwe.NameBasedFilter. 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: StandaloneBuilder.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected List<URI> collectResources(Iterable<String> roots, ResourceSet resourceSet) {
	String extensions = Joiner.on("|").join(languages.keySet());
	NameBasedFilter nameBasedFilter = new NameBasedFilter();
	// TODO test with whitespaced file extensions
	nameBasedFilter.setRegularExpression(".*\\.(?:(" + extensions + "))$");
	List<URI> resources = new ArrayList<>();
	Multimap<String, URI> modelsFound = new PathTraverser().resolvePathes(IterableExtensions.toList(roots),
			(URI input) -> {
				boolean matches = nameBasedFilter.matches(input);
				if (matches) {
					forceDebugLog("Adding file \'" + input + "\'");
					resources.add(input);
				}
				return matches;
			});
	modelsFound.asMap().forEach((String uri, Collection<URI> resource) -> {
		File file = new File(uri);
		if (resource != null && !file.isDirectory() && file.getName().endsWith(".jar")) {
			registerBundle(file);
		}
	});
	return resources;
}
 
Example #2
Source File: XtendBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected ResourceSet loadXtendFiles(final ResourceSet resourceSet) {
	encodingProvider.setDefaultEncoding(getFileEncoding());
	final NameBasedFilter nameBasedFilter = new NameBasedFilter();
	nameBasedFilter.setExtension(fileExtensionProvider.getPrimaryFileExtension());
	PathTraverser pathTraverser = new PathTraverser();
	List<String> sourcePathDirectories = getSourcePathDirectories();
	Multimap<String, URI> pathes = pathTraverser.resolvePathes(sourcePathDirectories, new Predicate<URI>() {
		@Override
		public boolean apply(URI input) {
			boolean matches = nameBasedFilter.matches(input);
			return matches;
		}
	});
	for (String src : pathes.keySet()) {
		for (URI uri : pathes.get(src)) {
			if (log.isDebugEnabled()) {
				log.debug("load xtend file '" + uri + "'");
			}
			resourceSet.getResource(uri, true);
		}
	}
	return resourceSet;
}