From 71cd0c32eeaedd32b0b28948e1c7993729407dc2 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 16 Nov 2014 18:02:13 -0700 Subject: [PATCH] clean up some warnings --- .../mode/experimental/ASTGenerator.java | 4 ++-- .../mode/experimental/ASTNodeWrapper.java | 12 ++++++---- .../mode/experimental/CompilationChecker.java | 11 ++++----- .../mode/experimental/CompletionPanel.java | 23 ++++++++----------- .../experimental/ErrorMessageSimplifier.java | 1 - .../processing/mode/experimental/Problem.java | 1 - .../mode/experimental/XQErrorTable.java | 2 +- 7 files changed, 25 insertions(+), 29 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index aaadb4683..21d0e5a9f 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -2281,7 +2281,7 @@ public class ASTGenerator { temp.push(codeTree); while(!temp.isEmpty()){ - DefaultMutableTreeNode cnode = (DefaultMutableTreeNode) temp.pop(); + DefaultMutableTreeNode cnode = temp.pop(); for (int i = 0; i < cnode.getChildCount(); i++) { temp.push((DefaultMutableTreeNode) cnode.getChildAt(i)); } @@ -2380,7 +2380,7 @@ public class ASTGenerator { temp.push(codeTree); while (!temp.isEmpty()) { - DefaultMutableTreeNode cnode = (DefaultMutableTreeNode) temp.pop(); + DefaultMutableTreeNode cnode = temp.pop(); for (int i = 0; i < cnode.getChildCount(); i++) { temp.push((DefaultMutableTreeNode) cnode.getChildAt(i)); } diff --git a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java index 52aa937f5..537cb92d6 100644 --- a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java +++ b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java @@ -20,6 +20,7 @@ package processing.mode.experimental; import static processing.mode.experimental.ExperimentalMode.log; import static processing.mode.experimental.ExperimentalMode.logE; import static processing.mode.experimental.ExperimentalMode.log2; + import java.util.Iterator; import java.util.List; import java.util.TreeMap; @@ -157,7 +158,8 @@ public class ASTNodeWrapper { if (jd == null) { log("Visiting children of node " + getNodeAsString(thisNode)); - Iterator it = (Iterator) + @SuppressWarnings("unchecked") + Iterator it = thisNode.structuralPropertiesForType().iterator(); boolean flag = true; while (it.hasNext()) { @@ -213,7 +215,7 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(FieldDeclaration fd){ - List list = (List) fd.modifiers(); + List list = fd.modifiers(); SimpleName sn = (SimpleName) getNode(); Type tp = fd.getType(); @@ -247,7 +249,8 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(MethodDeclaration md) { - List list = (List) md.modifiers(); + @SuppressWarnings("unchecked") + List list = md.modifiers(); SimpleName sn = (SimpleName) getNode(); int lineNum = getLineNumber(sn); log("SN " + sn + ", " + lineNum); @@ -282,7 +285,8 @@ public class ASTNodeWrapper { */ private int getJavadocOffset(TypeDeclaration td){ // TODO: This isn't perfect yet. Class \n \n \n className still breaks it.. :'( - List list= (List)td.modifiers(); + @SuppressWarnings("unchecked") + List list = td.modifiers(); SimpleName sn = (SimpleName) getNode(); int lineNum = getLineNumber(sn); diff --git a/pdex/src/processing/mode/experimental/CompilationChecker.java b/pdex/src/processing/mode/experimental/CompilationChecker.java index f457b7ebf..7bc8bf780 100644 --- a/pdex/src/processing/mode/experimental/CompilationChecker.java +++ b/pdex/src/processing/mode/experimental/CompilationChecker.java @@ -380,11 +380,11 @@ public class CompilationChecker { return null; } - private void compileMeQuitely(ICompilationUnit unit, Map compilerSettings) { + private void compileMeQuitely(ICompilationUnit unit, Map compilerSettings) { - Map settings; + Map settings; if (compilerSettings == null) { - settings = new HashMap(); + settings = new HashMap<>(); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); @@ -423,7 +423,6 @@ public class CompilationChecker { IProblem problem = (IProblem) it.next(); prob[count++] = problem; } - } private void compileMeQuitely(ICompilationUnit unit) { @@ -506,7 +505,7 @@ public class CompilationChecker { * @param classLoader - custom classloader which can load all dependencies * @return IProblem[] - list of compiler errors and warnings */ - public IProblem[] getErrors(String sourceName, String source, Map settings, + public IProblem[] getErrors(String sourceName, String source, Map settings, URLClassLoader classLoader) { fileName = sourceName; readFromFile = false; @@ -528,7 +527,7 @@ public class CompilationChecker { } @SuppressWarnings("rawtypes") - public IProblem[] getErrors(String sourceName, String source, Map settings) { + public IProblem[] getErrors(String sourceName, String source, Map settings) { fileName = sourceName; readFromFile = false; sourceText = "package " + fileName + ";\n" + source; diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index 8cf1e1f0c..d74244c87 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -117,8 +117,7 @@ public class CompletionPanel { scrollPane.setViewportView(completionList = createSuggestionList(position, items)); popupMenu.add(scrollPane, BorderLayout.CENTER); popupMenu.setPopupSize(calcWidth(), calcHeight(items.getSize())); //TODO: Eradicate this evil - this.textarea.errorCheckerService.getASTGenerator() - .updateJavaDoc((CompletionCandidate) completionList.getSelectedValue()); + this.textarea.errorCheckerService.getASTGenerator().updateJavaDoc(completionList.getSelectedValue()); textarea.requestFocusInWindow(); popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y); @@ -227,8 +226,7 @@ public class CompletionPanel { float min = 0; FontMetrics fm = textarea.getGraphics().getFontMetrics(); for (int i = 0; i < completionList.getModel().getSize(); i++) { - float h = fm.stringWidth(((CompletionCandidate) completionList.getModel() - .getElementAt(i)).getLabel()); + float h = fm.stringWidth(completionList.getModel().getElementAt(i).getLabel()); min = Math.max(min, h); } int w = Math.min((int) min, maxWidth); @@ -307,8 +305,8 @@ public class CompletionPanel { int currentSubwordLen = currentSubword == null ? 0 : currentSubword .length(); //logE(currentSubword + " <= subword,len => " + currentSubword.length()); - String selectedSuggestion = ((CompletionCandidate) completionList - .getSelectedValue()).getCompletionString(); + String selectedSuggestion = + completionList.getSelectedValue().getCompletionString(); if (currentSubword != null) { selectedSuggestion = selectedSuggestion.substring(currentSubwordLen); @@ -316,8 +314,8 @@ public class CompletionPanel { currentSubword = ""; } - String completionString = ((CompletionCandidate) completionList - .getSelectedValue()).getCompletionString(); + String completionString = + completionList.getSelectedValue().getCompletionString(); if (selectedSuggestion.endsWith(" )")) { // the case of single param methods // selectedSuggestion = ")"; if (completionString.endsWith(" )")) { @@ -358,8 +356,7 @@ public class CompletionPanel { } log("Suggestion inserted: " + System.currentTimeMillis()); - if (((CompletionCandidate) completionList.getSelectedValue()) - .getLabel().contains("...")) { + if (completionList.getSelectedValue().getLabel().contains("...")) { // log("No hide"); // Why not hide it? Coz this is the case of // overloaded methods. See #2755 @@ -488,8 +485,7 @@ public class CompletionPanel { .getVerticalScrollBar() .getValue() - step); - textarea.errorCheckerService.getASTGenerator() - .updateJavaDoc((CompletionCandidate) completionList.getSelectedValue()); + textarea.errorCheckerService.getASTGenerator().updateJavaDoc(completionList.getSelectedValue()); } @@ -506,8 +502,7 @@ public class CompletionPanel { .getSize() - 1); selectIndex(index); } - textarea.errorCheckerService.getASTGenerator() - .updateJavaDoc((CompletionCandidate) completionList.getSelectedValue()); + textarea.errorCheckerService.getASTGenerator().updateJavaDoc(completionList.getSelectedValue()); int step = scrollPane.getVerticalScrollBar().getMaximum() / completionList.getModel().getSize(); scrollPane.getVerticalScrollBar().setValue(scrollPane diff --git a/pdex/src/processing/mode/experimental/ErrorMessageSimplifier.java b/pdex/src/processing/mode/experimental/ErrorMessageSimplifier.java index 5e3b22844..357a980d1 100644 --- a/pdex/src/processing/mode/experimental/ErrorMessageSimplifier.java +++ b/pdex/src/processing/mode/experimental/ErrorMessageSimplifier.java @@ -7,7 +7,6 @@ import java.util.TreeMap; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; -import static processing.mode.experimental.ExperimentalMode.log; public class ErrorMessageSimplifier { /** diff --git a/pdex/src/processing/mode/experimental/Problem.java b/pdex/src/processing/mode/experimental/Problem.java index 2cae43ce7..49e72cc01 100644 --- a/pdex/src/processing/mode/experimental/Problem.java +++ b/pdex/src/processing/mode/experimental/Problem.java @@ -22,7 +22,6 @@ package processing.mode.experimental; -import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/pdex/src/processing/mode/experimental/XQErrorTable.java b/pdex/src/processing/mode/experimental/XQErrorTable.java index 25a3be894..d6b29d9bc 100755 --- a/pdex/src/processing/mode/experimental/XQErrorTable.java +++ b/pdex/src/processing/mode/experimental/XQErrorTable.java @@ -133,7 +133,7 @@ public class XQErrorTable extends JTable { // String tip = null; // java.awt.Point p = evt.getPoint(); int rowIndex = rowAtPoint(evt.getPoint()); - int colIndex = columnAtPoint(evt.getPoint()); +// int colIndex = columnAtPoint(evt.getPoint()); synchronized (errorCheckerService.problemsList) { if (rowIndex < errorCheckerService.problemsList.size()) {