We use (Antlr4ide) to generate .java from .g4(antlr) files.
My question is there a way to indicate in eclipse that these .java files are generated files, and maybe also show what was the file they were generated from. I checked the code of antlride and it seems currently it is not supported, so i want to add it.
I Checked the IFile description in Eclipse documentation but I don't find any useful procedure. Do you know where can I find some plugin or class for it.
Thx.
You can set a file to be 'derived' to indicate it has been generated.
IFile file = ... your IFile
file.setDerived(true, progressMonitor);
Note: Some source control systems will ignore derived resources and not check them in.
The derived state is shown in the 'Resource' tab of the file 'Properties' dialog.
You could use the IFile
/IResource
setPersistentPropery
method to set a persistent property on the file containing information about what generated the file. However there is no UI to show these values so you would have to write something (such as a PropertyPage
) to display this.
You can use the org.eclipse.ui.decorators
extension point to add decorations to various views (such as the Package Explorer).
<extension point="org.eclipse.ui.decorators">
<decorator
id="com.xyz.lightweight.decorator"
label="XYZ Lightweight Decorator"
state="false"
class="com.xyz.LightweightDecoratorContributor"
lightweight="true" >
<enablement>
<objectClass name="org.eclipse.core.resources.IResource"/>
</enablement>
</decorator>
</extension>
For the decorator you write a class implementing ILightweightLabelDecorator
which can add text and / or image overlays, see the Eclipse help for more details. You will have to have some way for the decorator to decide if the file has been generated, perhaps using persistent properties.