Example #1
0
 protected IScope createLocalVarScopeForBlock(
     XBlockExpression block,
     int indexOfContextExpressionInBlock,
     boolean referredFromClosure,
     IScope parentScope) {
   List<IValidatedEObjectDescription> descriptions = Lists.newArrayList();
   for (int i = 0; i < indexOfContextExpressionInBlock; i++) {
     XExpression expression = block.getExpressions().get(i);
     if (expression instanceof XVariableDeclaration) {
       XVariableDeclaration varDecl = (XVariableDeclaration) expression;
       if (varDecl.getName() != null) {
         IValidatedEObjectDescription desc = createLocalVarDescription(varDecl);
         if (referredFromClosure && varDecl.isWriteable())
           desc.setIssueCode(IssueCodes.INVALID_MUTABLE_VARIABLE_ACCESS);
         descriptions.add(desc);
       }
     }
   }
   return new JvmFeatureScope(parentScope, "XBlockExpression", descriptions);
 }
 public String check(IEObjectDescription input) {
   if (input instanceof IValidatedEObjectDescription) {
     final IValidatedEObjectDescription validatedDescription =
         (IValidatedEObjectDescription) input;
     JvmIdentifiableElement identifiable = validatedDescription.getEObjectOrProxy();
     if (identifiable.eIsProxy())
       identifiable = (JvmIdentifiableElement) EcoreUtil.resolve(identifiable, context);
     String issueCode;
     if (identifiable.eIsProxy()) issueCode = UNRESOLVABLE_PROXY;
     else if (!validatedDescription.isValid()) {
       if (Strings.isEmpty(validatedDescription.getIssueCode())) issueCode = FEATURE_NOT_VISIBLE;
       else return validatedDescription.getIssueCode();
     } else issueCode = dispatcher.invoke(identifiable, context, reference, validatedDescription);
     validatedDescription.setIssueCode(issueCode);
     return issueCode;
   }
   return null;
 }