diff --git a/src/mycompiler/MyCompiler.java b/src/mycompiler/MyCompiler.java index d7a90d61..a40d0554 100755 --- a/src/mycompiler/MyCompiler.java +++ b/src/mycompiler/MyCompiler.java @@ -828,8 +828,10 @@ public class MyCompiler implements MyCompilerAPI } @Override - public void parse(String sourceCode) { - this.m_AbstractSyntaxTree.add(this.parse2SyntaxTree(new StringReader(sourceCode))); + public SourceFile parse(String sourceCode) { + SourceFile ret = this.parse2SyntaxTree(new StringReader(sourceCode)); + this.m_AbstractSyntaxTree.add(ret); + return ret; } } // ino.end diff --git a/src/mycompiler/MyCompilerAPI.java b/src/mycompiler/MyCompilerAPI.java index 126242a8..9120cb74 100755 --- a/src/mycompiler/MyCompilerAPI.java +++ b/src/mycompiler/MyCompilerAPI.java @@ -127,8 +127,9 @@ public interface MyCompilerAPI /** * Parst den SourceCode einer Datei. * @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 diff --git a/src/mycompiler/SyntaxTreeNode.java b/src/mycompiler/SyntaxTreeNode.java index eeb0bd7a..cc8f4d6d 100644 --- a/src/mycompiler/SyntaxTreeNode.java +++ b/src/mycompiler/SyntaxTreeNode.java @@ -33,4 +33,12 @@ public abstract class SyntaxTreeNode { if(parent == null)throw new TypinferenzException("Das Wurzelelement eines Syntaxbaumes muss Class sein"); return parent.getParentClass(); } + + /** + * Eine Beschreibung/Name des SyntaxTree-Nodes + * @return + */ + public String getDescription(){ + return this.toString(); + } } diff --git a/src/mycompiler/myclass/Class.java b/src/mycompiler/myclass/Class.java index e89d30a7..35f9dbfe 100755 --- a/src/mycompiler/myclass/Class.java +++ b/src/mycompiler/myclass/Class.java @@ -1314,5 +1314,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface return true; } + + @Override + public String getDescription(){ + return "class "+this.getName(); + } } // ino.end diff --git a/src/mycompiler/myclass/Field.java b/src/mycompiler/myclass/Field.java index e3885aa4..a3907920 100644 --- a/src/mycompiler/myclass/Field.java +++ b/src/mycompiler/myclass/Field.java @@ -90,4 +90,9 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty public String getIdentifier() { return this.get_Name().firstElement().get_Name(); } + + @Override + public String getDescription(){ + return this.getIdentifier(); + } } diff --git a/src/mycompiler/myclass/Method.java b/src/mycompiler/myclass/Method.java index f41a2a99..76562ccb 100755 --- a/src/mycompiler/myclass/Method.java +++ b/src/mycompiler/myclass/Method.java @@ -699,7 +699,5 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable return ret; } - - } // ino.end diff --git a/test/plugindevelopment/SyntaxTreeTests.java b/test/plugindevelopment/SyntaxTreeTests.java new file mode 100644 index 00000000..105897a1 --- /dev/null +++ b/test/plugindevelopment/SyntaxTreeTests.java @@ -0,0 +1,7 @@ +package plugindevelopment; + +public class SyntaxTreeTests { + + //TODO: Hier tests für getChildren anfügen. + +}