Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[imp-dev] FYI: New support for the structured comparison viewer

Hi All,

I just committed a few changes to add a draft implementation of a new IMP language service: a "Compare Node Identifier", which enables the structured compare viewer on source files in IMP-based IDEs.

I'd like to solicit comments on the shape of the new interface, as well as on the overall approach.

That said, I'm actually fairly pleased with how simply this all worked out.

==================================================================================

Details:

The structured compare viewer basically needs 3 things:

 1) a tree representing the source file's contents
 2) a label provider
 3) a way to identify the unique entities in a given source file (e.g., functions, types, methods, etc.), so that it knows what chunks of source text to compare in detail

For (1), the treeModelBuilder extension point already provides what's necessary.
For (2), the labelProvider already provides what's necessary.
For (3), we needed something new. I added a simple interface ICompareNodeIdentifier that looks like this:

public interface ICompareNodeIdentifier extends ILanguageService {
    /**
     * Returns a "type code" for the given entity, which generally indicates the
     * kind of entity it is, and thus serves to distinguish it from other entities
     * that might have the same ID. The implementation of this interface is free
     * to use any set of "type codes" that it wishes.
     */
    public int getTypeCode(Object o);

    /**
     * Returns an ID for the given entity which is unique within the given file,
     * and which can thus be used to identify entities across two versions of the
     * same source file. The implementation of this interface is free to use any
     * set/format for IDs that it wishes.
     */
    public String getID(Object o);
}

This is the only additional language-specific code needed to enable the structured comparison view for a given language. The rest is in services most IDEs already probably provide, and in the IMP runtime itself.

For example ICompareNodeIdentifier implementations, see the CompareNodeIdentifier classes in the LPG and prefspecs IDEs.

Cheers,
 - Bob


Back to the top