Hi all,
am creating an Eclipse plug-in that is compiling JAVA files upon click of the plug-in button.
Thanks to a StackOverflow question, the answerer gave the perfect solution for the requirement. I now have a project that can compile and run classes from an external folder.
Now, I am trying to port this into a plug-in. I have created the commands and tried to plug the same code into the plug-in code but nothing happens. I found out that task.call() is returning 'false'.
The code by the answerer that works in a JAVA project class:
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
Iterable<? extends JavaFileObject> compilationUnit = fileManager.getJavaFileObjectsFromFiles(Arrays.asList(listOfFiles));
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnit);
if (task.call()) {
//insert logic here
}
Diagnostics showed the following errors: package xxxxplugin_handlers.CheckHandler does not exist and method does not override or implement a method from a supertype.
Here's a snippet of the file I am trying to compile:
public class checkClass implements xxxxplugin.handlers.CheckHandler.DoStuff{
@Override
public String doStuff(String code)
{
//class function here
}
And yes, the package is within the plug-in, it's the default package for handlers.
I am currently stuck. It is really weird that all other handles within that package are working fine (exception of course, this one because it uses JavaCompiler class). Any idea on how to resolve this?