org.eclipse.xtext.common.types.access.IJvmTypeProvider Java Examples

The following examples show how to use org.eclipse.xtext.common.types.access.IJvmTypeProvider. 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: SarlFieldBuilderImpl.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Initialize the Ecore element.
 * @param container the container of the SarlField.
 * @param name the name of the SarlField.
 */
public void eInit(XtendTypeDeclaration container, String name, String modifier, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlField == null) {
		this.container = container;
		this.sarlField = SarlFactory.eINSTANCE.createSarlField();
		this.sarlField.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
		this.sarlField.setName(name);
		if (Strings.equal(modifier, "var")
			|| Strings.equal(modifier, "val")) {
			this.sarlField.getModifiers().add(modifier);
		} else {
			throw new IllegalStateException("Invalid modifier");
		}
		container.getMembers().add(this.sarlField);
	}
}
 
Example #2
Source File: JavaSourceLanguageRuntimeModule.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(Resource.Factory.class).to(JavaResource.Factory.class);
	bind(IResourceValidator.class).toInstance(IResourceValidator.NULL);
	bind(IGenerator.class).to(IGenerator.NullGenerator.class);
	bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
	bind(IResourceServiceProvider.class).to(JavaResourceServiceProvider.class);
	bind(IContainer.Manager.class).to(SimpleResourceDescriptionsBasedContainerManager.class);
	bind(IResourceDescription.Manager.class).to(JavaResourceDescriptionManager.class);
	bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
	bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("java");
	bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME))
			.toInstance("org.eclipse.xtext.java.Java");
	bind(IJvmTypeProvider.Factory.class).to(ClasspathTypeProviderFactory.class);
	bind(ClassLoader.class).toInstance(JavaSourceLanguageRuntimeModule.class.getClassLoader());
	bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.GenericUnloader.class);
	bind(IResourceDescriptionsProvider.class)
			.toInstance((ResourceSet rs) -> ChunkedResourceDescriptions.findInEmfObject(rs));
}
 
Example #3
Source File: JavaLinkingTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testGetXtendClassAsArray() throws Exception {
	IFile xtendFile = testHelper.createFile(
			"test/XtendClass", 
			"package test\nclass XtendClass {}");
	waitForBuild();

	assertNumberOfMarkers(xtendFile, 0);
	
	ResourceSet resourceSet = resourceSetProvider.get(testHelper.getProject());
	IJvmTypeProvider jvmTypeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
	JvmType xtendArrayType = jvmTypeProvider.findTypeByName("test.XtendClass[][]");
	assertNotNull(xtendArrayType);
	assertTrue(xtendArrayType instanceof JvmArrayType);
	assertEquals("test.XtendClass[][]", xtendArrayType.getQualifiedName());
	Resource xtendResource = xtendArrayType.eResource();
	assertEquals("platform:/resource" + xtendFile.getFullPath(), xtendResource.getURI().toString());
}
 
Example #4
Source File: SarlConstructorBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element.
 * @param container the container of the SarlConstructor.
 */
public void eInit(XtendTypeDeclaration container, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlConstructor == null) {
		this.container = container;
		this.sarlConstructor = SarlFactory.eINSTANCE.createSarlConstructor();
		this.sarlConstructor.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
		container.getMembers().add(this.sarlConstructor);
	}
}
 
Example #5
Source File: SarlArtifactBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlArtifact == null) {
		this.sarlArtifact = SarlFactory.eINSTANCE.createSarlArtifact();
		script.getXtendTypes().add(this.sarlArtifact);
		this.sarlArtifact.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlArtifact.setName(name);
		}
	}
}
 
Example #6
Source File: SarlInterfaceBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlInterface == null) {
		this.container = script;
		this.sarlInterface = SarlFactory.eINSTANCE.createSarlInterface();
		script.getXtendTypes().add(this.sarlInterface);
		this.sarlInterface.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlInterface.setName(name);
		}
	}
}
 
Example #7
Source File: NewSarlInterfaceWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 2);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlInterfaceBuilder inter = scriptBuilder.addSarlInterface(getTypeName());
	for (final String type : getSuperInterfaces()) {
		inter.addExtends(type);
	}
	inter.setDocumentation(comment);
	mon.worked(1);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #8
Source File: SarlCapacityBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlCapacity == null) {
		this.sarlCapacity = SarlFactory.eINSTANCE.createSarlCapacity();
		script.getXtendTypes().add(this.sarlCapacity);
		this.sarlCapacity.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlCapacity.setName(name);
		}
	}
}
 
Example #9
Source File: NewSarlSkillWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("all")
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlSkillBuilder skill = scriptBuilder.addSarlSkill(getTypeName());
	skill.setExtends(getSuperClass());
	for (final String type : getSuperInterfaces()) {
		skill.addImplements(type);
	}
	skill.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLLifecycleFunctionTemplates(
			"skill",
			(it) -> skill.addSarlAction(it),
			(it) -> skill.addSarlCapacityUses(it));
	mon.worked(2);
	createInheritedMembers(
			Skill.class.getCanonicalName(),
			skill.getSarlSkill(),
			true,
			() -> skill.addSarlConstructor(),
			(name) -> skill.addOverrideSarlAction(name),
			getSuperClass(),
			getSuperInterfaces());
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #10
Source File: SarlClassBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inner type declaration.
 */
public void eInit(XtendTypeDeclaration container, String name, IJvmTypeProvider context) {
	if (this.sarlClass == null) {
		this.container = container;
		this.sarlClass = SarlFactory.eINSTANCE.createSarlClass();
		container.getMembers().add(this.sarlClass);
		if (!Strings.isEmpty(name)) {
			this.sarlClass.setName(name);
		}
	}
}
 
Example #11
Source File: NewSarlBehaviorWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlBehaviorBuilder behavior = scriptBuilder.addSarlBehavior(getTypeName());
	behavior.setExtends(getSuperClass());
	behavior.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLEventTemplates(Messages.NewSarlBehaviorWizardPage_4,
		name -> behavior.addSarlBehaviorUnit(name),
		name -> behavior.addSarlCapacityUses(name));
	mon.worked(2);
	if (behavior.getSarlBehavior().getExtends() != null) {
		createInheritedMembers(
			Behavior.class.getCanonicalName(),
			behavior.getSarlBehavior(),
			true,
			() -> behavior.addSarlConstructor(),
			name -> behavior.addOverrideSarlAction(name),
			getSuperClass());
	}
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #12
Source File: SarlEnumerationBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlEnumeration == null) {
		this.container = script;
		this.sarlEnumeration = SarlFactory.eINSTANCE.createSarlEnumeration();
		script.getXtendTypes().add(this.sarlEnumeration);
		this.sarlEnumeration.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlEnumeration.setName(name);
		}
	}
}
 
Example #13
Source File: AbstractXbaseContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected final XtextResourceSet getResourceSet() {
	XtextResourceSet resourceSet = get(XtextResourceSet.class);
	IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
	typeProviderFactory.findOrCreateTypeProvider(resourceSet);
	resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
	return resourceSet;
}
 
Example #14
Source File: AbstractTypeScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected AbstractTypeScope(IJvmTypeProvider typeProvider, IQualifiedNameConverter qualifiedNameConverter,
		Predicate<IEObjectDescription> filter) {
	super(IScope.NULLSCOPE, false);
	this.typeProvider = typeProvider;
	this.qualifiedNameConverter = qualifiedNameConverter;
	this.filter = filter;
}
 
Example #15
Source File: SarlClassBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlClass == null) {
		this.container = script;
		this.sarlClass = SarlFactory.eINSTANCE.createSarlClass();
		script.getXtendTypes().add(this.sarlClass);
		this.sarlClass.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlClass.setName(name);
		}
	}
}
 
Example #16
Source File: SarlSpaceBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlSpace == null) {
		this.sarlSpace = SarlFactory.eINSTANCE.createSarlSpace();
		script.getXtendTypes().add(this.sarlSpace);
		this.sarlSpace.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlSpace.setName(name);
		}
	}
}
 
Example #17
Source File: BlockExpressionBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create the XBlockExpression.
 */
public void eInit(IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.block == null) {
		this.block = XbaseFactory.eINSTANCE.createXBlockExpression();
	}
}
 
Example #18
Source File: JvmTypeReferences.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public JvmParameterizedTypeReferenceConstructor(JvmType jvmType, TypesFactory typesFactory, IJvmTypeProvider typesProvider, JvmParameterizedTypeReferenceConstructor parent) {
	this.reference = typesFactory.createJvmParameterizedTypeReference();
	reference.setType(jvmType);
	this.typesFactory = typesFactory;
	this.typesProvider = typesProvider;
	this.parent  = parent;
}
 
Example #19
Source File: SharedCommonTypesModule.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void configure(Binder binder) {
	binder.bind(IEObjectHoverProvider.class).to(JdtHoverProvider.class);
	binder.bind(IEObjectHoverDocumentationProvider.class).to(JdtHoverDocumentationProvider.class);
	binder.bind(IResourceServiceProvider.class).to(SharedCommonTypesResourceServiceProvider.class);
	binder.bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
	binder.bindConstant().annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).to("java");

	binder.bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
	binder.bind(ICopyQualifiedNameService.class).to(DefaultCopyQualifiedNameService.class);
	binder.bind(IJvmTypeProvider.Factory.class).to(JdtTypeProviderFactory.class);
	binder.bind(IRenameRefactoringProvider.class).to(DefaultRenameRefactoringProvider.class);
	binder.bind(AbstractRenameProcessor.class).to(JvmMemberRenameProcessor.class);
	binder.bind(IRenameStrategy.Provider.class).to(JvmMemberRenameStrategy.Provider.class);
	binder.bind(RefactoringResourceSetProvider.class).to(JvmRefactoringResourceSetProvider.class);
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("Java");

	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE))
			.to(LiveShadowedResourceDescriptions.class);
	binder.bind(IResourceDescriptions.class)
			.annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE))
			.to(CurrentDescriptions.ResourceSetAware.class);
	binder.bind(IResourceDescriptions.class)
			.annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS))
			.to(IBuilderState.class);

	binder.bind(IWorkspaceRoot.class).toInstance(ResourcesPlugin.getWorkspace().getRoot());
	binder.bind(ITraceForStorageProvider.class).to(TraceForStorageProvider.class);

	binder.bind(IReferenceUpdater.class).to(NullReferenceUpdater.class);
}
 
Example #20
Source File: JvmTypeReferences.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public JvmParameterizedTypeReferenceConstructor(JvmType jvmType, TypesFactory typesFactory, IJvmTypeProvider typesProvider, JvmParameterizedTypeReferenceConstructor parent) {
	this.reference = typesFactory.createJvmParameterizedTypeReference();
	reference.setType(jvmType);
	this.typesFactory = typesFactory;
	this.typesProvider = typesProvider;
	this.parent  = parent;
}
 
Example #21
Source File: CodeBuilderFactory.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create the factory for a Sarl script.
 * @param packageName the name of the package of the script.
 * @param resource the resource in which the script is created.
 * @param context the context for type resolution.
 * @return the factory.
 */
@Pure
public IScriptBuilder createScript(String packageName, Resource resource, IJvmTypeProvider context) {
	IScriptBuilder builder = getProvider(IScriptBuilder.class).get();
	builder.eInit(resource, packageName, context);
	return builder;
}
 
Example #22
Source File: SarlSkillBuilderImpl.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	setTypeResolutionContext(context);
	if (this.sarlSkill == null) {
		this.sarlSkill = SarlFactory.eINSTANCE.createSarlSkill();
		script.getXtendTypes().add(this.sarlSkill);
		this.sarlSkill.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
		if (!Strings.isEmpty(name)) {
			this.sarlSkill.setName(name);
		}
	}
}
 
Example #23
Source File: AbstractXbaseContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected final XtextResourceSet getResourceSet() {
	XtextResourceSet resourceSet = get(XtextResourceSet.class);
	IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
	typeProviderFactory.findOrCreateTypeProvider(resourceSet);
	resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
	return resourceSet;
}
 
Example #24
Source File: AbstractXtendContentAssistBugTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected void initializeTypeProvider(XtextResource result) {
	XtextResourceSet resourceSet = (XtextResourceSet) result.getResourceSet();
	IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
	typeProviderFactory.findOrCreateTypeProvider(resourceSet);
	resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
}
 
Example #25
Source File: LocalResourceFilteringTypeScope.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IJvmTypeProvider getTypeProvider() {
	return delegate.getTypeProvider();
}
 
Example #26
Source File: SarlEnumerationSourceAppender.java    From sarl with Apache License 2.0 4 votes vote down vote up
public IJvmTypeProvider getTypeResolutionContext() {
	return this.builder.getTypeResolutionContext();
}
 
Example #27
Source File: SarlAnnotationTypeSourceAppender.java    From sarl with Apache License 2.0 4 votes vote down vote up
public IJvmTypeProvider getTypeResolutionContext() {
	return this.builder.getTypeResolutionContext();
}
 
Example #28
Source File: SarlEventSourceAppender.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Initialize the Ecore element when inside a script.
 */
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
	this.builder.eInit(script, name, context);
}
 
Example #29
Source File: TypeParameterSourceAppender.java    From sarl with Apache License 2.0 4 votes vote down vote up
public IJvmTypeProvider getTypeResolutionContext() {
	return this.builder.getTypeResolutionContext();
}
 
Example #30
Source File: FormalParameterSourceAppender.java    From sarl with Apache License 2.0 4 votes vote down vote up
public IJvmTypeProvider getTypeResolutionContext() {
	return this.builder.getTypeResolutionContext();
}