|
Re: Is there code example for inferring a method? [message #529952 is a reply to message #529040] |
Tue, 27 April 2010 19:54 |
|
On 4/22/2010 1:30 PM, Eugene Ostroukhov wrote:
> I'm trying to implement content assist for PhoneGap. This library adds
> several properties to the navigator object and I need to make them
> available in the pop-up.
>
> The PhoneGap JavaScript file is copied to the project. I can see classes
> but the properties are not there. Navigator class is declared in the
> Browser library that is on the project include path.
>
> I tried to implement InferEngine - but I don't see a way to add those
> properties. Is there some article/code example?
>
> I would really appreciate any pointers - i.e. APIs to look at, JSDT
> implementation classes.
The best example is the default implementation in
org.eclipse.wst.jsdt.core.infer.InferEngine.
You would go about adding your properties by first adding the Navigator
type to the CompilationUnitDeclaration [part of the inference code being
provisional is that the relied upon CompilationUnitDeclaration class is
not itself yet correct API] and then adding your properties that that
InferredType object using the methods on
org.eclipse.wst.jsdt.core.infer.InferredType itself. The indexer and
content assist will take care of merging the properties when presented
to the user for content assist and search. You will want to take care
that your InferrenceProvider#applysTo() returns MAYBE_THIS only for
files where the PhoneGap library is present.
Are the properties on your classes declared in an unusual way so that
they're not picked up as expected?
--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
|
|
Re: Is there code example for inferring a method? [message #530502 is a reply to message #530102] |
Thu, 29 April 2010 20:23 |
|
On 4/28/2010 9:38 AM, Eugene Ostroukhov wrote:
> I added following code to my infer engine:
....
> return addType(NAVIGATOR_TYPE);
....
> But still - there is nothing in CA pop-up.
The SourceElementParser won't transfer the InferredType's properties
into the Index unless you mark it's isDefined field as true.
--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
|
Re: Is there code example for inferring a method? [message #531045 is a reply to message #530904] |
Mon, 03 May 2010 13:49 |
|
Eugene Ostroukhov wrote:
> The code gets executed - in the debugger I can see as the type is built:
> class Navigator extends Object{
> Accelerometer accelerometer;
> Camera camera;
> Contacts contacts;
> ?? device;
> Geolocation geolocation;
> Map map;
> }
>
> I found one difference - if I add isInferred=true then "camera" and
> other PhoneGap contributions appear twice in the pop-up.
Generally you wouldn't want to add properties to every file that refers
to the navigator, only to files where a type you are interested in is
already being defined. One technique I've seen is to override the
addType() method to add specific properties from a white-list of type
names. Don't forget that any InferredAttributes you add should
themselves have their types set, and those inferred types also added,
although not necessarily isDefinition=true, to the
CompilationUnitDeclaration as needed.
--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
Powered by
FUDForum. Page generated in 0.04935 seconds