Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366507

Summary: Content Assist need to get Enumeration from environment. NOT hardcoding
Product: z_Archived Reporter: Xiao Bin Chen <xiaobinc>
Component: EDTAssignee: Xiao Bin Chen <xiaobinc>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P1 CC: pharmon, smythew, svihovec
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch for this enhancement v1 xiaobinc: iplog+

Description Xiao Bin Chen CLA 2011-12-13 04:58:55 EST

    
Comment 1 Xiao Bin Chen CLA 2012-02-22 03:23:05 EST
Hi Brian & Paul,

To do this enhancement, I have two questions to ask.

1>What kind of Enumeration defined in system package should be listed in Content Assist dialog and what should not be listed?

2>I notice that there is a  EnumerationManager enumerationManager defined in SystemEnviroment. But those system Enumeration types can never add to the enumerationManager. 

Because this function always be false.(Before add to EnumerationManager, this should be true)

private boolean enumerationIsImplicitlyUsed(IPartBinding part) {
	return getImplicitlyUsedEnumerationNames().contains(part.getName());
}

I think might be some reason for this. 

So, PAUL,could you give me some suggestion on How to get those system Enumeration types from SystemEnvironment or other place?

Thanks
xiaobin.
Comment 2 Xiao Bin Chen CLA 2012-02-22 03:23:49 EST
Paul, add you to this enhancement.
Comment 3 Paul Harmon CLA 2012-02-22 09:00:12 EST
Could you include the list of hardcoded enumerations that appear in content assist today?

Also, the check that you refer to is not always false. It evalutates to true for the list of enumerations in EDTCompiler.getImplicitlyUsedEnumerations().

The SystemEvironment already caches all the system parts in a hashmap. We could make the getter for this map (getSystemPackages()) public. This would enable the content assist code to iterate through all of the system parts and identify all Enumerations.

Alternatively, there is already an API in PartEnvironment named getAllKeysFromPkg(). This will return a list of environment keys representing all parts in a given environment. So, you could use this api to return the key (includes package name and part name) for all parts in the SystemEnvironment:

new PartEnvironment(sytemEnvironment.getIREnvironment).getAllKeysFromPkg("", true);

You could then query the systemEnvironment (getPartBinding()) for each part returned by this query to determine the list of Enumerations.
Comment 4 Xiao Bin Chen CLA 2012-02-22 09:40:47 EST
Hi Paul,

Currently ContentAssist get EGL system Enumeration from EGLEnumeration.
And the list is 

"AlignKind";
"CallingConventionKind";
"CaseFormatKind";
"ColorKind";
"DeviceTypeKind";
"DisplayUseKind";
"EncodingKind";
"EventKind";
"ExportFormat";
"PCBKind";
"SignKind";
...
which were hard-coding in the EGLEnumeration class.
Some of those maybe invalid in EDT.


Thanks providing the way to get Enumerations from system enviroment.

One question is whether those Enumerations from system enviroment could all be listed in Content Assist? Is there a rule or something to determine it?

Also could we use a map to store those Enumerations instead of iterate this map every time we invoke Content Assist?
Comment 5 Xiao Bin Chen CLA 2012-02-22 09:57:54 EST
One more questions,
Could we use EnumerationManager to store those system enumerations? where addSystemEntry is invoked?
Comment 6 Xiao Bin Chen CLA 2012-02-23 04:48:13 EST
Created attachment 211477 [details]
Patch for this enhancement v1
Comment 7 Xiao Bin Chen CLA 2012-02-26 21:32:16 EST
fixed,patch was tony.
Comment 8 Xiao Bin Chen CLA 2012-02-26 22:18:29 EST
(In reply to comment #7)
> fixed,patch was reviewed by tony.
Comment 9 Paul Harmon CLA 2012-02-27 08:15:01 EST
This change is fine for now. In the long term, we need to come up with a better solution. The problem with the current approach is that extra processing is being done when the system environment is being set up. This caching of enumeration/libraries/externalTypes is only really necessary when running in the IDE. One possible approach would be to register ContentAssist as a SystemEnvironment listener. It would receive notification whenever a part was read from the EGLARs on the system path and could cache whatever information it needed.
Comment 10 Xiao Bin Chen CLA 2012-02-29 00:14:42 EST
Hi Paul,
I think you are right. Does compiler or other component support this kind of listener currently? Could you give some snippet or doc on how to use it?
Comment 11 Paul Harmon CLA 2012-02-29 08:14:29 EST
Listeners are used in a lot of places throughout EGL code. For instance, the EGLEditor sets up a listener to be notified of selection changes in the outline view.

The general idea would work like this:

We would define an interface:

Interface ISystemPartListener {
   public void partAdded(IPartBinding part, ISystemEnvironment env, ICompiler Compiler);
end

In SystemEnvironment, we would  create a new static method, such as:
public static addSystemPartListener(ISystemPartListener listener) {
    listeners.add(listener);
end

Content assist would then create a class that implements ISystemPartListener and register this listener with the SystemEnvironment (via SystemEnvironment.addSystemPartListener). This would probably be done in the statup method of the plugin class in the plugin that holds the content assist code.

Whenever a part is added to the systemEnvironment, the systemEnvironment would notify all of it's listeners of the new part. The listener would be informed of the part, the sytem environement that loaded the part, and the compiler that created the systemEnvironment. Content Assist's listener could then use this information to build up the indexing information it needs.

Paul
Comment 12 Xiao Bin Chen CLA 2012-02-29 20:36:22 EST
I have opened another enhancement to implement the listener for IDE tools like CA, or others.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=372929
Comment 13 Lisa Lasher CLA 2012-03-30 18:31:57 EDT
close