How to get Get JavaScript" type resolution" in script blocks of HTML/JSP files [message #512667] |
Fri, 05 February 2010 17:53  |
Eclipse User |
|
|
|
Originally posted by: adataylo.cisco.com
I'm trying to workaround this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298751
I'm using the "org.eclipse.wst.sse.ui.editorConfiguration" extension pt.
with a
target of "org.eclipse.wst.html.SCRIPT" to get JavaScript completions into
script blocks of the HTML and JSP editors. However when this approach
is used
I don't have access to any of the "type resolution" information that I
do when
using the
"org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer" extension pt.
Is there any way to get this information? Perhaps in the example below
there is
a better way of getting the IJavaScriptUnit?
More details:
JavaScript:
var x = new MyFancyObject();
x. <-- Ctrl + Space
In the JavaScript editor using the
"org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer" extension I can
do the
following:
JavaContentAssistInvocationContext javaContext =
(JavaContentAssistInvocationContext) context;
IJavaScriptUnit unit = javaContext.getCompilationUnit();
SourceField field = (SourceField)unit.getField("x");
SourceFieldElementInfo info =
(SourceFieldElementInfo)field.getElementInfo();
char[] name = info.getTypeName();
String type = new String(name);
<-- type is now equal to "MyFancyObject" -->
In the HTML editor using the "org.eclipse.wst.sse.ui.editorConfiguration" I
first need to find a way of getting an IJavaScriptUnit:
IDOMModel xmlModel = (IDOMModel) StructuredModelManager.getModelManager()
.getExistingModelForRead(viewer.getDocument());
IDOMDocument xmlDoc = xmlModel.getDocument();
JsTranslationAdapter fTranslationAdapter = (JsTranslationAdapter) xmlDoc
.getAdapterFor(IJsTranslation.class);
IJsTranslation translation = fTranslationAdapter.getJsTranslation(true);
IJavaScriptUnit unit = translation.getCompilationUnit();
SourceField field = (SourceField)unit.getField("x");
SourceFieldElementInfo info =
(SourceFieldElementInfo)field.getElementInfo();
char[] name = info.getTypeName();
<-- name is now equal to null -->
|
|
|
|
Powered by
FUDForum. Page generated in 0.04385 seconds