Java Code Examples for org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor#accept()

The following examples show how to use org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor#accept() . 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: PureXbaseJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _infer(final Model m, final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) {
  final XBlockExpression e = m.getBlock();
  final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
    EList<JvmMember> _members = it.getMembers();
    final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
      EList<JvmTypeReference> _exceptions = it_1.getExceptions();
      JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Throwable.class);
      this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
      this._jvmTypesBuilder.setBody(it_1, e);
    };
    JvmOperation _method = this._jvmTypesBuilder.toMethod(e, "myMethod", this._jvmTypesBuilder.inferredType(), _function_1);
    this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
  };
  acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(e, this.name(e.eResource())), _function);
}
 
Example 2
Source File: SimpleJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void infer(EObject e, IJvmDeclaredTypeAcceptor acceptor, boolean prelinkingPhase) {
	acceptor.accept(jvmTypesBuilder.toClass(e, "Test"), (Procedure1<JvmGenericType>) (JvmGenericType it) -> {
		it.getMembers().add(jvmTypesBuilder.toMethod(e, "doStuff", references.getTypeForName(String.class, e), (JvmOperation op) -> {
			op.getParameters().add(jvmTypesBuilder.toParameter(e, "s", references.getTypeForName(String.class, e)));
			jvmTypesBuilder.setBody(op, ((XExpression) e));
		}));
	});
}
 
Example 3
Source File: Bug462047LangJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _infer(final Bug462047Element element, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
  String _name = element.getName();
  String _plus = ("CORE." + _name);
  final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
    StringConcatenation _builder = new StringConcatenation();
    JvmGenericType _ref = element.getRef();
    String _qualifiedName = null;
    if (_ref!=null) {
      _qualifiedName=_ref.getQualifiedName();
    }
    _builder.append(_qualifiedName);
    this._jvmTypesBuilder.setDocumentation(it, _builder.toString());
  };
  acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(element, _plus), _function);
}
 
Example 4
Source File: XtendJvmModelInferrer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void inferTypeSceleton(final XtendTypeDeclaration declaration, final IJvmDeclaredTypeAcceptor acceptor, 
		boolean preIndexingPhase, XtendFile xtendFile, List<Runnable> doLater, JvmDeclaredType containerSceleton) { 
	JvmDeclaredType inferredSceleton = doInferTypeSceleton(declaration, acceptor, preIndexingPhase, xtendFile, doLater);
	if(inferredSceleton != null) {
		setNameAndAssociate(xtendFile, declaration, inferredSceleton);
		if(containerSceleton != null)
			containerSceleton.getMembers().add(inferredSceleton);
		acceptor.accept(inferredSceleton);
		for(XtendMember member: declaration.getMembers()) {
			if(member instanceof XtendTypeDeclaration)
				inferTypeSceleton((XtendTypeDeclaration) member, acceptor, preIndexingPhase, xtendFile, doLater, inferredSceleton);
		}
	}
}
 
Example 5
Source File: ContentAssistFragmentTestLangJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * The dispatch method {@code infer} is called for each instance of the
 * given element's type that is contained in a resource.
 * 
 * @param element
 *            the model to create one or more
 *            {@link org.eclipse.xtext.common.types.JvmDeclaredType declared
 *            types} from.
 * @param acceptor
 *            each created
 *            {@link org.eclipse.xtext.common.types.JvmDeclaredType type}
 *            without a container should be passed to the acceptor in order
 *            get attached to the current resource. The acceptor's
 *            {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType)
 *            accept(..)} method takes the constructed empty type for the
 *            pre-indexing phase. This one is further initialized in the
 *            indexing phase using the closure you pass to the returned
 *            {@link org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor.IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
 *            initializeLater(..)}.
 * @param isPreIndexingPhase
 *            whether the method is called in a pre-indexing phase, i.e.
 *            when the global index is not yet fully updated. You must not
 *            rely on linking using the index if isPreIndexingPhase is
 *            <code>true</code>.
 */
protected void _infer(final ContentAssistFragmentTestLanguageRoot element, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
  final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
    EList<JvmMember> _members = it.getMembers();
    final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
      this._jvmTypesBuilder.setBody(it_1, element.getExpression());
    };
    JvmOperation _method = this._jvmTypesBuilder.toMethod(element, "hello", this._typeReferenceBuilder.typeRef(Void.class), _function_1);
    this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
  };
  acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(element, "my.test.MyClass"), _function);
}