Ejemplo n.º 1
0
 static void addCreateMemberProposals(
     Collection<ICompletionProposal> proposals,
     IProject project,
     DefinitionGenerator dg,
     Tree.QualifiedMemberOrTypeExpression qmte,
     Tree.Statement statement) {
   Tree.Primary p = ((Tree.QualifiedMemberOrTypeExpression) qmte).getPrimary();
   if (p.getTypeModel() != null) {
     Declaration typeDec = p.getTypeModel().getDeclaration();
     addCreateMemberProposals(proposals, project, dg, typeDec, statement);
   }
 }
Ejemplo n.º 2
0
  private void visitReference(Tree.Primary that) {
    Declaration member;
    boolean assigned;
    boolean metamodel;
    if (that instanceof Tree.MemberOrTypeExpression) {
      Tree.MemberOrTypeExpression mte = (Tree.MemberOrTypeExpression) that;
      member = mte.getDeclaration();
      assigned = mte.getAssigned();
      metamodel = false;
    } else if (that instanceof Tree.MetaLiteral) {
      Tree.MetaLiteral ml = (Tree.MetaLiteral) that;
      member = ml.getDeclaration();
      assigned = false;
      metamodel = true;
    } else {
      return;
    }

    if (member == declaration && member.isDefinedInScope(that.getScope())) {
      if (!declared) {
        // you are allowed to refer to later
        // declarations in a class declaration
        // section or interface
        if (withinAttributeInitializer
            && member instanceof Value
            && !(((Value) member).isTransient())) {
          that.addError(
              "reference to value within its initializer: '" + member.getName() + "'", 1460);
        } else if (!metamodel && !isForwardReferenceable() && !hasParameter) {
          Scope container = declaration.getContainer();
          if (container instanceof Class) {
            that.addError(
                "forward reference to class member in initializer: '"
                    + member.getName()
                    + "' is not yet declared (forward references must occur in declaration section)");
          } else {
            that.addError(
                "forward reference to local declaration: '"
                    + member.getName()
                    + "' is not yet declared");
          }
        }
      } else if (!specified.definitely || declaration.isFormal()) {
        // you are allowed to refer to formal
        // declarations in a class declaration
        // section or interface
        if (declaration.isFormal()) {
          if (!isForwardReferenceable()) {
            that.addError(
                "formal member may not be used in initializer: '" + member.getName() + "'");
          }
        } else if (!metamodel
            && !isNativeHeader(declaration)
            && (!isLate() || !isForwardReferenceable())) {
          if (isVariable()) {
            that.addError("not definitely initialized: '" + member.getName() + "'");
          } else {
            that.addError("not definitely specified: '" + member.getName() + "'");
          }
        }
      }
      if (!assigned && member.isDefault() && !isForwardReferenceable()) {
        that.addError("default member may not be used in initializer: '" + member.getName() + "'");
      }
      if (inAnonFunctionOrComprehension && specified.definitely && isVariable()) {
        that.addError(
            "variable member may not be captured by comprehension or function in extends clause: '"
                + member.getName()
                + "'");
      }
    }
  }