diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/AntlrToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/AntlrToken.java index 05c38caaff..0a36e9419a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/AntlrToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/AntlrToken.java @@ -132,6 +132,7 @@ public class AntlrToken implements GenericToken { } } + @Override public int getKind() { return token.getType(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java index 18798da868..479fa67a81 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java @@ -51,4 +51,11 @@ public interface GenericToken { * @return a non-negative integer containing the begin column */ int getEndColumn(); + + /** + * Gets a unique integer representing the kind of token this is. + * + * The semantics of this kind depend on the language. + */ + int getKind(); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilterTest.java index 2478e0c913..3f5d8a7750 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilterTest.java @@ -63,6 +63,11 @@ public class BaseTokenFilterTest { public int getEndColumn() { return 0; } + + @Override + public int getKind() { + return 0; + } } class StringTokenManager implements TokenManager { diff --git a/pmd-cpp/src/main/ant/alljavacc.xml b/pmd-cpp/src/main/ant/alljavacc.xml index 800af4264b..aa41ee0817 100644 --- a/pmd-cpp/src/main/ant/alljavacc.xml +++ b/pmd-cpp/src/main/ant/alljavacc.xml @@ -88,6 +88,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-java/src/main/ant/alljavacc.xml b/pmd-java/src/main/ant/alljavacc.xml index d2c6296b63..ee9bcfe7b8 100644 --- a/pmd-java/src/main/ant/alljavacc.xml +++ b/pmd-java/src/main/ant/alljavacc.xml @@ -130,6 +130,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-javascript/src/main/ant/alljavacc.xml b/pmd-javascript/src/main/ant/alljavacc.xml index 405026b5cd..43c075273e 100644 --- a/pmd-javascript/src/main/ant/alljavacc.xml +++ b/pmd-javascript/src/main/ant/alljavacc.xml @@ -88,6 +88,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-jsp/src/main/ant/alljavacc.xml b/pmd-jsp/src/main/ant/alljavacc.xml index 80c1b43001..367e3e14cc 100644 --- a/pmd-jsp/src/main/ant/alljavacc.xml +++ b/pmd-jsp/src/main/ant/alljavacc.xml @@ -108,6 +108,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-matlab/src/main/ant/alljavacc.xml b/pmd-matlab/src/main/ant/alljavacc.xml index 646b4740f1..a6295481be 100644 --- a/pmd-matlab/src/main/ant/alljavacc.xml +++ b/pmd-matlab/src/main/ant/alljavacc.xml @@ -88,6 +88,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-modelica/src/main/ant/alljavacc.xml b/pmd-modelica/src/main/ant/alljavacc.xml index 0b6c12a533..06e0de1824 100644 --- a/pmd-modelica/src/main/ant/alljavacc.xml +++ b/pmd-modelica/src/main/ant/alljavacc.xml @@ -120,6 +120,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-objectivec/src/main/ant/alljavacc.xml b/pmd-objectivec/src/main/ant/alljavacc.xml index 16a4dd9e84..27f2b9e62b 100644 --- a/pmd-objectivec/src/main/ant/alljavacc.xml +++ b/pmd-objectivec/src/main/ant/alljavacc.xml @@ -88,6 +88,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-plsql/src/main/ant/alljavacc.xml b/pmd-plsql/src/main/ant/alljavacc.xml index 5d0e23135a..d0752af8bf 100644 --- a/pmd-plsql/src/main/ant/alljavacc.xml +++ b/pmd-plsql/src/main/ant/alljavacc.xml @@ -141,6 +141,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-python/src/main/ant/alljavacc.xml b/pmd-python/src/main/ant/alljavacc.xml index 1996f86bf1..e62797eed7 100644 --- a/pmd-python/src/main/ant/alljavacc.xml +++ b/pmd-python/src/main/ant/alljavacc.xml @@ -88,6 +88,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/cpd/ScalaTokenAdapter.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/cpd/ScalaTokenAdapter.java index c4842eccf9..5904cea775 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/cpd/ScalaTokenAdapter.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/cpd/ScalaTokenAdapter.java @@ -56,6 +56,11 @@ public class ScalaTokenAdapter implements GenericToken { return token.pos().endColumn() + 1; } + @Override + public int getKind() { + throw new UnsupportedOperationException(); + } + @Override public String toString() { return "ScalaTokenAdapter{" diff --git a/pmd-visualforce/src/main/ant/alljavacc.xml b/pmd-visualforce/src/main/ant/alljavacc.xml index fff5966898..b8b6b922c9 100644 --- a/pmd-visualforce/src/main/ant/alljavacc.xml +++ b/pmd-visualforce/src/main/ant/alljavacc.xml @@ -108,6 +108,11 @@ public class Token implements GenericToken, java.io.Serializable]]> diff --git a/pmd-vm/src/main/ant/alljavacc.xml b/pmd-vm/src/main/ant/alljavacc.xml index 5be48f1bc5..4650be5669 100644 --- a/pmd-vm/src/main/ant/alljavacc.xml +++ b/pmd-vm/src/main/ant/alljavacc.xml @@ -121,6 +121,11 @@ public class Token implements GenericToken, java.io.Serializable]]>