Fehler bei GenericInsertPoints beheben

This commit is contained in:
JanUlrich 2017-06-30 12:14:07 +02:00
parent 3b8ef58222
commit d64823ea30
6 changed files with 11 additions and 19 deletions

View File

@ -31,7 +31,7 @@ public class NewClass extends MethodCall
* @param start
*/
public NewClass(RefType newClass, ArgumentList args, Token start) {
super(newClass, new Receiver(new EmptyStmt(start)), "new "+newClass.getName().toString(), args, start);
super(newClass, new Receiver(new EmptyStmt(start)), newClass.getName().toString(), args, start);
}
@Override

View File

@ -245,7 +245,8 @@ public class OutputGenerator implements ASTVisitor {
@Override
public void visit(NewClass methodCall) {
out.append("new ");
visit((MethodCall) methodCall);
out.append(methodCall.name);
methodCall.getArgumentList().accept(this);
}
@Override

View File

@ -173,8 +173,6 @@ public class TypeOutputGenerator extends OutputGenerator {
@Override
public void visit(NewClass methodCall) {
super.visit(methodCall);
this.out.append("::");
methodCall.getType().accept(this);
}
@Override

View File

@ -128,10 +128,11 @@ public class TypeInsertFactory {
//Offset zum Einstzen bestimmen:
Token offset;
String insert = "";
String end =" ";
String end;
if(cl.getGenerics().iterator().hasNext()){
offset = cl.getGenerics().iterator().next().getOffset();
insert+=",";
//offset = cl.getGenerics().iterator().next().getOffset();
offset = cl.getGenerics().getOffset();
end=",";
}else{
offset = cl.getGenerics().getOffset();
insert += "<";
@ -154,6 +155,7 @@ public class TypeInsertFactory {
//String zum Einsetzen (Generics mit bounds) generieren:
Iterator<TypePlaceholder> it = genericsAndBounds.keySet().iterator();
if(! it.hasNext())return new TypeInsertPoint(offset, "");
while(it.hasNext()){
TypePlaceholder tph = it.next();
insert += tph.getName();

View File

@ -11,7 +11,7 @@ public class TypeInsertPoint {
public TypeInsertPoint(Token point, String toInsert){
this.point = point;
this.insertString = toInsert + " ";
this.insertString = (toInsert.length()>1) ? toInsert + " " : toInsert;
}
public String insert(String intoSource, List<TypeInsertPoint> additionalOffset){

View File

@ -30,8 +30,8 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
@Test
public void test() throws IOException, ClassNotFoundException {
filesToTest.add(new File(rootDirectory+"Faculty.jav"));
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
@ -58,13 +58,4 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
return new String(encoded, encoding);
}
static String showTPHInformation(Iterable<TypePlaceholder> tphs){
StringBuilder ret = new StringBuilder();
OutputGenerator gen = new OutputGenerator(ret);
for(TypePlaceholder tph : tphs){
gen.visit(tph);
}
return ret.toString();
}
}