Fixed bug 1205709 - PMD no longer takes a long time to report certain parsing errors.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3504 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2005-05-24 21:50:29 +00:00
parent 96a1f4b3db
commit 2eb65c2e9a
6 changed files with 14 additions and 17 deletions

View File

@ -72,8 +72,8 @@
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<pmd rulesetfiles="rulesets/unusedcode.xml" shortFilenames="true">
<formatter type="text" toFile="rpt.txt"/>
<fileset dir="/home/tom/tmp/">
<include name="Foo.java"/>
<fileset dir="/home/tom/tmp/pmd/">
<include name="ConnectionResponse.java"/>
</fileset>
</pmd>
</target>
@ -124,8 +124,8 @@
<delete file="src/net/sourceforge/pmd/ast/JavaParserConstants.java"/>
<delete file="src/net/sourceforge/pmd/ast/JavaParserTreeConstants.java"/>
<delete file="src/net/sourceforge/pmd/ast/JavaParserTokenManager.java"/>
<jjtree target="etc/grammar/Java.jjt" outputdirectory="src/net/sourceforge/pmd/ast" javacchome="/usr/local/javacc-3.2/"/>
<javacc target="src/net/sourceforge/pmd/ast/Java.jj" outputdirectory="src/net/sourceforge/pmd/ast" javacchome="/usr/local/javacc-3.2/"/>
<jjtree target="etc/grammar/Java.jjt" outputdirectory="src/net/sourceforge/pmd/ast" javacchome="/usr/local/javacc/"/>
<javacc target="src/net/sourceforge/pmd/ast/Java.jj" outputdirectory="src/net/sourceforge/pmd/ast" javacchome="/usr/local/javacc/"/>
<delete file="src/net/sourceforge/pmd/ast/Java.jj"/>
<replace file="src/net/sourceforge/pmd/ast/JavaParserTokenManager.java" token="throw new Error" value="throw new RuntimeException"/>
<replace file="src/net/sourceforge/pmd/ast/JavaParser.java" token="(Error)" value="(RuntimeException)"/>
@ -145,7 +145,7 @@
<exclude name="SymtabManager.java"/>
</fileset>
</delete>
<javacc target="../etc/grammar/cpp.jj" outputdirectory="src/net/sourceforge/pmd/cpd/cppast" javacchome="/usr/local/javacc-3.2/"/>
<javacc target="../etc/grammar/cpp.jj" outputdirectory="src/net/sourceforge/pmd/cpd/cppast" javacchome="/usr/local/javacc/"/>
<replace file="src/net/sourceforge/pmd/cpd/cppast/ParseException.java" token="extends Exception" value="extends RuntimeException"/>
</target>

View File

@ -1,5 +1,6 @@
????, 2005 - 3.2:
Fixed bug 1201577 - PMD now correctly parses method declarations that return generic types.
Fixed bug 1205709 - PMD no longer takes a long time to report certain parsing errors.
Fixed bug which caused MissingSerialVersionUID to trigger on all interfaces that implemented other interfaces.
Implemented RFE 1188604 - AvoidThrowingCertainExceptionTypes has been split into AvoidThrowingRawExceptionTypes and AvoidThrowingNullPointerException.
Implemented RFE 1188369 - UnnecessaryBooleanAssertion now checks for things like 'assertTrue(!foo)'. These should be changed to 'assertFalse(foo)' for clarity.

View File

@ -98,19 +98,19 @@ public class ParseException extends RuntimeException {
if (!specialConstructor) {
return super.getMessage();
}
String expected = "";
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected += tokenImage[expectedTokenSequences[i][j]] + " ";
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected += "...";
expected.append("...");
}
expected += eol + " ";
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
@ -130,7 +130,7 @@ public class ParseException extends RuntimeException {
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected;
retval += expected.toString();
return retval;
}

View File

@ -30,10 +30,7 @@ public class LanguageFactory {
return new PHPLanguage();
} else if (language.equals(RUBY_KEY)) {
return new RubyLanguage();
} else {
// try any....
return new AnyLanguage(language);
}
//throw new RuntimeException("Can't create language " + language);
return new AnyLanguage(language);
}
}

View File

@ -8,8 +8,7 @@ import java.util.List;
public class RubyTokenizer implements Tokenizer {
private boolean downcaseString = true;
//private boolean downcaseString = false;
public void tokenize(SourceCode tokens, Tokens tokenEntries) {
List code = tokens.getCode();
for (int i = 0; i < code.size(); i++) {
@ -18,7 +17,6 @@ public class RubyTokenizer implements Tokenizer {
while (loc < currentLine.length()) {
StringBuffer token = new StringBuffer();
loc = getTokenFromLine(currentLine,token,loc);
//System.out.println("Token for ;"+ tokens.getFileName()+" ;line:" + i + ";loc:" + loc + ";" + token.toString());
if (token.length() > 0 && !isIgnorableString(token.toString())) {
if (downcaseString) {
token = new StringBuffer(token.toString().toLowerCase());

View File

@ -43,6 +43,7 @@
</subsection>
<subsection name="Contributors">
<ul>
<li>Glen Cordrey - Reported bug involved JavaCC string handling</li>
<li>Dave Brosius - a couple of nice patches to clean up some string handling inefficiencies, non-static class usages, and unclosed streams/readers - found with Findbugs, I daresay :-)</li>
<li>Tom Parker - Suggested addition to UnnecessaryBooleanAssertion, suggested splitting up AvoidThrowingCertainExceptionTypes, AvoidInstantiatingObjectsInLoops bug report, AtLeastOneConstructor bug report</li>
<li>Oto 'tapik' Buchta - Patched XMLRenderer for UTF8 support</li>