Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339637 - Provide a language id constant
Summary: Provide a language id constant
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 01:08 EST by Ed Willink CLA
Modified: 2012-04-03 02:19 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2011-03-11 01:08:26 EST
The language name such as

"org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL"

is a long fragile string.

Applications attempting to instantiate Xtext editors need to use this string, but there is no global constant that can be referenced from Java.

Suggest that the AbstractXXXRuntime provide a LANGUAGE_ID constant.
Comment 1 Sebastian Zarnekow CLA 2012-04-02 16:20:20 EDT
see org.eclipse.xtext.LanguageInfo.getLanguageName() and the generated activator in the UI plugin. Is that sufficient for your use case?
Comment 2 Knut Wannheden CLA 2012-04-02 17:06:34 EDT
I've also come across this need a few times. Neither LanguageInfo nor the generator UI activator is helpful when requiring this information in code of another plug-in. Further I think it would be great if we could use the language ID when accessing the IResourceServiceProvider.Registry.
Comment 3 Ed Willink CLA 2012-04-03 02:19:10 EDT
(In reply to comment #1)
> see org.eclipse.xtext.LanguageInfo.getLanguageName() and the generated
> activator in the UI plugin. Is that sufficient for your use case?

Thanks, these are helpful but not as helpful as they could be:

The long cryptic constant ORG_ECLIPSE_OCL_EXAMPLES_XTEXT_OCLSTDLIB_OCLSTDLIB ensures that spelling errors can be compile-time failures, but a normalised name such as LANGUAGE_ID would be easier to use. Also the name is in an internal plugin.

My specific use case is for activation of an editor in an embedded context where I do

Injector injector = XtextConsolePlugin.getInstance().getInjector(EssentialOCLPlugin.LANGUAGE_ID);
Composite editorComposite = client; //new Composite(client, SWT.NULL);
editor = new EmbeddedXtextEditor(editorComposite, injector, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);

to pass the correct injector to the embedded editor.

I don't appear to require the name in the non-ui plugin, so I can put a static method in XtextConsolePlugin to exploit the new constant. I suspect that there may be multi-grammar parsing applications that may benefit from the name in the non-ui plugin so I think my original suggestion is still worth doing.