Examples of MethodScope


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope

/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public TypeBinding checkFieldAccess(BlockScope scope) {
  FieldBinding fieldBinding = (FieldBinding) this.binding;
  MethodScope methodScope = scope.methodScope();
  // check for forward references
  if (this.indexOfFirstFieldBinding == 1
      && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
      && methodScope.lastVisibleFieldID >= 0
      && fieldBinding.id >= methodScope.lastVisibleFieldID
      && (!fieldBinding.isStatic() || methodScope.isStatic)) {
    scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType());
  }
  this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
  this.bits |= Binding.FIELD;
  return getOtherFieldBindings(scope);
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope

          this.bits |= Binding.LOCAL;
          return this.resolvedType = getOtherFieldBindings(scope);
        }
        if (this.binding instanceof FieldBinding) {
          FieldBinding fieldBinding = (FieldBinding) this.binding;
          MethodScope methodScope = scope.methodScope();
          // check for forward references
          if (this.indexOfFirstFieldBinding == 1
              && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
              && methodScope.lastVisibleFieldID >= 0
              && fieldBinding.id >= methodScope.lastVisibleFieldID
              && (!fieldBinding.isStatic() || methodScope.isStatic)) {
            scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType());
          }
          if (!fieldBinding.isStatic()
              && this.indexOfFirstFieldBinding == 1
              && scope.compilerOptions().getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
            scope.problemReporter().unqualifiedFieldAccess(this, fieldBinding);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope

          knownScopes.put(scope, newElement);
        }
        break;
      case Scope.METHOD_SCOPE :
        IType parentType = (IType) createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
        MethodScope methodScope = (MethodScope) scope;
        if (methodScope.isInsideInitializer()) {
          // inside field or initializer, must find proper one
          TypeDeclaration type = methodScope.referenceType();
          int occurenceCount = 1;
          for (int i = 0, length = type.fields.length; i < length; i++) {
            FieldDeclaration field = type.fields[i];
            if (field.declarationSourceStart < elementPosition && field.declarationSourceEnd > elementPosition) {
              switch (field.getKind()) {
                case AbstractVariableDeclaration.FIELD :
                case AbstractVariableDeclaration.ENUM_CONSTANT :
                  newElement = parentType.getField(new String(field.name));
                  break;
                case AbstractVariableDeclaration.INITIALIZER :
                  newElement = parentType.getInitializer(occurenceCount);
                  break;
              }
              break;
            } else if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
              occurenceCount++;
            }
          }
        } else {
          // method element
          AbstractMethodDeclaration method = methodScope.referenceMethod();
          newElement = parentType.getMethod(new String(method.selector), Util.typeParameterSignatures(method));
          if (newElement != null) {
            knownScopes.put(scope, newElement);
          }
        }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope

  private AdviceDeclaration findEnclosingAround(Scope scope) {
    if (scope == null) return null;
       
    if (scope instanceof MethodScope) {
      MethodScope methodScope = (MethodScope)scope;
      ReferenceContext context = methodScope.referenceContext;
      if (context instanceof AdviceDeclaration) {
        AdviceDeclaration adviceDecl = (AdviceDeclaration)context;
        if (adviceDecl.kind == AdviceKind.Around) {
          // pr 53981 only match "bare" calls to proceed
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope

    pre.arguments = AstUtil.copyArguments(this.arguments);

    // XXX should do exceptions

    pre.scope = new MethodScope(scope, pre, true);
    // ??? do we need to do anything with scope???

    // Use the factory to build a semi-correct resolvedmember - then patch it up with
    // reset calls. This is SAFE
    ResolvedMemberImpl preIntroducedConstructorRM = world.makeResolvedMember(binding);
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.dynamicimpl.JavaCodeGenerator.MethodScope

    @Override
    void writeMethodImplementationJava(ClassScope classScope, Method m) {
      writeMethodDeclarationJava(classScope, m, Collections.<String>emptyList());
      classScope.startLine("{\n");

      MethodScope scope = classScope.newMethodScope();

      scope.indentRight();

      scope.startLine("");
      quickParser.appendFinishedValueTypeNameJava(scope);
      scope.append(" result;\n");

      boolean wrap = quickParser.javaCodeThrowsException() || !isOptional;
      if (wrap) {
        scope.startLine("try {\n");
        scope.indentRight();
      }

      String valueRef = scope.newMethodScopedName("value");
      String hasValueRef = scope.newMethodScopedName("hasValue");
      Util.writeReadValueAndHasValue(scope, fieldName, "underlying", valueRef, hasValueRef);
      scope.startLine("if (" + hasValueRef + ") {\n");
      scope.indentRight();
      if (quickParser.javaCodeThrowsException()) {
        scope.startLine("try {\n");
        scope.indentRight();
        quickParser.writeParseQuickCode(scope, valueRef, "r1");
        scope.startLine("result = r1;\n");
        scope.indentLeft();
        scope.startLine("} catch (" + Util.BASE_PACKAGE + ".JsonProtocolParseException e) {\n");
        scope.startLine("  throw new " + Util.BASE_PACKAGE + ".JsonProtocolParseException(" +
            "\"Failed to parse field " + fieldName + " in type ");
        scope.append(typeClass.getName() + "\", e);\n");
        scope.startLine("}\n");
      } else {
        quickParser.writeParseQuickCode(scope, valueRef, "r1");
        scope.startLine("result = r1;\n");
      }
      scope.indentLeft();
      scope.startLine("} else {\n");
      scope.indentRight();
      if (isOptional) {
        scope.startLine("result = null;\n");
      } else {
        scope.startLine("throw new " + Util.BASE_PACKAGE + ".JsonProtocolParseException(" +
            "\"Field is not optional: " + fieldName + "\");\n");
      }
      scope.indentLeft();
      scope.startLine("}\n");

      if (wrap) {
        scope.indentLeft();
        scope.startLine("} catch (" + Util.BASE_PACKAGE + ".JsonProtocolParseException e) {\n");
        scope.startLine("  throw new " + Util.BASE_PACKAGE +
            ".implutil.CommonImpl.ParseRuntimeException(" +
            "\"On demand parsing failed for \" + underlying, e);\n");
        scope.startLine("}\n");
      }
      scope.startLine("return result;\n");
      scope.indentLeft();
      scope.startLine("}\n");
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.dynamicimpl.JavaCodeGenerator.MethodScope

            Util.writeJavaTypeName(exceptions[i], classScope.getStringBuilder());
          }
        }
      }

      MethodScope scope = classScope.newMethodScope();
      scope.append(" {\n");
      scope.indentRight();

      classScope.startLine("");
      writeReturnTypeJava(classScope, m);
      scope.append(" result = ");
      getFieldBinding().writeGetExpressionJava(scope.getStringBuilder());
      scope.append(";\n");

      scope.startLine("if (result != null) {\n");
      scope.startLine("  return result;\n");
      scope.startLine("}\n");

      String parseResultRef = scope.newMethodScopedName("parseResult");
      writeParseJava(scope, parseResultRef);

      scope.startLine("if (" + parseResultRef + " != null) {\n");
      scope.indentRight();
      getFieldBinding().writeSetAndGetJava(scope, parseResultRef, "cachedResult");
      scope.startLine(parseResultRef + " = cachedResult;\n");
      scope.indentLeft();
      scope.startLine("}\n");

      scope.startLine("return " + parseResultRef + ";\n");

      scope.indentLeft();
      scope.startLine("}\n");
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.dynamicimpl.JavaCodeGenerator.MethodScope

    classScope.startLine(valueImplClassName + "(Object input");
    subtypeAspect.writeSuperConstructorParamJava(classScope);
    classScope.append(")" + Util.THROWS_CLAUSE + " {\n");

    {
      MethodScope methodScope = classScope.newMethodScope();
      methodScope.indentRight();
      methodScope.startLine("super(input);\n");

      subtypeAspect.writeSuperConstructorInitializationJava(methodScope);

      for (FieldLoader fieldLoader : fieldLoaders) {
        String valueRef = methodScope.newMethodScopedName("value");
        String hasValueRef = methodScope.newMethodScopedName("hasValue");
        String fieldName = fieldLoader.getFieldName();
        methodScope.append("\n");
        Util.writeReadValueAndHasValue(methodScope, fieldName, "underlying", valueRef,
            hasValueRef);
        fieldLoader.writeFieldLoadJava(methodScope, valueRef, hasValueRef);
      }

      if (algCasesData != null) {
        algCasesData.writeConstructorCodeJava(methodScope);
      }

      methodScope.indentLeft();

    }

    classScope.startLine("}\n");
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.dynamicimpl.JavaCodeGenerator.MethodScope

    @Override
    void writeHelperMethodsJava(ClassScope classScope) {
      classScope.startLine("public static boolean checkSubtypeConditions(" +
          "org.json.simple.JSONObject input)" + Util.THROWS_CLAUSE + " {\n");
      MethodScope methodScope = classScope.newMethodScope();
      methodScope.indentRight();
      for (FieldCondition condition : fieldConditions) {
        String name = condition.getPropertyName();
        methodScope.startLine("{\n");
        methodScope.startLine("  Object value = input.get(\"" + name + "\");\n");
        methodScope.startLine("  boolean hasValue;\n");
        methodScope.startLine("  if (value == null) {\n");
        methodScope.startLine("    hasValue = input.containsKey(\"" + name + "\");\n");
        methodScope.startLine("  } else {\n");
        methodScope.startLine("    hasValue = true;\n");
        methodScope.startLine("  }\n");
        condition.writeCheckJava(methodScope, "value", "hasValue", "conditionRes");
        methodScope.startLine("  if (!conditionRes) {\n");
        methodScope.startLine("    return false;\n");
        methodScope.startLine("  }\n");
        methodScope.startLine("}\n");
      }
      methodScope.startLine("return true;\n");
      methodScope.indentLeft();
      methodScope.startLine("}\n");
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.MethodScope

      return synthetic;
    }

    private JMethodBody findEnclosingMethod(BlockScope scope) {
      JMethod method;
      MethodScope methodScope = scope.methodScope();
      if (methodScope.isInsideInitializer()) {
        JDeclaredType enclosingType = (JDeclaredType) typeMap.get(scope.classScope().referenceContext.binding);
        if (methodScope.isStatic) {
          // clinit
          method = enclosingType.getMethods().get(0);
        } else {
          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.getMethods().get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) method.getBody();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.