refactory: change signature of Infere
This commit is contained in:
parent
5ddfc9e8ec
commit
220968985b
|
@ -97,9 +97,9 @@ abstract public class AbstractLangProcessor {
|
|||
private List<String> includePaths;
|
||||
private static Logger logger = LoggerFactory.getLogger(AbstractLangProcessor.class);
|
||||
|
||||
public AbstractLangProcessor(boolean eagerExpressionResolve) {
|
||||
public AbstractLangProcessor() {
|
||||
entityRepo = new InMemoryEntityRepo();
|
||||
inferer = new Inferer(entityRepo, getImportLookupStrategy(), getBuiltInType(), eagerExpressionResolve);
|
||||
inferer = new Inferer(entityRepo, getImportLookupStrategy(), getBuiltInType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,4 +260,7 @@ abstract public class AbstractLangProcessor {
|
|||
return relation;
|
||||
}
|
||||
|
||||
public boolean isEagerExpressionResolve(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ public class CppProcessor extends AbstractLangProcessor {
|
|||
MacroRepo macroRepo = null;
|
||||
|
||||
public CppProcessor() {
|
||||
super(false);
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class GoProcessor extends AbstractLangProcessor {
|
|||
private static final String LANG = "go";
|
||||
private static final String[] SUFFIX = new String[] { ".go" };
|
||||
public GoProcessor() {
|
||||
super(false);
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,6 @@ public class JavaProcessor extends AbstractLangProcessor {
|
|||
private static final String JAVA_SUFFIX = ".java";
|
||||
|
||||
public JavaProcessor() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@ import static depends.deptypes.DependencyType.*;
|
|||
public class KotlinProcessor extends AbstractLangProcessor {
|
||||
|
||||
public KotlinProcessor() {
|
||||
super(true);
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,12 @@ public class KotlinProcessor extends AbstractLangProcessor {
|
|||
protected FileParser createFileParser(String fileFullPath) {
|
||||
return new KotlinFileParser(fileFullPath,entityRepo, inferer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEagerExpressionResolve(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> supportedRelations() {
|
||||
ArrayList<String> depedencyTypes = new ArrayList<>();
|
||||
|
|
|
@ -38,10 +38,7 @@ import static depends.deptypes.DependencyType.*;
|
|||
|
||||
public class PomProcessor extends AbstractLangProcessor {
|
||||
|
||||
public PomProcessor() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String supportedLanguage() {
|
||||
return "pom";
|
||||
|
|
|
@ -12,10 +12,6 @@ import static depends.deptypes.DependencyType.*;
|
|||
public abstract class BasePythonProcessor extends AbstractLangProcessor{
|
||||
private PythonImportLookupStrategy importedLookupStrategy;
|
||||
|
||||
public BasePythonProcessor(boolean eagerExpressionResolve) {
|
||||
super(eagerExpressionResolve);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] fileSuffixes() {
|
||||
return new String[] {".py"};
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
package depends.extractor.python.union;
|
||||
|
||||
import static depends.deptypes.DependencyType.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import depends.entity.repo.BuiltInType;
|
||||
import depends.extractor.AbstractLangProcessor;
|
||||
import depends.extractor.FileParser;
|
||||
import depends.extractor.python.BasePythonProcessor;
|
||||
import depends.extractor.python.PythonBuiltInType;
|
||||
import depends.extractor.python.PythonImportLookupStrategy;
|
||||
import depends.extractor.ruby.IncludedFileLocator;
|
||||
import depends.relations.ImportLookupStrategy;
|
||||
|
||||
public class PythonProcessor extends BasePythonProcessor {
|
||||
|
||||
public PythonProcessor() {
|
||||
/* Because Python is dynamic languange,
|
||||
* we eagerly resolve expression*/
|
||||
super(true);
|
||||
@Override
|
||||
public boolean isEagerExpressionResolve(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,9 +42,6 @@ public class RubyProcessor extends AbstractLangProcessor implements ParserCreato
|
|||
private static final String LANG = "ruby";
|
||||
private static final String[] SUFFIX = new String[] {".rb"};
|
||||
private ExecutorService executor;
|
||||
public RubyProcessor() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String supportedLanguage() {
|
||||
|
@ -97,5 +94,10 @@ public class RubyProcessor extends AbstractLangProcessor implements ParserCreato
|
|||
depedencyTypes.add(THROW);
|
||||
depedencyTypes.add(MIXIN);
|
||||
return depedencyTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEagerExpressionResolve(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,11 @@ public class Inferer {
|
|||
private boolean isDuckTypingDeduce = true;
|
||||
private static Logger logger = LoggerFactory.getLogger(Inferer.class);
|
||||
|
||||
public Inferer(EntityRepo repo, ImportLookupStrategy importLookupStrategy, BuiltInType buildInTypeManager, boolean eagerExpressionResolve) {
|
||||
public Inferer(EntityRepo repo, ImportLookupStrategy importLookupStrategy, BuiltInType buildInTypeManager) {
|
||||
this.repo = repo;
|
||||
this.importLookupStrategy = importLookupStrategy;
|
||||
this.buildInTypeManager = buildInTypeManager;
|
||||
unsolvedSymbols= new HashSet<>();
|
||||
this.eagerExpressionResolve = eagerExpressionResolve;
|
||||
importLookupStrategy.setInferer(this);
|
||||
}
|
||||
|
||||
|
@ -70,7 +69,7 @@ public class Inferer {
|
|||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Resolve type bindings...");
|
||||
}
|
||||
resolveTypes();
|
||||
resolveTypes(langProcessor.isEagerExpressionResolve());
|
||||
System.out.println("Dependency analaysing....");
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Dependency analaysing...");
|
||||
|
@ -82,11 +81,9 @@ public class Inferer {
|
|||
return unsolvedSymbols;
|
||||
}
|
||||
|
||||
public Set<UnsolvedBindings> resolveAllBindings() {
|
||||
return resolveAllBindings(false,null);
|
||||
}
|
||||
|
||||
private void resolveTypes() {
|
||||
|
||||
private void resolveTypes(boolean eagerExpressionResolve) {
|
||||
this.eagerExpressionResolve = eagerExpressionResolve;
|
||||
Iterator<Entity> iterator = repo.sortedFileIterator();
|
||||
while(iterator.hasNext()) {
|
||||
Entity entity= iterator.next();
|
||||
|
|
|
@ -20,7 +20,7 @@ public class AliasTest extends CppParserTest{
|
|||
String src = "./src/test/resources/cpp-code-examples/Alias.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("bar"), DependencyType.CALL, "F.foo");
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class AliasTest extends CppParserTest{
|
|||
String src = "./src/test/resources/cpp-code-examples/AliasType.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("C"), DependencyType.INHERIT, "A");
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class AliasTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("bar"), DependencyType.CALL, "foo");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class ConstructFunctionReturnValueTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
//assertEquals(1,repo.getEntity("UnderTest").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class ConstructFunctionReturnValueTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
//assertEquals(1,repo.getEntity("UnderTest").getRelations().size());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ContainRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,repo.getEntity("UnderTest").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ContainRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(2,repo.getEntity("UnderTest").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ContainRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("UnderTest"), DependencyType.CONTAIN, "Member");
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class ContainRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class CppExpressionTest extends CppParserTest{
|
|||
String src = "./src/test/resources/cpp-code-examples/Expressions.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("foo");
|
||||
this.assertContainsRelation(e, DependencyType.PARAMETER,"ClassA");
|
||||
this.assertContainsRelation(e, DependencyType.CAST,"ClassA");
|
||||
|
@ -37,7 +37,7 @@ public class CppExpressionTest extends CppParserTest{
|
|||
String src = "./src/test/resources/cpp-code-examples/DupExpressions.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("foo");
|
||||
assertEquals(4,e.getRelations().size());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class CppParameterParserTest extends CppParserTest{
|
|||
String src = "./src/test/resources/cpp-code-examples/FunctionParameters.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(4,repo.getEntity("FunctionParameters.function_with_parameters_same_type").getRelations().size());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package depends.extractor.cpp;
|
|||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.entity.repo.InMemoryEntityRepo;
|
||||
import depends.extractor.AbstractLangProcessor;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.extractor.cpp.cdt.CdtCppFileParser;
|
||||
import depends.extractor.cpp.cdt.PreprocessorHandler;
|
||||
|
@ -15,10 +16,12 @@ public abstract class CppParserTest extends ParserTest{
|
|||
protected Inferer inferer;
|
||||
protected PreprocessorHandler preprocessorHandler;
|
||||
private MacroRepo macroRepo;
|
||||
protected AbstractLangProcessor langProcessor;
|
||||
|
||||
public void init() {
|
||||
langProcessor = new CppProcessor();
|
||||
repo = new InMemoryEntityRepo();
|
||||
inferer = new Inferer(repo,new CppImportLookupStrategy(repo),new CppBuiltInType(),false);
|
||||
inferer = new Inferer(repo,new CppImportLookupStrategy(repo),new CppBuiltInType());
|
||||
preprocessorHandler = new PreprocessorHandler("./src/test/resources/cpp-code-examples/",new ArrayList<>());
|
||||
TemporaryFile.reset();
|
||||
// macroRepo = new MacroMemoryRepo();
|
||||
|
@ -30,4 +33,8 @@ public abstract class CppParserTest extends ParserTest{
|
|||
public CppFileParser createParser(String src) {
|
||||
return new CdtCppFileParser(src,repo, preprocessorHandler,inferer,macroRepo );
|
||||
}
|
||||
|
||||
public void resolveAllBindings(){
|
||||
inferer.resolveAllBindings(false,langProcessor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class DuplicateDeclarationTest extends CppParserTest {
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("X.invoke");
|
||||
this.assertContainsRelation(e, DependencyType.CONTAIN,"DupClass");
|
||||
this.assertContainsRelation(e, DependencyType.CALL,"DupClass");
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ForwardDeclareTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
//TODO: to be complete
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/TempateStructure.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(repo.getEntity("hash"));
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/GenericTypes.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("xStack"), DependencyType.PARAMETER, "X");
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/GenericTypes.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("XStack"), DependencyType.INHERIT, "Stack");
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/EmbededTemplates.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("GenericTypeEmbededTest"), DependencyType.CONTAIN, "MyHashMap");
|
||||
this.assertContainsRelation(repo.getEntity("GenericTypeEmbededTest.data"), DependencyType.PARAMETER, "MyList");
|
||||
this.assertContainsRelation(repo.getEntity("GenericTypeEmbededTest.data"), DependencyType.PARAMETER, "MyArray");
|
||||
|
@ -59,7 +59,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/TemplateWithDots.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(repo.getEntity("foo.t2"));
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class GenericTypeTest extends CppParserTest {
|
|||
String src = "./src/test/resources/cpp-code-examples/template/TemplateInReturnValue.cpp";
|
||||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity) repo.getEntity("get");
|
||||
this.assertContainsRelation(func, DependencyType.RETURN, "std.tuple_element.type");
|
||||
this.assertContainsRelation(repo.getEntity("get"), DependencyType.PARAMETER, "Index");
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ImplementRelationTest extends CppParserTest{
|
|||
CppFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
MultiDeclareEntities multiDeclare = (MultiDeclareEntities)( repo.getEntity("foo"));
|
||||
List<Entity> f = multiDeclare.getEntities().stream().filter(item->item.getClass().equals(FunctionEntityImpl.class)).collect(Collectors.toList());
|
||||
this.assertContainsRelation(f.get(0),DependencyType.IMPLEMENT,"foo");
|
||||
|
|
|
@ -33,7 +33,7 @@ public class IncludeRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
File f = new File(srcs[0]);
|
||||
assertEquals(3,repo.getEntity(f.getCanonicalPath()).getRelations().size());
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class IncludeRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
File f = new File(srcs[0]);
|
||||
assertEquals(1,repo.getEntity(f.getCanonicalPath()).getRelations().size());
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class IncludeRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals("abc",((AliasEntity)repo.getEntity("abc_t")).getOriginType().getRawName().uniqName());
|
||||
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class IncludeRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(this.repo.getEntity("foo"), DependencyType.CALL, "bar");
|
||||
this.assertNotContainsRelation(this.repo.getEntity("foo2"), DependencyType.CALL, "bar");
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class IncludeRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(this.repo.getEntity(FileUtil.uniqFilePath(srcs[0])), DependencyType.IMPORT, FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(this.repo.getEntity(FileUtil.uniqFilePath(srcs[0])), DependencyType.IMPORT, FileUtil.uniqFilePath(srcs[2]));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class MacroRelationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("foo");
|
||||
this.assertContainsRelation(e, DependencyType.RETURN, Inferer.buildInType.getQualifiedName());
|
||||
this.assertContainsRelation(e, DependencyType.CONTAIN, Inferer.buildInType.getQualifiedName());
|
||||
|
|
|
@ -28,7 +28,7 @@ public class MacroTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
|
||||
assertNotNull(this.repo.getEntity("Macro"));
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class MacroTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
|
||||
assertFalse(repo.getEntity("foo") instanceof MultiDeclareEntities);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class MacroTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
|
||||
assertNotNull(repo.getEntity("Macro3.bar"));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ParseErrorTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -39,7 +39,7 @@ public class ParseErrorTest extends CppParserTest{
|
|||
macroMap.put("AP_DECLARE(x)","x");
|
||||
parser.parse(true,macroMap);
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RelationInSameFileTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings(true,null);
|
||||
inferer.resolveAllBindings(true,langProcessor);
|
||||
Entity bar = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
int matchCount = 0;
|
||||
for (Relation relation:bar.getRelations()) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RelationToImplementationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings(true,null);
|
||||
inferer.resolveAllBindings(true,langProcessor);
|
||||
Entity bar = repo.getEntity("bar");
|
||||
int matchCount = 0;
|
||||
for (Relation relation:bar.getRelations()) {
|
||||
|
@ -56,7 +56,7 @@ public class RelationToImplementationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings(true,null);
|
||||
inferer.resolveAllBindings(true,langProcessor);
|
||||
Entity bar = repo.getEntity("baz");
|
||||
int matchCount = 0;
|
||||
for (Relation relation:bar.getRelations()) {
|
||||
|
@ -80,7 +80,7 @@ public class RelationToImplementationTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings(true,null);
|
||||
inferer.resolveAllBindings(true,langProcessor);
|
||||
Entity bar = repo.getEntity("qux");
|
||||
int matchCount = 0;
|
||||
for (Relation relation:bar.getRelations()) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class TypeDefTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("foo"), DependencyType.PARAMETER, "MyInt");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class UsingTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("foo");
|
||||
this.assertContainsRelation(e, DependencyType.RETURN, Inferer.buildInType.getQualifiedName());
|
||||
this.assertContainsRelation(e, DependencyType.CONTAIN, "A.C");
|
||||
|
@ -44,7 +44,7 @@ public class UsingTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("bar");
|
||||
this.assertContainsRelation(e, DependencyType.RETURN, Inferer.buildInType.getQualifiedName());
|
||||
this.assertContainsRelation(e, DependencyType.CONTAIN, "A.C");
|
||||
|
|
|
@ -24,7 +24,7 @@ public class extendsTest extends CppParserTest{
|
|||
CppFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = repo.getEntity("B");
|
||||
assertEquals(2,e.getRelations().size());
|
||||
}
|
||||
|
|
|
@ -20,16 +20,17 @@ public class GoFunctionsTest extends GolangParserTest {
|
|||
String src = "./src/test/resources/go-code-examples/func.go";
|
||||
GoFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(entityRepo.getEntity("main"));
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
public void test_could_parse_struct_type() throws IOException {
|
||||
String src = "./src/test/resources/go-code-examples/struct.go";
|
||||
GoFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(entityRepo.getEntity("Books"));
|
||||
}
|
||||
|
||||
|
@ -38,7 +39,7 @@ public class GoFunctionsTest extends GolangParserTest {
|
|||
String src = "./src/test/resources/go-code-examples/struct.go";
|
||||
GoFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(entityRepo.getEntity("Books"));
|
||||
TypeEntity book = (TypeEntity)entityRepo.getEntity("Books");
|
||||
assertEquals(4,book.getChildren().size());
|
||||
|
|
|
@ -2,6 +2,7 @@ package depends.extractor.golang;
|
|||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.entity.repo.InMemoryEntityRepo;
|
||||
import depends.extractor.AbstractLangProcessor;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.relations.Inferer;
|
||||
import multilang.depends.util.file.TemporaryFile;
|
||||
|
@ -9,14 +10,21 @@ import multilang.depends.util.file.TemporaryFile;
|
|||
public abstract class GolangParserTest extends ParserTest{
|
||||
protected EntityRepo entityRepo ;
|
||||
protected Inferer inferer ;
|
||||
private AbstractLangProcessor langProcessor;
|
||||
|
||||
public void init() {
|
||||
langProcessor = new GoProcessor();
|
||||
entityRepo = new InMemoryEntityRepo();
|
||||
inferer = new Inferer(entityRepo,new GoImportLookupStrategy(entityRepo),new GoBuiltInType(),false);
|
||||
inferer = new Inferer(entityRepo,new GoImportLookupStrategy(entityRepo),new GoBuiltInType());
|
||||
TemporaryFile.reset();
|
||||
}
|
||||
|
||||
public GoFileParser createParser(String src) {
|
||||
return new GoFileParser(src,entityRepo, inferer);
|
||||
}
|
||||
|
||||
public void resolveAllBindings() {
|
||||
inferer.resolveAllBindings(false,langProcessor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class InheritTypeTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/InheritTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("InheritTest").getRelations().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class JavaAnnotationParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/AnnotationTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("AnnotationTest.value").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class JavaAnnotationParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/AnnotationTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("TheClass"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class JavaAnnotationParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/AnnotationTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("TheFunction.foo"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class JavaAnnotationParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/AnnotationTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertNotContainsRelation(entityRepo.getEntity("TheFunction.bar"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class JavaAnnotationParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/AnnotationTest.java";
|
||||
JavaFileParser parser =createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("TheClass.TheClass"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
this.assertContainsRelation(entityRepo.getEntity("TheEnum"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
this.assertContainsRelation(entityRepo.getEntity("TheInterface.foo"), DependencyType.ANNOTATION, "AnnotationTest");
|
||||
|
|
|
@ -19,7 +19,7 @@ public class JavaCallExpressionTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/SimpleExpressionCallTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class JavaComplexExpressionTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/ComplexExpressionTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
ContainerEntity entity = (ContainerEntity)(entityRepo.getEntity("ComplexExpressionTest.other"));
|
||||
assertEquals(3,entity.getRelations().size());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class JavaCylicInheritTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/CyclicInherit.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class JavaEmbededClassTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/EmbededTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("x.EmbededTest").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class JavaEmbededClassTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/EmbededTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("x.EmbededTest2").getRelations().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class JavaExpressionCreatorTest extends JavaParserTest{
|
|||
FileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity entity = (entityRepo.getEntity("A.foo"));
|
||||
this.assertContainsRelation(entity, DependencyType.CREATE, "b.B");
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class JavaExpressionCreatorTest extends JavaParserTest{
|
|||
FileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity entity = (entityRepo.getEntity("X.foo"));
|
||||
this.assertContainsRelation(entity, DependencyType.CREATE, "b.B");
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class JavaFileImportTest extends JavaParserTest{
|
|||
FileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
TypeEntity type = (TypeEntity)(entityRepo.getEntity("a.Importing"));
|
||||
this.assertContainsRelation(type, DependencyType.INHERIT, "b.B");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class JavaGenericTypeTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/GenericTypeTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("x.GenericTypeTest.v"),
|
||||
DependencyType.PARAMETER, "x.Parent2.Enum");
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class JavaGenericTypeTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/GenericTypeEmbededTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("GenericTypeEmbededTest"),
|
||||
DependencyType.CONTAIN, "MyHashMap");
|
||||
this.assertContainsRelation(entityRepo.getEntity("GenericTypeEmbededTest.data"),
|
||||
|
|
|
@ -18,7 +18,7 @@ public class JavaParameterParserTest extends JavaParserTest {
|
|||
String src = "./src/test/resources/java-code-examples/FunctionParameters.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(4,entityRepo.getEntity("FunctionParameters.function_with_parameters_same_type").getRelations().size());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class JavaParseErrorFileTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/IncompleteFile.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -24,7 +24,7 @@ public class JavaParseErrorFileTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/EclipseTestBase_No_ResponseDuirngTypeResolve.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,21 +2,31 @@ package depends.extractor.java;
|
|||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.entity.repo.InMemoryEntityRepo;
|
||||
import depends.extractor.AbstractLangProcessor;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.extractor.UnsolvedBindings;
|
||||
import depends.relations.Inferer;
|
||||
import multilang.depends.util.file.TemporaryFile;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class JavaParserTest extends ParserTest{
|
||||
protected EntityRepo entityRepo ;
|
||||
protected Inferer inferer ;
|
||||
private AbstractLangProcessor langProcessor;
|
||||
|
||||
public void init() {
|
||||
entityRepo = new InMemoryEntityRepo();
|
||||
inferer = new Inferer(entityRepo,new JavaImportLookupStrategy(entityRepo),new JavaBuiltInType(),false);
|
||||
inferer = new Inferer(entityRepo,new JavaImportLookupStrategy(entityRepo),new JavaBuiltInType());
|
||||
TemporaryFile.reset();
|
||||
langProcessor = new JavaProcessor();
|
||||
}
|
||||
|
||||
public JavaFileParser createParser(String src) {
|
||||
return new JavaFileParser(src,entityRepo, inferer);
|
||||
}
|
||||
|
||||
public Set<UnsolvedBindings> resolveAllBindings() {
|
||||
return inferer.resolveAllBindings(false,langProcessor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class JavaTypeInferUnderSamePackageTest extends JavaParserTest{
|
|||
src = "./src/test/resources/java-code-examples/TypeInferUnderSamePackageB.java";
|
||||
parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("x.TypeInferUnderSamePackageA").getRelations().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/FieldVar.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity classEntity = entityRepo.getEntity("FieldVar");
|
||||
assertEquals(3,((TypeEntity)classEntity).getVars().size());
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/LocalVar.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,((TypeEntity)entityRepo.getEntity("LocalVar")).getVars().size());
|
||||
assertEquals(1,((FunctionEntity)entityRepo.getEntity("LocalVar.foo")).getVars().size());
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/LocalVarInferExample.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
ContainerEntity e = (ContainerEntity) entityRepo.getEntity("LocalVarInferExample.setExample");
|
||||
this.assertContainsRelation(e, DependencyType.CONTAIN, "MyInteger");
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/ComplexExpressionExample.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity e = entityRepo.getEntity("test.ComplexExpressionExample.setExample");
|
||||
this.assertContainsRelation(e, DependencyType.PARAMETER, "test.ClassA");
|
||||
this.assertContainsRelation(e, DependencyType.CREATE, "test.ClassA");
|
||||
|
@ -73,7 +73,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/LongExpressionWithAbsolutePath.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(5,entityRepo.getEntity("x.LongExpressionWithAbsolutePath.setExample").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/ExpressionCallTest.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(10,entityRepo.getEntity("ValidateAll.validate").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class JavaVarResolveTest extends JavaParserTest{
|
|||
String src = "./src/test/resources/java-code-examples/TypeArgument.java";
|
||||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("JDepObject.cells"),DependencyType.PARAMETER, "JCellObject");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class UnsolvedSymbolsTest extends JavaParserTest {
|
|||
JavaFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
inferer.setCollectUnsolvedBindings(true);
|
||||
Set<UnsolvedBindings> missing = inferer.resolveAllBindings();
|
||||
Set<UnsolvedBindings> missing = resolveAllBindings();
|
||||
assertEquals(1,missing.size());
|
||||
assertEquals("a.b",missing.iterator().next().getRawName());
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package depends.extractor.pom;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DependencyTest extends MavenParserTest{
|
||||
@Before
|
||||
|
@ -26,8 +22,8 @@ public class DependencyTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.CONTAIN, "a-dep-group.a-artifact_0.2_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomDependency, "a-dep-group.a-artifact_0.2_");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -41,8 +37,8 @@ public class DependencyTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.USE, "aplugins.aplugin_0.1_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomPlugin, "aplugins.aplugin_0.1_");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package depends.extractor.pom;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import depends.entity.MultiDeclareEntities;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import depends.entity.MultiDeclareEntities;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class DependencyWithPropertiesOfParentTest extends MavenParserTest{
|
||||
@Before
|
||||
|
@ -27,9 +26,9 @@ public class DependencyWithPropertiesOfParentTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertFalse(repo.getEntity("parent-group.a-parent_1.0_") instanceof MultiDeclareEntities);
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.CONTAIN, "a-dep-group.a-artifact_0.2_");
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomDependency, "a-dep-group.a-artifact_0.2_");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -44,8 +43,8 @@ public class DependencyWithPropertiesOfParentTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.USE, "aplugins.aplugin_0.1_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomPlugin, "aplugins.aplugin_0.1_");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package depends.extractor.pom;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DependencyWithPropertiesTest extends MavenParserTest{
|
||||
@Before
|
||||
|
@ -26,8 +22,8 @@ public class DependencyWithPropertiesTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.CONTAIN, "a-dep-group.a-artifact_0.2_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomDependency, "a-dep-group.a-artifact_0.2_");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -41,8 +37,8 @@ public class DependencyWithPropertiesTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.USE, "aplugins.aplugin_0.1_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomPlugin, "aplugins.aplugin_0.1_");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package depends.extractor.pom;
|
||||
import java.io.IOException;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import depends.deptypes.DependencyType;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DependencyWithoutVersionTest extends MavenParserTest{
|
||||
@Before
|
||||
|
@ -23,8 +22,8 @@ public class DependencyWithoutVersionTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.CONTAIN, "a-dep-group.a-artifact_0.2_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomDependency, "a-dep-group.a-artifact_0.2_");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -38,8 +37,8 @@ public class DependencyWithoutVersionTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.USE, "aplugins.aplugin_0.1_");
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity("testgroup.test_1.0_"), DependencyType.PomPlugin, "aplugins.aplugin_0.1_");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class EntityExtractTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(0,repo.getEntity("org.log4j-test.log4j_1.2.12_").getRelations().size());
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class EntityExtractTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(repo.getEntity("org.apache.maven.surefire.surefire-junit4_2.12.4_"));
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class EntityExtractTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
PomArtifactEntity entity = (PomArtifactEntity)(repo.getEntity("properties-test.test_1_"));
|
||||
/*
|
||||
<project.version>1.00</project.version>
|
||||
|
@ -74,7 +74,7 @@ public class EntityExtractTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
PomArtifactEntity entity = (PomArtifactEntity)(repo.getEntity("properties-test.test_1_"));
|
||||
/*
|
||||
<project.version>1.00</project.version>
|
||||
|
@ -94,7 +94,7 @@ public class EntityExtractTest extends MavenParserTest{
|
|||
PomFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
PomArtifactEntity entity = (PomArtifactEntity)(repo.getEntity("properties-test.test_1_"));
|
||||
assertEquals("13",entity.getProperty("project.version"));
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
package depends.extractor.pom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.extractor.UnsolvedBindings;
|
||||
import depends.relations.Inferer;
|
||||
import multilang.depends.util.file.TemporaryFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class MavenParserTest extends ParserTest{
|
||||
|
||||
protected EntityRepo repo;
|
||||
private PomProcessor p;
|
||||
private PomProcessor langProcessor;
|
||||
protected Inferer inferer;
|
||||
|
||||
public void init() {
|
||||
|
@ -20,16 +22,20 @@ public abstract class MavenParserTest extends ParserTest{
|
|||
includeDir.add("./src/test/resources/maven-code-examples/dependencyWithPropertiesOfParent");
|
||||
includeDir.add("./src/test/resources/maven-code-examples/dependencyWithoutVersion");
|
||||
|
||||
this.p = new PomProcessor();
|
||||
p.includeDirs = includeDir.toArray(new String[] {});
|
||||
this.langProcessor = new PomProcessor();
|
||||
langProcessor.includeDirs = includeDir.toArray(new String[] {});
|
||||
|
||||
this.repo = p.getEntityRepo();
|
||||
this.inferer = p.inferer;
|
||||
this.repo = langProcessor.getEntityRepo();
|
||||
this.inferer = langProcessor.inferer;
|
||||
TemporaryFile.reset();
|
||||
|
||||
}
|
||||
|
||||
public PomFileParser createParser(String src) {
|
||||
return (PomFileParser) p.createFileParser(src);
|
||||
return (PomFileParser) langProcessor.createFileParser(src);
|
||||
}
|
||||
|
||||
public Set<UnsolvedBindings> resolveAllBindings() {
|
||||
return inferer.resolveAllBindings(false, langProcessor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class PythonClassTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(repo.getEntity(withPackageName(srcs[0],"Foo")));
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class PythonClassTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
TypeEntity type = (TypeEntity)repo.getEntity(withPackageName(srcs[0],"Foo"));
|
||||
assertEquals(2,type.getFunctions().size());
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class PythonClassTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
TypeEntity type = (TypeEntity)repo.getEntity(withPackageName(srcs[0],"Bar"));
|
||||
this.assertContainsRelation(type, DependencyType.INHERIT, withPackageName(srcs[0],"Foo"));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class PythonDecoratorTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(func, DependencyType.ANNOTATION , withPackageName(srcs[0],"our_decorator"));
|
||||
assertEquals(1,func.getResolvedAnnotations().size());
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PythonFuncCallTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[0],"bar"));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class PythonFuncCallTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"baz"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[0],"A.foo"));
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class PythonFuncCallTest extends PythonParserTest {
|
|||
parser.parse();
|
||||
}
|
||||
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"C.test"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[0],"A.fooA"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[0],"B.fooB"));
|
||||
|
|
|
@ -27,7 +27,7 @@ public class PythonFunctionTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertNotNull(repo.getEntity(withPackageName(srcs[0],"foo")));
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class PythonFunctionTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"foo"));
|
||||
assertEquals(2,func.getParameters().size());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class PythonGlobalVarTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings(true,null);
|
||||
inferer.resolveAllBindings(true,langProcessor);
|
||||
Entity foo = repo.getEntity(withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(foo, DependencyType.USE, "global_var");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[0]));
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(file, DependencyType.CALL,withPackageName(srcs[0],"foo"));
|
||||
|
@ -64,7 +64,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(file, DependencyType.CALL,withPackageName(srcs[0],"foo"));
|
||||
|
@ -81,7 +81,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(file, DependencyType.CALL,withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
|
@ -99,7 +99,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(file, DependencyType.CALL,withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
|
@ -117,7 +117,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
Entity file = repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(file, DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(file, DependencyType.CALL,withPackageName(srcs[1],"foo"));
|
||||
|
@ -136,7 +136,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity(FileUtil.uniqFilePath(srcs[0])), DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(repo.getEntity(FileUtil.uniqFilePath(srcs[2])), DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
this.assertContainsRelation(repo.getEntity(FileUtil.uniqFilePath(srcs[3])), DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
|
@ -152,7 +152,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity(FileUtil.uniqFilePath(srcs[0])), DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(repo.getEntity(FileUtil.uniqFilePath(srcs[0])), DependencyType.IMPORT,FileUtil.uniqFilePath(srcs[1]));
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"test"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[1],"foo"));
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
|
||||
MultiDeclareEntities funcs = (MultiDeclareEntities)repo.getEntity(withPackageName(srcs[1],"in_the_forest"));
|
||||
Entity func = funcs.getEntities().get(0);
|
||||
|
@ -240,7 +240,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
|
||||
MultiDeclareEntities funcs = (MultiDeclareEntities)repo.getEntity(withPackageName(srcs[1],"in_the_forest"));
|
||||
Entity func = funcs.getEntities().get(0);
|
||||
|
@ -261,7 +261,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"bar"));
|
||||
this.assertContainsRelation(func, DependencyType.CALL, withPackageName(srcs[2],"C"));
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public class PythonImportTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FileEntity f = (FileEntity)repo.getEntity(FileUtil.uniqFilePath(srcs[0]));
|
||||
this.assertContainsRelation(f, DependencyType.CALL, withPackageName(srcs[1],"Core.foo"));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PythonObjectCreationTest extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"foo"));
|
||||
this.assertContainsRelation(func, DependencyType.CREATE, withPackageName(srcs[0],"Bar"));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PythonObjectThrowReturn extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"t1"));
|
||||
this.assertContainsRelation(func, DependencyType.THROW, withPackageName(srcs[0],"Bar"));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class PythonObjectThrowReturn extends PythonParserTest {
|
|||
PythonFileParser parser = createParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity func = (FunctionEntity)repo.getEntity(withPackageName(srcs[0],"t2"));
|
||||
this.assertContainsRelation(func, DependencyType.RETURN, withPackageName(srcs[0],"Bar"));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class PythonParameterTypeDedudceTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
String name = withPackageName(srcs[0],"test");
|
||||
FunctionEntity function = (FunctionEntity)( repo.getEntity(name));
|
||||
VarEntity var = function.lookupVarLocally("t1");
|
||||
|
@ -51,7 +51,7 @@ public class PythonParameterTypeDedudceTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
String name = withPackageName(srcs[0],"test");
|
||||
FunctionEntity function = (FunctionEntity)( repo.getEntity(name));
|
||||
VarEntity var = function.lookupVarLocally("t1");
|
||||
|
@ -70,7 +70,7 @@ public class PythonParameterTypeDedudceTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
String name = withPackageName(srcs[0],"test2");
|
||||
FunctionEntity function = (FunctionEntity)( repo.getEntity(name));
|
||||
VarEntity var = function.lookupVarLocally("t1");
|
||||
|
@ -90,7 +90,7 @@ public class PythonParameterTypeDedudceTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
String name = withPackageName(srcs[0],"test");
|
||||
FunctionEntity function = (FunctionEntity)( repo.getEntity(name));
|
||||
VarEntity var = function.lookupVarLocally("t2");
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
package depends.extractor.python;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.extractor.FileParser;
|
||||
import depends.extractor.ParserCreator;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.extractor.*;
|
||||
import depends.extractor.python.union.PythonFileParser;
|
||||
import depends.extractor.python.union.PythonProcessor;
|
||||
import depends.relations.Inferer;
|
||||
import multilang.depends.util.file.FileUtil;
|
||||
import multilang.depends.util.file.TemporaryFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class PythonParserTest extends ParserTest implements ParserCreator {
|
||||
|
||||
protected EntityRepo repo;
|
||||
private PythonProcessor p;
|
||||
protected PythonProcessor langProcessor;
|
||||
protected Inferer inferer;
|
||||
|
||||
public void init() {
|
||||
List<String> includeDir = new ArrayList<>();
|
||||
includeDir.add("./src/test/resources/python-code-examples/");
|
||||
this.p = new PythonProcessor();
|
||||
p.includeDirs = includeDir.toArray(new String[] {});
|
||||
this.langProcessor = new PythonProcessor();
|
||||
langProcessor.includeDirs = includeDir.toArray(new String[] {});
|
||||
|
||||
this.repo = p.getEntityRepo();
|
||||
this.inferer = p.inferer;
|
||||
this.repo = langProcessor.getEntityRepo();
|
||||
this.inferer = langProcessor.inferer;
|
||||
TemporaryFile.reset();
|
||||
|
||||
}
|
||||
|
@ -37,10 +36,14 @@ public abstract class PythonParserTest extends ParserTest implements ParserCreat
|
|||
|
||||
@Override
|
||||
public FileParser createFileParser(String src) {
|
||||
return p.createFileParser(FileUtil.uniqFilePath(src));
|
||||
return langProcessor.createFileParser(FileUtil.uniqFilePath(src));
|
||||
}
|
||||
|
||||
protected String withPackageName(String theFile,String entityName) {
|
||||
return FileUtil.uniqFilePath(FileUtil.getLocatedDir(theFile))+"."+entityName;
|
||||
}
|
||||
|
||||
public Set<UnsolvedBindings> resolveAllBindings() {
|
||||
return inferer.resolveAllBindings(false, langProcessor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SelfShouldBeThisTypeTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(repo.getEntity(withPackageName(srcs[0],"A.foo")));
|
||||
VarEntity var = function.lookupVarLocally("self");
|
||||
TypeEntity type = var.getType();
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ShouldGetRelationInSamePackageTest extends PythonParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(repo.getEntity(withPackageName(srcs[0],"bar")));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, withPackageName(srcs[0],"foo"));
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RubyAssignedVariableTypeDedudceTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("Class.test"));
|
||||
VarEntity var = function.lookupVarLocally("var_int");
|
||||
assertEquals(Inferer.buildInType.getRawName(),var.getType().getRawName());
|
||||
|
@ -56,7 +56,7 @@ public class RubyAssignedVariableTypeDedudceTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("Class.operator_is_call"));
|
||||
VarEntity var = function.lookupVarLocally("var_compose");
|
||||
assertEquals(Inferer.buildInType.getRawName(),var.getType().getRawName());
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyClassMethodcallTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("called_from"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "Foo1.bar");
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "Foo2.bar");
|
||||
|
|
|
@ -27,7 +27,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("Cat"), DependencyType.INHERIT, "Animal");
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("Cat"), DependencyType.INHERIT, "Animal");
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
super.assertContainsRelation(entityRepo.getEntity("Cat"), DependencyType.INHERIT, "Animal");
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
super.assertContainsRelation(entityRepo.getEntity("ZooCat"), DependencyType.INHERIT, "Zoo.Animal");
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
this.assertContainsRelation(entityRepo.getEntity("Zoo.Cow"), DependencyType.INHERIT, "Zoo.Animal");
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class RubyInheritTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertEquals(1,entityRepo.getEntity("Cat").getRelations().size());
|
||||
Relation r = entityRepo.getEntity("Cat").getRelations().get(0);
|
||||
assertEquals(DependencyType.INHERIT,r.getType());
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RubyMixinTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
assertContainsRelation(entityRepo.getEntity("MixedIn"),DependencyType.MIXIN,"ToBeMixin");
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyNameInfererTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("M1.test"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "M1.f1");
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "M1.f2");
|
||||
|
@ -41,7 +41,7 @@ public class RubyNameInfererTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("M2.M1.test2"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "M2.M1.f1");
|
||||
function = (FunctionEntity)(entityRepo.getEntity("M2.M1.test1"));
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RubyObjectCreationTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
super.assertContainsRelation(entityRepo.getEntity("T.foo"), DependencyType.CREATE, "M");
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class RubyParameterTypeDedudceTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("test"));
|
||||
VarEntity var = function.lookupVarLocally("t1");
|
||||
TypeEntity type = var.getType();
|
||||
|
|
|
@ -2,25 +2,26 @@ package depends.extractor.ruby;
|
|||
|
||||
import depends.entity.repo.EntityRepo;
|
||||
import depends.entity.repo.InMemoryEntityRepo;
|
||||
import depends.extractor.FileParser;
|
||||
import depends.extractor.ParserCreator;
|
||||
import depends.extractor.ParserTest;
|
||||
import depends.extractor.*;
|
||||
import depends.extractor.ruby.jruby.JRubyFileParser;
|
||||
import depends.relations.Inferer;
|
||||
import multilang.depends.util.file.TemporaryFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
public abstract class RubyParserTest extends ParserTest implements ParserCreator{
|
||||
protected EntityRepo entityRepo ;
|
||||
protected Inferer inferer ;
|
||||
private AbstractLangProcessor langProcessor;
|
||||
|
||||
public void init() {
|
||||
entityRepo = new InMemoryEntityRepo();
|
||||
inferer = new Inferer(entityRepo,new RubyImportLookupStrategy(entityRepo),new RubyBuiltInType(),true);
|
||||
inferer = new Inferer(entityRepo,new RubyImportLookupStrategy(entityRepo),new RubyBuiltInType());
|
||||
TemporaryFile.reset();
|
||||
langProcessor = new RubyProcessor();
|
||||
}
|
||||
|
||||
public FileParser createFileParser(String src) {
|
||||
|
@ -31,6 +32,8 @@ public abstract class RubyParserTest extends ParserTest implements ParserCreator
|
|||
private List<String> includePaths() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public Set<UnsolvedBindings> resolveAllBindings() {
|
||||
return inferer.resolveAllBindings(false, langProcessor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyRaiseTypeDedudceTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("Class.test"));
|
||||
this.assertContainsRelation(function, DependencyType.THROW, "Class1");
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyRequireTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
File f = new File(srcs[0]);
|
||||
File f2 = new File(srcs[1]);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class RubyReturnTypeDedudceTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("Class.test"));
|
||||
this.assertContainReturnType(function,"Class");
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyVCallTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("called_from"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "called");
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class RubyVCallTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("test"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "foo");
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "bar");
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RubyVariableCallTest extends RubyParserTest {
|
|||
FileParser parser = createFileParser(src);
|
||||
parser.parse();
|
||||
}
|
||||
inferer.resolveAllBindings();
|
||||
resolveAllBindings();
|
||||
FunctionEntity function = (FunctionEntity)(entityRepo.getEntity("test"));
|
||||
this.assertContainsRelation(function, DependencyType.CALL, "Class.function");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue