ISourceParser interface change
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonAssistParser.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonAssistParser.java index 8b5b601..3538595 100644 --- a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonAssistParser.java +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonAssistParser.java
@@ -17,7 +17,7 @@ import org.eclipse.dltk.ast.declarations.ModuleDeclaration; import org.eclipse.dltk.ast.parser.ISourceParser; import org.eclipse.dltk.codeassist.IAssistParser; -import org.eclipse.dltk.compiler.env.ISourceModule; +import org.eclipse.dltk.compiler.env.IModuleSource; import org.eclipse.dltk.core.DLTKLanguageManager; import org.eclipse.dltk.python.core.PythonNature; @@ -74,9 +74,8 @@ this.module = unit; } - public ModuleDeclaration parse(ISourceModule sourceUnit) { - ModuleDeclaration module = this.parser.parse(sourceUnit.getFileName().toCharArray(), - sourceUnit.getContentsAsCharArray(), null); + public ModuleDeclaration parse(IModuleSource sourceUnit) { + ModuleDeclaration module = (ModuleDeclaration) this.parser.parse(sourceUnit, null); module.rebuild(); PythonASTUtil.extendStatements(module, sourceUnit.getSourceContents());
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonSelectionEngine.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonSelectionEngine.java index 4b82677..888c0a9 100644 --- a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonSelectionEngine.java +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/codeassist/PythonSelectionEngine.java
@@ -16,7 +16,7 @@ import org.eclipse.dltk.ast.declarations.ModuleDeclaration; import org.eclipse.dltk.codeassist.IAssistParser; import org.eclipse.dltk.codeassist.ScriptSelectionEngine; -import org.eclipse.dltk.compiler.env.ISourceModule; +import org.eclipse.dltk.compiler.env.IModuleSource; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IDLTKLanguageToolkit; import org.eclipse.dltk.core.IModelElement; @@ -42,7 +42,7 @@ // this.lookupEnvironment = new LookupEnvironment(this, nameEnvironment); } - public IModelElement[] select(ISourceModule sourceUnit, + public IModelElement[] select(IModuleSource sourceUnit, int selectionSourceStart, int selectionSourceEnd) { String source = sourceUnit.getSourceContents();
diff --git a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/parser/PythonSourceParser.java b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/parser/PythonSourceParser.java index fc16d24..0a64509 100644 --- a/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/parser/PythonSourceParser.java +++ b/plugins/org.eclipse.dltk.python.core/src/org/eclipse/dltk/python/internal/core/parser/PythonSourceParser.java
@@ -14,10 +14,9 @@ import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.Token; import org.antlr.runtime.TokenStream; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.dltk.ast.declarations.ModuleDeclaration; import org.eclipse.dltk.ast.parser.AbstractSourceParser; +import org.eclipse.dltk.ast.parser.IModuleDeclaration; +import org.eclipse.dltk.compiler.env.IModuleSource; import org.eclipse.dltk.compiler.problem.IProblemReporter; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.python.internal.core.parsers.DLTKPythonErrorReporter; @@ -32,7 +31,7 @@ private IProblemReporter problemReporter = null; public PythonSourceParser(/* IProblemReporter reporter */) { -// this.problemReporter = reporter; + // this.problemReporter = reporter; } public static class MyLexer extends python_v3Lexer { @@ -50,13 +49,15 @@ * Parses selected context to module declaration using python parser. * */ - public ModuleDeclaration parse(char[] fileName, char[] content0, IProblemReporter reporter) {// throws + public IModuleDeclaration parse(IModuleSource input, + IProblemReporter reporter) {// throws this.problemReporter = reporter; - + char[] content0 = input.getContentsAsCharArray(); + PythonModuleDeclaration moduleDeclaration = new PythonModuleDeclaration( content0.length, true); - CharStream st = new ANTLRStringStream(new String(content0)); + CharStream st = new ANTLRStringStream(content0, content0.length); python_v3Lexer pythonLexer = new MyLexer(st); CommonTokenStream tokens = new CommonTokenStream(pythonLexer); @@ -69,7 +70,8 @@ pythonParser.decl = moduleDeclaration; pythonParser.length = content0.length; pythonParser.converter = new DLTKTokenConverter(content0); - pythonParser.reporter = new DLTKPythonErrorReporter(pythonParser.converter, problemReporter, pythonParser); + pythonParser.reporter = new DLTKPythonErrorReporter( + pythonParser.converter, problemReporter, pythonParser); try { pythonParser.file_input();