Home » Language IDEs » Java Development Tools (JDT) » JavaCorrectionProcessor.collectCorrections does not collect any available correction
JavaCorrectionProcessor.collectCorrections does not collect any available correction [message #1027320] |
Tue, 26 March 2013 21:15 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi all,
For the following code:
public class QFSDemo {
private string name_;
}
I am running JavaCorrectionProcessor.collectCorrections(..) with the context and location of the compilation error for 'string' to get the quick fixes offered for that location. My plug-in runs on top of a headless application (e.g., IApplication) that dynamically loads Eclipse UI libraries (e.g., org.eclipse.ui and org.eclipse.jdt.ui).
For some reason, JavaCorrectionProcessor.collectCorrections(..) does not collect any proposal (e.g., the array list I pass to that method returns empty). However, if I load the same file in Eclipse and invoke quick fix, I get 12 Quick Fix Proposals.
Any idea why I am not getting any proposals in my headless application? Is there any way to get all proposals offered for a specific compilation error in a headless application (other than I currently use)?
For reference, I use the following code to get the proposals offered for a specific compilation error:
ArrayList <IJavaCompletionProposal> proposals = new ArrayList <>();
IProblemLocation location = // Location for the compilation error.
IInvocationContext context = // Context for the compilation error.
IProblemLocation [] locations = new IProblemLocation [1];
locations[0] = location;
JavaCorrectionProcessor.collectCorrections(context, locations, proposals);
return proposals;
Let me know if I am doing a mistake in my logic. Thanks in advance, best regards,
[Updated on: Tue, 26 March 2013 21:18] Report message to a moderator
|
|
| | | |
Re: JavaCorrectionProcessor.collectCorrections does not collect any available correction [message #1027400 is a reply to message #1027385] |
Tue, 26 March 2013 23:33 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi Stephan,
Thanks for the explanation.
I might be missing some terminology, but my understanding is:
I need to load jdt.ui through Equinox so that it loads the JavaCorrectionProcessors (which are extensions, which don't get loaded when I do the class-path hack). However, as I am running a headless IApplication, Equinox might fail while loading jdt.ui, is that the case?
Also, would JavaCorrectionProcessors get loaded correctly, if I were to also add them into the class-path of the main thread of my application, or do they need to be loaded differently (you mentioned registration of the extensions)?
I generally don't like repacking existing Eclipse core plug-ins. I did this once for my previous projects, however it increases the maintenance, distribution and installation of the end plug-in. However, if that is the only choice, I might consider it.
A side question: is there a reason Eclipse developers not separating the non-UI dependent parts of ui and jdt.ui into separate plug-ins and let us load them in headless applications? I am sure that this would be a lot of work, however it would help a lot to us as it even took around a month for me to be able to create an instance of ProblemLocation in my headless plug-in because it was complaining that it could not find ProblemLocation in the class-path
Finally, could you point me some tutorial/API/document for both cases (e.g., loading jdt.ui through Equinox or loading registering extensions manually)?
Thanks, best regards,
|
|
| | |
Re: JavaCorrectionProcessor.collectCorrections does not collect any available correction [message #1030492 is a reply to message #1030023] |
Sun, 31 March 2013 08:02 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi Stephan,
Yes, I was looking for QuickFixProcessor. My system is difficult to debug because the main plug-in (which runs through Eclipse and completely debuggable), creates another Eclipse as a sub-process and runs my IApplication (which I am trying to debug) on top (which is very hard to debug) .
Still, I confirmed that it finds QuickFixProcessor with success. I believe the problem is the following: QuickFixProcessor.process(..) eventually calls PlatformUI.getWorkbench(..), which throws an internal Eclipse exception as my headless IApplication has no workbench at all. JavaCorrectionProcessor.collectCorrections(..) runs the processors in 'safe' mode, so I guess the internal exception becomes silent and it just returns empty set as the result. Here is the complete stack trace I managed to get:
Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(ASTProvider.java:245)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:236)
at org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPlugin.java:710)
at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
at org.eclipse.jdt.internal.ui.text.correction.AssistContext.getASTRoot(AssistContext.java:119)
at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getTypeProposals(UnresolvedElementsSubProcessor.java:587)
at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:349)
at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:290)
Do you see any workaround to fool the QuickFixProcessor as if the workbench was loaded? Alternatively, is it possible to create a workbench that is invisible?
Thanks for all the help, much appreciated. Best regards,
|
|
| |
Goto Forum:
Current Time: Mon Sep 23 20:10:31 GMT 2024
Powered by FUDForum. Page generated in 0.03046 seconds
|