Community
Participate
Working Groups
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.
Paul, add you to this enhancement.
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.
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?
One more questions, Could we use EnumerationManager to store those system enumerations? where addSystemEntry is invoked?
Created attachment 211477 [details] Patch for this enhancement v1
fixed,patch was tony.
(In reply to comment #7) > fixed,patch was reviewed by tony.
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.
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?
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
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
close