Java 类org.eclipse.xtext.common.types.JvmIdentifiableElement 实例源码

项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkDelegateConstructorIsFirst(XFeatureCall featureCall) {
    JvmIdentifiableElement feature = featureCall.getFeature();
    if (feature != null && !feature.eIsProxy() && feature instanceof JvmConstructor) {
        JvmIdentifiableElement container = logicalContainerProvider.getNearestLogicalContainer(featureCall);
        if (container != null) {
            if (container instanceof JvmConstructor) {
                XExpression body = logicalContainerProvider.getAssociatedExpression(container);
                if (body == featureCall)
                    return;
                if (body instanceof XBlockExpression) {
                    List<XExpression> expressions = ((XBlockExpression) body).getExpressions();
                    if (expressions.isEmpty() || expressions.get(0) != featureCall) {
                        error("Constructor call must be the first expression in a constructor", null, INVALID_CONSTRUCTOR_INVOCATION);
                    }
                }
            } else {
                error("Constructor call must be the first expression in a constructor", null, INVALID_CONSTRUCTOR_INVOCATION);
            }
        }
    }
}
项目:xtext-extras    文件:JvmElementAtOffsetHelper.java   
public JvmIdentifiableElement getJvmIdentifiableElement(final XtextResource resource, final int offset) {
  final EObject selectedElement = this.eObjectAtOffsetHelper.resolveElementAt(resource, offset);
  if ((selectedElement == null)) {
    return null;
  }
  if ((selectedElement instanceof JvmIdentifiableElement)) {
    return ((JvmIdentifiableElement)selectedElement);
  }
  final Set<EObject> jvmElements = this.associations.getJvmElements(selectedElement);
  boolean _isEmpty = jvmElements.isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final EObject firstElement = IterableExtensions.<EObject>head(jvmElements);
    if ((firstElement instanceof JvmIdentifiableElement)) {
      return ((JvmIdentifiableElement)firstElement);
    }
  }
  return null;
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected LightweightTypeReference appendVariableTypeAndName(XVariableDeclaration varDeclaration, ITreeAppendable appendable) {
    if (!varDeclaration.isWriteable()) {
        appendable.append("final ");
    }
    LightweightTypeReference type = null;
    if (varDeclaration.getType() != null) {
        serialize(varDeclaration.getType(), varDeclaration, appendable);
        type = getLightweightType((JvmIdentifiableElement) varDeclaration);
    } else {
        type = getLightweightType(varDeclaration.getRight());
        if (type.isAny()) {
            type = getTypeForVariableDeclaration(varDeclaration.getRight());
        }
        appendable.append(type);
    }
    appendable.append(" ");
    appendable.append(appendable.declareVariable(varDeclaration, makeJavaIdentifier(varDeclaration.getName())));
    return type;
}
项目:xtext-extras    文件:ConstantConditionsInterpreter.java   
public EvaluationResult evaluateAssociatedExpression(final XExpression it, final EvaluationContext context) {
  EvaluationResult _switchResult = null;
  boolean _matched = false;
  if (it instanceof XAbstractFeatureCall) {
    JvmIdentifiableElement _feature = ((XAbstractFeatureCall)it).getFeature();
    if ((_feature instanceof JvmEnumerationLiteral)) {
      _matched=true;
      final EvaluationResult arg = this.doEvaluate(it, context);
      Object _rawValue = arg.getRawValue();
      return new EvaluationResult(_rawValue, false);
    }
  }
  if (!_matched) {
    _switchResult = this.doEvaluate(it, context);
  }
  return _switchResult;
}
项目:xtext-extras    文件:ResolvedTypes.java   
protected JvmTypeReference getDeclaredType(JvmIdentifiableElement identifiable) {
    if (identifiable instanceof JvmOperation) {
        return ((JvmOperation) identifiable).getReturnType();
    }
    if (identifiable instanceof JvmField) {
        return ((JvmField) identifiable).getType();
    }
    if (identifiable instanceof JvmConstructor) {
        return shared.resolver.getServices().getTypeReferences().createTypeRef(((JvmConstructor) identifiable).getDeclaringType());
    }
    if (identifiable instanceof JvmFormalParameter) {
        JvmTypeReference parameterType = ((JvmFormalParameter) identifiable).getParameterType();
        return parameterType;
    }
    return null;
}
项目:xtext-extras    文件:StackedResolvedTypes.java   
@Override
/* @Nullable */
protected Map<JvmIdentifiableElement, LightweightTypeReference> getFlattenedReassignedTypes() {
    if (flattenedReassignedTypes != null) {
        // already computed
        return flattenedReassignedTypes.orNull();
    }
    Map<JvmIdentifiableElement, LightweightTypeReference> result = parent.getFlattenedReassignedTypes();
    if (result == null) {
        // parent doesn't have reassigned types
        // use only locally reassigned types
        return (flattenedReassignedTypes = Optional.fromNullable(super.getFlattenedReassignedTypes())).orNull();
    }
    Map<JvmIdentifiableElement, LightweightTypeReference> myReassignedTypes = basicGetReassignedTypes();
    if (myReassignedTypes.isEmpty()) {
        // no locally reassigned types, use result from parent which was already checked for null
        return (flattenedReassignedTypes = Optional.of(result)).orNull();
    }
    // merge parent's reassigned types and locally reassigned types
    result = Maps.newHashMap(result);
    result.putAll(myReassignedTypes);
    return (flattenedReassignedTypes = Optional.of(result)).orNull();
}
项目:xtext-extras    文件:LogicalContainerAwareReentrantTypeResolver.java   
@Override
protected boolean isHandled(XExpression expression) {
    // short cut - shaves off around 20% of all calls
    if (rootedInstances.contains(expression)) {
        return true;
    }
    JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(expression);
    if (logicalContainer == null)
        return false;
    XExpression associatedExpression = logicalContainerProvider.getAssociatedExpression(logicalContainer);
    if (associatedExpression != null && EcoreUtil.isAncestor(associatedExpression, expression) && rootedInstances.contains(associatedExpression)) {
        return true;
    }
    // special treatment for annotations
    EObject root = expression;
    EObject container = root.eContainer();
    while(isPartOfExpressionTree(container)) {
        root = container;
        container = root.eContainer();
    }
    if (rootedInstances.contains(root)) {
        return true;
    }
    return false;
}
项目:xtext-extras    文件:FeatureKinds.java   
public static String getTypeName(JvmIdentifiableElement feature) {
    if (feature instanceof JvmFormalParameter) {
        return "parameter";
    }
    if (feature instanceof XVariableDeclaration) {
        return "local variable";
    }
    if (feature instanceof JvmEnumerationLiteral) {
        return "enum literal";
    }
    if (feature instanceof JvmField) {
        return "field";
    }
    if (feature instanceof JvmOperation) {
        return "method";
    }
    if (feature instanceof JvmConstructor) {
        return "constructor";
    }
    if (feature instanceof JvmType) {
        return "type";
    }
    throw new IllegalStateException();
}
项目:xtext-extras    文件:FeatureCallCompiler.java   
private boolean isPotentialJavaOperation(XAbstractFeatureCall featureCall) {
    if (featureCall.isOperation()) {
        return true;
    }
    if (featureCall.eClass() == XbasePackage.Literals.XMEMBER_FEATURE_CALL && featureCall.isStatic() && featureCall.isExtension() && featureCall.getActualArguments().size() == 2) {
        JvmIdentifiableElement feature = featureCall.getFeature();
        if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) {
            JvmDeclaredType declarator = ((JvmOperation) feature).getDeclaringType();
            if (IntegerExtensions.class.getName().equals(declarator.getIdentifier()) || LongExtensions.class.getName().equals(declarator.getIdentifier())) {
                String simpleName = feature.getSimpleName();
                if (simpleName.startsWith("bitwise") || simpleName.startsWith("shift")) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:xtext-extras    文件:ScopeProviderAccess.java   
protected IFeatureLinkingCandidate getKnownFeature(XAbstractFeatureCall featureCall, AbstractTypeComputationState state, ResolvedTypes resolvedTypes) {
    IFeatureLinkingCandidate result = resolvedTypes.getFeature(featureCall);
    if (result != null) {
        return new AppliedFeatureLinkingCandidate(result);
    }
    EObject proxyOrResolved = (EObject) featureCall.eGet(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, false);
    if (proxyOrResolved == null) {
        return new NullFeatureLinkingCandidate(featureCall, state);
    }
    if (!proxyOrResolved.eIsProxy()) {
        return state.createResolvedLink(featureCall, (JvmIdentifiableElement) proxyOrResolved);
    }
    if (!encoder.isCrossLinkFragment(featureCall.eResource(), EcoreUtil.getURI(proxyOrResolved).fragment())) {
        JvmIdentifiableElement feature = featureCall.getFeature();
        if (!feature.eIsProxy()) {
            return state.createResolvedLink(featureCall, feature);
        }
    }
    return null;
}
项目:xtext-extras    文件:TypeLiteralHelper.java   
protected LightweightTypeReference getAsClassLiteral(final JvmIdentifiableElement feature) {
    if (feature instanceof JvmType) {
        final ITypeReferenceOwner owner = state.getReferenceOwner();
        return owner.newReferenceTo(Class.class, new TypeReferenceInitializer<ParameterizedTypeReference>() {
            @Override
            public LightweightTypeReference enhance(ParameterizedTypeReference reference) {
                LightweightTypeReference argumentType = owner.newParameterizedTypeReference((JvmType) feature);
                if (argumentType.isPrimitiveVoid()) {
                    argumentType = owner.newReferenceTo(Void.class);
                } else {
                    argumentType = argumentType.getWrapperTypeIfPrimitive();
                }
                reference.addTypeArgument(argumentType);
                return reference;
            }
        });
    }
    throw new IllegalArgumentException(String.valueOf(feature));
}
项目:xtext-extras    文件:FeatureScopes.java   
protected IScope createImplicitFeatureCallScope(QualifiedName implicitName, EObject featureCall,
        IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) {
    IEObjectDescription thisDescription = session.getLocalElement(implicitName);
    if (thisDescription != null) {
        JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy();
        boolean validStaticScope = true;
        if (thisElement instanceof JvmType && THIS.equals(implicitName) && !session.isInstanceContext()) {
            validStaticScope = false;
        }
        LightweightTypeReference type = resolvedTypes.getActualType(thisElement);
        if (type !=null && !type.isUnknown()) {
            XFeatureCall implicitReceiver = xbaseFactory.createXFeatureCall();
            implicitReceiver.setFeature(thisElement);
            return createFeatureScopeForTypeRef(implicitReceiver, type, true, featureCall, session, thisElement, parent, validStaticScope);
        }
    }
    return parent;
}
项目:xtext-extras    文件:BucketedEObjectDescription.java   
protected void computeShadowingKey(JvmIdentifiableElement identifiable, StringBuilder result) {
    if (identifiable instanceof JvmExecutable) {
        JvmExecutable executable = (JvmExecutable) identifiable;
        result.append('(');
        boolean first = true;
        for(JvmFormalParameter parameter: executable.getParameters()) {
            if (!first) {
                result.append(',');
            } else {
                first = false;
            }
            if (parameter.getParameterType() != null && parameter.getParameterType().getType() != null)
                result.append(parameter.getParameterType().getType().getIdentifier());
            else
                result.append("null");
        }
        result.append(')');
    }
    if (getImplicitFirstArgument() != null) {
        result.append(":implicitFirstArgument");
    }
    if (getImplicitReceiver() != null) {
        result.append(":implicitReceiver");
    }
    if (isTypeLiteral()) {
        result.append(":typeLiteral");
    }
    if (isVisible()) {
        result.append('+');
    } else {
        result.append('-');
    }
}
项目:xtext-extras    文件:ConstantConditionsInterpreter.java   
public JvmIdentifiableElement getFeature(final XAbstractFeatureCall call, final EvaluationContext context) {
  Object _eGet = call.eGet(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, false);
  JvmIdentifiableElement feature = ((JvmIdentifiableElement) _eGet);
  if (((feature == null) || feature.eIsProxy())) {
    feature = context.getResolvedTypes().getLinkedFeature(call);
  }
  return feature;
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
/**
 * Returns <code>true</code> if the method {@link Class#getClass()} is bound and
 * the receiver is a type literal. This may indicate a bug.
 */
protected boolean isGetClassOnTypeLiteral() {
    JvmIdentifiableElement feature = getFeature();
    if (isGetClass(feature)) {
        XExpression receiver = getSyntacticReceiver();
        if (receiver instanceof XAbstractFeatureCall) {
            IFeatureLinkingCandidate linkingCandidate = getState().getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) receiver);
            if (linkingCandidate != null && linkingCandidate.isTypeLiteral()) {
                return true;
            }
        }
    }
    return false;
}
项目:xtext-extras    文件:InvokedResolvedOperation.java   
protected InvokedResolvedOperation resolve(XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes, ITypeReferenceOwner owner) {
    JvmIdentifiableElement feature = featureCall.getFeature();
    if (feature instanceof JvmOperation) {
        LightweightTypeReference contextType = getReceiverType(featureCall, resolvedTypes, owner);
        return new InvokedResolvedOperation((JvmOperation) feature, contextType, resolvedTypes.getActualTypeArguments(featureCall), overrideTester);
    } else {
        throw new IllegalArgumentException();
    }
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkVariableIsNotInferredAsVoid(XVariableDeclaration declaration) {
    if (declaration.getType() != null)
        return;
    LightweightTypeReference variableType = typeResolver.resolveTypes(declaration).getActualType((JvmIdentifiableElement) declaration);
    // TODO move to type resolver
    if (variableType != null && variableType.isPrimitiveVoid()) {
        error("void is an invalid type for the variable " + declaration.getName(), declaration,
                XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, INVALID_USE_OF_TYPE);
    }
}
项目:xtext-extras    文件:XbaseValidator.java   
@Check
public void checkConstructorArgumentsAreValid(XFeatureCall featureCall) {
    JvmIdentifiableElement feature = featureCall.getFeature();
    if (feature != null && !feature.eIsProxy() && feature instanceof JvmConstructor) {
        JvmType containerType = EcoreUtil2.getContainerOfType(logicalContainerProvider.getNearestLogicalContainer(featureCall), JvmType.class);
        for(XExpression argument: featureCall.getFeatureCallArguments()) {
            checkIsValidConstructorArgument(argument, containerType);
        }
    }
}
项目:xtext-extras    文件:XAbstractFeatureCallImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setFeature(JvmIdentifiableElement newFeature)
{
    JvmIdentifiableElement oldFeature = feature;
    feature = newFeature;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XABSTRACT_FEATURE_CALL__FEATURE, oldFeature, feature));
}
项目:xtext-extras    文件:ValidatingReassigningResolvedTypes.java   
@Override
public void reassignType(final JvmIdentifiableElement identifiable, final LightweightTypeReference reference) {
  if (((reference != null) && (!reference.isOwnedBy(this.getReferenceOwner())))) {
    throw new IllegalArgumentException("reference is not owned by this resolved types");
  }
  super.reassignType(identifiable, reference);
}
项目:xtext-extras    文件:TypeConvertingCompiler.java   
/**
 * @param wrapper unused in this context but useful for inheritors 
 */
private void convertWrapperToPrimitive(
        final LightweightTypeReference wrapper, 
        final LightweightTypeReference primitive, 
        XExpression context, 
        final ITreeAppendable appendable,
        final Later expression) {
    XExpression normalized = normalizeBlockExpression(context);
    if (normalized instanceof XAbstractFeatureCall && !(context.eContainer() instanceof XAbstractFeatureCall)) {
        // Avoid javac bug
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=410797
        // TODO make that dependent on the compiler version (javac 1.7 fixed that bug)
        XAbstractFeatureCall featureCall = (XAbstractFeatureCall) normalized;
        if (featureCall.isStatic()) {
            JvmIdentifiableElement feature = featureCall.getFeature();
            if (feature instanceof JvmOperation) {
                if (!((JvmOperation) feature).getTypeParameters().isEmpty()) {
                    appendable.append("(");
                    appendable.append(primitive);
                    appendable.append(") ");
                    expression.exec(appendable);
                    return;
                }
            }
        }
    }
    appendable.append("(");
    if (mustInsertTypeCast(context, wrapper)) {
        appendable.append("(");
        appendable.append(wrapper);
        appendable.append(") ");
    } 
    expression.exec(appendable);
    appendable.append(")");
    appendable.append(".");
    appendable.append(primitive);
    appendable.append("Value()");
}
项目:xtext-extras    文件:FeatureScopes.java   
protected IScope createConstructorDelegates(EObject context, IScope parent, IFeatureScopeSession session, IResolvedTypes resolvedTypes) {
    if (session.isConstructorContext()) {
        IEObjectDescription thisDescription = session.getLocalElement(THIS);
        if (thisDescription != null) {
            JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy();
            LightweightTypeReference type = resolvedTypes.getActualType(thisElement);
            if (type != null && !type.isUnknown()) {
                return createConstructorDelegateScope(context, type, parent, session);
            }
        }
    }
    return parent;
}
项目:xtext-extras    文件:XbaseInterpreter.java   
protected Object assignValueTo(JvmIdentifiableElement feature, XAbstractFeatureCall assignment, Object value, IEvaluationContext context, CancelIndicator indicator) {
    if (feature instanceof XVariableDeclaration) {
        return _assignValueTo((XVariableDeclaration) feature, assignment, value, context, indicator);
    } else if (feature instanceof JvmField) {
        return _assignValueTo((JvmField) feature, assignment, value, context, indicator);
    } else if (feature instanceof JvmOperation) {
        return _assignValueTo((JvmOperation) feature, assignment, value, context, indicator);
    } else {
        throw new IllegalArgumentException("Couldn't invoke 'assignValueTo' for feature "+feature+"");
    }
}
项目:xtext-extras    文件:SwitchConstantExpressionsInterpreter.java   
public Object evaluateAssociatedExpression(final XExpression it, final Context ctx) {
  Object _switchResult = null;
  boolean _matched = false;
  if (it instanceof XAbstractFeatureCall) {
    JvmIdentifiableElement _feature = ((XAbstractFeatureCall)it).getFeature();
    if ((_feature instanceof JvmEnumerationLiteral)) {
      _matched=true;
      throw this.notConstantExpression(it);
    }
  }
  if (!_matched) {
    _switchResult = this.evaluate(it, ctx);
  }
  return _switchResult;
}
项目:xtext-extras    文件:IdentifiableSimpleNameProvider.java   
public /* @Nullable */ String getSimpleName(JvmIdentifiableElement element) {
    if (element == null || element.eIsProxy()) {
        return null;
    }
    if (element instanceof JvmFeature) {
        return ((JvmFeature) element).getSimpleName();
    }
    if (element instanceof JvmFormalParameter) {
        return ((JvmFormalParameter) element).getName();
    }
    if (element instanceof XVariableDeclaration) {
        return ((XVariableDeclaration) element).getName();
    }
    return element.getSimpleName();
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
/**
 * If the condition is a {@link XInstanceOfExpression type check}, the checked expression
 * will be automatically casted in the returned state.
 */
protected ITypeComputationState reassignCheckedType(XExpression condition, /* @Nullable */ XExpression guardedExpression, ITypeComputationState state) {
    if (condition instanceof XInstanceOfExpression) {
        XInstanceOfExpression instanceOfExpression = (XInstanceOfExpression) condition;
        JvmTypeReference castedType = instanceOfExpression.getType();
        if (castedType != null) {
            state = state.withTypeCheckpoint(guardedExpression);
            JvmIdentifiableElement refinable = getRefinableCandidate(instanceOfExpression.getExpression(), state);
            if (refinable != null) {
                state.reassignType(refinable, state.getReferenceOwner().toLightweightTypeReference(castedType));
            }
        }
    }
    return state;
}
项目: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    文件:NonOverridableTypesProvider.java   
protected void addInnerTypes(
        JvmDeclaredType type,
        String prefix,
        IVisibilityHelper visibilityHelper,
        Map<String, JvmIdentifiableElement> result) {
    for (JvmMember member : type.getMembers()) {
        if (member instanceof JvmDeclaredType && visibilityHelper.isVisible(member)) {
            String localName = prefix + member.getSimpleName();
            if (!result.containsKey(localName)) {
                result.put(localName, member);
            }
            addInnerTypes((JvmDeclaredType) member, prefix + member.getSimpleName() + ".", visibilityHelper, result);
        }
    }
}
项目:xtext-extras    文件:ResolvedTypeLiteral.java   
protected ResolvedTypeLiteral(
        XAbstractFeatureCall featureCall,
        JvmIdentifiableElement resolvedElement,
        ITypeExpectation expectation,
        ExpressionTypeComputationState state) {
    super(featureCall, resolvedElement, expectation, state);
    this.helper = new TypeLiteralHelper(state);
}
项目:xtext-extras    文件:FeatureLinkingCandidate.java   
@Override
protected boolean validateArity(IAcceptor<? super AbstractDiagnostic> result) {
    if (getFeatureCall() instanceof XFeatureCall) {
        XExpression implicitReceiver = getImplicitReceiver();
        if (implicitReceiver instanceof XFeatureCall) {
            JvmIdentifiableElement feature = ((XFeatureCall) implicitReceiver).getFeature();
            if (feature instanceof JvmType && !getState().isInstanceContext()) {
                return false;
            }
        }
    }
    return super.validateArity(result);
}
项目:xtext-extras    文件:ResolvedOperationTest.java   
public IResolvedOperation toOperation(final String expression) {
  try {
    XExpression _expression = this.expression(expression);
    final XMemberFeatureCall featureCall = ((XMemberFeatureCall) _expression);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(featureCall);
    final LightweightTypeReference receiverType = resolvedTypes.getActualType(featureCall.getMemberCallTarget());
    JvmIdentifiableElement _feature = featureCall.getFeature();
    final JvmOperation operation = ((JvmOperation) _feature);
    Assert.assertFalse(operation.eIsProxy());
    return new BottomResolvedOperation(operation, receiverType, this.overrideTester);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-extras    文件:ExpressionScope.java   
protected String getSignature(IIdentifiableElementDescription desc) {
    String descName = desc.getName().getFirstSegment();
    StringBuilder builder = new StringBuilder(64).append(descName);
    JvmIdentifiableElement elementOrProxy = desc.getElementOrProxy();
    if (elementOrProxy instanceof JvmExecutable) {
        JvmExecutable executable = (JvmExecutable) desc.getElementOrProxy();
        String opName = executable.getSimpleName();
        if (opName.length() - 3 == descName.length() && opName.startsWith("set")) {
            builder.append("=");
        }
        appendParameters(executable, builder, desc.isExtension());
    }
    return builder.toString();
}
项目:xtext-extras    文件:AbstractFeatureScopeSession.java   
@Override
public IFeatureScopeSession addLocalElements(Map<QualifiedName, JvmIdentifiableElement> elements, ITypeReferenceOwner owner) {
    if (elements.isEmpty())
        return this;
    AbstractNestedFeatureScopeSession result = tryCreateNestedSessionWithVisibilityContext(elements, owner, IFeatureNames.THIS);
    if (result != null)
        return result;
    result = tryCreateNestedSessionWithVisibilityContext(elements, owner, IFeatureNames.SELF);
    if (result != null)
        return result;
    result = new FeatureScopeSessionWithLocalElements(this, elements);
    return result;
}
项目:xtext-extras    文件:ArithmeticExtensionsTest.java   
protected void assertOnlyPrimitiveOperationsBound(XExpression expression) {
    boolean operationsFound = false;
    for (XAbstractFeatureCall featureCall : EcoreUtil2.eAllOfType(expression, XAbstractFeatureCall.class)) {
        JvmIdentifiableElement feature = featureCall.getFeature();
        if (feature instanceof JvmOperation) {
            for (JvmFormalParameter parameter : ((JvmOperation) feature).getParameters()) {
                operationsFound = true;
                assertTrue(parameter.getParameterType().getIdentifier(),
                        primitives.isPrimitive(parameter.getParameterType()));
            }
        }
    }
    assertTrue("No operations found", operationsFound);
}
项目:xtext-extras    文件:AbstractXbaseLinkingTest.java   
@Test public void testOverloadedMethods_04() throws Exception {
    XBlockExpression block = (XBlockExpression) expression(
            "{\n" +
            "    var java.util.List<? extends Object> objects = null\n" +
            "    var testdata.OverloadedMethods<Object> receiver = null\n" +
            "    receiver.overloaded(objects, objects)\n" +
            "}");
    XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(2);
    JvmIdentifiableElement overloaded = featureCall.getFeature();
    assertNotNull(overloaded);
    assertFalse(overloaded.eIsProxy());
    assertEquals("testdata.OverloadedMethods.overloaded(java.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier());
}
项目: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    文件: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    文件:AbstractTypeComputationState.java   
@Override
public void addLocalToCurrentScope(JvmIdentifiableElement element) {
    String simpleName = element.getSimpleName();
    if (Strings.isNullOrEmpty(simpleName))
        return;
    QualifiedName elementName = QualifiedName.create(simpleName);
    addLocalToCurrentScope(elementName, element, !getResolver().isShadowingAllowed(elementName));
}
项目:xtext-extras    文件:AbstractTypeComputationState.java   
protected IIdentifiableElementDescription toIdentifiableDescription(IEObjectDescription description) {
    if (description instanceof IIdentifiableElementDescription)
        return (IIdentifiableElementDescription) description;
    if (!(description.getEObjectOrProxy() instanceof JvmIdentifiableElement)) {
        throw new IllegalStateException("Given description does not describe an identifable element");
    }
    return new SimpleIdentifiableElementDescription(description);
}
项目:xtext-extras    文件:CompoundReentrantTypeResolver.java   
@Override
public LightweightTypeReference getActualType(JvmIdentifiableElement identifiable) {
    for(int i = 0; i < resolvers.size(); i++) {
        AbstractRootedReentrantTypeResolver resolver = resolvers.get(i);
        if (resolver.isHandled(identifiable)) {
            IResolvedTypes delegate = getDelegate(i);
            return delegate.getActualType(identifiable);
        }
    }
    return null;
}