From 591cfc0a51febd8aa9869277f5c16914798c97e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Tue, 17 Sep 2019 04:24:30 +0200 Subject: [PATCH] Remove old test --- .../net/sourceforge/pmd/lang/ast/Node.java | 1 + .../pmd/lang/scala/ast/ScalaNode.java | 3 +- .../pmd/lang/scala/ast/ScalaParserTest.java | 51 ------------------- 3 files changed, 3 insertions(+), 52 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java index dfac6c1d07..67e610bbb3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java @@ -115,6 +115,7 @@ public interface Node { int getEndLine(); + // FIXME should not be inclusive int getEndColumn(); DataFlowNode getDataFlowNode(); diff --git a/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/ast/ScalaNode.java b/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/ast/ScalaNode.java index 278e11d5a3..3a3405d3de 100644 --- a/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/ast/ScalaNode.java +++ b/pmd-scala/src/main/java/net/sourceforge/pmd/lang/scala/ast/ScalaNode.java @@ -44,7 +44,8 @@ public interface ScalaNode extends Node { * Returns true if the node is implicit. If this node has no non-implicit * descendant, then its text bounds identify an empty region of the source * document. In that case, the {@linkplain #getEndColumn() end column} is - * smaller than the {@linkplain #getBeginColumn() begin column}. + * smaller than the {@linkplain #getBeginColumn() begin column}. That's + * because the end column is inclusive. */ // TODO this would be useful on the node interface for 7.0.0. // we could filter them out from violations transparently diff --git a/pmd-scala/src/test/java/net/sourceforge/pmd/lang/scala/ast/ScalaParserTest.java b/pmd-scala/src/test/java/net/sourceforge/pmd/lang/scala/ast/ScalaParserTest.java index 1d530f9919..ec262aec16 100644 --- a/pmd-scala/src/test/java/net/sourceforge/pmd/lang/scala/ast/ScalaParserTest.java +++ b/pmd-scala/src/test/java/net/sourceforge/pmd/lang/scala/ast/ScalaParserTest.java @@ -5,8 +5,6 @@ package net.sourceforge.pmd.lang.scala.ast; import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.io.IOUtils; @@ -17,59 +15,10 @@ import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersionHandler; import net.sourceforge.pmd.lang.Parser; import net.sourceforge.pmd.lang.scala.ScalaLanguageModule; -import net.sourceforge.pmd.lang.scala.ast.ScalaNode; -import net.sourceforge.pmd.lang.scala.ast.ScalaParserVisitorAdapter; public class ScalaParserTest { private static final String SCALA_TEST = "/parserFiles/helloworld.scala"; - @Test - public void testLineNumbersAccuracy() throws Exception { - LanguageVersionHandler scalaVersionHandler = LanguageRegistry.getLanguage(ScalaLanguageModule.NAME) - .getDefaultVersion().getLanguageVersionHandler(); - Parser parser = scalaVersionHandler.getParser(scalaVersionHandler.getDefaultParserOptions()); - ScalaNode root = (ScalaNode) parser.parse(null, - new StringReader(IOUtils.toString(getClass().getResourceAsStream(SCALA_TEST), "UTF-8"))); - - final List nodeLineTargets = new ArrayList(); - nodeLineTargets.add(new NodeLineMatcher("TermName", "Main", 1)); - nodeLineTargets.add(new NodeLineMatcher("TypeName", "App", 1)); - nodeLineTargets.add(new NodeLineMatcher("TermName", "println", 2)); - - ScalaParserVisitorAdapter visitor = new ScalaParserVisitorAdapter() { - public Void visit(ScalaNode node, Void data) { - for (NodeLineMatcher nodeLine : nodeLineTargets) { - if (nodeLine.nodeName.equals(node.getXPathNodeName()) && nodeLine.nodeValue.equals(node.getImage()) - && nodeLine.lineNumber == node.getBeginLine()) { - nodeLine.matched = true; - } - } - return super.visit(node, data); - } - }; - visitor.visit(root, null); - - for (NodeLineMatcher nodeLine : nodeLineTargets) { - Assert.assertTrue("Did not successfully find the node " + nodeLine, nodeLine.matched); - } - } - - class NodeLineMatcher { - String nodeName; - String nodeValue; - Integer lineNumber; - boolean matched = false; - - NodeLineMatcher(String nodeName, String nodeValue, Integer lineNumber) { - this.nodeName = nodeName; - this.nodeValue = nodeValue; - this.lineNumber = lineNumber; - } - - public String toString() { - return "NodeName: " + nodeName + " NodeValue: " + nodeValue + " Line Number: " + lineNumber; - } - } @Test public void testCountNodes() throws Exception {