org.eclipse.xtext.LanguageInfo Java Examples

The following examples show how to use org.eclipse.xtext.LanguageInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TraceAsSmapInstaller.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected String getStratumName(final SourceRelativeURI path) {
	IResourceServiceProvider provider = serviceProviderRegistry.getResourceServiceProvider(path.getURI());
	if (provider == null) {
		// it might happen that trace data is in the workspace but the corresponding language is not installed.
		// we use the file extension then.
		String result = path.getURI().fileExtension();
		if (result != null) {
			return result;
		}
		return "unknown";
	}
	final LanguageInfo languageInfo = provider.get(LanguageInfo.class);
	String name = languageInfo.getShortName();
	return name;
}
 
Example #2
Source File: DirtyStateEditorSupport.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
protected IResourceDescription.Manager getResourceDescriptionManagerIfOwnLanguage(XtextResource resource) {
	IResourceServiceProvider rsp = resourceServiceProviderRegistry.getResourceServiceProvider(resource.getURI());
	if (rsp == null)
		return null;
	String uriLanguageName = rsp.get(LanguageInfo.class).getLanguageName();
	String resourceLanguageName = resource.getLanguageName();
	if (!uriLanguageName.equals(resourceLanguageName))
		return null;
	return getResourceDescriptionManager(resource.getURI());
}
 
Example #3
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Before
@BeforeEach
public void setup() {
  final Injector injector = Guice.createInjector(this.getServerModule());
  injector.injectMembers(this);
  final Object resourceServiceProvider = this.resourceServerProviderRegistry.getExtensionToFactoryMap().get(this.fileExtension);
  if ((resourceServiceProvider instanceof IResourceServiceProvider)) {
    this.languageInfo = ((IResourceServiceProvider)resourceServiceProvider).<LanguageInfo>get(LanguageInfo.class);
  }
  this.languageServer.connect(ServiceEndpoints.toServiceObject(this, this.getLanguageClientClass()));
  this.languageServer.supportedMethods();
  File _absoluteFile = new File("").getAbsoluteFile();
  File _file = new File(_absoluteFile, AbstractLanguageServerTest.TEST_PROJECT_PATH);
  this.root = _file;
}
 
Example #4
Source File: DirtyStateEditorSupportTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	document = this;
	resourceSet = new ResourceSetImpl();
	resourceURI = URI.createURI("scheme://foo");
	resource = new XtextResource(resourceURI);
	resource.setLanguageName("FooLanguage");
	final DefaultResourceServiceProvider resourceServiceProvider = new DefaultResourceServiceProvider() {
		@Override
		public org.eclipse.xtext.resource.IResourceDescription.Manager getResourceDescriptionManager() {
			return DirtyStateEditorSupportTest.this;
		}
		
		@SuppressWarnings("unchecked")
		@Override
		public <T> T get(Class<T> t) {
			if(DirtyStateResourceDescription.Manager.class.isAssignableFrom(t)) 
				return (T) new DirtyStateResourceDescription.Manager(DirtyStateEditorSupportTest.this);
			if(LanguageInfo.class.isAssignableFrom(t))
				return (T) new LanguageInfo("FooLanguage");
			return super.get(t);
		}
	};
	ResourceServiceProviderRegistryImpl registry = new ResourceServiceProviderRegistryImpl() {
		@Override
		public IResourceServiceProvider getResourceServiceProvider(URI uri) {
			return resourceServiceProvider;
		}
	};
	resource.setResourceServiceProvider(resourceServiceProvider);
	resourceSet.getResources().add(resource);
	dirtyStateSupport = new DirtyStateEditorSupport();
	dirtyStateSupport.setConcurrentEditingWarningDialog(this);
	dirtyStateSupport.setResourceDescriptions(this);
	dirtyStateManager = new DirtyStateManager();
	stateChangeEventBroker = new StateChangeEventBroker();
	dirtyStateManager.addListener(stateChangeEventBroker);
	dirtyStateSupport.setDirtyStateManager(dirtyStateManager);
	dirtyStateSupport.setStateChangeEventBroker(stateChangeEventBroker);
	dirtyResource = new DocumentBasedDirtyResource();
	dirtyStateSupport.setDirtyResource(dirtyResource);
	dirtyStateSupport.setResourceServiceProviderRegistry(registry);
	ignoreConcurrentEditing = Lists.newLinkedList();
	exportedObjects = Collections.emptyList();
}
 
Example #5
Source File: LanguageAwareMarkerTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public void initialize(LanguageInfo languageInfo, AbstractUIPlugin uiPlugin) {
	String bundleName = uiPlugin.getBundle().getSymbolicName();
	String languageName = languageInfo.getShortName().toLowerCase();
	setMarkerTypes(bundleName + "." + languageName);
}
 
Example #6
Source File: LanguageAwareTaskMarkerTypeProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public void initialize(LanguageInfo languageInfo, AbstractUIPlugin uiPlugin) {
	String bundleName = uiPlugin.getBundle().getSymbolicName();
	String languageName = languageInfo.getShortName().toLowerCase();
	taskMarkerType = bundleName + "." + languageName + ".task";
}
 
Example #7
Source File: XtextEditorInfo.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public XtextEditorInfo(LanguageInfo languageInfo) {
	this.languageInfo = languageInfo;
}
 
Example #8
Source File: XtextEditorInfo.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public LanguageInfo getLanguageInfo() {
	return languageInfo;
}
 
Example #9
Source File: AbstractLocationInResource.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public LanguageInfo getLanguage() {
	LanguageInfo result = trace.findLanguage(getAbsoluteResourceURI());
	return result;
}
 
Example #10
Source File: AbstractTrace.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public LanguageInfo getLocalLanguage() {
	return findLanguage(getLocalURI());
}
 
Example #11
Source File: AbstractTrace.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected LanguageInfo findLanguage(AbstractURIWrapper uri) {
	return getService(uri, LanguageInfo.class);
}
 
Example #12
Source File: ILocationInResource.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * @return the language that this resource belongs to. May be <code>null</code>.
 */
LanguageInfo getLanguage();
 
Example #13
Source File: ITrace.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the language that is associated with the local resource. May be <code>null</code>
 * if the artifact does not have an associated Xtext language, e.g. for html or java files.
 * 
 * @return the language that is associated with the local resource. May be <code>null</code>.
 */
LanguageInfo getLocalLanguage();