Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to get Get JavaScript" type resolution" in script blocks of HTML/JSP files
How to get Get JavaScript" type resolution" in script blocks of HTML/JSP files [message #512667] Fri, 05 February 2010 22:53 Go to next message
Eclipse UserFriend
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 -->
Re: How to get Get JavaScript" type resolution" in script blocks of HTML/JSP files [message #512819 is a reply to message #512667] Mon, 08 February 2010 02:17 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

On 2/5/2010 5:53 PM, adam taylor wrote:
> 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?

It's going to require fixing a limitation in the way content assist is
contributed to the HTML editor,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=258999 .

--
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:XML Catalog User entries ignored by embedded tomcat
Next Topic:Customize publishing to the server
Goto Forum:
  


Current Time: Sat Apr 20 01:39:40 GMT 2024

Powered by FUDForum. Page generated in 0.02664 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top