org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor Java Examples

The following examples show how to use org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor. 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: PureXbaseJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public void infer(final EObject m, final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) {
  if (m instanceof Model) {
    _infer((Model)m, acceptor, prelinkingPhase);
    return;
  } else if (m != null) {
    _infer(m, acceptor, prelinkingPhase);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(m, acceptor, prelinkingPhase).toString());
  }
}
 
Example #3
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 #4
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 #5
Source File: Bug462047LangJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public void infer(final EObject element, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
  if (element instanceof Bug462047Element) {
    _infer((Bug462047Element)element, acceptor, isPreIndexingPhase);
    return;
  } else if (element != null) {
    _infer(element, acceptor, isPreIndexingPhase);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(element, acceptor, isPreIndexingPhase).toString());
  }
}
 
Example #6
Source File: ContentAssistFragmentTestLangJvmModelInferrer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public void infer(final EObject element, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
  if (element instanceof ContentAssistFragmentTestLanguageRoot) {
    _infer((ContentAssistFragmentTestLanguageRoot)element, acceptor, isPreIndexingPhase);
    return;
  } else if (element != null) {
    _infer(element, acceptor, isPreIndexingPhase);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(element, acceptor, isPreIndexingPhase).toString());
  }
}
 
Example #7
Source File: DomainmodelJvmModelInferrer.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void infer(final EObject entity, final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) {
  if (entity instanceof Entity) {
    _infer((Entity)entity, acceptor, prelinkingPhase);
    return;
  } else if (entity != null) {
    _infer(entity, acceptor, prelinkingPhase);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(entity, acceptor, prelinkingPhase).toString());
  }
}
 
Example #8
Source File: RuleEngineJvmModelInferrer.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void infer(final EObject element, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
  if (element instanceof Model) {
    _infer((Model)element, acceptor, isPreIndexingPhase);
    return;
  } else if (element != null) {
    _infer(element, acceptor, isPreIndexingPhase);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(element, acceptor, isPreIndexingPhase).toString());
  }
}
 
Example #9
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 #10
Source File: AnnotationProcessor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * gets called from Xtend compiler, during "model inference", i.e. translation of Xtend AST to Java AST
 */
public Object indexingPhase(final ActiveAnnotationContext ctx, final IJvmDeclaredTypeAcceptor acceptor, final CancelIndicator monitor) {
  Object _xblockexpression = null;
  {
    final Stopwatches.StoppedTask task = Stopwatches.forTask("[macros] indexingPhase (AnnotationProcessor.indexingPhase)");
    task.start();
    Object _xtrycatchfinallyexpression = null;
    try {
      Object _switchResult = null;
      Object _processorInstance = ctx.getProcessorInstance();
      final Object processor = _processorInstance;
      boolean _matched = false;
      if (processor instanceof RegisterGlobalsParticipant) {
        _matched=true;
        Object _xblockexpression_1 = null;
        {
          final RegisterGlobalsContextImpl registerGlobalsCtx = this.registerGlobalsContextProvider.get();
          registerGlobalsCtx.setAcceptor(acceptor);
          registerGlobalsCtx.setCompilationUnit(ctx.getCompilationUnit());
          final Runnable _function = () -> {
            final Function1<XtendAnnotationTarget, Declaration> _function_1 = (XtendAnnotationTarget it) -> {
              Declaration _switchResult_1 = null;
              boolean _matched_1 = false;
              if (it instanceof XtendMember) {
                _matched_1=true;
                _switchResult_1 = ctx.getCompilationUnit().toXtendMemberDeclaration(((XtendMember)it));
              }
              if (!_matched_1) {
                if (it instanceof XtendParameter) {
                  _matched_1=true;
                  _switchResult_1 = ctx.getCompilationUnit().toXtendParameterDeclaration(((XtendParameter)it));
                }
              }
              final Declaration xtendMember = _switchResult_1;
              return xtendMember;
            };
            ((RegisterGlobalsParticipant<NamedElement>)processor).doRegisterGlobals(
              ListExtensions.<XtendAnnotationTarget, Declaration>map(ctx.getAnnotatedSourceElements(), _function_1), registerGlobalsCtx);
          };
          _xblockexpression_1 = this.runWithCancelIndiciator(ctx, monitor, _function);
        }
        _switchResult = _xblockexpression_1;
      }
      _xtrycatchfinallyexpression = _switchResult;
    } finally {
      task.stop();
    }
    _xblockexpression = _xtrycatchfinallyexpression;
  }
  return _xblockexpression;
}
 
Example #11
Source File: RegisterGlobalsContextImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
public IJvmDeclaredTypeAcceptor getAcceptor() {
  return this.acceptor;
}
 
Example #12
Source File: RegisterGlobalsContextImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void setAcceptor(final IJvmDeclaredTypeAcceptor acceptor) {
  this.acceptor = acceptor;
}
 
Example #13
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);
}