Skip to content

Commit 011eeae

Browse files
authored
Merge pull request #99 from FlorianLehmann/master
Missing TypeDeclaration name in gen.jdt
2 parents f316899 + 8e6c40e commit 011eeae

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

gen.jdt/src/main/java/com/github/gumtreediff/gen/jdt/JdtVisitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ protected String getLabel(ASTNode n) {
4848
if (n instanceof Assignment) return ((Assignment) n).getOperator().toString();
4949
if (n instanceof TextElement) return n.toString();
5050
if (n instanceof TagElement) return ((TagElement) n).getTagName();
51+
if (n instanceof TypeDeclaration) return ((TypeDeclaration) n).isInterface()?"interface":"class";
5152

5253
return "";
5354
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of GumTree.
3+
*
4+
* GumTree is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* GumTree is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with GumTree. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Copyright 2011-2015 Jean-Rémy Falleri <[email protected]>
18+
* Copyright 2011-2015 Floréal Morandat <[email protected]>
19+
*/
20+
21+
package com.github.gumtreediff.gen.jdt;
22+
23+
import com.github.gumtreediff.actions.ActionGenerator;
24+
import com.github.gumtreediff.actions.model.Action;
25+
import com.github.gumtreediff.matchers.Matcher;
26+
import com.github.gumtreediff.matchers.Matchers;
27+
import com.github.gumtreediff.tree.ITree;
28+
import com.github.gumtreediff.tree.TreeContext;
29+
import org.junit.Test;
30+
31+
import java.io.IOException;
32+
import java.util.List;
33+
34+
import static org.junit.Assert.assertEquals;
35+
36+
public class TestIssue98 {
37+
38+
@Test
39+
public void shouldHaveDifferentTree() throws IOException {
40+
String left = "public interface Main { }";
41+
String right = "public class Main { }";
42+
43+
ITree leftTree = new JdtTreeGenerator().generateFromString(left).getRoot();
44+
ITree rightTree = new JdtTreeGenerator().generateFromString(right).getRoot();
45+
Matcher m = Matchers.getInstance().getMatcher(leftTree, rightTree);
46+
m.match();
47+
48+
ActionGenerator g = new ActionGenerator(leftTree, rightTree, m.getMappings());
49+
List<Action> actions = g.generate();
50+
51+
assertEquals(1, actions.size());
52+
}
53+
54+
}

0 commit comments

Comments
 (0)