Error checker refactoring

This commit is contained in:
Jakub Valtar
2015-09-22 20:52:52 -04:00
parent 1d85937041
commit 5e574a963b
6 changed files with 328 additions and 483 deletions

View File

@@ -140,7 +140,7 @@ public class JavaEditor extends Editor {
//initializeErrorChecker();
errorCheckerService = new ErrorCheckerService(this);
new Thread(errorCheckerService).start();
errorCheckerService.start();
// hack to add a JPanel to the right-hand side of the text area
JPanel textAndError = new JPanel();
@@ -1307,7 +1307,7 @@ public class JavaEditor extends Editor {
if (inspector != null) {
inspector.dispose();
}
errorCheckerService.stopThread();
errorCheckerService.stop();
super.dispose();
}
@@ -1872,7 +1872,7 @@ public class JavaEditor extends Editor {
autoSave();
super.prepareRun();
downloadImports();
errorCheckerService.quickErrorCheck();
errorCheckerService.cancel();
}
@@ -2487,15 +2487,13 @@ public class JavaEditor extends Editor {
public LineMarker findError(int line) {
List<LineMarker> errorPoints = getErrorPoints();
JavaTextArea textArea = getJavaTextArea();
synchronized (errorPoints) {
for (LineMarker emarker : errorPoints) {
Problem p = emarker.getProblem();
int pStartLine = p.getLineNumber();
int pEndOffset = textArea.getLineStartOffset(pStartLine) + p.getPDELineStopOffset() + 1;
int pEndLine = textArea.getLineOfOffset(pEndOffset);
if (line >= pStartLine && line <= pEndLine) {
return emarker;
}
for (LineMarker emarker : errorPoints) {
Problem p = emarker.getProblem();
int pStartLine = p.getLineNumber();
int pEndOffset = textArea.getLineStartOffset(pStartLine) + p.getPDELineStopOffset() + 1;
int pEndLine = textArea.getLineOfOffset(pEndOffset);
if (line >= pStartLine && line <= pEndLine) {
return emarker;
}
}
return null;
@@ -2712,7 +2710,7 @@ public class JavaEditor extends Editor {
jmode.loadPreferences();
Messages.log("Applying prefs");
// trigger it once to refresh UI
errorCheckerService.runManualErrorCheck();
errorCheckerService.request();
}
}

View File

@@ -142,6 +142,7 @@ public class MarkerColumn extends JPanel {
protected void done() {
repaint();
editor.getErrorChecker().updateEditorStatus();
}
}.execute();

View File

@@ -407,10 +407,6 @@ public class ASTGenerator {
}
public DefaultMutableTreeNode buildAST(CompilationUnit cu) {
return buildAST(errorCheckerService.sourceCode, cu);
}
public static CompletionCandidate[] checkForTypes(ASTNode node) {
List<VariableDeclarationFragment> vdfs = null;
@@ -1292,7 +1288,7 @@ public class ASTGenerator {
public String getJavaSourceCodeLine(int javaLineNumber) {
try {
PlainDocument javaSource = new PlainDocument();
javaSource.insertString(0, errorCheckerService.sourceCode, null);
javaSource.insertString(0, errorCheckerService.lastCodeCheckResult.sourceCode, null);
Element lineElement = javaSource.getDefaultRootElement()
.getElement(javaLineNumber - 1);
if (lineElement == null) {
@@ -1319,7 +1315,7 @@ public class ASTGenerator {
public Element getJavaSourceCodeElement(int javaLineNumber) {
try {
PlainDocument javaSource = new PlainDocument();
javaSource.insertString(0, errorCheckerService.sourceCode, null);
javaSource.insertString(0, errorCheckerService.lastCodeCheckResult.sourceCode, null);
Element lineElement = javaSource.getDefaultRootElement()
.getElement(javaLineNumber - 1);
if (lineElement == null) {
@@ -1956,7 +1952,7 @@ public class ASTGenerator {
int pdeOffs[] = errorCheckerService
.calculateTabIndexAndLineNumber(javaLineNumber);
PlainDocument javaSource = new PlainDocument();
javaSource.insertString(0, errorCheckerService.sourceCode, null);
javaSource.insertString(0, errorCheckerService.lastCodeCheckResult.sourceCode, null);
Element lineElement = javaSource.getDefaultRootElement()
.getElement(javaLineNumber-1);
if(lineElement == null) {
@@ -2076,7 +2072,7 @@ public class ASTGenerator {
}
//else log("New name looks K.");
errorCheckerService.pauseThread();
errorCheckerService.cancel();
if(refactorTree.isVisible()){
refactorTree.setModel(new DefaultTreeModel(defCU));
((DefaultTreeModel) refactorTree.getModel()).reload();
@@ -2128,9 +2124,9 @@ public class ASTGenerator {
editor.getTextArea().setSelectedText(newName);
}
editor.stopCompoundEdit();
errorCheckerService.resumeThread();
errorCheckerService.request();
editor.getSketch().setModified(true);
errorCheckerService.runManualErrorCheck();
errorCheckerService.request();
// frmOccurenceList.setVisible(false);
frmRename.setVisible(false);
lastClickedWord = null;
@@ -3492,7 +3488,7 @@ public class ASTGenerator {
editor.getSketch().setCurrentCode(0);
editor.getTextArea().getDocument().insertString(0, impString, null);
editor.getSketch().setCurrentCode(ct);
errorCheckerService.runManualErrorCheck();
errorCheckerService.request();
frmImportSuggest.setVisible(false);
frmImportSuggest = null;
} catch (BadLocationException e) {

View File

@@ -555,7 +555,7 @@ public class ASTNodeWrapper {
int javaLineNumber = getLineNumber(nodeName);
int pdeOffs[] = editor.getErrorChecker().calculateTabIndexAndLineNumber(javaLineNumber);
PlainDocument javaSource = new PlainDocument();
javaSource.insertString(0, editor.getErrorChecker().sourceCode, null);
javaSource.insertString(0, editor.getErrorChecker().lastCodeCheckResult.sourceCode, null);
Element lineElement = javaSource.getDefaultRootElement()
.getElement(javaLineNumber-1);
if(lineElement == null) {

File diff suppressed because it is too large Load Diff

View File

@@ -348,7 +348,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
*/
protected void paintErrorLine(Graphics gfx, int line, int x) {
ErrorCheckerService ecs = getJavaEditor().getErrorChecker();
if (ecs == null || ecs.problemsList == null) {
if (ecs == null || ecs.lastCodeCheckResult.problems.isEmpty()) {
return;
}