Alle Klassen aus Standard Library laden
This commit is contained in:
parent
b104ff591f
commit
e341d9075e
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
@ -40,12 +40,12 @@ public class JavaTXCompiler {
|
||||
}
|
||||
|
||||
public List<ResultSet> typeInference(){
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();
|
||||
List<ClassOrInterface> allClasses = environment.getAllAvailableClasses();
|
||||
for(SourceFile sf : sourceFiles.values()){
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses);
|
||||
final ConstraintSet<Pair> cons = new TYPE(sourceFiles.values()).getConstraints();
|
||||
final ConstraintSet<Pair> cons = new TYPE(sourceFiles.values(), allClasses).getConstraints();
|
||||
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
||||
|
||||
TypeUnify unify = new TypeUnify();
|
||||
|
@ -10,6 +10,9 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.ResourcesScanner;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
@ -31,7 +34,8 @@ import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
||||
*/
|
||||
public class CompilationEnvironment {
|
||||
private final List<URL> librarys;
|
||||
|
||||
private final List<File> sourceFiles;
|
||||
|
||||
/**
|
||||
* Imitiert die Environment beim Aufruf des JavaCompilers auf einer Menge von java-Dateien
|
||||
* Die Environment enth<EFBFBD>lt automatisch die Java Standard Library
|
||||
@ -47,12 +51,21 @@ public class CompilationEnvironment {
|
||||
new DebugException("Fehler im Classpath auf diesem System");
|
||||
}
|
||||
}
|
||||
this.sourceFiles = sourceFiles;
|
||||
}
|
||||
|
||||
public JavaClassRegistry getRegistry(File forSourceFile) throws ClassNotFoundException, IOException {
|
||||
List<String> allNames = new ArrayList<>();
|
||||
List<String> allNames;
|
||||
CompilationUnitContext tree = JavaTXParser.parse(forSourceFile);
|
||||
allNames = GatherNames.getNames(tree, new PackageCrawler(librarys));
|
||||
return new JavaClassRegistry(allNames);
|
||||
}
|
||||
|
||||
public List<ClassOrInterface> getAllAvailableClasses() {
|
||||
List<ClassOrInterface> ret = new ArrayList<>();
|
||||
for(Class c : new PackageCrawler(librarys).getAllAvailableClasses()){
|
||||
ret.add(ASTFactory.createClass(c));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,16 @@ public class PackageCrawler {
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
public Set<Class<?>> getAllAvailableClasses(){
|
||||
Reflections reflections = new Reflections(new ConfigurationBuilder()
|
||||
.setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
|
||||
.setUrls(urls));
|
||||
|
||||
Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
public List<String> getClassNames(String packageName){
|
||||
List<String> nameList = new ArrayList();
|
||||
|
@ -11,13 +11,6 @@ import java.util.List;
|
||||
|
||||
public class RefType extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
{
|
||||
/**
|
||||
* Ist IsArray auf true, muss beim Codegen ein Zeichen [ gesetzt werden
|
||||
* Bsp.: 15| tag = CONSTANT_Utf8, length = 22, ([Ljava/lang/String;)V
|
||||
* Ist IsArray auf false, muss beim Codegen ein Zeichen [ gesetzt werden
|
||||
* Bsp.: 9| tag = CONSTANT_Utf8, length = 21, (Ljava/lang/String;)V
|
||||
*/
|
||||
private boolean IsArray = false;
|
||||
protected final JavaClassName name;
|
||||
protected final List<RefTypeOrTPHOrWildcardOrGeneric> parameter;
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@ import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.stream.Collectors;
|
||||
@ -17,7 +18,7 @@ public class TypeInferenceBlockInformation extends TypeInferenceInformation {
|
||||
private TypeScope methodContext;
|
||||
private ClassOrInterface currentClass;
|
||||
|
||||
public TypeInferenceBlockInformation(Set<ClassOrInterface> availableClasses,
|
||||
public TypeInferenceBlockInformation(Collection<ClassOrInterface> availableClasses,
|
||||
ClassOrInterface currentClass, TypeScope methodContext) {
|
||||
super(availableClasses);
|
||||
this.methodContext = new TypeScopeContainer(currentClass, methodContext);
|
||||
|
@ -12,6 +12,7 @@ import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -26,9 +27,9 @@ Zweiteres hat den Vorteil, dass bei der Entwicklung leichter Dinge hinzugefügt
|
||||
Die ganze Logik steckt in dieser Klasse.
|
||||
*/
|
||||
public class TypeInferenceInformation {
|
||||
private Set<ClassOrInterface> classes;
|
||||
private Collection<ClassOrInterface> classes;
|
||||
|
||||
public TypeInferenceInformation(Set<ClassOrInterface> availableClasses){
|
||||
public TypeInferenceInformation(Collection<ClassOrInterface> availableClasses){
|
||||
classes = availableClasses;
|
||||
}
|
||||
|
||||
@ -52,7 +53,7 @@ public class TypeInferenceInformation {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<ClassOrInterface> getAvailableClasses() {
|
||||
public Collection<ClassOrInterface> getAvailableClasses() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
@ -13,18 +13,19 @@ import java.util.*;
|
||||
public class TYPE {
|
||||
|
||||
private final Collection<SourceFile> sfs;
|
||||
private final TypeInferenceInformation typeInferenceInformation;
|
||||
|
||||
public TYPE(Collection<SourceFile> sourceFiles){
|
||||
public TYPE(Collection<SourceFile> sourceFiles, Collection<ClassOrInterface> allAvailableClasses){
|
||||
sfs = sourceFiles;
|
||||
this.typeInferenceInformation = new TypeInferenceInformation(allAvailableClasses);
|
||||
}
|
||||
|
||||
|
||||
public ConstraintSet getConstraints() {
|
||||
ConstraintSet ret = new ConstraintSet();
|
||||
TypeInferenceInformation info = getTypeInferenceInformation();
|
||||
for(SourceFile sf : sfs)
|
||||
for (ClassOrInterface cl : sf.KlassenVektor) {
|
||||
ret.addAll(getConstraintsClass(cl ,info));
|
||||
ret.addAll(getConstraintsClass(cl ,typeInferenceInformation));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -39,25 +40,28 @@ public class TYPE {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
TODO: Hier eine Information erstellen nur mit den importierte Klassen einer einzigen SourceFile
|
||||
private TypeInferenceInformation getTypeInferenceInformation(sourceFile) {
|
||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
Set<ClassOrInterface> classes = new HashSet<>();
|
||||
|
||||
private TypeInferenceInformation getTypeInferenceInformation() {
|
||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
Set<ClassOrInterface> classes = new HashSet<>();
|
||||
for(SourceFile sourceFile : sfs){
|
||||
for(JavaClassName importName : sourceFile.imports){
|
||||
System.out.println(importName);
|
||||
try {
|
||||
classes.add(ASTFactory.createClass(classLoader.loadClass(importName.toString())));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new DebugException("Klasse " + importName + " konnte nicht geladen werden");
|
||||
for(SourceFile sourceFile : sfs){
|
||||
for(JavaClassName importName : sourceFile.imports){
|
||||
System.out.println(importName);
|
||||
try {
|
||||
classes.add(ASTFactory.createClass(classLoader.loadClass(importName.toString())));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new DebugException("Klasse " + importName + " konnte nicht geladen werden");
|
||||
}
|
||||
}
|
||||
classes.addAll(sourceFile.KlassenVektor);
|
||||
}
|
||||
classes.addAll(sourceFile.KlassenVektor);
|
||||
|
||||
return new TypeInferenceInformation(classes);
|
||||
}
|
||||
|
||||
return new TypeInferenceInformation(classes);
|
||||
}
|
||||
|
||||
*/
|
||||
private ConstraintSet getConstraintsMethod(Method m, TypeInferenceInformation info, ClassOrInterface currentClass) {
|
||||
if(m.block == null)return new ConstraintSet(); //Abstrakte Methoden generieren keine Constraints
|
||||
TypeInferenceBlockInformation blockInfo = new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, m);
|
||||
|
Loading…
Reference in New Issue
Block a user