How to generate binding (key) for a CompilationUnit? [100$ reward for solution] [message #1726164] |
Thu, 10 March 2016 09:14 |
Sergey Toshin Messages: 56 Registered: May 2015 |
Member |
|
|
Hi, I'm making ASTs for a whole project and I don't know how to generate bindings:
getDefaultParser().createASTs(files.toArray(new String[files.size()]), null, createBindings(files), fileAstRequestor, null);
private String[] createBindings(List<String> files)
{
String[] bindings = new String[files.size()];
for(int i = 0; i < files.size(); i++)
{
bindings[i] = createBinding(files.get(i));
}
return bindings;
}
private String createBinding(String file)
{
return file.replace(File.separatorChar, '.');
}
But how is that right? I see that here's a problem and I'm doing something wrong, because some of bindings are not resolved
UPD:
Anyone who will help me to resolve this problem will receive 100$ on his paypal
[Updated on: Fri, 18 March 2016 06:38] Report message to a moderator
|
|
|
Re: How to generate binding for a CompilationUnit? [message #1726267 is a reply to message #1726164] |
Thu, 10 March 2016 20:22 |
Erick Hagstrom Messages: 107 Registered: April 2014 Location: USA |
Senior Member |
|
|
Ok, so first, the bindingKeys parameter on createASTs() expects binding keys, not bindings. You are supplying file path names, and those are not binding keys. Second, you can't create binding keys, you can only safely use binding keys that you have gotten from an IBinding. (The algorithm is not published and can't be expected to remain constant between releases.) See JavaDoc for IBinding.getKey(). So the parser is not finding any of the "bindings" that you've specified. If any bindings are being resolved, they're being resolved simply by the normal actions of the parser. (Default parser resolves all of the bindings that it can.)
So, um, some bindings are not resolved. What can you share that will help narrow down that statement?
|
|
|
Re: How to generate binding for a CompilationUnit? [message #1726295 is a reply to message #1726267] |
Fri, 11 March 2016 07:49 |
Sergey Toshin Messages: 56 Registered: May 2015 |
Member |
|
|
So if I have a source path, how can I generate binding key for a file inside it? I just want to create CompilationUnits for files related to one project
Also how to handle exceptions from ASTParser.createASTs(...)? If bad code is specified, sometimes it throws IllegalArgumentException/ArrayIndexOutOfBoundsException/NullPointerException etc. If I just wrap this call with try{}catch(){} then other CompilationUnits won't be created
[Updated on: Fri, 11 March 2016 08:38] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03726 seconds