Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Dltk-dev] i like to have a core interface change in ISourceElementParser (add one method)

Hi,

past week i was very busy with getting the js code completion into overdrive
now i have that pretty much all working, i am still working on tweaks and stuff (like better/full support of all the build in stuff like string, date, number and array)

But what is working now is that we can have code completion on pretty much anything we use including what the IDesignTimeDOMProvider provides for completion
it is pretty much 'typed' all the way now, its very cool and very helpful for us.

The changes are almost all in the _javascript_ projects except one and that is the entry point to it all:

ISourceElementParser.
void parseSourceModule(char[] contents, ISourceModuleInfo cache,
            char[] filename);

ISourceElement parser has that method and that is called in in SourceParserUtils like this:

public static void parseSourceModule(ISourceModule module,
            ISourceElementParser parser) {
        char[] contents;
        try {
            contents = module.getSourceAsCharArray();
            ISourceModuleInfoCache sourceModuleInfoCache = ModelManager
                    .getModelManager().getSourceModuleInfoCache();
            ISourceModuleInfo mifo = sourceModuleInfoCache.get(module);
            parser.parseSourceModule(contents, mifo, module.getPath()
                    .toString().toCharArray());
        } catch (ModelException e) {
            if (DLTKCore.DEBUG) {
                e.printStackTrace();
            }
        }
    }

so the source module is already broken up there. But in the _javascript_ElementParser i need the ISourceModule

so i added
ISourceElementParser
    void parseSourceModule(ISourceModule module, ISourceModuleInfo mifo);

and let the SourceParserUtils call that method instead of breaking down ISourceModule before hand.

Is it ok to check this in? Other implementations can just do what SourceParserUtils  does and have a very simple implementation that just
call the existing method by extracting the contents and the path from tthe source module

johan



### Eclipse Workspace Patch 1.0
#P org.eclipse.dltk.core
Index: model/org/eclipse/dltk/core/ISourceElementParser.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/ISourceElementParser.java,v
retrieving revision 1.9
diff -u -r1.9 ISourceElementParser.java
--- model/org/eclipse/dltk/core/ISourceElementParser.java	6 May 2008 11:39:12 -0000	1.9
+++ model/org/eclipse/dltk/core/ISourceElementParser.java	8 Sep 2008 08:46:37 -0000
@@ -20,6 +20,13 @@
 	void parseSourceModule(char[] contents, ISourceModuleInfo cache,
 			char[] filename);
 
+	/**
+	 * Parses contens fo th module with ast creation. Also it is recommended to
+	 * use SourceParserUtils to put delcaration into cache, and retrive it from
+	 * it.
+	 */
+	void parseSourceModule(ISourceModule module, ISourceModuleInfo mifo);
+
 	void setRequestor(ISourceElementRequestor requestor);
 
 	void setReporter(IProblemReporter reporter);
Index: model/org/eclipse/dltk/core/SourceParserUtil.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/SourceParserUtil.java,v
retrieving revision 1.19
diff -u -r1.19 SourceParserUtil.java
--- model/org/eclipse/dltk/core/SourceParserUtil.java	28 Jul 2008 04:44:26 -0000	1.19
+++ model/org/eclipse/dltk/core/SourceParserUtil.java	8 Sep 2008 08:46:37 -0000
@@ -202,18 +202,9 @@
 
 	public static void parseSourceModule(ISourceModule module,
 			ISourceElementParser parser) {
-		char[] contents;
-		try {
-			contents = module.getSourceAsCharArray();
-			ISourceModuleInfoCache sourceModuleInfoCache = ModelManager
-					.getModelManager().getSourceModuleInfoCache();
-			ISourceModuleInfo mifo = sourceModuleInfoCache.get(module);
-			parser.parseSourceModule(contents, mifo, module.getPath()
-					.toString().toCharArray());
-		} catch (ModelException e) {
-			if (DLTKCore.DEBUG) {
-				e.printStackTrace();
-			}
-		}
+		ISourceModuleInfoCache sourceModuleInfoCache = ModelManager
+				.getModelManager().getSourceModuleInfoCache();
+		ISourceModuleInfo mifo = sourceModuleInfoCache.get(module);
+		parser.parseSourceModule(module, mifo);
 	}
 }

Back to the top