Class : AbstractModifier FinalModifier CLASS INDENTIFIER ExtendsModifier ImplementsModifier COLON Terminator ClassContent
332973
def p_Class(p):
    '''
    
    '''
    p[0] = Class(p[1], p[2], p[4], p[5], p[6], p[8], p[9])
1288088
private void addReturnTypeNarrowingDeclarations(AbstractTypeDeclaration node) {
    TypeElement type = node.getTypeElement();

    // No need to run this if the entire class is dead.
    if (deadCodeMap != null && deadCodeMap.containsClass(type, elementUtil)) {
      return;
    }

    Map<String, ExecutablePair> newDeclarations = new HashMap<>();
    Map<String, TypeMirror> resolvedReturnTypes = new HashMap<>();
    for (DeclaredType inheritedType : typeUtil.getObjcOrderedInheritedTypes(type.asType())) {
      TypeElement inheritedElem = (TypeElement) inheritedType.asElement();
      for (ExecutableElement methodElem : ElementUtil.getMethods(inheritedElem)) {
        if (ElementUtil.isPrivate(methodElem)) {
          continue;
        }
        TypeMirror declaredReturnType = typeUtil.erasure(methodElem.getReturnType());
        if (!TypeUtil.isReferenceType(declaredReturnType)) {
          continue;  // Short circuit
        }
        String selector = nameTable.getMethodSelector(methodElem);
        ExecutableType methodType = typeUtil.asMemberOf(inheritedType, methodElem);
        TypeMirror returnType = typeUtil.erasure(methodType.getReturnType());
        TypeMirror resolvedReturnType = resolvedReturnTypes.get(selector);
        if (resolvedReturnType == null) {
          resolvedReturnType = declaredReturnType;
          resolvedReturnTypes.put(selector, resolvedReturnType);
        } else if (!typeUtil.isSubtype(returnType, resolvedReturnType)) {
          continue;
        }
        if (resolvedReturnType != returnType
            && !nameTable.getObjCType(resolvedReturnType).equals(
                nameTable.getObjCType(returnType))) {
          newDeclarations.put(selector, new ExecutablePair(methodElem, methodType));
          resolvedReturnTypes.put(selector, returnType);
        }
      }
    }

    for (Map.Entry<String, ExecutablePair> newDecl : newDeclarations.entrySet()) {
      if (deadCodeMap != null
          && deadCodeMap.containsMethod(newDecl.getValue().element(), typeUtil)) {
        continue;
      }
      node.addBodyDeclaration(newReturnTypeNarrowingDeclaration(
          newDecl.getKey(), newDecl.getValue(), type));
    }
  }
112738
public void addModifier(String modifier) {
		if (!Strings.isEmpty(modifier)) {
			getSarlConstructor().getModifiers().add(modifier);
		}
	}
1364352
JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
        if (token.kind == CLASS) {
            return classDeclaration(mods, dc);
        } else if (token.kind == INTERFACE) {
            return interfaceDeclaration(mods, dc);
        } else if (allowEnums) {
            if (token.kind == ENUM) {
                return enumDeclaration(mods, dc);
            } else {
                int pos = token.pos;
                List<JCTree> errs;
                if (LAX_IDENTIFIER.accepts(token.kind)) {
                    errs = List.<JCTree>of(mods, toP(F.at(pos).Ident(ident())));
                    setErrorEndPos(token.pos);
                } else {
                    errs = List.<JCTree>of(mods);
                }
                return toP(F.Exec(syntaxError(pos, errs, "expected3",
                                              CLASS, INTERFACE, ENUM)));
            }
        } else {
            if (token.kind == ENUM) {
                error(token.pos, "enums.not.supported.in.source", source.name);
                allowEnums = true;
                return enumDeclaration(mods, dc);
            }
            int pos = token.pos;
            List<JCTree> errs;
            if (LAX_IDENTIFIER.accepts(token.kind)) {
                errs = List.<JCTree>of(mods, toP(F.at(pos).Ident(ident())));
                setErrorEndPos(token.pos);
            } else {
                errs = List.<JCTree>of(mods);
            }
            return toP(F.Exec(syntaxError(pos, errs, "expected2",
                                          CLASS, INTERFACE)));
        }
    }
151263
void generateMultiAdminObjectClassCode(Definition def, String className, int num)
   {
      if (className == null || className.equals(""))
         return;

      try
      {
         String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";

         Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
         AbstractCodeGen codeGen = (AbstractCodeGen) clazz.newInstance();

         String javaFile = "";
         if (codeGen instanceof AoImplCodeGen)
         {
            ((AoImplCodeGen) codeGen).setNumOfAo(num);
            javaFile = def.getAdminObjects().get(num).getAdminObjectClass() + ".java";
         }
         else if (codeGen instanceof AoInterfaceCodeGen)
         {
            ((AoInterfaceCodeGen) codeGen).setNumOfAo(num);
            javaFile = def.getAdminObjects().get(num).getAdminObjectInterface() + ".java";
         }

         FileWriter fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
         codeGen.generate(def, fw);

         fw.flush();
         fw.close();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
1012337
private VariableDeclaration generateAccessorInterface(
      String className, TemplateElementNode node) {
    ImmutableList.Builder<MethodDeclaration> parameterMethods = ImmutableList.builder();
    for (TemplateParam param : node.getParams()) {
      parameterMethods.add(this.generateGetParamMethodForSoyElementClass(param, true));
    }

    ClassExpression soyElementClass =
        ClassExpression.create(ImmutableList.copyOf(parameterMethods.build()));
    VariableDeclaration classExpression =
        VariableDeclaration.builder(className)
            .setJsDoc(JsDoc.builder().addAnnotation("interface").build())
            .setRhs(soyElementClass)
            .build();
    return classExpression;
  }
214130
private static int adjustedClassModifiersForInnerClassTable(ClassNode classNode) {
        int modifiers = classNode.getModifiers();
        modifiers = modifiers & ~ACC_SUPER;
        // (JLS §9.1.1.1). Such a class file must not have its ACC_FINAL, ACC_SUPER or ACC_ENUM flags set.
        if (classNode.isInterface()) {
            modifiers = modifiers & ~ACC_ENUM;
            modifiers = modifiers & ~ACC_FINAL;
        }
        modifiers = fixInnerClassModifiers(classNode, modifiers);
        return modifiers;
    }
1155426
void writeConstructor(Definition def, Writer out, int indent) throws IOException
   {
      writeSimpleMethodSignature(out, indent, " * Default constructor", "public " + getClassName(def) + "()");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1, "this.mbeanServer = null;\n");
      writeWithIndent(out, indent + 1, "this.objectName = \"" + def.getDefaultValue() + ",class=HelloWorld\";\n");
      writeWithIndent(out, indent + 1, "this.registered = false;\n\n");

      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
1039956
function finalizeMixinMerge(classDef) {
  const propNames = Object.keys(classDef.properties || {});
  propNames.forEach((name) => {
    if (classDef['__' + name]) {

      // NOTE: Modes are currently applied to properties, but we do not yet support OVERWRITE mode.
      const setters = Util.sortBy(classDef['__' + name].filter(def => def.set), (setter) => {
        switch (setter.mode) {
          case registerComponent.MODES.BEFORE:
            return 1;
          case registerComponent.MODES.AFTER:
            return 3;
          default:
            return 2;
        }
      });
      classDef['__set_' + name] = setters.map(setter => setter.set);
    }
  });

  const methodNames = Object.keys(classDef.methods || {});

  methodNames.forEach((methodName) => {
    const methodDef = classDef.methods[methodName];
    let methodList = [
      ...methodDef.methodsBefore,
      ...methodDef.methodsMiddle,
      ...methodDef.methodsAfter,
      ...methodDef.methodLast,
    ];
    if (methodDef.lock) methodList = [methodDef.lock, ...methodDef.methodLast];

    // For each method, either set the method to be the function, or set it to be the
    // getTheMethod function which assembles all of the conditionals and mixins into a single function.
    if (methodList.length === 1 && !methodDef.conditional.length) {
      classDef.methods[methodName] = methodList[0];
    } else {
      classDef['__method_' + methodName] = methodList;
      classDef.methods[methodName] = getTheMethod(classDef, methodDef.conditional, classDef['__method_' + methodName]);
    }
  });
}
881320
private static int getTypeModifiers(TypeElement type) {
    int modifiers = ElementUtil.fromModifierSet(type.getModifiers());
    if (type.getKind().isInterface()) {
      modifiers |= java.lang.reflect.Modifier.INTERFACE | java.lang.reflect.Modifier.ABSTRACT
          | java.lang.reflect.Modifier.STATIC;
    }
    if (ElementUtil.isSynthetic(type)) {
      modifiers |= ElementUtil.ACC_SYNTHETIC;
    }
    if (ElementUtil.isAnnotationType(type)) {
      modifiers |= ElementUtil.ACC_ANNOTATION;
    }
    if (ElementUtil.isEnum(type)) {
      modifiers |= ElementUtil.ACC_ENUM;
    }
    if (ElementUtil.isAnonymous(type)) {
      modifiers |= ElementUtil.ACC_ANONYMOUS;
    }
    return modifiers;
  }
195611
protected void addModifierAndType(Element member, TypeMirror type,
            Content tdSummaryType) {
        HtmlTree code = new HtmlTree(HtmlTag.CODE);
        addModifier(member, code);
        if (type == null) {
            code.addContent(utils.isClass(member) ? "class" : "interface");
            code.addContent(Contents.SPACE);
        } else {
            List<? extends TypeParameterElement> list = utils.isExecutableElement(member)
                    ? ((ExecutableElement)member).getTypeParameters()
                    : null;
            if (list != null && !list.isEmpty()) {
                Content typeParameters = ((AbstractExecutableMemberWriter) this)
                        .getTypeParameters((ExecutableElement)member);
                    code.addContent(typeParameters);
                //Code to avoid ugly wrapping in member summary table.
                if (typeParameters.charCount() > 10) {
                    code.addContent(new HtmlTree(HtmlTag.BR));
                } else {
                    code.addContent(Contents.SPACE);
                }
                code.addContent(
                        writer.getLink(new LinkInfoImpl(configuration,
                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
            } else {
                code.addContent(
                        writer.getLink(new LinkInfoImpl(configuration,
                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
            }

        }
        tdSummaryType.addContent(code);
    }
365778
public Class<?> compile(String className, String code, ClassLoader classLoader, OutputStream os, long lastModify) {
        code = code.trim();
        try {
            return Class.forName(className, true, classLoader);
        } catch (ClassNotFoundException e) {
            if (!code.endsWith("}")) {
                throw new IllegalStateException("The java code not endsWith \"}\", code: \n" + code + "\n");
            }
            try {
                return doCompile(className, code, os);
            } catch (RuntimeException t) {
                throw t;
            } catch (Throwable t) {
                throw new IllegalStateException("Failed to compile class, cause: " + t.getMessage() + ", class: "
                        + className + ", code: \n" + code + "\n, stack: " + ClassUtils.toString(t));
            }
        }
    }
730755
private function classDeclaration() {
    $node = new ClassNode();
    $this->matchDocComment($node);
    $this->tryMatch(T_ABSTRACT, $node, 'abstract') || $this->tryMatch(T_FINAL, $node, 'final');
    $this->mustMatch(T_CLASS, $node);
    $name_node = new NameNode();
    $this->mustMatch(T_STRING, $name_node, NULL, TRUE);
    $node->addChild($name_node, 'name');
    if ($this->tryMatch(T_EXTENDS, $node)) {
      $node->addChild($this->name(), 'extends');
    }
    if ($this->tryMatch(T_IMPLEMENTS, $node)) {
      $implements = new CommaListNode();
      do {
        $implements->addChild($this->name());
      } while ($this->tryMatch(',', $implements));
      $node->addChild($implements, 'implements');
    }
    $this->matchHidden($node);
    $statement_block = new StatementBlockNode();
    $this->mustMatch('{', $statement_block, NULL, FALSE, TRUE);
    $is_abstract = $node->getAbstract() !== NULL;
    while ($this->currentType !== NULL && $this->currentType !== '}') {
      $this->matchHidden($statement_block);
      $statement_block->addChild($this->classStatement($is_abstract));
    }
    $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE);
    $node->addChild($statement_block, 'statements');
    return $node;
  }
903664
@Override
    public void emitConstructorMethod(Sink sink, String indent, Constructor constructor) {
    	logger.finest("Generating constructor method for " + constructor.name);
    	final List<JavaComment> javaDoc = commentProcessor.leftAlign(commentProcessor.javaDocOnly(constructor.comments));
    	for (Arg arg : constructor.args) {
    	    final List<JavaComment> paramDoc = commentProcessor.paramDoc(arg.name, javaDoc);
    	    sink.write(ASTPrinter.printComments(indent, paramDoc));
            sink.write(indent + "public ");
            sink.write(ASTPrinter.printArgModifiers(arg.modifiers));
            sink.write(ASTPrinter.print(arg.type) + " " + arg.name + ";\n");
        }
    	sink.write("\n");
        sink.write(ASTPrinter.printComments(indent, commentProcessor.leftAlign(commentProcessor.stripTags(CONSTRUCTOR_METHOD_STRIP, commentProcessor.javaDocOnly(constructor.comments)))));    	
        sink.write(indent + "public " + constructor.name + "("); 
        constructorArgs(sink, constructor, true);        
        sink.write(") {");
        for (Arg arg : constructor.args) {
            sink.write("\n" + indent + "   this." + arg.name + " = " + arg.name + ";");
        }
        sink.write("\n" + indent + "}");
    }
213720
public static <T extends Tree> Matcher<T> hasModifier(final Modifier modifier) {
    return new Matcher<T>() {
      @Override
      public boolean matches(T tree, VisitorState state) {
        Symbol sym = ASTHelpers.getSymbol(tree);
        return sym != null && sym.getModifiers().contains(modifier);
      }
    };
  }
137645
void writeDefaultConstructor(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " */\n");

      //constructor
      writeWithIndent(out, indent, "public " + getClassName(def) + "()");
      writeLeftCurlyBracket(out, indent);
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
303382
function isModifyingProp(reference) {
			var node = reference.identifier;
			var parent = node.parent;

			while (parent && !stopNodePattern.test(parent.type)) {
				switch (parent.type) {

					// e.g. foo.a = 0;
					case "AssignmentExpression":
						return parent.left === node;

					// e.g. ++foo.a;
					case "UpdateExpression":
						return true;

					// e.g. delete foo.a;
					case "UnaryExpression":
						if (parent.operator === "delete") {
							return true;
						}
						break;

					// EXCLUDES: e.g. cache.get(foo.a).b = 0;
					case "CallExpression":
						if (parent.callee !== node) {
							return false;
						}
						break;

					// EXCLUDES: e.g. cache[foo.a] = 0;
					case "MemberExpression":
						if (parent.property === node) {
							return false;
						}
						break;

					default:
						break;
				}

				node = parent;
				parent = node.parent;
			}

			return false;
		}