SyntaxTreeNode.getDescription() angefügt

This commit is contained in:
JanUlrich 2014-03-12 15:27:26 +01:00
parent b29fa03782
commit 5d57179364
7 changed files with 31 additions and 5 deletions

View File

@ -828,8 +828,10 @@ public class MyCompiler implements MyCompilerAPI
} }
@Override @Override
public void parse(String sourceCode) { public SourceFile parse(String sourceCode) {
this.m_AbstractSyntaxTree.add(this.parse2SyntaxTree(new StringReader(sourceCode))); SourceFile ret = this.parse2SyntaxTree(new StringReader(sourceCode));
this.m_AbstractSyntaxTree.add(ret);
return ret;
} }
} }
// ino.end // ino.end

View File

@ -127,8 +127,9 @@ public interface MyCompilerAPI
/** /**
* Parst den SourceCode einer Datei. * Parst den SourceCode einer Datei.
* @param sourceCode - SourceCode einer Java-Quellcodedatei * @param sourceCode - SourceCode einer Java-Quellcodedatei
* @return den aus dem sourceCode generierten Syntaxbaum
*/ */
public void parse(String sourceCode); public SourceFile parse(String sourceCode);
} }
// ino.end // ino.end

View File

@ -33,4 +33,12 @@ public abstract class SyntaxTreeNode {
if(parent == null)throw new TypinferenzException("Das Wurzelelement eines Syntaxbaumes muss Class sein"); if(parent == null)throw new TypinferenzException("Das Wurzelelement eines Syntaxbaumes muss Class sein");
return parent.getParentClass(); return parent.getParentClass();
} }
/**
* Eine Beschreibung/Name des SyntaxTree-Nodes
* @return
*/
public String getDescription(){
return this.toString();
}
} }

View File

@ -1314,5 +1314,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
return true; return true;
} }
@Override
public String getDescription(){
return "class "+this.getName();
}
} }
// ino.end // ino.end

View File

@ -90,4 +90,9 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
public String getIdentifier() { public String getIdentifier() {
return this.get_Name().firstElement().get_Name(); return this.get_Name().firstElement().get_Name();
} }
@Override
public String getDescription(){
return this.getIdentifier();
}
} }

View File

@ -699,7 +699,5 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
return ret; return ret;
} }
} }
// ino.end // ino.end

View File

@ -0,0 +1,7 @@
package plugindevelopment;
public class SyntaxTreeTests {
//TODO: Hier tests für getChildren anfügen.
}