forked from JavaTX/JavaCompilerCore
modified: src/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/FCGenerator.java Die Anzahl der mehrfachen Lösungen bei sorting.jav reduziert
This commit is contained in:
parent
5768783828
commit
315b6172a0
@ -79,10 +79,16 @@ public class JavaTXCompiler {
|
||||
}
|
||||
|
||||
public List<ClassOrInterface> getAvailableClasses(SourceFile forSourceFile) throws ClassNotFoundException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||
//PL 2018-09-18: List durch Set ersetzt, damit die Klassen nur einmal hinzugefuegt werden
|
||||
//List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||
Set<ClassOrInterface> allClasses = new HashSet<>();
|
||||
|
||||
/* PL 2018-09-19 geloescht werden bereits in typeInference hinzugefuegt
|
||||
for (SourceFile sf : sourceFiles.values()) {
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
*/
|
||||
|
||||
List<ClassOrInterface> importedClasses = new ArrayList<>();
|
||||
for (JavaClassName name : forSourceFile.getImports()) {
|
||||
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
||||
@ -91,7 +97,7 @@ public class JavaTXCompiler {
|
||||
importedClasses.add(importedClass);
|
||||
allClasses.addAll(importedClasses);
|
||||
}
|
||||
return allClasses;
|
||||
return new ArrayList<>(allClasses);
|
||||
}
|
||||
|
||||
public List<ResultSet> typeInference() throws ClassNotFoundException {
|
||||
|
@ -13,6 +13,8 @@ import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class FCGenerator {
|
||||
/**
|
||||
* Baut die FiniteClosure aus availableClasses.
|
||||
@ -26,11 +28,18 @@ public class FCGenerator {
|
||||
|
||||
public static Set<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
|
||||
HashSet<Pair> pairs = new HashSet<>();
|
||||
//PL 2018-09-18: gtvs vor die for-Schleife gezogen, damit immer die gleichen Typeplaceholder eingesetzt werden.
|
||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs = new HashMap<>();
|
||||
for(ClassOrInterface cly : availableClasses){
|
||||
pairs.addAll(getSuperTypes(cly, availableClasses));
|
||||
pairs.addAll(getSuperTypes(cly, availableClasses, gtvs));
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bildet eine Kette vom übergebenen Typ bis hin zum höchsten bekannten Typ
|
||||
|
@ -105,7 +105,7 @@ public class RefType extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(ASTVisitor visitor) {
|
||||
|
@ -15,4 +15,5 @@ public abstract class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{
|
||||
|
||||
public abstract <A> A acceptTV(TypeVisitor<A> visitor);
|
||||
public abstract void accept(ResultSetVisitor visitor);
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "TPH " + this.name;
|
||||
|
Loading…
Reference in New Issue
Block a user