Skip to content

Commit

Permalink
fix wrong location of symbol static method
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfaller committed Apr 8, 2019
1 parent 3ad766d commit 1794461
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public final class TreeIoUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.List;
import java.util.Map.Entry;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import static org.junit.Assert.*;

public class TestMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.github.gumtreediff.io.TreeIoUtils;
import com.github.gumtreediff.tree.ITree;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import com.github.gumtreediff.tree.Symbol;
import com.github.gumtreediff.tree.TreeContext;
import org.junit.Test;
Expand All @@ -31,7 +32,6 @@

import java.io.ByteArrayOutputStream;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static org.junit.Assert.*;

public class TestTreeIoUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

package com.github.gumtreediff.gen.antlr3.json;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import static org.junit.Assert.*;

import java.io.InputStreamReader;

import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.Symbol;
import com.github.gumtreediff.tree.TreeContext;
Expand All @@ -36,8 +34,8 @@ public class TestJsonParsing {

@Test
public void testJsonParsing() throws Exception {
TreeContext tc = new AntlrJsonTreeGenerator().generateFrom().charset("UTF-8").
stream(getClass().getResourceAsStream("/sample.json"));
TreeContext tc = new AntlrJsonTreeGenerator().generateFrom().charset("UTF-8")
.stream(getClass().getResourceAsStream("/sample.json"));
ITree tree = tc.getRoot();

assertEquals(ARRAY, tree.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import static org.junit.Assert.*;

@RunWith(Parameterized.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.io.IOException;
import java.io.Reader;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

@Register(id = "xml-antlr", accept = {"\\.xml$", "\\.xsd$", "\\.wadl$"})
public class XmlTreeGenerator extends AbstractAntlr3TreeGenerator<XMLLexer, XMLParser> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.github.gumtreediff.gen.SyntaxException;
import com.github.gumtreediff.tree.Symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.CommonTree;

Expand Down Expand Up @@ -91,7 +92,7 @@ protected Symbol getTokenName(int tokenType) {
String[] names = getTokenNames();
if (tokenType < 0 || tokenType >= names.length)
return Symbol.NO_SYMBOL;
return Symbol.symbol(names[tokenType]);
return symbol(names[tokenType]);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public abstract class AbstractAntlr4TreeGenerator extends TreeGenerator {

Expand Down Expand Up @@ -74,14 +74,14 @@ protected Symbol getTokenName(int tokenType) {
String[] names = getTokenNames();
if (tokenType < 0 || tokenType >= names.length)
return Symbol.NO_SYMBOL;
return Symbol.symbol(names[tokenType]);
return symbol(names[tokenType]);
}

protected Symbol getRuleName(int ruleType) {
String[] names = getRuleNames();
if (ruleType < 0 || ruleType >= names.length)
return Symbol.NO_SYMBOL;
return Symbol.symbol(names[ruleType]);
return symbol(names[ruleType]);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.github.gumtreediff.io.LineReader;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.Symbol;
import com.github.gumtreediff.tree.SymbolSet;
import com.github.gumtreediff.tree.TreeContext;
import com.helger.css.CSSSourceLocation;
import com.helger.css.ICSSSourceLocationAware;
Expand Down Expand Up @@ -72,7 +73,7 @@ private void setLocation(ITree t, ICSSSourceLocationAware a) {
}

private Symbol symbol(ICSSSourceLocationAware a) {
return Symbol.symbol(a.getClass().getName());
return SymbolSet.symbol(a.getClass().getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.github.gumtreediff.io.LineReader;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.Symbol;
import com.github.gumtreediff.tree.SymbolSet;
import com.github.gumtreediff.tree.TreeContext;
import com.github.javaparser.Position;
import com.github.javaparser.ast.Node;
Expand Down Expand Up @@ -86,7 +87,7 @@ protected void pushNode(Node n, String label) {
}

protected Symbol nodeAsSymbol(Node n) {
return Symbol.symbol(n.getClass().getSimpleName());
return SymbolSet.symbol(n.getClass().getSimpleName());
}

private void push(Symbol type, String label, int startPosition, int length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package com.github.gumtreediff.gen.javaparser;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import static org.junit.Assert.assertEquals;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public abstract class AbstractJdtVisitor extends ASTVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.dom.*;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public class JdtVisitor extends AbstractJdtVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public class RhinoTreeVisitor implements NodeVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void testComment() throws IOException {

@Test
public void testComplexFile() throws IOException {
ITree tree = new RhinoTreeGenerator().generateFrom().charset("UTF-8").
stream(getClass().getResourceAsStream("/sample.js")).getRoot();
ITree tree = new RhinoTreeGenerator().generateFrom().charset("UTF-8")
.stream(getClass().getResourceAsStream("/sample.js")).getRoot();
assertEquals(402, tree.getSize());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.io.*;
import java.util.*;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

@Register(id = "python-pythonparser", accept = {"\\.py$"}, priority = Registry.Priority.MAXIMUM)
public class PythonTreeGenerator extends ExternalProcessTreeGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.io.IOException;
import java.io.Reader;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

@Register(id = "ruby-jruby", accept = {"\\.ruby$", "\\.rb$"}, priority = Registry.Priority.MAXIMUM)
public class RubyTreeGenerator extends TreeGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
package com.github.gumtreediff.gen.ruby;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

import com.github.gumtreediff.gen.SyntaxException;
import com.github.gumtreediff.tree.ITree;
Expand All @@ -31,7 +29,7 @@
import org.jrubyparser.ast.NodeType;
import org.junit.Test;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;
import static org.junit.Assert.*;

public class TestRubyGenerator {
Expand All @@ -40,8 +38,8 @@ public class TestRubyGenerator {

@Test
public void testFileParsing() throws IOException {
ITree tree = new RubyTreeGenerator().generateFrom().
charset("UTF-8").stream(getClass().getResourceAsStream("/sample.rb")).getRoot();
ITree tree = new RubyTreeGenerator().generateFrom()
.charset("UTF-8").stream(getClass().getResourceAsStream("/sample.rb")).getRoot();
assertEquals(ROOT_NODE, tree.getType());
assertEquals(1726, tree.getSize());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.io.*;
import java.util.*;

import static com.github.gumtreediff.tree.Symbol.symbol;
import static com.github.gumtreediff.tree.SymbolSet.symbol;

public abstract class AbstractSrcmlTreeGenerator extends ExternalProcessTreeGenerator {

Expand Down

0 comments on commit 1794461

Please sign in to comment.