Bug 389494 - The PathTraverser class does not support wildcards in path
Summary: The PathTraverser class does not support wildcards in path
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2012-09-13 07:47 EDT by Serano Colameo CLA
Modified: 2013-08-26 03:49 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serano Colameo CLA 2012-09-13 07:47:26 EDT
The PathTraverser class does not support wildcards:
     [java] java.lang.IllegalArgumentException: Unsupported path : C:\data\projects\workspaces\workspace-jap7\CACHE\agl\CACHE\*.jar (only folders and archives are supported).
     [java] 	at org.eclipse.xtext.mwe.PathTraverser.findAllResourceUris(PathTraverser.java:46)
     [java] 	at org.eclipse.xtext.mwe.PathTraverser.resolvePathes(PathTraverser.java:33)
     [java] 	at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getPathToUriMap(RuntimeResourceSetInitializer.java:54)
     [java] 	at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getInitializedResourceSet(RuntimeResourceSetInitializer.java:72)
     [java] 	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.findModule(Mwe2Runner.java:112)
     [java] 	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:77)

As described in http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html) a classpath can contain also wildcards (e.g. /myjars/*.jar).

The method findAllResourceUris(...) should be extended to something like this:

public Set<URI> findAllResourceUris(String path, Predicate<URI> isValidPredicate) {
	if (path.contains("*")) {
		FileFilter fileFilter = new WildcardFileFilter(new File(path)); 
		File[] files = dir.listFiles(fileFilter); 
		for (File file : files) {    
			return findAllResourceUris(file.getAbsolutePath(), isValidPredicate); 
		} 
	} else ...
}

Regards
Serano