This commit is contained in:
Daniel Holle 2024-11-05 17:17:26 +01:00
parent bebfba864e
commit d940866c9f
6 changed files with 109 additions and 13 deletions

View File

@ -68,7 +68,7 @@ public class Typinferenz {
// Keine Exception bei leerem Editor
if (Strings.isNullOrEmpty(editor.getSourceCode())) {
return new UnifyResultModel(new ConstraintSet<>(), new FiniteClosure(new HashSet<>(), new OutputStreamWriter(new NullOutputStream())));
return new UnifyResultModel(new ConstraintSet<>(), new FiniteClosure(new HashSet<>(), new OutputStreamWriter(new NullOutputStream()), compiler));
}
return compiler.typeInferenceAsync(resultListener, new OutputStreamWriter(new NullOutputStream()));
} catch (ClassNotFoundException e) {
@ -96,7 +96,7 @@ public class Typinferenz {
for (SourceFile sf : compiler.sourceFiles.values()) {
try {
var generatedClasses = compiler.generateBytecode(sf, tiResults);
compiler.writeClassFile(generatedClasses, new File(outputDirectory));
compiler.writeClassFile(generatedClasses, new File(outputDirectory), false);
} catch (IOException ex) {
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
ret.add(toAdd);

View File

@ -12,6 +12,7 @@ import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.Pattern;
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
@ -102,13 +103,15 @@ public class IdentifierFinder extends AbstractASTWalker implements ASTVisitor, R
@Override
public void visit(ParameterList formalParameters) {
for (FormalParameter fp : formalParameters) {
if (fp.getName().equals(identifier)) {
this.result = fp.getType();
if (fp.getType() instanceof TypePlaceholder) {
((TypePlaceholder)fp.getType()).accept((ASTVisitor)this);
} else if (fp.getType() instanceof RefType) {
((RefType)fp.getType()).accept((ASTVisitor)this);
for (Pattern pat : formalParameters) {
if (pat instanceof FormalParameter fp) {
if (fp.getName().equals(identifier)) {
this.result = fp.getType();
if (fp.getType() instanceof TypePlaceholder) {
((TypePlaceholder)fp.getType()).accept((ASTVisitor)this);
} else if (fp.getType() instanceof RefType) {
((RefType)fp.getType()).accept((ASTVisitor)this);
}
}
}
}

View File

@ -57,7 +57,7 @@ public class JafCompletionProcessor implements IContentAssistProcessor {
Set<String> fieldNames = new TreeSet<>();
//LOG.log(new Status(WARNING, PLUGIN_ID,"New path for classpath: " + editor.getFilePath().toFile().getAbsolutePath()));
ClassLoader additionalCP = addPath(editor.getFilePath().toFile().getParentFile());
ClassLoader additionalCP = addPath(new File(editor.getFilePath().toFile().getParentFile(), "classFiles"));
for (String prop : editor.resolveTypeInserts(prefix, evaluateLineNumber(doc, offset))) {
if (prop.contains("<")) {

View File

@ -7,10 +7,14 @@ import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.ExpressionPattern;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Pattern;
import de.dhbwstuttgart.syntaxtree.RecordPattern;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.GuardedPattern;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.SourceFile;
@ -20,11 +24,14 @@ import de.dhbwstuttgart.syntaxtree.statement.Assign;
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr;
import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.BoolExpression;
import de.dhbwstuttgart.syntaxtree.statement.Break;
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
import de.dhbwstuttgart.syntaxtree.statement.ForEachStmt;
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
@ -42,9 +49,16 @@ import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
import de.dhbwstuttgart.syntaxtree.statement.Super;
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.statement.Switch;
import de.dhbwstuttgart.syntaxtree.statement.SwitchBlock;
import de.dhbwstuttgart.syntaxtree.statement.SwitchLabel;
import de.dhbwstuttgart.syntaxtree.statement.Ternary;
import de.dhbwstuttgart.syntaxtree.statement.This;
import de.dhbwstuttgart.syntaxtree.statement.ThisCall;
import de.dhbwstuttgart.syntaxtree.statement.Throw;
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr;
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
import de.dhbwstuttgart.syntaxtree.statement.Yield;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
@ -53,6 +67,30 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
public class ASTChildren implements ASTVisitor{
@Override
public void visit(ForEachStmt forEachStmt) {
// TODO Auto-generated method stub
}
@Override
public void visit(ThisCall thisCall) {
// TODO Auto-generated method stub
}
@Override
public void visit(Throw aThrow) {
// TODO Auto-generated method stub
}
@Override
public void visit(Ternary ternary) {
// TODO Auto-generated method stub
}
private final List<SyntaxTreeNode> children = new ArrayList<>();
public ASTChildren(SyntaxTreeNode ofNode) {
@ -226,7 +264,7 @@ public class ASTChildren implements ASTVisitor{
@Override
public void visit(Method field) {
for(FormalParameter fp : field.getParameterList().getFormalparalist()) {
for(Pattern fp : field.getParameterList().getFormalparalist()) {
children.add(fp);
}
}
@ -324,5 +362,55 @@ public class ASTChildren implements ASTVisitor{
// TODO Auto-generated method stub
}
@Override
public void visit(ExpressionPattern aPattern) {
}
@Override
public void visit(RecordPattern aRecordPattern) {
}
@Override
public void visit(GuardedPattern aGuardedPattern) {
}
@Override
public void visit(BoolExpression logical) {
// TODO Auto-generated method stub
}
@Override
public void visit(Switch switchStmt) {
// TODO Auto-generated method stub
}
@Override
public void visit(SwitchBlock switchBlock) {
// TODO Auto-generated method stub
}
@Override
public void visit(SwitchLabel switchLabel) {
// TODO Auto-generated method stub
}
@Override
public void visit(Break aBreak) {
// TODO Auto-generated method stub
}
@Override
public void visit(Yield aYield) {
// TODO Auto-generated method stub
}
}

View File

@ -16,6 +16,11 @@
<module>releng</module>
</modules>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>

View File

@ -6,7 +6,7 @@
<packaging>pom</packaging>
<properties>
<tycho.version>3.0.5</tycho.version>
<tycho.version>4.0.7</tycho.version>
<eclipse-repo.url>https://download.eclipse.org/eclipse/updates/4.28</eclipse-repo.url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<downloadSources>true</downloadSources>
@ -77,7 +77,7 @@
<dependency>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
<version>0.1.0</version>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>