Compare commits

...
Author SHA1 Message Date
Andreas Dangel 242ea1065b [maven-release-plugin] prepare release pmd_releases/5.1.1 2014-04-27 08:23:21 +02:00
Andreas Dangel 9273d334ac Prepare pmd release 5.1.1 2014-04-27 08:01:36 +02:00
Andreas Dangel d52db39846 Merge branch 'pmd/5.1.x' 2014-04-27 07:45:13 +02:00
Andreas Dangel 6f61b41e20 Fix #1191 Ecmascript fails to parse "void(0)" 2014-04-26 19:13:15 +02:00
Andreas Dangel d03f5a339c Adding TodoComment checkstyle rule. 2014-04-26 18:11:51 +02:00
Andreas Dangel 3b47b5d408 Checkstyle fixes. 2014-04-26 18:07:43 +02:00
Andreas Dangel 324f5707d2 Fix changelog layout 2014-04-26 17:53:13 +02:00
Andreas Dangel b2b02a69a4 Checkstyle fixes 2014-04-26 17:46:49 +02:00
Andreas Dangel dcb7668c57 Update changelog 2014-04-26 11:51:20 +02:00
Andreas Dangel 22647630b7 Merge branch 'commentrequired-enums' of https://github.com/igniti-gmbh/pmd into igniti-gmbh-master 2014-04-26 11:48:36 +02:00
Andreas Dangel 85d8660c6d Merge branch 'master' of https://github.com/igniti-gmbh/pmd into igniti-gmbh-master 2014-04-26 11:47:16 +02:00
Andreas Dangel f0346a9aee Verify #1189 GuardLogStatementRule and GuardDebugLoggingRule broken for log4j2 2014-04-23 16:54:39 +02:00
Andreas Dangel 0796dad74e Fix #1188 False positive in UnusedPrivateField 2014-04-23 16:29:57 +02:00
Alexander Stillich 785f01b0fa Added support for enums in CommentRequiredRule and extended corresponsing test 2014-04-16 14:33:11 +02:00
Alexander Stillich dbddeb01f1 Fixed NPE in ConsecutiveAppendsShouldReuseRule.getVariableAppended() which was triggered with the dogfood ruleset 2014-04-16 13:29:32 +02:00
Andreas Dangel 8694a26caf Fix #1167 Error while processing PLSQL file with BOM 2014-04-13 10:48:20 -04:00
Andreas Dangel 6eb8f84769 Fix #1165 SimplifyConditional false positive 2014-04-13 09:44:17 -04:00
Andreas Dangel 4bcef67b42 Fix #1185 UnusedModifier throws NPE when parsing enum with a nested static interface 2014-04-13 09:43:58 -04:00
Andreas Dangel 0f72ff41d9 Deleted all the folders that have been moved out into own repositories.
pmd-eclipse-plugin -> https://github.com/pmd/pmd-eclipse-plugin
pmd-jdeveloper* -> https://github.com/pmd/pmd-jdeveloper
website -> https://github.com/pmd/pmd.sourceforge.net
pmd-emacs -> https://github.com/pmd/pmd-emacs
everything else -> https://github.com/pmd/pmd-misc
2014-04-12 19:50:56 -04:00
Andreas Dangel 24c9bb9de9 Add test for AbstractCommentRule 2014-04-12 10:00:18 -04:00
Andreas Dangel 1fcc5ceeae Merge branch 'comment-fixes' of https://github.com/igniti-gmbh/pmd into igniti-gmbh-comment-fixes 2014-04-12 09:40:12 -04:00
Stuart Turton db000f3ad0 DBURI - add more feedback for problems returning DataSources from DBURIs 2014-04-11 20:37:12 -04:00
Stuart Turton 5ad79006ab PLSQL - Add InlinePragma class to support PRAGMA INLINE( method , ('YESY'|'NO') ) statement 2014-04-11 20:37:05 -04:00
Stuart Turton a12bc08c3b PLSQL - remove commented out Java Rule for PLSQ code size.xml Rules file 2014-04-11 20:36:57 -04:00
Andreas Dangel 423ac78d91 Enable PLSQL XPath Rule TooManyMethods 2014-04-11 20:34:42 -04:00
Stuart Turton 9a61116259 Incorporate PLDoc changes:-
Adding [EDITIONABLE|NONEDITIONABLE] keyword broke LOOKAHEAD Increase
QuickFix for Inline PRAGMA compiler instruction (support clause without adding new AST Type)
2014-04-11 20:24:11 -04:00
Andreas Dangel 2b11c5e1f2 Fix #1166 PLSQL XPath Rules Fail for XPath 1.0 2014-04-11 20:19:56 -04:00
Stuart Turton 06057f17ee PLSQL- Add minimal XPathHandler to PLSQLHandler in order to avoid NPE in XPath rules for XPath 1.0. 2014-04-11 20:06:49 -04:00
Andreas Dangel 1e3dbdb357 Add unit test for bug #1166 PLSQL XPath Rules Fail for XPath 1.0 2014-04-11 20:06:14 -04:00
Alexander Stillich e42bc43287 Fix comments between other comments being wrongly assigned:
/** Comment 1 */
	public void method1() {}

	/** Comment 2 */

	/** Comment 3 */
	public void method2() {}

Would assign Comment 2 to method2, should assign Comment 3.

Also added support for enums in AbstractCommentRule.orderedCommentsAndDeclarations().
2014-04-10 15:54:37 +02:00
Andreas Dangel 1aa11e5ee7 Fix unit test DesignerTest so that it runs in headless mode, too. 2014-04-07 21:02:11 -04:00
Andreas Dangel e8e7420027 Document that PMD requires java 1.6 2014-04-07 20:05:01 -04:00
Andreas Dangel 4dd18721c1 pmd: fix #1168 Designer errors when trying to copy xml to clipboard 2014-04-04 18:32:09 -04:00
Andreas Dangel 552acfd0c1 pmd: fix #1180 False Positive for ConsecutiveAppendsShouldReuse on different variable names 2014-04-03 20:20:28 -04:00
Andreas Dangel bc4f7cc1c2 pmd: fix #1177 Incorrect StringBuffer warning when that class is not used 2014-04-03 19:33:01 -04:00
Andreas Dangel 36fc87c3c8 pmd/cpd: add skipLexicalErrors and skipDuplicateFiles to CPD's ant task 2014-04-02 21:29:57 -04:00
Andreas Dangel 12adae6034 pmd: fix #1178 LexicalError while parsing Java code aborts CPD run 2014-04-02 20:22:34 -04:00
Andreas Dangel 88ee9c47d8 pmd: fix #1176 ShortVariable false positive with for-each loops 2014-03-30 16:58:26 -04:00
Andreas Dangel e54b6dd22f pmd: fix #1173 Java 8 support: method references 2014-03-30 09:32:10 -04:00
Andreas Dangel e0ece8f82a pmd: fix #1170 false positive with switch in loop 2014-03-29 19:49:38 -04:00
Andreas Dangel 7a806df932 pmd: verify #1173 Java 8 support: method references 2014-03-29 19:34:15 -04:00
Andreas Dangel 87989b524a pmd: fix #1175 false positive for StringBuilder.append called 2 consecutive times 2014-03-29 19:18:46 -04:00
Andreas Dangel 6e1927ee2a pmd: fix #1171 Specifying minimum priority from command line gives NPE 2014-03-29 16:51:21 -04:00
Andreas Dangel f0049c5946 pmd: format source, no changes 2014-03-29 16:44:57 -04:00
Andreas Dangel 21750b9bc4 pmd: update release process documentation
pmd.website.baseurl is set correctly if the profile "pmd-release" is used
  during releasing
2014-02-12 20:46:58 +01:00
Andreas Dangel 4aee867fc2 [maven-release-plugin] prepare for next development iteration 2014-02-11 21:32:12 +01:00
Andreas Dangel 79a9af14f2 [maven-release-plugin] prepare release pmd_releases/5.1.0 2014-02-11 21:30:13 +01:00
Andreas Dangel c7bba5bf26 pmd: Update changelog for next development version 2014-02-11 20:26:15 +01:00
Andreas Dangel b970324b97 pmd: Prepare pmd release 5.1.0 2014-02-11 20:26:15 +01:00
Andreas Dangel d36190ea7c pmd: Prepare next development version 5.2.0-SNAPSHOT 2014-02-11 20:26:15 +01:00
Andreas Dangel 83552fb843 pmd: Fix rulesets not meeting pmd conventions 2014-02-11 20:26:08 +01:00
Andreas Dangel f4343f6b19 pmd: update documentation about new supported languages. 2014-02-09 09:37:19 +01:00
Andreas Dangel c011fc6dd1 pmd: fix #1054 XML Rules ever report a line -1 and not the line/column where the error occurs 2014-02-08 22:46:55 +01:00
Andreas Dangel 93a46d17e7 pmd: fix #1045 //NOPMD not working (or not implemented) with ECMAscript 2014-02-02 22:37:15 +01:00
Andreas Dangel ec0471cebe pmd: fix #1164 Violations are not suppressed with @java.lang.SuppressWarnings("all") 2014-02-02 13:21:30 +01:00
Andreas Dangel 8aa83291c0 pmd: update changelog 2014-02-02 12:12:10 +01:00
Andreas Dangel 08041af650 pmd: fix #1124 PMD.run() multithreading issue 2014-02-02 12:09:55 +01:00
Andreas Dangel 8482948518 pmd: fix #1120 equalsnull false positive 2014-02-02 11:51:59 +01:00
Andreas Dangel a0a7f58dec pmd: verify #1122 parse error at class.super 2014-02-02 11:18:42 +01:00
Andreas Dangel 29a139797c pmd: verify #1143 ShortClassName fires with a 5-letter class name 2014-02-02 11:14:31 +01:00
Andreas Dangel 8607d02120 pmd: fix #1146 UseArrayListInsteadOfVector false positive when using own Vector class 2014-02-02 11:11:07 +01:00
Andreas Dangel 8e8cec667e pmd: fix #1125 Missing Static Method In Non Instantiatable Class 2014-02-02 10:54:03 +01:00
Andreas Dangel 5b52ba642c pmd: fix #1126 False positive with FieldDeclarationsShouldBeAtStartOfClass for static enums 2014-02-02 10:33:31 +01:00
Andreas Dangel bbb36686b9 pmd: fix #1147 EmptyMethodInAbstractClassShouldBeAbstract false positives 2014-02-01 19:47:43 +01:00
Andreas Dangel c0efb45c10 pmd: verify #1149 getBeginLine and getEndLine not working (ECMAScript) 2014-02-01 19:31:27 +01:00
Andreas Dangel ab158fe19f pmd: fix #1150 "EmptyExpression" for valid statements! 2014-02-01 19:15:06 +01:00
Andreas Dangel 86d9c1060c pmd: fix #1154 Call super onPause when there is no super 2014-02-01 18:56:30 +01:00
Andreas Dangel cc27363c97 pmd: verify #1156 False failure with "Avoid unused private methods" 2014-02-01 18:42:22 +01:00
Andreas Dangel aad969665f pmd: fix #1159 false positive UnusedFormalParameter readObject(ObjectInputStream) if not used 2014-02-01 18:36:07 +01:00
Andreas Dangel dff3d181f9 pmd-eclipse: update release notes 2014-02-01 13:02:04 +01:00
Andreas Dangel 8cac431226 Merge branch 'project-ruleset-workspace-path' of github.com:robinst/pmd 2014-02-01 12:53:38 +01:00
Andreas Dangel 4e30abe315 Merge branch 'preference-keyword' of github.com:robinst/pmd 2014-02-01 12:52:32 +01:00
Andreas Dangel 964f6933e1 pmd: update changelog 2014-02-01 12:50:03 +01:00
Andreas Dangel d9064e6956 Merge branch 'cpd_concurrency' of github.com:golpira/pmd into golpira-cpd_concurrency 2014-02-01 12:46:47 +01:00
Andreas Dangel 1a48102d9a pmd: register plsql dates ruleset 2014-02-01 12:44:16 +01:00
Andreas Dangel dc945f78b2 Merge branch 'master' of github.com:sturton/pmd into sturton-master 2014-02-01 11:37:45 +01:00
Andreas Dangel 570d6cedc6 pmd: enable some ignored tests and remove System.out in tests... 2014-02-01 11:34:12 +01:00
Andreas Dangel 2624b6b3ea pmd: add test code that cannot be parsed, but is valid java 8 code. 2014-02-01 10:09:01 +01:00
Andreas Dangel ee708b42ea pmd: add intersectionTypes flag to ASTCastExpression 2014-01-31 22:33:04 +01:00
Andreas Dangel 6355c1f6f4 pmd: adjust variable declarator id for missing type node in case
of lambda expressions.
2014-01-31 19:38:05 +01:00
Andreas Dangel 6dc3701cc8 pmd: add java 8 syntax for type annotations 2014-01-30 23:13:12 +01:00
Andreas Dangel 9fbaf13bd9 pmd: fix unit tests after changing default java version to 1.8. 2014-01-30 20:44:41 +01:00
Andreas Dangel 64ab7b78e7 pmd: Improve java 8 parser 2014-01-30 20:36:40 +01:00
Robin Stocker 4de96d5dd2 pmd-eclipse: Support workspace-relative path in ruleSetFile property
When using multiple projects that want to share the rule set definitions
in a single file, it's currently only possible to reference the shared
file using an absolute path. The downside of the absolute path is that
it is different for each developer, so the resulting .pmd file can not
be committed in the repository.

To fix this, this change also tries to resolve the path against the
workspace root, so e.g. "/foo/.ruleset" can be used to refer to the
.ruleset file in the foo project.

Such a path can be ambiguous to an absolute file system path, but in
practice it should not be a problem. An alternative solution would be to
support variables (as known from Eclipse run configurations) such as
"${project_loc:foo}" in the path.
2014-01-29 13:35:47 +01:00
Robin Stocker 5f9598815f pmd-eclipse: Add "PMD" keyword to all preference pages
Otherwise the subpages are not shown when searching for "PMD" in the
preferences.
2014-01-29 12:31:29 +01:00
Andreas Dangel bef23a8d2d pmd: use java 8 as default version of java. 2014-01-28 22:28:00 +01:00
Andreas Dangel bfa925a44f pmd: feature #1161 Confusing Ternary should skip else if statements (or have a property to do so) 2014-01-27 20:35:46 +01:00
Andreas Dangel b3af64fa52 pmd: update changelog for java 1.8 support. 2014-01-26 20:17:23 +01:00
Andreas Dangel 65864b6189 pmd: fix java 8 grammar with LambdaExpression to not be confused with Expression 2014-01-26 20:10:16 +01:00
Andreas Dangel 350d0c3cfc pmd: improve java parse exceptions - tell, where the parse exception occurred. 2014-01-26 19:47:17 +01:00
Andreas Dangel 9ba87965ca pmd: Integrate LambdaExpressions in java symboltable.
Lambda parameters are not added to the local scope's symbol table.
2014-01-26 12:29:05 +01:00
Andreas Dangel e57eb66c55 pmd: add Java language version 1.8 and enable checks in grammar/parser. 2014-01-26 12:00:12 +01:00
Andreas Dangel a49391f3f5 pmd: Adjust grammar to not break other parsing corner cases with java 8 enhancements. 2014-01-26 11:52:15 +01:00
Andreas Dangel 88d766ee8b pmd: Extend java grammar to support Java 8 language features. 2014-01-25 19:47:49 +01:00
Andreas Dangel 9b91690f21 pmd: make pmd jdk8 ready
* Upgrade asm so that it understands jdk8 class files
2014-01-23 22:46:02 +01:00
David Golpira 8c0a4f6e4f Changed TokenEntry to use ThreadLocal.
Two static fields are now stored in ThreadLocal.  This allows
multiple instances of CPD to run concurrently without stepping
on each other (eg: multi-module Maven projects.)
2014-01-23 01:08:24 -05:00
Stuart Turton 5f02803d78 CPD: add getter for all identified or added Sources 2014-01-10 22:05:12 +00:00
Stuart Turton f7b61616ea CPD: Rename List<String> getSources() to getSourcePaths() 2014-01-10 21:58:14 +00:00
Stuart Turton 28449e7f71 XPATH - make DocumentNavigator more robust 2014-01-09 00:03:33 +00:00
Stuart Turton 61c25b793e CPD- add getter for list of Source paths 2014-01-08 23:59:31 +00:00
Stuart Turton faa035b1c1 PMD-PLSQL - derive different faux-filename suffices for package/type specifications and bodies
-  Add rules for date
2014-01-08 23:47:05 +00:00
Andreas Dangel 4d9b7b0f8b pmd: checkstyle fixes 2014-01-05 15:17:20 +01:00
Andreas Dangel 36224a5ef7 pmd: checkstyle fixes 2014-01-05 14:48:16 +01:00
Andreas Dangel bc47a7109e pmd: checkstyle fixes 2014-01-03 14:51:51 +01:00
Andreas Dangel 9bf3895a48 pmd: update changelog and integrate it into the site
* The changelog uses now markdown for formatting
2014-01-03 11:55:46 +01:00
Andreas Dangel 7ec06b3adb pmd: review Velocity pull request
* Introduced AbstractVmNode (formerly SimpleNode)
* Added VmNode interface
* Added PMD's license header to the rule implementations, etc.
* Added rulesets.properties file for velocity rules
* Added externalInfoUrl to the rules
* Added Apache License info
2014-01-02 18:46:39 +01:00
Andreas Dangel 4fe4b40279 Merge branch 'master' of github.com:andrey81inmd/pmd into velocity
Conflicts:
	pmd/src/main/ant/alljavacc.xml
	pmd/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java
2014-01-02 10:10:17 +01:00
Andreas Dangel cce09d0f64 Merge branch 'm2e-error' of github.com:robinst/pmd 2014-01-02 10:06:36 +01:00
Andreas Dangel 388b1f5e65 pmd: code cleanups - no functional change
* checkstyle and pmd dogfood
2014-01-01 11:12:32 +01:00
Andreas Dangel 687eadbb10 pmd: update maven-pmd-plugin to 3.0.1 2013-12-31 16:06:07 +01:00
Andreas Dangel 75addab584 pmd: add howto about adding new languages to PMD. Thanks to Andrey Utis. 2013-12-31 16:06:07 +01:00
Andreas Dangel 0dd9ffb390 pmd: add markdown as additional documentation language 2013-12-31 16:05:12 +01:00
Andreas Dangel 6fd188a2ab pmd: Reviewed plsql pull request
* reworked symboltable implementation of plsql to use the refactored
general interfaces
2013-12-31 16:01:58 +01:00
Andreas Dangel d8ec3bfd39 Merge branch 'master' into plsql 2013-12-31 15:58:08 +01:00
Andreas Dangel 6a09146169 Merge branch 'symboltable' 2013-12-31 15:50:32 +01:00
Andreas Dangel 7d455c0064 pmd: update changelog with symboltable API changes 2013-12-25 10:20:31 +01:00
Andreas Dangel 5ed9bd8a0a pmd: move ScopedNode into the symboltable package 2013-12-25 10:19:50 +01:00
Andreas Dangel 93a5d77184 pmd: update changelog and add test for bug #1155 2013-12-23 13:17:34 +01:00
Henning Schmiedehausen c1cb3bfb5e Fix NPE with empty rulesets.
This is the fix for bug #1155 (https://sourceforge.net/p/pmd/bugs/1155/)

The whole code is in dire need of revisiting its behaviour when a
value is null or empty. Same goes for e.g. createRules whether it
should return null values (then the caller will have to deal with it)
or empty Rulesets.

Catching and discarding the rule not found exception looks pretty
suspicious.
2013-12-23 13:10:48 +01:00
Andreas Dangel e2b5b3753e pmd: add changelog and test for #1144 2013-12-23 13:09:33 +01:00
Andreas Dangel d4719914fa pmd: Refactor designer to not be Java specific anymore 2013-12-22 18:44:33 +01:00
Andreas Dangel 036cd3c143 pmd: Refactor rule implementation to use new generic symboltable 2013-12-22 18:44:33 +01:00
Andreas Dangel eee76b0248 pmd: Refactor java's symboltable implementation to use the new generic base classes 2013-12-22 18:44:32 +01:00
Andreas Dangel 1354f6f1fa pmd: Add basic/abstract implementations for Scope and NameDeclaration 2013-12-22 18:44:32 +01:00
Andreas Dangel a10c7dc78e pmd: Introduce generic Scope, NameDeclaration and NameOccurrence 2013-12-22 18:44:32 +01:00
Andreas Dangel 7f3a949935 pmd: Correct usage of generic ParseException 2013-12-22 18:44:32 +01:00
Andreas Dangel dee9df77c6 pmd: Refactor DFA and Designer, so that DFA is not Java specific 2013-12-22 18:44:32 +01:00
Robin Stocker 8412e5eb62 pmd-eclipse: Relax versionRange in pluginExecutionFilter for m2e 2013-11-30 15:17:07 +01:00
Pelisse Romain aea2504b2b Merge pull request #29 from hgschmie/master
Bring back the old CPDConfiguration constructor
2013-11-26 14:21:05 -08:00
Henning Schmiedehausen 8ad4a6a375 Bring back the old CPDConfiguration constructor; removing it will break
at least the maven pmd plugin which uses it.
2013-11-26 10:19:22 -08:00
Robin Stocker eb31689e26 pmd-eclipse: Fix "maven-dependency-plugin ... is not supported by m2e"
After importing the projects into Eclipse, m2e had the following error:

maven-dependency-plugin (goals "copy-dependencies", "unpack") is not
supported by m2e.

The error can be suppressed by adding a pluginExecutionFilter for m2e.
This does not affect the command-line build.
2013-11-18 17:00:13 +01:00
Andreas Dangel 9c9ab97523 pmd: improve doc example "how to write a rule" 2013-11-11 20:41:19 +01:00
Andreas Dangel 5c461b738d pmd: Verify UncommentedEmptyConstructor and move the tests to use the common test infrastructure. 2013-11-11 20:08:48 +01:00
Andreas Dangel 54f77b9ad4 pmd-eclipse: update release procedure 2013-10-31 12:47:01 +01:00
Andreas Dangel d6b6afab23 Prepare next pmd-eclipse-plugin development version 4.0.3-SNAPSHOT 2013-10-31 12:31:52 +01:00
Stuart Turton e9d7dddfbd plsql - make RELEASE an unreserved keywo 2013-10-22 00:15:48 +01:00
Andrey Utis 7ee2493593 Adding noinlinestyles rule 2013-10-17 13:38:00 -04:00
Andrey Utis 3a96e8ada3 Adding NoInlineJavaScript rule 2013-10-17 13:13:07 -04:00
Andrey Utis f5d9785625 Adding UnusedMacroParameterRule 2013-10-16 09:12:45 -04:00
Andrey Utis 3af86ec2aa Added EmptyForeachStmt rule 2013-10-11 16:40:25 -04:00
Andrey Utis f8e02bbd9f Adding EmptyIfStmt rule 2013-10-11 15:38:32 -04:00
Andrey Utis 3df53c4e1b Adding ExcessiveTemplateLengthRule and AvoidReassigningParameters rules 2013-10-09 15:38:08 -04:00
Andrey Utis 8e9bf2f321 Adding CollapsibleIfStatements rule for Velocity 2013-10-08 16:39:12 -04:00
Andrey Utis 2f21e2db42 creating Nested IF statement rule for VM 2013-10-07 21:20:21 -04:00
Andrey Utis b394464dcb Add VM visitor classes 2013-10-04 17:18:43 -04:00
Andrey Utis 916cdca56f fixing a couple more parsing issues 2013-10-01 21:56:49 -04:00
Andrey Utis d2bb244256 more cleanup - making dump work for vm 2013-10-01 21:23:36 -04:00
Andrey Utis 76beb2c48a removing dependency on velocity and cleanup 2013-10-01 20:59:52 -04:00
Andrey Utis d6df33915a fixing #foreach and cleanup 2013-09-30 22:23:59 -04:00
Andrey Utis 24b19cfd55 adding directives 2013-09-28 22:19:31 -04:00
Andrey Utis cbba43c6a3 initial attempt to add velocity language 2013-09-24 22:42:26 -04:00
Stuart Turton be4b6ecc5c Incorporate PLDoc 1.5.6 changes - Make NULLIF and RENAME unreserved keywords 2013-08-29 21:24:16 +01:00
Stuart Turton c8d41ce3b3 PLSQL Correct AccessibleByClause for second and successive accessors 2013-07-22 19:08:17 +01:00
Stuart Turton 67a4ed5b2e Merge branch 'master' of https://github.com/sturton/pmd
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java
2013-07-21 18:05:43 +01:00
Stuart Turton ddacf7ec44 PLSQL- bring parser up to PLDoc 1.5.4 (11g EDITIONABLE/NONEDITIONABLE, 12c ACCESSIBLE BY clause )
Remove unused imports and variables
2013-07-21 00:58:03 +01:00
Stuart Turton a739794218 Merge commit '989672f8fb65b310f815d19667dd2e3dbdc92550'
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/RuleSet.java
	pmd/src/main/java/net/sourceforge/pmd/cpd/CPDCommandLineInterface.java
	pmd/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java
	pmd/src/test/java/net/sourceforge/pmd/LanguageVersionTest.java
2013-06-24 23:52:32 +01:00
Stuart Turton 3aa04a8860 PLSQL: Allow DEFINE SQL*Plus keyword to be used as a PL/SQL keyword 2013-06-17 19:31:14 +01:00
Stuart Turton 4781cdbcb5 Support ANSI DATE literals (DATE 'YYYY-MM-DD')
Allow TRIGGER REFERENCING clause to have ZERO subclauses.
2013-05-01 22:32:33 +01:00
Stuart Turton 391cf253ed PMD-PLSQL - correct AST for Named Global Block (Block Label(s) were checked for in LOOKAHEAD but not included in subsequent processing) 2013-03-24 21:05:25 +00:00
Stuart Turton 5b3b8df945 PMD-PLSQL - add plsql LanguageVersion tests 2013-03-24 21:03:44 +00:00
Stuart Turton cb5fea59ae Merge branch 'master' of git://github.com/pmd/pmd
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/cli/PMDParameters.java
2013-03-24 21:02:51 +00:00
Stuart Turton 782135b18a PMD-DB Add support for passing connection parameters via DBURI parameters and DBType properties with this priority (highest to lowest):-
explicit properties or explicit user and password
DBURI parameters
DBType properties

Update comments
2013-03-23 22:35:10 +00:00
Stuart Turton 584743234c PMD- DBURI changes - add getDataSourceName() to avoid calling getNiceFileName(….) with ignored parameters 2013-03-23 00:41:18 +00:00
Stuart Turton 5e1f79148f PMD-PLSQL: map TYPE and PACKAGE DBA_OBJECTS.OBJECT_TYPE values to DBMS_METADATA.GET_DDL TYPE_SPEC and PACKAGE_SPEC parameter values respectively - unchanged these values return both the specification and body objects. 2013-03-23 00:39:06 +00:00
Stuart Turton ace4fa4b46 PMD-PLSQL: comment out TooManyMethods because it throws a NULL pointer exception when used (works in PLSQLDesigner) 2013-03-23 00:35:48 +00:00
Stuart Turton 4034dbbe39 PMD - add helper method getURIDataSources to simplify use of DBURIs from maven-pmd-plugin 2013-03-21 19:45:45 +00:00
Stuart Turton 0d8b89aeeb CPD - refactor to simplify use of DBURIs from maven-pmd-plugin 2013-03-21 19:44:15 +00:00
Stuart Turton c58ad5603c PMD-DB - correct test defaults 2013-03-19 02:01:22 +00:00
Stuart Turton 42193382a1 Add some DBType property files used in tests 2013-03-19 01:25:09 +00:00
Stuart Turton a8cb39b313 Add BSD licensing boilerplate 2013-03-15 22:44:17 +00:00
Stuart Turton dfaca12bd3 PMD- add command line support for (database) URI source code location 2013-03-15 21:49:26 +00:00
Stuart Turton 9d302ed969 Merge branch 'master' of git://github.com/pmd/pmd
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/cpd/GUI.java
	pmd/src/main/java/net/sourceforge/pmd/cpd/LanguageFactory.java

Also:
Add ability to read source code via JDBC
net/sourceforge/pmd/util/database
CPD has been modified
2013-03-10 21:55:44 +00:00
Stuart Turton da68c9c6d3 Use Apache Commons IOUtils 2013-01-06 19:21:39 +00:00
Stuart Turton 9278e565aa Merge branch 'master' of git://github.com/pmd/pmd
Conflicts:
	pmd/src/test/java/net/sourceforge/pmd/ast/ParserCornersTest.java
2013-01-06 19:19:53 +00:00
Stuart Turton cfd4a980bd Set Image for BooleanLiteral and NullLiteral 2013-01-06 18:19:16 +00:00
Stuart Turton 718e918777 PLSQL: Alter Naming and Scope class changes to reflect adangel's refactoring 2013-01-06 16:18:13 +00:00
Stuart Turton b27d17f064 Support FORCE keyword in CREATE OR REPLACE TYPE (from PLDoc bug-fix) 2013-01-06 16:13:03 +00:00
Stuart Turton 78d5532b6f Merge branch 'master' of https://github.com/sturton/pmd into HEAD
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/NameOccurrence.java
2012-12-29 15:47:31 +00:00
Stuart Turton 509cc2a9ab Pre-Origin Pull commit to store CanonicalImage and dumpNodes changes to remove PLSQL Scope case-sensitivity 2012-12-29 15:43:21 +00:00
Stuart Turton 1c2fbb4c00 Merge branch 'adangel-master'
Conflicts:
	pmd/src/test/java/net/sourceforge/pmd/lang/plsql/dfa/StatementAndBraceFinderTest.java
2012-12-20 01:30:15 +00:00
Stuart Turton ec057aff19 PLSQL: sdd tests for code size rules; correct NcssObjectCountTule to ignore ProgramUnits not at the SchemaLevel 2012-12-20 01:18:59 +00:00
Stuart Turton 78a8735615 PLSQL: add tests for CASE statement 2012-12-16 17:53:39 +00:00
Stuart Turton 72dc749ef4 Ensure that tests can display standard output and error- use latest version of surefire plugin 2012-12-16 17:52:02 +00:00
Andreas Dangel f1ead3be52 pmd: make the java compiler happy by moving the string concatenation into a resource file 2012-12-14 15:40:25 +01:00
Andreas Dangel f88bcf144a pmd: plsql - added unit test for NPathComplexity and a initial PLSQL parser test 2012-12-13 18:22:43 +01:00
Andreas Dangel 2d5e59ba73 pmd: minor cleanups 2012-12-13 17:20:05 +01:00
Andreas Dangel cf1a1a2db9 pmd: adding license header to new files 2012-12-13 15:35:09 +01:00
Andreas Dangel 4fb3a50df2 pmd: refactored PLSQL integration
* Using now javacc during build time to regenerate most of the AST nodes
   and the parser
 * all AST nodes inherit now from the new class AbstractPLSQLNode. This
   class replaces the former SimpleNode. This class implements
   the interface PLSQLNode which inherits from PMD's Node.
 * Deleted all AST nodes that didn't have any modification after
   generating them.
 * PLSQL integration is now more like the Java integration
2012-12-13 15:24:18 +01:00
Andreas Dangel fa45557845 Merge remote-tracking branch 'pmd/master' into plsql 2012-12-12 19:23:37 +01:00
Stuart Turton 7a571b741e Amend StatementAndBraceFinder to add SWITCH_START for Searched CASE statement ; garden commented out code
Add more instrumentation into Linker
2012-12-11 23:39:24 +00:00
Stuart Turton 5d5b9e6a18 Correct control flow stack generation for ELSIF clause 2012-12-09 20:10:41 +00:00
Stuart Turton 873d9f6f83 PLSQL:codesize.xmlConvert Java examples to equivalent PLSQL examples; rewrite TooManyMethods Rule for PLSQL 2012-12-05 00:01:44 +00:00
Stuart Turton 4013461794 Avoid null pointer exception in PLSQLParser.canonicalName() 2012-12-04 23:58:15 +00:00
Stuart Turton 20bd584634 Add generic Oracle Object Length Rule - based on the OracleObject interface
Add PLSQL codesize ruleset file and example PLSQL  XPATH Rule (TomKytesDespair.xml)
2012-12-03 01:05:50 +00:00
Stuart Turton 17c9eadc61 Create OracleObject to flag AST that are (or for functions and procedures may be) schema-level items
Add  more statistical Rules (cribbed from Java Rules)
2012-12-03 00:05:02 +00:00
Stuart Turton 526b5610f0 Add unit tests for PLSQLParser and PLSQLStatementAndBraceFinder 2012-12-02 23:13:44 +00:00
Stuart Turton 374c734a98 Correct PLSQLDataNode to describe TypeMethod as a method
Remove System.err.println() from DFAPLSQLPanel
2012-12-02 21:53:55 +00:00
Stuart Turton d41ade9d10 Expose PLSQLParser.canonicalName() as helper method getCanonicalName() in SimpleNode
Correct logging message for StatementExpression equivalent inStatementAndBraceFinder
Correct off-by-one error when displaying code text )lines is zero-based so that it was displaying the next line- possibly what was intended)
Remove unused import from PLSQLDesigner (Interface ExecutableCode used instead)
2012-12-02 21:44:07 +00:00
Stuart Turton f5f4660b0a null pointer in Skip2NextTokenOccurrence 2012-11-30 19:14:14 +00:00
Stuart Turton 47ad0bbd7c PLSQL AST - Change StringBuffers to StringBuilders, parse Synonyms, Directories, Database Links, and the USING and RETURNING INTO clauses of embedded SQL.
Add a DDLCommand production, and add LOOKAHEAD to cope with otherwise unparsed  CREATE[ OR REPLACE] and  ALTER  statements.
2012-11-30 00:00:06 +00:00
Stuart Turton ef23c93398 Minor refactoring of NodeType and class which reference it StackObject, SequenceChecker, Linker etc.
The aspiration in  NodeType was to convert it to an enumeration: this refactoring moves AbstractDataFlowNode.stringFromType to make the class a bit more enum like and to make it publicly available for use in debugging other languages.
2012-11-29 23:47:10 +00:00
Stuart Turton 4a49e67caa Remove unused fields from TooManyFieldsRule 2012-11-29 23:05:51 +00:00
Stuart Turton 4f50ec7bc7 PLSQL - Correct DataFlow Stack generation for ELSIF clause 2012-11-29 23:01:51 +00:00
Stuart Turton 21a1afb2df Use StringBuilder instead of StringBuffer; add LOOKAHEAD for all input; parse and ignore DDL commands/system changes not already parsed; add static parser method to return a canonical Oracle name from arbitrary input 2012-11-28 00:26:46 +00:00
Stuart Turton 28f5d5d1ed Overwrite PLSQLParser and TokenManager after incorrect merge/rebase 2012-11-24 23:02:07 +00:00
Stuart Turton aab003ea51 Add support for SYNONYM, DIRECTORY and DATABASE LINK 2012-11-24 22:41:09 +00:00
Stuart Turton 969b29c1c8 Correct comment 2012-11-24 20:18:04 +00:00
Stuart Turton d21fdaf31d Remove end of line characters from Special Token SINGLE_LINE_TOKEN in order to allow the Skip* productions to search for the EOL Special Token without missing. 2012-11-24 20:13:40 +00:00
Stuart Turton 86f37b529c PLSQL: Attempt to set Class equivalent (Oracle Object level) for AbstractPLSQLRule; override getViolationParameters to return actual calculated measure for ExcessiveLength and AbstractNcssCountRule PLSQL Rules. 2012-11-21 00:11:07 +00:00
Stuart Turton 0f6ace560b PLSQL: Non-commented Source Statement and Too Many Methods (Package Specification and Object Type Specification 2012-11-20 22:47:20 +00:00
Stuart Turton 2ab85d1c35 Merge commit 'b0c2721c22dd03fd4c4fb1579b75f3005afd229b' 2012-11-20 19:43:06 +00:00
Stuart Turton ab0c209e53 Make Cyclomatic Complexity and NPath Complexity function with schema-level functions and procedures, object type bodies and triggers 2012-11-20 19:41:13 +00:00
Stuart Turton bfe1932037 PLSQL AST grammar with draft BSD lichence 2012-11-20 19:38:21 +00:00
Stuart Turton 93f5e8b2b4 Add more logging to PLSQL rules; Add visit() method for ExecutableCode interface 2012-11-16 20:56:22 +00:00
Stuart Turton 77fa5b6d1d Merge commit '3545b58820289b9dff7d404fb24f400323dd8f1f' 2012-11-16 20:51:31 +00:00
Stuart Turton 85f865e5e7 Add some code size rules (taken directly) from the Java rules: object length, Cyclomatic Complexity and NPath Complexity 2012-11-16 20:50:27 +00:00
Stuart Turton d157f8f869 The generated PLSQLParser code sets the last token _AFTER_ closing the scope, so getLastToken
cannot be used to identify the last Token: use getToken(0) instead.
         <code>
	      jjtreeCloseNodeScope(jjtn000);
	      jjtn000.jjtSetLastToken(getToken(0));
         </code>
2012-11-16 20:37:30 +00:00
Stuart Turton 3fb8fc1642 MethodDeclaration - ensure that TypeMethod is processed when building Dataflows.
MethodDeclaration covers both ProgramUnit and TypeMethod - previous  processing seemed to ignore TypeMethod when building data flows in Type Bodies.
2012-11-12 00:32:47 +00:00
Stuart Turton 878596e15f Support DFA analysis of simple and compound PL/SQL Triggers 2012-11-11 23:08:52 +00:00
Stuart Turton 03af9d4760 Correct comment spelling 2012-11-11 23:07:12 +00:00
Stuart Turton 1491532ea2 Allow PLSQLDesigner to process multiple types - create minimal interface ExecutableCode and refactor the relevant AST classes, graph rule, panel and PLSQDesigner to manipulate ExecutableCode objects. 2012-11-11 23:06:00 +00:00
Stuart Turton 66deb16cb1 Correct treatment of Labelled Statements 2012-11-07 00:02:44 +00:00
Stuart Turton 84853e2099 PL/SQL CASE statements with added BREAKS 2012-11-04 23:38:05 +00:00
Stuart Turton f47e6b9813 IF, IF,ELSE, IF,ELSIF, IF,ELSIF,ELSE, WHILE, amd LOOP statements now return 2012-11-04 18:54:52 +00:00
Stuart Turton 06e0af2cfe Add logging message and add comment about SquenceChecker infinite loop control index 2012-11-03 17:02:49 +00:00
Stuart Turton 037eaf9d2b Remove generated java classes from src/main/java ; change StringBuffer to StringBuilder in Structure.java 2012-11-03 16:59:57 +00:00
Stuart Turton 8dbd3798f9 Merge branch 'master' of git://github.com/pmd/pmd
Conflicts:
	pmd/src/main/java/net/sourceforge/pmd/lang/ast/CharStream.java
	pmd/src/main/java/net/sourceforge/pmd/lang/ast/JavaCharStream.java
	pmd/src/main/java/net/sourceforge/pmd/lang/ast/SimpleCharStream.java
	pmd/src/main/java/net/sourceforge/pmd/lang/ast/TokenMgrError.java
	pmd/src/main/java/net/sourceforge/pmd/lang/cpp/ast/Token.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/JJTJavaParserState.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParser.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserTreeConstants.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaParserVisitor.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/ParseException.java
	pmd/src/main/java/net/sourceforge/pmd/lang/java/ast/Token.java
	pmd/src/main/java/net/sourceforge/pmd/lang/jsp/ast/JJTJspParserState.java
	pmd/src/main/java/net/sourceforge/pmd/lang/jsp/ast/JspParserTreeConstants.java
	pmd/src/main/java/net/sourceforge/pmd/lang/jsp/ast/JspParserVisitor.java
	pmd/src/main/java/net/sourceforge/pmd/lang/jsp/ast/ParseException.java
	pmd/src/main/java/net/sourceforge/pmd/lang/jsp/ast/Token.java
2012-11-02 23:55:26 +00:00
Stuart Turton f0eafc912b Instrument code to identify infinite loop she procession PLSQL IF/THEN/ELSE
Amend AST to make this easier
2012-11-02 01:11:02 +00:00
Stuart Turton 6de746a359 Bring PLSQL AST file up to current code level 2012-10-21 23:09:01 +01:00
Stuart Turton cfa1b0c574 Cope with Object Type Bodies (TypeMethods) when generating scope; commit outstanding PLSQL changes after recovery from filename case problems 2012-10-21 22:39:32 +01:00
Stuart Turton 342b0848d1 Commit outstanding changes after merge 2012-10-21 22:25:02 +01:00
Stuart Turton 6dd19418d8 Merge branch 'master' of https://github.com/sturton/pmd 2012-10-21 22:21:44 +01:00
Stuart Turton f8b1ee358e Correct the filename case of AST production classes within git again 2012-10-21 22:21:02 +01:00
Stuart Turton 6d4905335c Merge commit '3d2ff17d8345c442bd94236892e1750112cd48f0' 2012-10-21 22:13:22 +01:00
Stuart Turton 4677cf8634 Correct case of filenames in github project 2012-10-21 21:02:46 +01:00
Stuart Turton 65edfe5e2f Push outstanding PLSQL changes 2012-10-20 22:52:52 +01:00
Stuart Turton ca5a24edd5 ASTTypeMethod added for TYPE BODY methods scope tracking; DFA works for PACKAGE BODIES 2012-10-17 22:33:32 +01:00
Stuart Turton d4a211087f Remeove terminating semi-colon from Conditional Compilation statement; add terminating semi-colon to global Block(); correct pasring for WRAPPED objects; assign ConditionalOrExpression() to avoid null pointer exception 2012-10-17 19:05:11 +01:00
Stuart Turton fb74093d2a Merge commit 'd126d9b0b89229de905dcaf3926b1321127fde9f' 2012-10-10 23:37:00 +01:00
Stuart Turton 8c4fefe4a8 Amended PLSQL AST 2012-10-10 20:00:47 +01:00
Stuart Turton daf1f4c632 PLSQL AST now supports CONTINUE as an 11G CONTINUE statement and as a variable name; EXIT may be a variable name; LabelledStatement is now cleaned up 2012-10-10 19:59:02 +01:00
Stuart Turton a9507e0ccd PLSQL AST now copes with 11G CONTINUE statements; PMD rule works for simple PLSQL; DFA is not working; PMD symbol handling is very buggy 2012-10-10 19:33:16 +01:00
Stuart Turton 99c71ddcbd PLSQL AST now copes with 11G CONTINUE statements; PMD rule works for simple PLSQL; DFA is not working; PMD symbol handling is very buggy 2012-10-10 19:28:30 +01:00
Stuart Turton 3b8d09cdd7 PLSQL AST now copes with 11G CONTINUE statements; PMD rule works for simple PLSQL; DFA is not working; PMD symbol handling is very buggy 2012-10-10 19:25:51 +01:00
Stuart Turton bf5bb5e2bb PLSQLDesigner - remove System.err 2012-10-02 23:14:07 +01:00
Stuart Turton c482f7a81a PLSQL AST JJTree - return Types from productions are accurate rather than all being declared as SimpleNode - NODE_EXTENDS,TRACK_TOKENS and NODE_SCOPE_HOOK are specified so that beginLine,beginColumn,endLine,endColumn fields are set 2012-10-02 23:02:55 +01:00
Stuart Turton 10e1e8cdb3 get XPath window working 2012-10-02 19:07:39 +01:00
Stuart Turton 3c3f811dff PldocAST.jjt - setImage() for IDs and Names 2012-10-01 23:24:00 +01:00
Stuart Turton fe3f159255 Hack PLSQLParser.java to avoid Arguments null pointer exception 2012-10-01 19:40:47 +01:00
Stuart Turton 501a4754f7 DumpFacade added 2012-09-30 23:48:57 +01:00
Stuart Turton 4580690ca9 PLSQLDesigner - removed System.err tracking 2012-09-30 23:35:32 +01:00
Stuart Turton 56df618d60 DumpFacade implemented- AST panel populates 2012-09-30 23:08:51 +01:00
Stuart Turton f513a0cad0 Merge branch 'master' of https://github.com/sturton/pmd
Conflicts:
	pmd/etc/grammar/PldocAST.jjt
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLHandler.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLParser.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/ASTArguments.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/ASTName.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/ASTPrimaryPrefix.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/ASTPrimarySuffix.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/Node.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParserVisitor.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParserVisitorAdapter.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/ast/SimpleNode.java
	pmd/src/main/java/net/sourceforge/pmd/lang/plsql/rule/PLSQLRuleChainVisitor.java
2012-09-30 17:45:37 +01:00
Stuart Turton 66f31a2c9a PLSQL AST rewritten to be more PMD-like; Scope compiles; PLSQLDesigner work in progress 2012-09-30 15:36:53 +01:00
Stuart Turton d7037af36f JJTree production names changed to be consistent with Java AST 2012-09-24 20:55:29 +01:00
Stuart Turton ba84d1d9fa Visitor JJTree language file 2012-09-24 20:47:00 +01:00
Stuart Turton 6f84da00a2 Convert parser classes from the initial (CPD) version to separate AST* classes in order allow the Visitor pattern (as used in
PMD).

These classes work with CPD, but also form an initial basis for PLSQL integration with PMD.

Also viewer_properties has been copied under src/main/resources so that it is automatically included in the packaged JAR file.
2012-08-26 15:29:02 +01:00
Stuart Turton ec4d9f9af2 PLSQL AST - modify PldocAST.jjt to allow Visitor pattern and return a terminal object (ASTinput) 2012-08-25 23:34:49 +01:00
Stuart Turton f7cdadc3a9 Revert "PLSQL AST - modify PldocAST.jjt to allow Visitor pattern and return a terminal object (ASTinput)"
This reverts commit 2e4e6b2231.
2012-08-25 23:26:45 +01:00
Stuart Turton 2e4e6b2231 PLSQL AST - modify PldocAST.jjt to allow Visitor pattern and return a terminal object (ASTinput) 2012-08-25 23:03:10 +01:00
Stuart Turton 0019f52074 Add PLSQL AST grammar for integrating PL/SQL parser for use in CPD.
This is the minimal conversion of the PLDoc parser (pldoc.sourceforge.net). This version is not suitable for incorporation into the main PMD suite, simply because PldocAST.jjt  does not specify the Visitor pattern, which seems to be required for PMD integration.
2012-08-25 22:43:07 +01:00
Stuart Turton 7ac8edb6a1 Add tests for PLSQLTokenizer 2012-08-08 20:17:32 +01:00
Stuart Turton 1d2d04b3eb Incorporate PLDoc 1.3.3 changes - support "AT LOCAL" and "AT TIME ZONE (DBTIMEZONE|SESSIONTIMEZONE|literal|expression)" time zone clauses 2012-08-05 23:03:09 +01:00
Stuart Turton 1cdbc0ca0a PMD-3546925 - Add PLSQL Language for PMD and CPD (extracted from PLDoc 1.3.2) 2012-07-23 21:11:10 +01:00
2118 changed files with 57704 additions and 151986 deletions

No files matched your search

@@ -1,41 +0,0 @@
package net.sourceforge.pmd.util.viewer;
import net.sourceforge.pmd.util.viewer.gui.MainFrame;
/**
* viewer's starter
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class Viewer {
/**
* starts the viewer
*
* @param args arguments
*/
public static void main(String[] args) {
new MainFrame();
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:41 tomcopeland
* Initial revision
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,147 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.ast.Node;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.viewer.gui.menu.ASTNodePopupMenu;
import net.sourceforge.pmd.util.viewer.model.ASTModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.LinkedList;
/**
* tree panel GUI
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ASTPanel
extends JPanel
implements ViewerModelListener, TreeSelectionListener {
private ViewerModel model;
private JTree tree;
/**
* constructs the panel
*
* @param model model to attach the panel to
*/
public ASTPanel(ViewerModel model) {
this.model = model;
init();
}
private void init() {
model.addViewerModelListener(this);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE")));
setLayout(new BorderLayout());
tree = new JTree((TreeNode) null);
tree.addTreeSelectionListener(this);
tree.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath path =
tree.getClosestPathForLocation(e.getX(), e.getY());
tree.setSelectionPath(path);
JPopupMenu menu =
new ASTNodePopupMenu(model, (SimpleNode) path.getLastPathComponent());
menu.show(tree, e.getX(), e.getY());
}
}
});
add(new JScrollPane(tree), BorderLayout.CENTER);
}
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
public void viewerModelChanged(ViewerModelEvent e) {
switch (e.getReason()) {
case ViewerModelEvent.CODE_RECOMPILED:
tree.setModel(new ASTModel(model.getRootNode()));
break;
case ViewerModelEvent.NODE_SELECTED:
if (e.getSource() != this) {
LinkedList list = new LinkedList();
for (
Node node = (Node) e.getParameter(); node != null;
node = node.jjtGetParent())
list.addFirst(node);
TreePath path = new TreePath(list.toArray());
tree.setSelectionPath(path);
tree.scrollPathToVisible(path);
}
break;
}
}
/**
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
*/
public void valueChanged(TreeSelectionEvent e) {
model.selectNode((SimpleNode) e.getNewLeadSelectionPath().getLastPathComponent(), this);
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.5 2005/02/16 15:46:05 mikkey
* javadoc fixes
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.3 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.2 2003/09/23 07:52:16 bgr
* menus added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,35 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
/**
* contains action command constants
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public interface ActionCommands {
String COMPILE_ACTION = "Compile";
String EVALUATE_ACTION = "Evaluate";
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.3 2004/12/22 20:52:12 tomcopeland
* Fixing some stuff PMD found
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,105 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout;
import java.util.Vector;
/**
* A panel showing XPath expression evaluation results
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class EvaluationResultsPanel
extends JPanel
implements ViewerModelListener {
private ViewerModel model;
private JList list;
/**
* constructs the panel
*
* @param model model to refer to
*/
public EvaluationResultsPanel(ViewerModel model) {
super(new BorderLayout());
this.model = model;
init();
}
private void init() {
model.addViewerModelListener(this);
list = new JList();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (list.getSelectedValue() != null) {
model.selectNode((SimpleNode) list.getSelectedValue(), EvaluationResultsPanel.this);
}
}
});
add(new JScrollPane(list), BorderLayout.CENTER);
}
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
public void viewerModelChanged(ViewerModelEvent e) {
switch (e.getReason()) {
case ViewerModelEvent.PATH_EXPRESSION_EVALUATED:
if (e.getSource() != this) {
list.setListData(new Vector(model.getLastEvaluationResults()));
}
break;
case ViewerModelEvent.CODE_RECOMPILED:
list.setListData(new Vector(0));
break;
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.5 2005/02/16 15:46:34 mikkey
* javadoc fixes
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
*/
@@ -1,172 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.ast.ParseException;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* viewer's main frame
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class MainFrame
extends JFrame
implements ActionListener, ActionCommands, ViewerModelListener {
private ViewerModel model;
private SourceCodePanel sourcePanel;
private ASTPanel astPanel;
private XPathPanel xPathPanel;
private JButton compileBtn;
private JButton evalBtn;
private JLabel statusLbl;
/**
* constructs and shows the frame
*/
public MainFrame() {
super(NLS.nls("MAIN.FRAME.TITLE"));
init();
}
private void init() {
model = new ViewerModel();
model.addViewerModelListener(this);
sourcePanel = new SourceCodePanel(model);
astPanel = new ASTPanel(model);
xPathPanel = new XPathPanel(model);
getContentPane().setLayout(new BorderLayout());
JSplitPane editingPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sourcePanel, astPanel);
editingPane.setResizeWeight(0.5d);
JPanel interactionsPane = new JPanel(new BorderLayout());
interactionsPane.add(xPathPanel, BorderLayout.SOUTH);
interactionsPane.add(editingPane, BorderLayout.CENTER);
getContentPane().add(interactionsPane, BorderLayout.CENTER);
compileBtn = new JButton(NLS.nls("MAIN.FRAME.COMPILE_BUTTON.TITLE"));
compileBtn.setActionCommand(COMPILE_ACTION);
compileBtn.addActionListener(this);
evalBtn = new JButton(NLS.nls("MAIN.FRAME.EVALUATE_BUTTON.TITLE"));
evalBtn.setActionCommand(EVALUATE_ACTION);
evalBtn.addActionListener(this);
evalBtn.setEnabled(false);
statusLbl = new JLabel();
statusLbl.setHorizontalAlignment(SwingConstants.RIGHT);
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
btnPane.add(compileBtn);
btnPane.add(evalBtn);
btnPane.add(statusLbl);
getContentPane().add(btnPane, BorderLayout.SOUTH);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pack();
setSize(800, 600);
setVisible(true);
}
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
long t0, t1;
if (command.equals(COMPILE_ACTION)) {
try {
t0 = System.currentTimeMillis();
model.commitSource(sourcePanel.getSourceCode());
t1 = System.currentTimeMillis();
setStatus(NLS.nls("MAIN.FRAME.COMPILATION.TOOK")+ " "+(t1-t0)+" ms");
} catch (ParseException exc) {
setStatus(NLS.nls("MAIN.FRAME.COMPILATION.PROBLEM")+ " "+exc.toString());
new ParseExceptionHandler(this, exc);
}
} else if (command.equals(EVALUATE_ACTION)) {
try {
t0 = System.currentTimeMillis();
model.evaluateXPathExpression(xPathPanel.getXPathExpression(), this);
t1 = System.currentTimeMillis();
setStatus(NLS.nls("MAIN.FRAME.EVALUATION.TOOK")+ " "+(t1-t0)+" ms");
} catch (Exception exc) {
setStatus(NLS.nls("MAIN.FRAME.EVALUATION.PROBLEM")+ " "+exc.toString());
new ParseExceptionHandler(this, exc);
}
}
}
/**
* Sets the status bar message
* @param string the new status, the empty string will be set if the value is <code>null</code>
*/
private void setStatus(String string) {
if (string == null)
string = "";
statusLbl.setText(string);
}
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
public void viewerModelChanged(ViewerModelEvent e) {
evalBtn.setEnabled(model.hasCompiledTree());
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.6 2005/02/16 15:47:01 mikkey
* javadoc fixes
*
* Revision 1.5 2004/12/13 14:46:11 tomcopeland
* Applied, thanks Miguel!
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.2 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,112 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* handles parsing exceptions
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ParseExceptionHandler
extends JDialog
implements ActionListener {
private Exception exc;
private JTextArea errorArea;
private JButton okBtn;
/**
* creates the dialog
*
* @param parent dialog's parent
* @param exc exception to be handled
*/
public ParseExceptionHandler(JFrame parent, Exception exc) {
super(parent, NLS.nls("COMPILE_ERROR.DIALOG.TITLE"), true);
this.exc = exc;
init();
}
private void init() {
errorArea = new JTextArea();
errorArea.setEditable(false);
errorArea.setText(exc.getMessage() + "\n");
getContentPane().setLayout(new BorderLayout());
JPanel messagePanel = new JPanel(new BorderLayout());
messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
getContentPane().add(messagePanel, BorderLayout.CENTER);
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
okBtn.addActionListener(this);
btnPane.add(okBtn);
getRootPane().setDefaultButton(okBtn);
getContentPane().add(btnPane, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(getParent());
setVisible(true);
}
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == okBtn) {
dispose();
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.2 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,119 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import java.awt.BorderLayout;
import java.awt.Color;
/**
* source code panel
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class SourceCodePanel
extends JPanel
implements ViewerModelListener {
private ViewerModel model;
private JTextArea sourceCodeArea;
public SourceCodePanel(ViewerModel model) {
this.model = model;
init();
}
private void init() {
model.addViewerModelListener(this);
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("SOURCE.PANEL.TITLE")));
setLayout(new BorderLayout());
sourceCodeArea = new JTextArea();
add(new JScrollPane(sourceCodeArea), BorderLayout.CENTER);
}
/**
* retrieves the string representation of the source code
*
* @return source code's string representation
*/
public String getSourceCode() {
return sourceCodeArea.getText();
}
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
public void viewerModelChanged(ViewerModelEvent e) {
if (e.getReason() == ViewerModelEvent.NODE_SELECTED) {
final SimpleNode node = (SimpleNode) e.getParameter();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
sourceCodeArea.getHighlighter().removeAllHighlights();
if (node == null) {
return;
}
int startOffset =
(sourceCodeArea.getLineStartOffset(node.getBeginLine() - 1) +
node.getBeginColumn()) - 1;
int end =
(sourceCodeArea.getLineStartOffset(node.getEndLine() - 1) +
node.getEndColumn());
sourceCodeArea.getHighlighter().addHighlight(startOffset, end,
new DefaultHighlighter.DefaultHighlightPainter(new Color(79, 237, 111)));
sourceCodeArea.moveCaretPosition(startOffset);
} catch (BadLocationException exc) {
throw new IllegalStateException(exc.getMessage());
}
}
});
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.5 2005/02/16 15:47:27 mikkey
* javadoc fixes
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,115 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.model.ViewerModelEvent;
import net.sourceforge.pmd.util.viewer.model.ViewerModelListener;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import java.awt.Dimension;
/**
* Panel for the XPath entry and editing
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class XPathPanel
extends JTabbedPane
implements ViewerModelListener {
private ViewerModel model;
private JTextArea xPathArea;
/**
* Constructs the panel
*
* @param model model to refer to
*/
public XPathPanel(ViewerModel model) {
super(JTabbedPane.BOTTOM);
this.model = model;
init();
}
private void init() {
model.addViewerModelListener(this);
xPathArea = new JTextArea();
setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("XPATH.PANEL.TITLE")));
add(new JScrollPane(xPathArea), NLS.nls("XPATH.PANEL.EXPRESSION"));
add(new EvaluationResultsPanel(model), NLS.nls("XPATH.PANEL.RESULTS"));
setPreferredSize(new Dimension(-1, 200));
}
/**
* retrieves the XPath expression typed into the text area
*
* @return XPath expression
*/
public String getXPathExpression() {
return xPathArea.getText();
}
/**
* @see ViewerModelListener#viewerModelChanged(ViewerModelEvent)
*/
public void viewerModelChanged(ViewerModelEvent e) {
switch (e.getReason()) {
case ViewerModelEvent.PATH_EXPRESSION_APPENDED:
if (e.getSource() != this) {
xPathArea.append((String) e.getParameter());
}
setSelectedIndex(0);
break;
case ViewerModelEvent.CODE_RECOMPILED:
setSelectedIndex(0);
break;
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.5 2005/02/16 15:47:48 mikkey
* javadoc fixes
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.3 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.2 2003/09/23 07:52:16 bgr
* menus added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,63 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui.menu;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import javax.swing.*;
/**
* context sensetive menu for the AST Panel
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ASTNodePopupMenu
extends JPopupMenu {
private ViewerModel model;
private SimpleNode node;
public ASTNodePopupMenu(ViewerModel model, SimpleNode node) {
this.model = model;
this.node = node;
init();
}
private void init() {
add(new SimpleNodeSubMenu(model, node));
addSeparator();
add(new AttributesSubMenu(model, node));
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
* Initial revision
*
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.4 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.3 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.2 2003/09/23 20:34:33 tomcopeland
* Fixed some stuff PMD found
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/23 07:52:16 bgr
* menus added
*
*/
@@ -1,73 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui.menu;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.jaxen.Attribute;
import net.sourceforge.pmd.jaxen.AttributeAxisIterator;
import net.sourceforge.pmd.util.viewer.model.AttributeToolkit;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import java.text.MessageFormat;
/**
* contains menu items for the predicate creation
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class AttributesSubMenu
extends JMenu {
private ViewerModel model;
private SimpleNode node;
public AttributesSubMenu(ViewerModel model, SimpleNode node) {
super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), new Object[]{node.toString()}));
this.model = model;
this.node = node;
init();
}
private void init() {
AttributeAxisIterator i = new AttributeAxisIterator(node);
while (i.hasNext()) {
Attribute attribute = (Attribute) i.next();
add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model,
AttributeToolkit.constructPredicate(attribute)));
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
* Initial revision
*
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.4 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.3 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.2 2003/09/23 20:34:34 tomcopeland
* Fixed some stuff PMD found
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/23 07:52:16 bgr
* menus added
*
*/
@@ -1,76 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui.menu;
import net.sourceforge.pmd.ast.Node;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import net.sourceforge.pmd.util.viewer.util.NLS;
import javax.swing.*;
import java.text.MessageFormat;
/**
* submenu for the simple node itself
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class SimpleNodeSubMenu
extends JMenu {
private ViewerModel model;
private SimpleNode node;
/**
* constructs the submenu
*
* @param model model to which the actions will be forwarded
* @param node menu's owner
*/
public SimpleNodeSubMenu(ViewerModel model, SimpleNode node) {
super(MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), new Object[]{node.toString()}));
this.model = model;
this.node = node;
init();
}
private void init() {
StringBuffer buf = new StringBuffer(200);
for (Node temp = node; temp != null; temp = temp.jjtGetParent()) {
buf.insert(0, "/" + temp.toString());
}
add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ABSOLUTE_PATH"), model, buf.toString()));
add(new XPathFragmentAddingItem(NLS.nls("AST.MENU.NODE.ADD_ALLDESCENDANTS"), model,
"//" + node.toString()));
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:43 tomcopeland
* Initial revision
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/23 07:52:16 bgr
* menus added
*
*/
@@ -1,70 +0,0 @@
package net.sourceforge.pmd.util.viewer.gui.menu;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* adds the given path fragment to the XPath expression upon action
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class XPathFragmentAddingItem
extends JMenuItem
implements ActionListener {
private ViewerModel model;
private String fragment;
/**
* constructs the item
*
* @param caption menu item's caption
* @param model model to refer to
* @param fragment XPath expression fragment to be added upon action
*/
public XPathFragmentAddingItem(String caption, ViewerModel model, String fragment) {
super(caption);
this.model = model;
this.fragment = fragment;
addActionListener(this);
}
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
model.appendToXPathExpression(fragment, this);
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.4 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.3 2004/04/15 18:21:58 tomcopeland
* Cleaned up imports with new version of IDEA; fixed some deprecated Ant junx
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/23 07:52:16 bgr
* menus added
*
*/
@@ -1,125 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
import net.sourceforge.pmd.ast.SimpleNode;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import java.util.Vector;
/**
* Model for the AST Panel Tree component
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ASTModel
implements TreeModel {
private SimpleNode root;
private Vector listeners = new Vector(1);
/**
* creates the tree model
*
* @param root tree's root
*/
public ASTModel(SimpleNode root) {
this.root = root;
}
/**
* @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
*/
public Object getChild(Object parent, int index) {
return ((SimpleNode) parent).jjtGetChild(index);
}
/**
* @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
*/
public int getChildCount(Object parent) {
return ((SimpleNode) parent).jjtGetNumChildren();
}
/**
* @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,
* java.lang.Object)
*/
public int getIndexOfChild(Object parent, Object child) {
SimpleNode node = ((SimpleNode) parent);
for (int i = 0; i < node.jjtGetNumChildren(); i++)
if (node.jjtGetChild(i).equals(child)) {
return i;
}
return -1;
}
/**
* @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
*/
public boolean isLeaf(Object node) {
return ((SimpleNode) node).jjtGetNumChildren() == 0;
}
/**
* @see javax.swing.tree.TreeModel#getRoot()
*/
public Object getRoot() {
return root;
}
/**
* @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath,
* java.lang.Object)
*/
public void valueForPathChanged(TreePath path, Object newValue) {
throw new UnsupportedOperationException();
}
/**
* @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
*/
public void addTreeModelListener(TreeModelListener l) {
listeners.add(l);
}
/**
* @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
*/
public void removeTreeModelListener(TreeModelListener l) {
listeners.remove(l);
}
protected void fireTreeModelEvent(TreeModelEvent e) {
for (int i = 0; i < listeners.size(); i++) {
((TreeModelListener) listeners.elementAt(i)).treeNodesChanged(e);
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.3 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
*/
@@ -1,53 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
import net.sourceforge.pmd.jaxen.Attribute;
/**
* A toolkit for vaious attribute translations
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class AttributeToolkit {
/**
* formats a value for it's usage in XPath expressions
*
* @param attribute atribute which value should be formatted
* @return formmated value
*/
public static String formatValueForXPath(Attribute attribute) {
return "'" + attribute.getValue() + "'";
}
/**
* constructs a predicate from the given attribute
*
* @param attribute attribute to be formatted as predicate
* @return predicate
*/
public static String constructPredicate(Attribute attribute) {
return "[@" + attribute.getName() + "=" +
formatValueForXPath(attribute) + "]";
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/23 07:52:16 bgr
* menus added
*
*/
@@ -1,142 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
import net.sourceforge.pmd.ast.SimpleNode;
import javax.swing.tree.TreeNode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
/**
* provides the adapter for the tree model
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class SimpleNodeTreeNodeAdapter
implements TreeNode {
private SimpleNode node;
private List children;
private SimpleNodeTreeNodeAdapter parent;
/**
* constructs the node
*
* @param node underlying AST's node
*/
public SimpleNodeTreeNodeAdapter(SimpleNodeTreeNodeAdapter parent, SimpleNode node) {
this.parent = parent;
this.node = node;
}
/**
* retrieves the underlying node
*
* @return AST node
*/
public SimpleNode getSimpleNode() {
return node;
}
/**
* @see javax.swing.tree.TreeNode#getChildAt(int)
*/
public TreeNode getChildAt(int childIndex) {
checkChildren();
return (TreeNode) children.get(childIndex);
}
/**
* @see javax.swing.tree.TreeNode#getChildCount()
*/
public int getChildCount() {
checkChildren();
return children.size();
}
/**
* @see javax.swing.tree.TreeNode#getParent()
*/
public TreeNode getParent() {
return parent;
}
/**
* @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
*/
public int getIndex(TreeNode node) {
checkChildren();
return children.indexOf(node);
}
/**
* @see javax.swing.tree.TreeNode#getAllowsChildren()
*/
public boolean getAllowsChildren() {
return true;
}
/**
* @see javax.swing.tree.TreeNode#isLeaf()
*/
public boolean isLeaf() {
checkChildren();
return children.size() == 0;
}
/**
* @see javax.swing.tree.TreeNode#children()
*/
public Enumeration children() {
return Collections.enumeration(children);
}
/**
* checks the children and creates them if neccessary
*/
private void checkChildren() {
if (children == null) {
children = new ArrayList(node.jjtGetNumChildren());
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
children.add(new SimpleNodeTreeNodeAdapter(this, (SimpleNode) node.jjtGetChild(i)));
}
}
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return node.toString();
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:41 tomcopeland
* Initial revision
*
* Revision 1.3 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,180 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
import net.sourceforge.pmd.TargetJDK1_4;
import net.sourceforge.pmd.ast.ASTCompilationUnit;
import net.sourceforge.pmd.ast.ParseException;
import net.sourceforge.pmd.ast.SimpleNode;
import net.sourceforge.pmd.jaxen.DocumentNavigator;
import org.jaxen.BaseXPath;
import org.jaxen.JaxenException;
import org.jaxen.XPath;
import java.io.StringReader;
import java.util.List;
import java.util.Vector;
/**
* The model for the viewer gui
* <p/>
* <p/>
* This is the model part of MVC
* </p>
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ViewerModel {
private Vector listeners;
private SimpleNode rootNode;
private List evaluationResults;
/**
* constructs the model
*/
public ViewerModel() {
listeners = new Vector(5);
}
/**
* Retrieves AST's root node
*
* @return AST's root node
*/
public SimpleNode getRootNode() {
return rootNode;
}
/**
* commits source code to the model.
* <p/>
* <p/>
* all existing source will be replaced
* </p>
*
* @param source source to be commited
*/
public void commitSource(String source) {
ASTCompilationUnit compilationUnit = new TargetJDK1_4().createParser(new StringReader(source)).CompilationUnit();
rootNode = compilationUnit;
fireViewerModelEvent(new ViewerModelEvent(this, ViewerModelEvent.CODE_RECOMPILED));
}
/**
* determines wheteher the model has a compiled tree at it's disposal
*
* @return true if there is an AST, false otherwise
*/
public boolean hasCompiledTree() {
return rootNode != null;
}
/**
* evaluates the given XPath expression against the current tree
*
* @param xPath XPath expression to be evaluated
* @param evaluator object which requests the evaluation
*/
public void evaluateXPathExpression(String xPath, Object evaluator)
throws ParseException, JaxenException {
XPath xpath = new BaseXPath(xPath, new DocumentNavigator());
evaluationResults = xpath.selectNodes(rootNode);
fireViewerModelEvent(new ViewerModelEvent(evaluator, ViewerModelEvent.PATH_EXPRESSION_EVALUATED));
}
/**
* retrieves the results of last evaluation
*
* @return a list containing the nodes selected by the last XPath expression
* evaluation
*/
public List getLastEvaluationResults() {
return evaluationResults;
}
/**
* selects the given node in the AST
*
* @param node node to be selected
* @param selector object which requests the selection
*/
public void selectNode(SimpleNode node, Object selector) {
fireViewerModelEvent(new ViewerModelEvent(selector, ViewerModelEvent.NODE_SELECTED, node));
}
/**
* appends the given fragment to the XPath expression
*
* @param pathFragment fragment to be added
* @param appender object that is trying to append the fragment
*/
public void appendToXPathExpression(String pathFragment, Object appender) {
fireViewerModelEvent(new ViewerModelEvent(appender, ViewerModelEvent.PATH_EXPRESSION_APPENDED, pathFragment));
}
/**
* adds a listener to the model
*
* @param l listener to be added
*/
public void addViewerModelListener(ViewerModelListener l) {
listeners.add(l);
}
/**
* removes the lisetener from the model
*
* @param l listener to be removed
*/
public void removeViewerModelListener(ViewerModelListener l) {
listeners.remove(l);
}
/**
* notifes all listener of a change in the model
*
* @param e change's reason
*/
protected void fireViewerModelEvent(ViewerModelEvent e) {
for (int i = 0; i < listeners.size(); i++) {
((ViewerModelListener) listeners.elementAt(i)).viewerModelChanged(e);
}
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.5 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.4 2004/04/12 17:35:09 tomcopeland
* Cleaned up imports
*
* Revision 1.3 2004/04/12 17:23:29 tomcopeland
* Moving all explicit JavaParser creations over to a factory-ish sort of thing. This makes the version of the parser explicit rather than assumed.
*
* Revision 1.2 2003/09/23 20:51:06 tomcopeland
* Cleaned up imports
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.3 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.2 2003/09/23 07:52:16 bgr
* menus added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,112 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
/**
* The event which will be sent every time the model changes
* <p/>
* <p/>
* Note: the instances will be immutable
* </p>
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class ViewerModelEvent {
/**
* reason in the case of code recompilation
*/
public static final int CODE_RECOMPILED = 1;
/**
* reason in the case of node selection
*/
public static final int NODE_SELECTED = 2;
/**
* reason in the case of path extension
*/
public static final int PATH_EXPRESSION_APPENDED = 3;
/**
* reason in the case of path expression evaluation
*/
public static final int PATH_EXPRESSION_EVALUATED = 4;
private Object source;
private int reason;
private Object parameter;
/**
* Creates an event
*
* @param source event's source
* @param reason event's reason
*/
public ViewerModelEvent(Object source, int reason) {
this(source, reason, null);
}
/**
* Creates an event
*
* @param source event's source
* @param reason event's reason
* @param parameter parameter object
*/
public ViewerModelEvent(Object source, int reason, Object parameter) {
this.source = source;
this.reason = reason;
this.parameter = parameter;
}
/**
* retrieves the reason for event's occurance
*
* @return event's reason
*/
public int getReason() {
return reason;
}
/**
* retrieves the object which caused the event
*
* @return object that casused the event
*/
public Object getSource() {
return source;
}
/**
* retrieves event's parameter
*
* @return event's parameter
*/
public Object getParameter() {
return parameter;
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.3 2003/09/24 00:40:35 bgr
* evaluation results browsing added
*
* Revision 1.2 2003/09/23 07:52:16 bgr
* menus added
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,39 +0,0 @@
package net.sourceforge.pmd.util.viewer.model;
/**
* identiefie a listener of the ViewerModel
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public interface ViewerModelListener {
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
void viewerModelChanged(ViewerModelEvent e);
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.3 2004/12/22 20:52:12 tomcopeland
* Fixing some stuff PMD found
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
@@ -1,34 +0,0 @@
##########################################################################
# english string translations for the viewer
#
##########################################################################
# Main Frame
MAIN.FRAME.TITLE = AST Viewer
MAIN.FRAME.COMPILE_BUTTON.TITLE = Compile
MAIN.FRAME.EVALUATE_BUTTON.TITLE = Evaluate XPath Expression
MAIN.FRAME.COMPILATION.TOOK = Compilation took
MAIN.FRAME.COMPILATION.PROBLEM = Compilation problem:
MAIN.FRAME.EVALUATION.TOOK = Evaluation took
MAIN.FRAME.EVALUATION.PROBLEM = Evaluation problem:
# Source Panel
SOURCE.PANEL.TITLE = Source code
# Tree Panel
AST.PANEL.TITLE = Abstract Syntax Tree
AST.MENU.ATTRIBUTES = Add predicate from {0}'a attributes
AST.MENU.NODE.TITLE = Add {0} to the XPath expression
AST.MENU.NODE.ADD_ABSOLUTE_PATH = Add with absolute path
AST.MENU.NODE.ADD_ALLDESCENDANTS = Add all descentands of this type
# XPath Panel
XPATH.PANEL.TITLE = XPath
XPATH.PANEL.EXPRESSION = Expression
XPATH.PANEL.RESULTS = Results
# Compile Error dialog
COMPILE_ERROR.DIALOG.TITLE = Compilation error
COMPILE_ERROR.PANEL.TITLE = Error message
COMPILE_ERROR.OK_BUTTON.CAPTION = Ok
@@ -1,49 +0,0 @@
package net.sourceforge.pmd.util.viewer.util;
import java.util.ResourceBundle;
/**
* helps with internationalization
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
*/
public class NLS {
private final static ResourceBundle bundle;
static {
bundle =
ResourceBundle.getBundle("net.sourceforge.pmd.util.viewer.resources.viewer_strings");
}
/**
* translates the given key to the message
*
* @param key key to be translated
* @return translated string
*/
public static String nls(String key) {
return bundle.getString(key);
}
}
/*
* $Log$
* Revision 1.1 2005/08/15 19:51:42 tomcopeland
* Initial revision
*
* Revision 1.2 2004/09/27 19:42:52 tomcopeland
* A ridiculously large checkin, but it's all just code reformatting. Nothing to see here...
*
* Revision 1.1 2003/09/23 20:32:42 tomcopeland
* Added Boris Gruschko's new AST/XPath viewer
*
* Revision 1.1 2003/09/24 01:33:03 bgr
* moved to a new package
*
* Revision 1.1 2003/09/22 05:21:54 bgr
* initial commit
*
*/
-89
View File
@@ -1,89 +0,0 @@
<project name="pmd-jbuilder" default="compile" basedir="../">
<property name="dir.lib" value="lib\"/>
<property name="dir.src" value="src\"/>
<property name="dir.build" value="build\"/>
<property name="version" value="1.0"/>
<property name="pmd.version" value="3.3"/>
<path id="dependencies.path">
<pathelement location="${dir.build}"/>
<fileset dir="${dir.lib}">
<include name="*.jar"/>
</fileset>
</path>
<target name="delete">
<delete dir="${dir.build}"/>
<delete file="${dir.lib}\PMDExtension.jar"/>
<mkdir dir="${dir.build}"/>
</target>
<target name="compile" description="Compiles the code">
<mkdir dir="${dir.build}"/>
<javac deprecation="false"
debug="true"
optimize="false"
srcdir="${dir.src}"
destdir="${dir.build}">
<classpath>
<path refid="dependencies.path"/>
</classpath>
</javac>
</target>
<target name="clean" depends="delete,compile" description="Does a complete recompile"/>
<target name="jar" depends="clean" description="Jars up the classes and rulesets">
<jar
jarfile="${dir.lib}\PMDExtension.jar"
includes="net/sourceforge/pmd/bluej/*.class"
basedir="${dir.build}">
<manifest>
<attribute name="Main-Class" value="net.sourceforge.pmd.bluej.PMDExtension"/>
<attribute name="Class-Path" value="pmd/pmd-${pmd.version}.jar pmd/jaxen-1.1-beta-7.jar"/>
</manifest>
</jar>
</target>
<target name="mergejars" depends="jar" description="Creates one uber-jar for easier deployment">
<unjar src="${dir.lib}/jaxen-1.1-beta-7.jar" dest="lib" overwrite="true"/>
<unjar src="${dir.lib}/pmd-${pmd.version}.jar" dest="lib" overwrite="true"/>
<unjar src="${dir.lib}/PMDExtension.jar" dest="lib" overwrite="true"/>
<delete file="${dir.lib}\PMDExtension.jar"/>
<jar
jarfile="${dir.lib}\PMDExtension.jar"
includes="net/**/*.*,org/**/*.*,META-INF/**/*.*,rulesets/**/*.*,"
basedir="${dir.lib}">
<manifest>
<attribute name="Main-Class" value="net.sourceforge.pmd.bluej.PMDExtension"/>
</manifest>
</jar>
<delete dir="${dir.lib}/net"/>
<delete dir="${dir.lib}/rulesets"/>
<delete dir="${dir.lib}/org"/>
<delete dir="${dir.lib}/test"/>
<delete dir="${dir.lib}/META-INF"/>
</target>
<target name="deploy" depends="mergejars" description="Deploys new jar file to my BlueJ install">
<copy todir="/home/tom/pmd/ides/bluej/lib/extensions">
<fileset dir="${dir.lib}">
<include name="PMDExtension.jar"/>
</fileset>
</copy>
</target>
<target name="deploysfserver" depends="mergejars" description="Deploys new jar file to my BlueJ install">
<echo message="Uploading jar file to SourceForge"/>
<exec executable="scp" os="Linux">
<arg line=" /home/tom/pmd/pmd-bluej/lib/PMDExtension.jar tomcopeland@pmd.sf.net:/home/groups/p/pm/pmd/htdocs/"/>
</exec>
<echo message="Uploading extensions.xml to SourceForge"/>
<exec executable="scp" os="Linux">
<arg line=" /home/tom/pmd/pmd-bluej/bin/extensions.xml tomcopeland@pmd.sf.net:/home/groups/p/pm/pmd/htdocs/"/>
</exec>
</target>
</project>
-2
View File
@@ -1,2 +0,0 @@
November 10, 2005 - 1.0:
Initial functionality - basic/unusedcode rules only, JDK 1.4 only, report is displayed in wonky JOptionPane.
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
ant deploy && ~/pmd/ides/bluej/bluej
-11
View File
@@ -1,11 +0,0 @@
Change the version number in PMDExtension.java
Check everything in
ant mergejars
ncftpput upload.sourceforge.net incoming/ ../PMDExtension.jar
Create release on SF
Post news item on SF
Post note to bluej-discuss
-11
View File
@@ -1,11 +0,0 @@
<?xml version = '1.0'?>
<extensions-list>
<extension>
<name>PMD</name>
<class>net.sourceforge.pmd.bluej.PMDExtension</class>
<version>1.0</version>
<size>924246</size>
<jarUrl>PMDExtension.jar</jarUrl>
<description>PMD extension - finds unused code, empty blocks, and more!</description>
</extension>
</extensions-list>
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,91 +0,0 @@
package net.sourceforge.pmd.bluej;
import bluej.extensions.BClass;
import bluej.extensions.MenuGenerator;
import bluej.extensions.BlueJ;
import bluej.extensions.editor.TextLocation;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.RuleSet;
import net.sourceforge.pmd.RuleSetFactory;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.TargetJDK1_4;
import net.sourceforge.pmd.RuleSetNotFoundException;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.Frame;
import java.io.StringReader;
import java.util.Iterator;
public class MenuBuilder extends MenuGenerator {
private BClass curClass;
private Frame frame;
private RuleSet ruleSet = new RuleSet();
public MenuBuilder(Frame frame) {
this.frame = frame;
try {
RuleSetFactory rsf = new RuleSetFactory();
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/basic.xml"));
ruleSet.addRuleSet(rsf.createRuleSet("rulesets/unusedcode.xml"));
} catch (RuleSetNotFoundException rsnfe) {
System.out.println("Hm, PMD couldn't find its rules");
rsnfe.printStackTrace();
}
}
public JMenuItem getClassMenuItem(BClass aClass) {
JMenu jm = new JMenu("PMD");
jm.add(new JMenuItem(new SimpleAction("Check code")));
return jm;
}
public void notifyPostClassMenu(BClass bc, JMenuItem jmi) {
curClass = bc;
}
// The nested class that instantiates the different (simple) menus.
class SimpleAction extends AbstractAction {
public SimpleAction(String menuName) {
putValue(AbstractAction.NAME, menuName);
}
public void actionPerformed(ActionEvent anEvent) {
try {
int textLen = curClass.getEditor().getTextLength();
TextLocation lastLine = curClass.getEditor().getTextLocationFromOffset(textLen);
String code = curClass.getEditor().getText(new TextLocation(0,0), lastLine);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(curClass.getJavaClass().getName());
StringReader reader = new StringReader(code);
new PMD(new TargetJDK1_4()).processFile(reader, ruleSet, ctx);
StringBuffer msg = new StringBuffer("");
if (ctx.getReport().size() == 0) {
msg.append("No problems found!");
} else {
if (ctx.getReport().size() == 1) {
msg.append(" " + ctx.getReport().size() + " problem found");
} else {
msg.append(" " + ctx.getReport().size() + " problems found");
}
msg.append(System.getProperty("line.separator"));
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
RuleViolation rv = (RuleViolation)i.next();
msg.append("Line " + rv.getNode().getBeginLine() + ": " + rv.getDescription());
msg.append(System.getProperty("line.separator"));
}
}
JOptionPane.showMessageDialog(frame, msg);
} catch (Exception exc) {
exc.printStackTrace();
JOptionPane.showMessageDialog(frame, "Couldn't run PMD: " + exc.getMessage());
}
}
}
}
@@ -1,45 +0,0 @@
package net.sourceforge.pmd.bluej;
import bluej.extensions.BlueJ;
import bluej.extensions.Extension;
import java.net.URL;
public class PMDExtension extends Extension {
public void startup (BlueJ bluej) {
bluej.setMenuGenerator(new MenuBuilder(bluej.getCurrentFrame()));
/*
Preferences myPreferences = new Preferences(bluej);
bluej.setPreferenceGenerator(myPreferences);
*/
}
public boolean isCompatible () {
return true;
}
public String getVersion () {
return ("1.0");
}
public String getName () {
return ("PMD");
}
public String getDescription () {
return "PMD extension - finds unused code, empty blocks, and more!";
}
public URL getURL () {
try {
return new URL("http://pmd.sf.net/");
} catch ( Exception e ) {
System.out.println ("Can't get PMD extension URL: "+e.getMessage());
return null;
}
}
}
Loaded 30 of 2118 files, more files were not shown because too many files have changed in this diff. Show more