-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from gpes/fix/estrutura
Fix/estrutura
- Loading branch information
Showing
110 changed files
with
1,245 additions
and
4,730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
/nbproject | ||
.DS_Store | ||
|
||
# Maven | ||
/target/ | ||
parse-jdt/target/ | ||
parse-javaparser/target/ | ||
**/target/ | ||
.DS_Store | ||
**/target/ | ||
|
||
# Netbeans | ||
/nbproject | ||
nb-configuration.xml | ||
|
||
# Eclipse | ||
**/.settings | ||
**/.project | ||
**/.classpath | ||
/parse-jdt/nbproject/ | ||
|
||
# IDEA | ||
**/target | ||
.idea/** | ||
**/*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>br.edu.ifpb.gpes.mcp</groupId> | ||
<artifactId>mcp</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>mcp-core-jdt</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>br.edu.ifpb.gpes.mcp</groupId> | ||
<artifactId>mcp-core</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>mcp-samples</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>org.eclipse.jdt.core</artifactId> | ||
<version>3.10.0.v20140604-1726</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.core</groupId> | ||
<artifactId>org.eclipse.core.runtime</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.core</groupId> | ||
<artifactId>org.eclipse.core.resources</artifactId> | ||
<version>3.7.100</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,32 +17,31 @@ | |
* @mail [email protected] | ||
* @since 02/06/2017, 14:49:57 | ||
*/ | ||
//TODO: alterar nome da classe | ||
public class SmartASTParser { | ||
public class DefaultASTParser { | ||
|
||
private final ASTParser parser = ASTParser.newParser(AST.JLS8); | ||
private final String[] sources; | ||
private final String[] classpath = {System.getProperty("java.home") + "/lib/rt.jar"}; | ||
|
||
public static SmartASTParser createParse(String[] sources) { | ||
public static DefaultASTParser createParse(String[] sources) { | ||
|
||
if (sources == null) { | ||
throw new IllegalArgumentException("sources is null"); | ||
} | ||
|
||
return new SmartASTParser(sources); | ||
return new DefaultASTParser(sources); | ||
} | ||
|
||
public static SmartASTParser from(String... sources) { | ||
public static DefaultASTParser from(String... sources) { | ||
|
||
if (sources == null) { | ||
throw new IllegalArgumentException("path is null"); | ||
} | ||
|
||
return new SmartASTParser(sources); | ||
return new DefaultASTParser(sources); | ||
} | ||
|
||
private SmartASTParser(String[] sources) { | ||
private DefaultASTParser(String[] sources) { | ||
this.sources = sources; | ||
this.parser.setKind(ASTParser.K_COMPILATION_UNIT); | ||
Hashtable options = JavaCore.getOptions(); | ||
|
@@ -63,14 +62,14 @@ public void updateUnitName(Path fileJava) { | |
this.parser.setEnvironment(classpath, sources, new String[]{"UTF-8"}, true); | ||
this.parser.setSource(str.toCharArray()); | ||
} catch (IOException ex) { | ||
Logger.getLogger(SmartASTParser.class.getName()).log(Level.SEVERE, null, ex); | ||
Logger.getLogger(DefaultASTParser.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
public void acceptVisitor(ASTVisitor visitor) { | ||
ASTNode createAST = parser.createAST(null); | ||
if (createAST.getAST().hasBindingsRecovery()) { | ||
Logger.getLogger(SmartASTParser.class.getName()).log(Level.INFO, "Binding activated."); | ||
Logger.getLogger(DefaultASTParser.class.getName()).log(Level.INFO, "Binding activated."); | ||
} | ||
createAST.accept(visitor); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...src/main/java/ifpb/gpes/jdt/ParseJDT.java → ...src/main/java/ifpb/gpes/jdt/ParseJDT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package ifpb.gpes.jdt; | ||
|
||
|
||
import ifpb.gpes.ParseStrategy; | ||
import org.eclipse.jdt.core.dom.ASTVisitor; | ||
|
||
|
1 change: 1 addition & 0 deletions
1
...n/java/ifpb/gpes/jdt/ParseStrategies.java → ...n/java/ifpb/gpes/jdt/ParseStrategies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package ifpb.gpes.jdt; | ||
|
||
|
||
import ifpb.gpes.Call; | ||
import ifpb.gpes.ParseStrategy; | ||
import ifpb.gpes.Project; | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
mcp-core-jdt/src/test/java/ifpb/gpes/jdt/AnonymousClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ifpb.gpes.jdt; | ||
|
||
import ifpb.gpes.Call; | ||
import ifpb.gpes.Parse; | ||
import ifpb.gpes.Project; | ||
import org.junit.Test; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import static org.hamcrest.CoreMatchers.*; | ||
import org.hamcrest.collection.IsIterableContainingInOrder; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class AnonymousClassTest { | ||
|
||
private final List<Call> result = ofAnonymousClass(); | ||
private static final Logger logger = Logger.getLogger(AnonymousClassTest.class.getName()); | ||
private static final String sources = "../mcp-samples/src/main/java/"; | ||
|
||
@Test | ||
public void testM1() { | ||
List<Call> expected = ofListM1(); | ||
|
||
assertThat(result, hasItems(Call.of("java.util.List", "add[ifpb.gpes.domain.HasJCFObject]", "boolean", "ifpb.gpes.domain.SampleObject", "m2[]", null), | ||
Call.of("java.util.List", "remove[java.lang.Object]", "boolean", "ifpb.gpes.domain.SampleObject", "m3[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m3[]", "isEmpty[]"), | ||
Call.of("java.util.List", "hashCode[]", "int", "ifpb.gpes.domain.AnonymousClass", "m1[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.AnonymousClass", "m1[]", "hashCode[]") | ||
)); | ||
|
||
assertEquals(result.size(), expected.size()); | ||
assertThat(result, is(expected)); | ||
assertThat(result, IsIterableContainingInOrder.contains(expected.toArray())); | ||
|
||
result.forEach(no -> logger.log(Level.INFO, no.callGraph())); | ||
|
||
} | ||
|
||
private List<Call> ofListM1() { | ||
return Arrays.asList(Call.of("java.util.List", "add[ifpb.gpes.domain.HasJCFObject]", "boolean", "ifpb.gpes.domain.SampleObject", "m2[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m2[]", "add[ifpb.gpes.domain.HasJCFObject]"), | ||
Call.of("java.util.List", "remove[java.lang.Object]", "boolean", "ifpb.gpes.domain.SampleObject", "m3[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m3[]", "remove[java.lang.Object]"), | ||
Call.of("java.util.List", "isEmpty[]", "boolean", "ifpb.gpes.domain.SampleObject", "m3[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m3[]", "isEmpty[]"), | ||
Call.of("java.util.List", "iterator[]", "java.util.Iterator<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m2[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m2[]", "iterator[]"), | ||
Call.of("java.util.List", "listIterator[]", "java.util.ListIterator<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m2[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.SampleObject", "m2[]", "listIterator[]"), | ||
Call.of("java.util.List", "iterator[]", "java.util.Iterator<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.Interface", "semRetorno[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.Interface", "semRetorno[]", "iterator[]"), | ||
Call.of("java.util.List", "hashCode[]", "int", "ifpb.gpes.domain.AnonymousClass", "m1[]", null), | ||
Call.of("ifpb.gpes.domain.HasJCFObject", "getElements[]", "java.util.List<ifpb.gpes.domain.HasJCFObject>", "ifpb.gpes.domain.AnonymousClass", "m1[]", "hashCode[]")); | ||
|
||
} | ||
|
||
private List<Call> ofAnonymousClass() { | ||
Project project = Project | ||
.root("") | ||
.path(sources + "ifpb/gpes/domain/AnonymousClass.java") // root | ||
.sources(sources) // root - não obrigatorio | ||
.filter(".java"); | ||
|
||
return Parse.with(ParseStrategies.JDT).from(project); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.