Java 类org.eclipse.xtext.xbase.XConstructorCall 实例源码

项目:xtext-extras    文件:AbstractTypeComputationState.java   
@Override
public List<IConstructorLinkingCandidate> getLinkingCandidates(XConstructorCall constructorCall) {
    IConstructorLinkingCandidate result = reentrantTypeResolver.getScopeProviderAccess().getKnownConstructor(constructorCall, this, resolvedTypes);
    if(result != null) {
        return Collections.singletonList(result);
    }
    EObject proxyOrResolved = (EObject) constructorCall.eGet(XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, false);
    Iterable<IEObjectDescription> descriptions = reentrantTypeResolver.getScopeProviderAccess().getCandidateDescriptions(
            constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, proxyOrResolved, featureScopeSession, resolvedTypes);
    List<IConstructorLinkingCandidate> resultList = Lists.newArrayList();
    for(IEObjectDescription description: descriptions) {
        resultList.add(createCandidate(constructorCall, toIdentifiableDescription(description)));
    }
    if (resultList.isEmpty()) {
        resultList.add(new NullConstructorLinkingCandidate(constructorCall, this));
    }
    return resultList;
}
项目:xtext-extras    文件:ScopeProviderAccess.java   
protected IConstructorLinkingCandidate getKnownConstructor(XConstructorCall constructorCall, AbstractTypeComputationState state,
        ResolvedTypes resolvedTypes) {
    IConstructorLinkingCandidate result = resolvedTypes.getConstructor(constructorCall);
    if (result != null) {
        return result;
    }
    EObject proxyOrResolved = (EObject) constructorCall.eGet(XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, false);
    if (proxyOrResolved == null) {
        result = new NullConstructorLinkingCandidate(constructorCall, state);
        return result;
    }
    if (!proxyOrResolved.eIsProxy()) {
        result = state.createResolvedLink(constructorCall, (JvmConstructor) proxyOrResolved);
        return result;
    }
    if (!encoder.isCrossLinkFragment(constructorCall.eResource(), EcoreUtil.getURI(proxyOrResolved).fragment())) {
        JvmConstructor constructor = constructorCall.getConstructor();
        if (!constructor.eIsProxy()) {
            return state.createResolvedLink(constructorCall, constructor);
        }
    }
    return null;
}
项目:xtext-extras    文件:XbaseSyntacticSequencer.java   
/**
 * Syntax: '('*
 */
@Override
protected void emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a(EObject semanticObject,
        ISynNavigable transition, List<INode> nodes) {

    Keyword kw = grammarAccess.getXParenthesizedExpressionAccess().getLeftParenthesisKeyword_0();

    if (nodes == null) {
        if (semanticObject instanceof XIfExpression || semanticObject instanceof XTryCatchFinallyExpression) {
            EObject cnt = semanticObject.eContainer();
            if (cnt instanceof XExpression && !(cnt instanceof XBlockExpression)
                    && !(cnt instanceof XForLoopExpression))
                acceptUnassignedKeyword(kw, kw.getValue(), null);
        }
        if (semanticObject instanceof XConstructorCall) {
            XConstructorCall call = (XConstructorCall) semanticObject;
            if (!call.isExplicitConstructorCall() && call.getArguments().isEmpty()) {
                acceptUnassignedKeyword(kw, kw.getValue(), null);
            }
        }
    }
    acceptNodes(transition, nodes);
}
项目:xtext-extras    文件:BrokenConstructorCallAwareEObjectAtOffsetHelper.java   
@Override
protected EObject resolveCrossReferencedElement(INode node) {
    EObject referenceOwner = NodeModelUtils.findActualSemanticObjectFor(node);
    if (referenceOwner != null) {
        EReference crossReference = GrammarUtil.getReference((CrossReference) node.getGrammarElement(),
                referenceOwner.eClass());
        if (!crossReference.isMany()) {
            EObject resultOrProxy = (EObject) referenceOwner.eGet(crossReference);
            if (resultOrProxy != null && resultOrProxy.eIsProxy() && crossReference == XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR) {
                if (referenceOwner instanceof XConstructorCall) {
                    JvmIdentifiableElement linkedType = batchTypeResolver.resolveTypes(referenceOwner).getLinkedFeature((XConstructorCall)referenceOwner);
                    if (linkedType != null)
                        return linkedType;
                }
            } 
            return resultOrProxy;
        } else {
            return super.resolveCrossReferencedElement(node);
        }
    }
    return null;
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected void _toJavaStatement(final XConstructorCall expr, ITreeAppendable b, final boolean isReferenced) {
    for (XExpression arg : expr.getArguments()) {
        prepareExpression(arg, b);
    }

    if (!isReferenced) {
        b.newLine();
        constructorCallToJavaExpression(expr, b);
        b.append(";");
    } else if (isVariableDeclarationRequired(expr, b, true)) {
        Later later = new Later() {
            @Override
            public void exec(ITreeAppendable appendable) {
                constructorCallToJavaExpression(expr, appendable);
            }
        };
        declareFreshLocalVariable(expr, b, later);
    }
}
项目:xtext-extras    文件:XbaseInterpreter.java   
protected Object _doEvaluate(XConstructorCall constructorCall, IEvaluationContext context, CancelIndicator indicator) {
    JvmConstructor jvmConstructor = constructorCall.getConstructor();
    List<Object> arguments = evaluateArgumentExpressions(jvmConstructor, constructorCall.getArguments(), context, indicator);
    Constructor<?> constructor = javaReflectAccess.getConstructor(jvmConstructor);
    try {
        if (constructor == null)
            throw new NoSuchMethodException("Could not find constructor " + jvmConstructor.getIdentifier());
        constructor.setAccessible(true);
        Object result = constructor.newInstance(arguments.toArray(new Object[arguments.size()]));
        return result;
    } catch (InvocationTargetException targetException) {
        throw new EvaluationException(targetException.getTargetException());
    } catch (Exception e) {
        throw new IllegalStateException("Could not invoke constructor: " + jvmConstructor.getIdentifier(), e);
    }
}
项目:xtext-extras    文件:BatchConstructorCallTypeTest.java   
@Override
public void resolvesConstructorCallsTo(final String expression, final String... types) {
  final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::");
  final List<XConstructorCall> featureCalls = this.findConstructorCalls(expressionWithQualifiedNames);
  Assert.assertFalse(featureCalls.isEmpty());
  Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), featureCalls.size());
  final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(IterableExtensions.<XConstructorCall>head(featureCalls));
  final Procedure2<XConstructorCall, Integer> _function = (XConstructorCall featureCall, Integer index) -> {
    final LightweightTypeReference type = resolvedTypes.getActualType(featureCall);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("failed for constructor call at ");
    _builder.append(index);
    Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName());
  };
  IterableExtensions.<XConstructorCall>forEach(featureCalls, _function);
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkExplicitOperationCall(XConstructorCall constructorCall) {
    if (!constructorCall.isExplicitConstructorCall() 
            && constructorCall.getArguments().isEmpty()) {
        addIssue("Constructor call without parentheses", constructorCall, OPERATION_WITHOUT_PARENTHESES);
    }
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkDeprecated(XConstructorCall expression) {
    if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) {
        JvmConstructor constructor = expression.getConstructor();
        checkDeprecated(
                constructor,
                expression,
                XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR);
    }
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkReferInvalidTypes(XConstructorCall constructorCall) {
    checkReferInvalidTypes(
            constructorCall.getConstructor(),
            constructorCall,
            XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR);
}
项目:xtext-extras    文件:CompoundTypeComputationState.java   
@Override
public List<? extends IConstructorLinkingCandidate> getLinkingCandidates(XConstructorCall constructorCall) {
    List<IConstructorLinkingCandidate> result = Lists.newArrayList();
    for (ITypeComputationState component : components) {
        result.addAll(component.getLinkingCandidates(constructorCall));
    }
    return result;
}
项目:xtext-extras    文件:AbstractTypeComputationState.java   
protected IConstructorLinkingCandidate createCandidate(XConstructorCall constructorCall, IIdentifiableElementDescription description) {
    StackedResolvedTypes stackedResolvedTypes = resolvedTypes.pushTypes(constructorCall);
    ExpressionTypeComputationState state = createExpressionComputationState(constructorCall, stackedResolvedTypes);
    if (description instanceof ScopeProviderAccess.ErrorDescription) {
        return new UnresolvableConstructorCall(constructorCall, ((ScopeProviderAccess.ErrorDescription) description).getNode(), description.getName().toString(), state);
    } else if (description.getElementOrProxy() instanceof JvmType) {
        return new TypeInsteadOfConstructorLinkingCandidate(constructorCall, description, state);
    } else {
        return new ConstructorLinkingCandidate(constructorCall, description, getSingleExpectation(state), state);
    }
}
项目:xtext-extras    文件:ConstructorLinkingCandidate.java   
public ConstructorLinkingCandidate(
        XConstructorCall constructorCall,
        IIdentifiableElementDescription description,
        ITypeExpectation expectation,
        ExpressionTypeComputationState state) {
    super(constructorCall, description, expectation, state);
}
项目:xtext-extras    文件:CompoundReentrantTypeResolver.java   
@Override
public JvmIdentifiableElement getLinkedFeature(/* @Nullable */ XConstructorCall constructorCall) {
    if (constructorCall == null)
        return null;
    IResolvedTypes delegate = getDelegate(constructorCall);
    return delegate.getLinkedFeature(constructorCall);
}
项目:xtext-extras    文件:CompoundReentrantTypeResolver.java   
@Override
public IConstructorLinkingCandidate getLinkingCandidate(/* @Nullable */ XConstructorCall constructorCall) {
    if (constructorCall == null)
        return null;
    IResolvedTypes delegate = getDelegate(constructorCall);
    return delegate.getLinkingCandidate(constructorCall);
}
项目:xtext-extras    文件:StackedResolvedTypes.java   
@Override
/* @Nullable */
protected IConstructorLinkingCandidate doGetConstructor(XConstructorCall constructorCall) {
    IConstructorLinkingCandidate result = super.doGetConstructor(constructorCall);
    if (result == null) {
        result = parent.doGetConstructor(constructorCall);
    }
    return result;
}
项目:xtext-extras    文件:ResolvedConstructor.java   
public ResolvedConstructor(
        XConstructorCall constructorCall,
        JvmConstructor constructor,
        ITypeExpectation expectation, 
        ExpressionTypeComputationState state) {
    super(constructorCall, constructor, expectation, state);
}
项目:xtext-extras    文件:ResolvedTypes.java   
@Override
public JvmIdentifiableElement getLinkedFeature(/* @Nullable */ XConstructorCall constructorCall) {
    if (!shared.allLinking.contains(constructorCall)) {
        return null;
    }
    return doGetLinkedFeature(constructorCall);
}
项目:xtext-extras    文件:ResolvedTypes.java   
@Override
public IConstructorLinkingCandidate getLinkingCandidate(/* @Nullable */ XConstructorCall constructorCall) {
    if (!shared.allLinking.contains(constructorCall)) {
        return null;
    }
    return (IConstructorLinkingCandidate) doGetCandidate(constructorCall);
}
项目:xtext-extras    文件:TypeInsteadOfConstructorLinkingCandidate.java   
public List<LightweightTypeReference> getSyntacticTypeArguments() {
    XConstructorCall constructorCall = getConstructorCall();
    List<JvmTypeReference> typeArguments = constructorCall.getTypeArguments();
    if (typeArguments.isEmpty())
        return Collections.emptyList();
    List<LightweightTypeReference> result = Lists.newArrayList();
    for(JvmTypeReference typeArgument: typeArguments) {
        result.add(getState().getReferenceOwner().toLightweightTypeReference(typeArgument));
    }
    return result;
}
项目:xtext-extras    文件:UnresolvableConstructorCall.java   
@Override
public List<LightweightTypeReference> getTypeArguments() {
    XConstructorCall constructorCall = getConstructorCall();
    List<JvmTypeReference> typeArguments = constructorCall.getTypeArguments();
    if (typeArguments.isEmpty())
        return Collections.emptyList();
    List<LightweightTypeReference> result = Lists.newArrayList();
    for(JvmTypeReference typeArgument: typeArguments) {
        result.add(getState().getReferenceOwner().toLightweightTypeReference(typeArgument));
    }
    return result;
}
项目:xtext-extras    文件:SerializerScopeProvider.java   
public IScope createConstructorCallSerializationScope(EObject context) {
    if (!(context instanceof XConstructorCall)) {
        return IScope.NULLSCOPE;
    }
    XConstructorCall constructorCall = (XConstructorCall) context;
    JvmConstructor constructor = constructorCall.getConstructor();
    if (constructor.eIsProxy()) {
        return IScope.NULLSCOPE;
    }
    return doCreateConstructorCallSerializationScope(constructorCall);
}
项目:xtext-extras    文件:ConstructorScopes.java   
/**
 * Creates the constructor scope for {@link XConstructorCall}.
 * The scope will likely contain descriptions for {@link JvmConstructor constructors}.
 * If there is not constructor declared, it may contain {@link JvmType types}.
 * 
 * @param session the currently available visibilityHelper data
 * @param reference the reference that will hold the resolved constructor
 * @param resolvedTypes the currently known resolved types
 */
public IScope createConstructorScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) {
    if (!(context instanceof XConstructorCall)) {
        return IScope.NULLSCOPE;
    }
    /*
     * We use a type scope here in order to provide better feedback for users,
     * e.g. if the constructor call refers to an interface or a primitive.
     */
    final IScope delegateScope = typeScopes.createTypeScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, session, resolvedTypes);
    IScope result = new ConstructorTypeScopeWrapper(context, session, delegateScope);
    return result;
}
项目:xtext-extras    文件:XExpressionHelper.java   
/**
 * @return whether the expression itself (not its children) possibly causes a side-effect
 */
public boolean hasSideEffects(XExpression expr) {
    if (expr instanceof XClosure
        || expr instanceof XStringLiteral
        || expr instanceof XTypeLiteral
        || expr instanceof XBooleanLiteral
        || expr instanceof XNumberLiteral
        || expr instanceof XNullLiteral
        || expr instanceof XAnnotation
        )
        return false;
    if(expr instanceof XCollectionLiteral) {
        for(XExpression element: ((XCollectionLiteral)expr).getElements()) {
            if(hasSideEffects(element))
                return true;
        }
        return false;
    }
    if (expr instanceof XAbstractFeatureCall) {
        XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expr;
        return hasSideEffects(featureCall, true);
    }
    if (expr instanceof XConstructorCall) {
        XConstructorCall constrCall = (XConstructorCall) expr;
        return findPureAnnotation(constrCall.getConstructor()) == null;
    }
    return true;
}
项目:xtext-extras    文件:XbaseCompiler.java   
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
    if (obj instanceof XBlockExpression) {
        _toJavaExpression((XBlockExpression) obj, appendable);
    } else if (obj instanceof XCastedExpression) {
        _toJavaExpression((XCastedExpression) obj, appendable);
    } else if (obj instanceof XClosure) {
        _toJavaExpression((XClosure) obj, appendable);
    } else if (obj instanceof XAnnotation) {
        _toJavaExpression((XAnnotation) obj, appendable);
    } else if (obj instanceof XConstructorCall) {
        _toJavaExpression((XConstructorCall) obj, appendable);
    } else if (obj instanceof XIfExpression) {
        _toJavaExpression((XIfExpression) obj, appendable);
    } else if (obj instanceof XInstanceOfExpression) {
        _toJavaExpression((XInstanceOfExpression) obj, appendable);
    } else if (obj instanceof XSwitchExpression) {
        _toJavaExpression((XSwitchExpression) obj, appendable);
    } else if (obj instanceof XTryCatchFinallyExpression) {
        _toJavaExpression((XTryCatchFinallyExpression) obj, appendable);
    } else if (obj instanceof XListLiteral) {
        _toJavaExpression((XListLiteral) obj, appendable);
    } else if (obj instanceof XSetLiteral) {
        _toJavaExpression((XSetLiteral) obj, appendable);
    } else if (obj instanceof XSynchronizedExpression) {
        _toJavaExpression((XSynchronizedExpression) obj, appendable);
    } else if (obj instanceof XReturnExpression) {
        _toJavaExpression((XReturnExpression) obj, appendable);
    } else if (obj instanceof XThrowExpression) {
        _toJavaExpression((XThrowExpression) obj, appendable);
    } else {
        super.internalToConvertedExpression(obj, appendable);
    }
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) {
    JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType();
    if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) {
        typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType());
    } else {
        typeAppendable.append(constructorCall.getConstructor().getDeclaringType());
    }
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected ILocationData getLocationWithNewKeyword(XConstructorCall call) {
    final ICompositeNode startNode = NodeModelUtils.getNode(call);
    if (startNode != null) {
        List<INode> resultNodes = Lists.newArrayList();
        for (INode child : startNode.getChildren()) {
            if (child.getGrammarElement() instanceof Keyword && "(".equals(child.getText()))
                break;
            resultNodes.add(child);
        }
        return toLocationData(resultNodes);
    }
    return null;
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected void _toJavaExpression(XConstructorCall expr, ITreeAppendable b) {
    String varName = getReferenceName(expr, b);
    if (varName != null) {
        b.trace(expr, false).append(varName);
    } else {
        constructorCallToJavaExpression(expr, b);
    }
}
项目:xtext-extras    文件:TypeUsageCollector.java   
protected JvmIdentifiableElement getReferencedElement(EObject owner, EReference reference) {
    JvmIdentifiableElement referencedThing = (JvmIdentifiableElement) owner.eGet(reference);
    if (referencedThing != null && owner instanceof XConstructorCall && referencedThing.eIsProxy()) {
        JvmIdentifiableElement potentiallyLinkedType = batchTypeResolver.resolveTypes(owner).getLinkedFeature((XConstructorCall)owner);
        if (potentiallyLinkedType != null && !potentiallyLinkedType.eIsProxy()) {
            referencedThing = potentiallyLinkedType;
        }
    }
    return referencedThing;
}
项目:xtext-extras    文件:DefaultEarlyExitComputer.java   
protected Collection<IEarlyExitComputer.ExitPoint> _exitPoints(final XConstructorCall expression) {
  EList<XExpression> _arguments = expression.getArguments();
  for (final XExpression argument : _arguments) {
    {
      Collection<IEarlyExitComputer.ExitPoint> argumentExitPoints = this.getExitPoints(argument);
      boolean _isNotEmpty = this.isNotEmpty(argumentExitPoints);
      if (_isNotEmpty) {
        return argumentExitPoints;
      }
    }
  }
  return Collections.<IEarlyExitComputer.ExitPoint>emptyList();
}
项目:xtext-extras    文件:DefaultEarlyExitComputer.java   
protected Collection<IEarlyExitComputer.ExitPoint> exitPoints(final XExpression expression) {
  if (expression instanceof XDoWhileExpression) {
    return _exitPoints((XDoWhileExpression)expression);
  } else if (expression instanceof XWhileExpression) {
    return _exitPoints((XWhileExpression)expression);
  } else if (expression instanceof XAbstractFeatureCall) {
    return _exitPoints((XAbstractFeatureCall)expression);
  } else if (expression instanceof XBasicForLoopExpression) {
    return _exitPoints((XBasicForLoopExpression)expression);
  } else if (expression instanceof XBlockExpression) {
    return _exitPoints((XBlockExpression)expression);
  } else if (expression instanceof XConstructorCall) {
    return _exitPoints((XConstructorCall)expression);
  } else if (expression instanceof XForLoopExpression) {
    return _exitPoints((XForLoopExpression)expression);
  } else if (expression instanceof XIfExpression) {
    return _exitPoints((XIfExpression)expression);
  } else if (expression instanceof XReturnExpression) {
    return _exitPoints((XReturnExpression)expression);
  } else if (expression instanceof XSwitchExpression) {
    return _exitPoints((XSwitchExpression)expression);
  } else if (expression instanceof XSynchronizedExpression) {
    return _exitPoints((XSynchronizedExpression)expression);
  } else if (expression instanceof XThrowExpression) {
    return _exitPoints((XThrowExpression)expression);
  } else if (expression instanceof XTryCatchFinallyExpression) {
    return _exitPoints((XTryCatchFinallyExpression)expression);
  } else if (expression instanceof XVariableDeclaration) {
    return _exitPoints((XVariableDeclaration)expression);
  } else if (expression != null) {
    return _exitPoints(expression);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(expression).toString());
  }
}
项目:xtext-extras    文件:XbaseFormatter2.java   
protected boolean _isMultiParamInOwnLine(final XConstructorCall fc, final FormattableDocument doc) {
  final ILeafNode closingBracket = this._nodeModelAccess.nodeForKeyword(fc, ")");
  HiddenLeafs _hiddenLeafsBefore = null;
  if (closingBracket!=null) {
    _hiddenLeafsBefore=this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket);
  }
  boolean _tripleNotEquals = (_hiddenLeafsBefore != null);
  if (_tripleNotEquals) {
    int _newLines = this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket).getNewLines();
    return (_newLines > 0);
  }
  final Iterable<XExpression> params = this.explicitParams(fc.getArguments());
  return ((IterableExtensions.size(params) > 1) && this.isEachExpressionInOwnLine(params));
}
项目:xtext-extras    文件:XbaseFormatter2.java   
protected boolean isMultiParamInOwnLine(final XExpression fc, final FormattableDocument doc) {
  if (fc instanceof XFeatureCall) {
    return _isMultiParamInOwnLine((XFeatureCall)fc, doc);
  } else if (fc instanceof XMemberFeatureCall) {
    return _isMultiParamInOwnLine((XMemberFeatureCall)fc, doc);
  } else if (fc instanceof XConstructorCall) {
    return _isMultiParamInOwnLine((XConstructorCall)fc, doc);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(fc, doc).toString());
  }
}
项目:xtext-extras    文件:ImportsCollector.java   
public void visit(final EObject jvmType, final INode originNode, final ImportsAcceptor acceptor) {
  if (jvmType instanceof JvmGenericType) {
    _visit((JvmGenericType)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof JvmDeclaredType) {
    _visit((JvmDeclaredType)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XFeatureCall) {
    _visit((XFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XMemberFeatureCall) {
    _visit((XMemberFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XAbstractFeatureCall) {
    _visit((XAbstractFeatureCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XConstructorCall) {
    _visit((XConstructorCall)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XTypeLiteral) {
    _visit((XTypeLiteral)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof XAnnotation) {
    _visit((XAnnotation)jvmType, originNode, acceptor);
    return;
  } else if (jvmType instanceof JvmTypeReference) {
    _visit((JvmTypeReference)jvmType, originNode, acceptor);
    return;
  } else if (jvmType != null) {
    _visit(jvmType, originNode, acceptor);
    return;
  } else if (jvmType == null) {
    _visit((Void)null, originNode, acceptor);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(jvmType, originNode, acceptor).toString());
  }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
@Override
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
    if (object instanceof XAbstractFeatureCall) {
        if (((XAbstractFeatureCall) object).isPackageFragment()) {
            return true;
        }
        if (SPECIAL_FEATURE_NAMES.contains(((XAbstractFeatureCall) object).getConcreteSyntaxFeatureName())) {
            return false;
        }
        operationCanceledManager.checkCanceled(cancelIndicator);
        computeFeatureCallHighlighting((XAbstractFeatureCall) object, acceptor);
    } else if (object instanceof JvmTypeParameter) {
        highlightTypeParameter((JvmTypeParameter) object, acceptor);
    } else if (object instanceof JvmFormalParameter) {
        highlightFormalParameter((JvmFormalParameter) object, acceptor);
    } else if (object instanceof XVariableDeclaration) {
        highlightVariableDeclaration((XVariableDeclaration) object, acceptor);
    } else if (object instanceof XNumberLiteral) {
        highlightNumberLiterals((XNumberLiteral) object, acceptor);
    } else if (object instanceof XConstructorCall) {
        highlightConstructorCall((XConstructorCall) object, acceptor);
    } else if (object instanceof XAnnotation) {
        // Handle XAnnotation in a special way because we want the @ highlighted too
        highlightAnnotation((XAnnotation) object, acceptor);
    } else {
        computeReferencedJvmTypeHighlighting(acceptor, object, cancelIndicator);
    }
    return false;
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightConstructorCall(XConstructorCall constructorCall, IHighlightedPositionAcceptor acceptor) {
    if (constructorCall.getConstructor() != null && !constructorCall.getConstructor().eIsProxy()) {
        EObject declaringType = constructorCall.getConstructor().getDeclaringType();
        if (declaringType instanceof JvmGenericType) {
            highlightFeature(acceptor, constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, getStyle((JvmGenericType) declaringType));
        }
    }
}
项目:xtext-extras    文件:XbaseParserTest.java   
@Test public void testShortClosure_3() throws Exception {
    XConstructorCall featureCall = (XConstructorCall) expression("new Something(a,b|a+b)");
    assertEquals(1, featureCall.getArguments().size());
    assertTrue(featureCall.getArguments().get(0) instanceof XClosure);
    XClosure closure = (XClosure) featureCall.getArguments().get(0);
    assertEquals(2, closure.getFormalParameters().size());
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testShadowing_1() throws Exception {
    XBlockExpression bop = (XBlockExpression) expression(
            "{ " +
            "   val this = new java.util.List<String>(); " +
            "   val size = 23;" +
            "   size;" +
            "}", false);
    final JvmIdentifiableElement feature = ((XFeatureCall)bop.getExpressions().get(2)).getFeature();
    assertTrue(feature.getClass().getName(), feature instanceof XVariableDeclaration);

    XConstructorCall xConstructorCall = (XConstructorCall)((XVariableDeclaration)bop.getExpressions().get(0)).getRight();
    assertTrue(xConstructorCall.getConstructor().eIsProxy());
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testOverloadedConstructors_01() throws Exception {
    XBlockExpression block = (XBlockExpression) expression(
            "{\n" +
            "    new testdata.OverloadedMethods<Object>()\n" +
            "}");
    XConstructorCall constructorCall = (XConstructorCall) block.getExpressions().get(0);
    JvmConstructor constructor = constructorCall.getConstructor();
    assertNotNull(constructor);
    assertFalse(constructor.eIsProxy());
    assertEquals("testdata.OverloadedMethods.OverloadedMethods()", constructor.getIdentifier());
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testOverloadedConstructors_02() throws Exception {
    XBlockExpression block = (XBlockExpression) expression(
            "{\n" +
            "    var java.util.List<CharSequence> chars = null\n" +
            "    var java.util.List<String> strings = null\n" +
            "    new testdata.OverloadedMethods<CharSequence>(chars, strings)\n" +
            "}");
    XConstructorCall constructorCall = (XConstructorCall) block.getExpressions().get(2);
    JvmConstructor constructor = constructorCall.getConstructor();
    assertNotNull(constructor);
    assertFalse(constructor.eIsProxy());
    assertEquals("testdata.OverloadedMethods.OverloadedMethods(java.util.Collection,java.lang.Iterable)", constructor.getIdentifier());
}