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

项目:xtext-extras    文件:FeatureLinkingCandidate.java   
@Override
protected int getConformanceFlags(int idx, boolean recompute) {
    if (isStatic()) {
        if (idx == -1) {
            return ConformanceFlags.CHECKED_SUCCESS;
        }
    }
    if (idx == 0) {
        if (getReceiver() != null) {
            int result = getReceiverConformanceFlags();
            return result;
        }
    } else if (idx == 1) {
        if (getExpression() instanceof XAssignment && getFeature() instanceof JvmField) {
            return super.getConformanceFlags(0, recompute);
        }
    }
    return super.getConformanceFlags(idx, recompute);
}
项目:xtext-extras    文件:FeatureLinkHelper.java   
public XExpression getSyntacticReceiver(XExpression expression) {
    if (expression instanceof XAbstractFeatureCall) {
        if (expression instanceof XFeatureCall) {
            return null;
        }
        if (expression instanceof XMemberFeatureCall) {
            return ((XMemberFeatureCall) expression).getMemberCallTarget();
        }
        if (expression instanceof XAssignment) {
            return ((XAssignment) expression).getAssignable();
        }
        if (expression instanceof XBinaryOperation) {
            return ((XBinaryOperation) expression).getLeftOperand();
        }
        if (expression instanceof XUnaryOperation) {
            return ((XUnaryOperation) expression).getOperand();
        }
        if (expression instanceof XPostfixOperation) {
            return ((XPostfixOperation) expression).getOperand();
        }
    }
    return null;
}
项目:xtext-extras    文件:FeatureLinkHelper.java   
public List<XExpression> getSyntacticArguments(XAbstractFeatureCall expression) {
    if (expression instanceof XFeatureCall) {
        return ((XFeatureCall) expression).getFeatureCallArguments();
    }
    if (expression instanceof XMemberFeatureCall) {
        return ((XMemberFeatureCall) expression).getMemberCallArguments();
    }
    if (expression instanceof XAssignment) {
        return Collections.singletonList(((XAssignment) expression).getValue());
    }
    if (expression instanceof XBinaryOperation) {
        return Collections.singletonList(((XBinaryOperation) expression).getRightOperand());
    }
    // explicit condition to make sure we thought about it
    if (expression instanceof XUnaryOperation) {
        return Collections.emptyList();
    }
    if (expression instanceof XPostfixOperation) {
        return Collections.emptyList();
    }
    return Collections.emptyList();
}
项目:xtext-extras    文件:AbstractSessionBasedScope.java   
/**
 * Considers the given name to be a property name. If the concrete syntax of the
 * processed feature matches a feature call or assignment, a prefix is added to the
 * name and that one is used as a variant that should be processed. 
 */
protected void processAsPropertyNames(QualifiedName name, NameAcceptor acceptor) {
    String nameAsPropertyName = tryGetAsPropertyName(name.toString());
    if (nameAsPropertyName != null) {
        if (featureCall == null || featureCall instanceof XAssignment) {
            String aliasedSetter = "set" + nameAsPropertyName;
            acceptor.accept(aliasedSetter, 2);
        }
        if (!(featureCall instanceof XAssignment)) {
            if (featureCall == null || !getFeatureCall().isExplicitOperationCallOrBuilderSyntax()) {
                String aliasedGetter = "get" + nameAsPropertyName;
                acceptor.accept(aliasedGetter, 2);
                String aliasedBooleanGetter = "is" + nameAsPropertyName;
                acceptor.accept(aliasedBooleanGetter, 2);
            }
        }
    }
}
项目:xtext-extras    文件:FeatureCallCompiler.java   
protected void featureCalltoJavaExpression(final XAbstractFeatureCall call, ITreeAppendable b, boolean isExpressionContext) {
    if (call instanceof XAssignment) {
        assignmentToJavaExpression((XAssignment) call, b, isExpressionContext);
    } else {
        if (needMultiAssignment(call)) {
            appendLeftOperand(call, b, isExpressionContext).append(" = ");
        }
        final JvmAnnotationReference annotationRef = this.expressionHelper.findInlineAnnotation(call);
        if (annotationRef == null || !isConstantExpression(annotationRef)) {
            boolean hasReceiver = appendReceiver(call, b, isExpressionContext);
            if (hasReceiver) {
                b.append(".");
                b = appendTypeArguments(call, b);
            }
        }
        appendFeatureCall(call, b);
    }
}
项目:xtext-extras    文件:ExpressionArgumentFactory.java   
public IFeatureCallArguments createExpressionArguments(XExpression expression, AbstractLinkingCandidate<?> candidate) {
    JvmIdentifiableElement feature = candidate.getFeature();
    if (feature instanceof JvmExecutable) {
        JvmExecutable executable = (JvmExecutable) feature;
        return createArgumentsForExecutable(executable.isVarArgs(), candidate.getArguments(), executable.getParameters(), candidate.hasReceiver(), candidate.getState().getReferenceOwner());
    } else {
        if (expression instanceof XAssignment) {
            XAssignment assignment = (XAssignment) expression;
            LightweightTypeReference featureType = candidate.getActualType(candidate.getFeature(), true);
            return new AssignmentFeatureCallArguments(assignment.getValue(), featureType);
        } else {
            return new StandardFeatureCallArguments(candidate.getArguments(), Collections.<JvmFormalParameter>emptyList(), candidate.hasReceiver(), candidate.getState().getReferenceOwner());
        }
    }
}
项目:xtext-extras    文件:AbstractLinkingCandidate.java   
protected boolean mustDiscardRefinement() {
    Expression expression = getExpression();
    if (expression instanceof XAssignment) {
        JvmIdentifiableElement feature = getFeature();
        if (feature instanceof XVariableDeclaration) {
            return ((XVariableDeclaration) feature).isWriteable();
        }
        if (feature instanceof JvmField) {
            return !((JvmField) feature).isFinal();
        }
    }
    return false;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected boolean isStaticWithDeclaringType() {
    XAbstractFeatureCall featureCall = getFeatureCall();
    if (featureCall instanceof XMemberFeatureCall) {
        return ((XMemberFeatureCall) featureCall).isStaticWithDeclaringType();
    }
    if (featureCall instanceof XAssignment) {
        return isStaticWithDeclaringType((XAssignment) featureCall);
    }
    return false;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected boolean isOperationCallSyntax() {
    XAbstractFeatureCall featureCall = getFeatureCall();
    if (featureCall instanceof XBinaryOperation || featureCall instanceof XAssignment) {
        return false;
    }
    return featureCall.isExplicitOperationCallOrBuilderSyntax();
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected boolean isAssignmentOrMemberFeatureCall() {
    if (getImplicitReceiverType() != null)
        return true;
    XAbstractFeatureCall featureCall = getFeatureCall();
    if (featureCall instanceof XAssignment) {
        return isSimpleAssignment((XAssignment) featureCall);
    }
    return featureCall instanceof XMemberFeatureCall;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
@Override
protected CandidateCompareResult compareByArgumentTypes(AbstractPendingLinkingCandidate<?> right, boolean recompute) {
    CandidateCompareResult result = super.compareByArgumentTypes(right, recompute);
    if (result == CandidateCompareResult.AMBIGUOUS && getExpression() instanceof XAssignment) {
        if (description.isValidStaticState() == right.description.isValidStaticState()) {
            if (getFeature() instanceof JvmExecutable != right.getFeature() instanceof JvmExecutable) {
                if (getFeature() instanceof JvmExecutable) {
                    return CandidateCompareResult.OTHER;
                }
                return CandidateCompareResult.THIS;
            }
        }
    }
    return result;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected CandidateCompareResult compareByAssignmentName(AbstractPendingLinkingCandidate<?> right) {
    if (getExpression() instanceof XAssignment) {
        if (isValidAssignmentName(description)) {
            if (!isValidAssignmentName(right.description)) {
                return CandidateCompareResult.THIS;
            }
        } else if (isValidAssignmentName(right.description)) {
            return CandidateCompareResult.OTHER;
        } else {
            return CandidateCompareResult.EQUALLY_INVALID;
        }
    }
    return CandidateCompareResult.AMBIGUOUS;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
@Override
protected CandidateCompareResult compareByArityWith(AbstractPendingLinkingCandidate<?> right) {
    CandidateCompareResult result = super.compareByArityWith(right);
    if (result == CandidateCompareResult.AMBIGUOUS) {
        boolean isExecutable = getFeature() instanceof JvmExecutable;
        if (isExecutable != right.getFeature() instanceof JvmExecutable && isVisible() == right.isVisible() && isTypeLiteral() == right.isTypeLiteral()) {
            // XAssignments return true from #isExplicitOperationCall though they may link to
            // a field or local variable
            if (!(getExpression() instanceof XAssignment) && isExplicitOperationCall()) {
                if (isExecutable)
                    return CandidateCompareResult.THIS;
                return CandidateCompareResult.OTHER;
            }
        } else if (getFeature() == right.getFeature() && right instanceof FeatureLinkingCandidate) {
            FeatureLinkingCandidate casted = (FeatureLinkingCandidate) right;
            if (isStatic() && casted.isStatic()) {
                if (getImplicitReceiver() != casted.getImplicitReceiver()) {
                    if (getImplicitReceiver() != null) {
                        return CandidateCompareResult.OTHER;
                    }
                    return CandidateCompareResult.THIS;
                }
                // we link to identical static features with equal assumptions
                // stop comparison and take this one
                if (getReceiver() == casted.getReceiver() 
                        && isSyntacticReceiverPossibleArgument() == casted.isSyntacticReceiverPossibleArgument()) {
                    return CandidateCompareResult.THIS; 
                }
            }
        }
    }
    return result;
}
项目:xtext-extras    文件:AbstractPendingLinkingCandidate.java   
/**
 * Returns the mismatch of actually given arguments and declared parameters.
 * Receivers and staticness of the feature is taken into account, too. The mismatch
 * may either be negative or positive.
 */
public int getArityMismatch() {
    JvmIdentifiableElement identifiable = getFeature();
    if (identifiable instanceof JvmExecutable) {
        return getArityMismatch((JvmExecutable) identifiable, getArguments());
    } else if (getExpression() instanceof XAssignment) {
        return getArguments().size() - 1;
    } else {
        return getArguments().size();
    }
}
项目:xtext-extras    文件:XbaseLocationInFileProvider.java   
@Override
protected List<INode> getLocationNodes(EObject obj) {
    if (obj instanceof XMemberFeatureCall || obj instanceof XAssignment || obj instanceof XFeatureCall) {
        List<INode> resultNodes = Lists.newArrayList();
        final ICompositeNode startNode = findNodeFor(obj);
        boolean crossRefConsumed = false;
        for (INode child : startNode.getChildren()) {
            if (crossRefConsumed) {
                resultNodes.add(child);
            } else {
                EObject grammarElement = child.getGrammarElement();
                if (grammarElement instanceof CrossReference) {
                    // We don't use the grammar access to be more robust against
                    // overwriting grammars
                    Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
                    if (XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE.getName().equals(assignment.getFeature())) {
                        crossRefConsumed = true;
                        resultNodes.add(child);
                    }
                }
            } 
        }
        if (!resultNodes.isEmpty())
            return resultNodes;
    }
    return super.getLocationNodes(obj);
}
项目:xtext-extras    文件:LocalVariableScope.java   
protected boolean canBeLocalVariable() {
    XAbstractFeatureCall featureCall = getFeatureCall();
    if (featureCall != null) {
        return looksLikeLocalVariable(featureCall) || featureCall instanceof XAssignment;
    }
    return true;
}
项目:xtext-extras    文件:XExpressionHelper.java   
public boolean hasSideEffects(XAbstractFeatureCall featureCall, boolean inspectContents) {
    if (featureCall instanceof XBinaryOperation) {
        XBinaryOperation binaryOperation = (XBinaryOperation) featureCall;
        if (binaryOperation.isReassignFirstArgument()) {
            return true;
        }
    }
    if (featureCall instanceof XAssignment) {
        return true;
    }
    if (featureCall.isPackageFragment() || featureCall.isTypeLiteral()) {
        return false;
    }
    final JvmIdentifiableElement feature = featureCall.getFeature();
    if (feature == null || feature.eIsProxy())
        return true; // linking problems ... could be anything
    if (feature instanceof JvmConstructor) { //super() and this()
        return true;
    }
    if (feature instanceof JvmOperation) {
        JvmOperation jvmOperation = (JvmOperation) feature;
        if (findPureAnnotation(jvmOperation) == null) {
            return true;
        } else {
            if(inspectContents) {
                for (XExpression param : featureCall.getActualArguments()) {
                    if (hasSideEffects(param))
                        return true;
                }
            }
        }
    }
    return false;
}
项目:xtext-extras    文件:XbaseInterpreter.java   
protected Object _doEvaluate(XAssignment assignment, IEvaluationContext context, CancelIndicator indicator) {
    JvmIdentifiableElement feature = assignment.getFeature();
    if (feature instanceof JvmOperation && ((JvmOperation) feature).isVarArgs()) {
        return _doEvaluate((XAbstractFeatureCall) assignment, context, indicator);
    }
    Object value = internalEvaluate(assignment.getValue(), context, indicator);
    Object assign = assignValueTo(feature, assignment, value, context, indicator);
    return assign;
}
项目:xtext-extras    文件:XbaseIdeContentProposalProvider.java   
protected void completeXMemberFeatureCall(final EObject model, final Assignment assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) {
  if ((model instanceof XMemberFeatureCall)) {
    AbstractElement _terminal = assignment.getTerminal();
    this.createReceiverProposals(((XMemberFeatureCall)model).getMemberCallTarget(), 
      ((CrossReference) _terminal), context, acceptor);
  } else {
    if ((model instanceof XAssignment)) {
      AbstractElement _terminal_1 = assignment.getTerminal();
      this.createReceiverProposals(((XAssignment)model).getAssignable(), 
        ((CrossReference) _terminal_1), context, acceptor);
    }
  }
}
项目:xtext-extras    文件:XbaseNodeModelTest.java   
@Test public void testAssignment_rhs_01() throws Exception {
    String text = "a=b";
    XAssignment assignment = (XAssignment) expression(text);
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE);
    assertEquals(1, nodesForFeature.size());
    String nodeText = nodesForFeature.get(0).getText();
    assertEquals("b", nodeText);
}
项目:xtext-extras    文件:XbaseNodeModelTest.java   
@Test public void testAssignment_rhs_02() throws Exception {
    String text = "a=b+=c";
    XAssignment assignment = (XAssignment) expression(text);
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE);
    assertEquals(1, nodesForFeature.size());
    String nodeText = nodesForFeature.get(0).getText();
    assertEquals("b+=c", nodeText);
}
项目:xtext-extras    文件:XbaseNodeModelTest.java   
@Test public void testAssignment_rhs_03() throws Exception {
    String text = "a=b+=c";
    XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue();
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND);
    assertEquals(1, nodesForFeature.size());
    String nodeText = nodesForFeature.get(0).getText();
    assertEquals("c", nodeText);
}
项目:xtext-extras    文件:XbaseNodeModelTest.java   
@Test public void testAssignment_rhs_04() throws Exception {
    String text = "a=b+=c";
    XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue();
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND);
    assertEquals(1, nodesForFeature.size());
    String nodeText = nodesForFeature.get(0).getText();
    assertEquals("b", nodeText);
}
项目:xtext-extras    文件:XbaseNodeModelTest.java   
@Test public void testAssignment_rhs_05() throws Exception {
    String text = "a = b += c = d";
    XAssignment assignment = (XAssignment) expression(text);
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE);
    assertEquals(1, nodesForFeature.size());
    String nodeText = nodesForFeature.get(0).getText();
    assertEquals(" b += c = d", nodeText);
}
项目:xtext-extras    文件:XbaseParserTest.java   
@Test public void testAssignment_RightAssociativity() throws Exception {
    XAssignment ass = (XAssignment) expression("foo = bar += baz");
    assertEquals(1,ass.getExplicitArguments().size());
    assertEquals("foo", ass.getConcreteSyntaxFeatureName());
    assertNull(ass.getAssignable());
    XBinaryOperation op = (XBinaryOperation) ass.getExplicitArguments().get(0);
    assertEquals(2,op.getExplicitArguments().size());
    assertEquals("+=", op.getConcreteSyntaxFeatureName());
    assertEquals("bar", ((XFeatureCall)op.getExplicitArguments().get(0)).getConcreteSyntaxFeatureName());
    assertEquals("baz", ((XFeatureCall)op.getExplicitArguments().get(1)).getConcreteSyntaxFeatureName());
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testQualifiedAssignment_01() throws Exception {
    String text = "'a'.doesNotExist = 'b'";
    XAssignment assignment = castedExpression(text);
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals(text.substring(text.indexOf('.') + 1) , significant);
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testAssignment_rhs_01() throws Exception {
    String text = "a = b";
    XAssignment assignment = (XAssignment) expression(text);
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE, 0);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals("b", significant);
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testAssignment_rhs_02() throws Exception {
    String text = "a = b += c";
    XAssignment assignment = (XAssignment) expression(text);
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE, 0);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals("b += c", significant);
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testAssignment_rhs_03() throws Exception {
    String text = "a = b += c";
    XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue();
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND, 0);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals("c", significant);
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testAssignment_rhs_04() throws Exception {
    String text = "a = b += c";
    XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue();
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND, 0);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals("b", significant);
}
项目:xtext-extras    文件:XbaseLocationInFileProviderTest.java   
@Test public void testAssignment_rhs_05() throws Exception {
    String text = "a = b += c = d";
    XAssignment assignment = (XAssignment) expression(text);
    ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE, 0);
    String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength());
    assertEquals("b += c = d", significant);
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testLocalVarAssignment_1() throws Exception {
    XBlockExpression block = (XBlockExpression) expression("{ var x = ''; x = '' }");
    XAssignment assignment = (XAssignment) block.getExpressions().get(1);
    assertNull(assignment.getAssignable());
    assertTrue(String.valueOf(assignment.getFeature()), assignment.getFeature() instanceof XVariableDeclaration);
    assertSame(block.getExpressions().get(0), assignment.getFeature());
}
项目:xtext-extras    文件:AbstractXbaseSemanticSequencer.java   
@Deprecated
protected void sequence_XAssignment_XMemberFeatureCall(EObject context, XAssignment semanticObject) {
    sequence_XAssignment_XMemberFeatureCall(createContext(context, semanticObject), semanticObject);
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkAssignment(XAssignment assignment) {
    checkAssignment(assignment, true);
}
项目:xtext-extras    文件:XbaseValidator.java   
protected void reportFieldAlreadyInitialized(XAssignment assignment, JvmField field) {
    error("The final field "+field.getSimpleName()+" may already have been assigned", assignment, null, FIELD_ALREADY_INITIALIZED );
}
项目:xtext-extras    文件:XbaseValidator.java   
protected boolean isValueExpectedRecursive(XExpression expr) {
    EStructuralFeature feature = expr.eContainingFeature();
    EObject container = expr.eContainer();

    // is part of block
    if (container instanceof XBlockExpression) {
        XBlockExpression blockExpression = (XBlockExpression) container;
        final List<XExpression> expressions = blockExpression.getExpressions();
        if (expressions.get(expressions.size()-1) != expr) {
            return false;
        }
    }
    // no expectation cases
    if (feature == XbasePackage.Literals.XTRY_CATCH_FINALLY_EXPRESSION__FINALLY_EXPRESSION
        || feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__BODY
        || feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) {
        return false;
    }
    // is value expected
    if (container instanceof XAbstractFeatureCall 
        || container instanceof XConstructorCall
        || container instanceof XAssignment
        || container instanceof XVariableDeclaration
        || container instanceof XReturnExpression
        || container instanceof XThrowExpression
        || feature == XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION
        || feature == XbasePackage.Literals.XSWITCH_EXPRESSION__SWITCH
        || feature == XbasePackage.Literals.XCASE_PART__CASE
        || feature == XbasePackage.Literals.XIF_EXPRESSION__IF
        || feature == XbasePackage.Literals.XABSTRACT_WHILE_EXPRESSION__PREDICATE
        || feature == XbasePackage.Literals.XBASIC_FOR_LOOP_EXPRESSION__EXPRESSION
        || feature == XbasePackage.Literals.XSYNCHRONIZED_EXPRESSION__PARAM) {
        return true;
    }
    if (isLocalClassSemantics(container) || logicalContainerProvider.getLogicalContainer(expr) != null) {
        LightweightTypeReference expectedReturnType = typeResolver.resolveTypes(expr).getExpectedReturnType(expr);
        return expectedReturnType == null || !expectedReturnType.isPrimitiveVoid();
    }
    if (container instanceof XCasePart || container instanceof XCatchClause) {
        container = container.eContainer();
    }
    if (container instanceof XExpression) {
        return isValueExpectedRecursive((XExpression) container);
    }
    return true;
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
@Override
public void computeTypes(XExpression expression, ITypeComputationState state) {
    if (expression instanceof XAssignment) {
        _computeTypes((XAssignment)expression, state);
    } else if (expression instanceof XAbstractFeatureCall) {
        _computeTypes((XAbstractFeatureCall)expression, state);
    } else if (expression instanceof XDoWhileExpression) {
        _computeTypes((XDoWhileExpression)expression, state);
    } else if (expression instanceof XWhileExpression) {
        _computeTypes((XWhileExpression)expression, state);
    } else if (expression instanceof XBlockExpression) {
        _computeTypes((XBlockExpression)expression, state);
    } else if (expression instanceof XBooleanLiteral) {
        _computeTypes((XBooleanLiteral)expression, state);
    } else if (expression instanceof XCastedExpression) {
        _computeTypes((XCastedExpression)expression, state);
    } else if (expression instanceof XClosure) {
        _computeTypes((XClosure)expression, state);
    } else if (expression instanceof XConstructorCall) {
        _computeTypes((XConstructorCall)expression, state);
    } else if (expression instanceof XForLoopExpression) {
        _computeTypes((XForLoopExpression)expression, state);
    } else if (expression instanceof XBasicForLoopExpression) {
        _computeTypes((XBasicForLoopExpression)expression, state);
    } else if (expression instanceof XIfExpression) {
        _computeTypes((XIfExpression)expression, state);
    } else if (expression instanceof XInstanceOfExpression) {
        _computeTypes((XInstanceOfExpression)expression, state);
    } else if (expression instanceof XNumberLiteral) {
        _computeTypes((XNumberLiteral)expression, state);
    } else if (expression instanceof XNullLiteral) {
        _computeTypes((XNullLiteral)expression, state);
    } else if (expression instanceof XReturnExpression) {
        _computeTypes((XReturnExpression)expression, state);
    } else if (expression instanceof XStringLiteral) {
        _computeTypes((XStringLiteral)expression, state);
    } else if (expression instanceof XSwitchExpression) {
        _computeTypes((XSwitchExpression)expression, state);
    } else if (expression instanceof XThrowExpression) {
        _computeTypes((XThrowExpression)expression, state);
    } else if (expression instanceof XTryCatchFinallyExpression) {
        _computeTypes((XTryCatchFinallyExpression)expression, state);
    } else if (expression instanceof XTypeLiteral) {
        _computeTypes((XTypeLiteral)expression, state);
    } else if (expression instanceof XVariableDeclaration) {
        _computeTypes((XVariableDeclaration)expression, state);
    } else if (expression instanceof XListLiteral) {
        _computeTypes((XListLiteral)expression, state);
    } else if (expression instanceof XSetLiteral) {
        _computeTypes((XSetLiteral)expression, state);
    } else if (expression instanceof XSynchronizedExpression) {
        _computeTypes((XSynchronizedExpression)expression, state);
    } else {
        throw new UnsupportedOperationException("Missing type computation for expression type: " + expression.eClass().getName() + " / " + state);
    }
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
protected void _computeTypes(final XAssignment assignment, ITypeComputationState state) {
    List<? extends IFeatureLinkingCandidate> candidates = state.getLinkingCandidates(assignment);
    ILinkingCandidate best = getBestCandidate(candidates);
    best.applyToComputationState();
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected boolean isStaticWithDeclaringType(XAssignment assignment) {
    return  assignment.isExplicitStatic() || isImplicitlyStatic(assignment);
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
protected boolean isImplicitlyStatic(XAssignment assignment) {
    return assignment.isStatic() && isTypeLiteral(assignment.getAssignable());
}