Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Tracking problems while modifying a ICompilationUnit (use none deprecated methods)
Tracking problems while modifying a ICompilationUnit (use none deprecated methods) [message #947666] Wed, 17 October 2012 05:45 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 4462
Registered: July 2009
Senior Member
Hi,

When trying to get informations about problems happening while modifying
a working copy of the ICompilationUnit I only managed find a way to do
this using the deprecated

ICompilationUnit#becomeWorkingCopy(IProblemRequestor, ProgressMonitor)

My current code looks something like this (please note I'm a JDT-Dummy
more or less so maybe what I do makes not really sense)

-----------8<---------------
class MyJDTEditor {
MyJDTEditor(IEditorInput input) {
IResourceFileInput fsInput = (IResourceFileInput) input;
unit = (ICompilationUnit) JavaCore.create(fsInput.getFile());

unit.becomeWorkingCopy(new IProblemRequestor() {
// ...
public void acceptProblem(IProblem problem) {
int linenumber = problem.getSourceLineNumber();
int srcStart = problem.getSourceStart();
int srcEnd = problem.getSourceEnd();
});
}


public void insert(int start, String data) {
try {
unit.getBuffer().replace(start, 0, data);
unit.reconcile(ICompilationUnit.NO_AST, true, null, null);
} catch (JavaModelException e) {}
}


public void set(String data) {
try {
unit.getBuffer().setContents(data);
unit.reconcile(ICompilationUnit.NO_AST, true, null, null);
} catch (JavaModelException e) {}
}

public void save() {
unit.commitWorkingCopy(true, null);
}
}
-----------8<---------------

So what is the none deprecated way to get access to the compilation
errors/warnings? Pointers to JDT-UI code to see how things are dealt are
probably even better ;-)

Thanks

Tom
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:Need Help getting Hello Program on screen
Next Topic:J2EE 4.2.1 from 4.2.0 update fail
Goto Forum:
  


Current Time: Sun May 19 01:13:32 EDT 2013

Powered by FUDForum. Page generated in 0.01732 seconds