private TypeDeclaration createTypeBody(lombok.ast.StrictListAccessor<lombok.ast.TypeMember, ?> members, lombok.ast.TypeDeclaration type, boolean canHaveConstructor, int extraModifiers, FieldDeclaration... initialFields) { TypeDeclaration decl = new TypeDeclaration(compilationResult); decl.modifiers = (type == null ? 0 : toModifiers(type.astModifiers())) | extraModifiers; if (members.isEmpty() && isUndocumented(members.owner())) decl.bits |= ASTNode.UndocumentedEmptyBlock; decl.sourceStart = start(type.astName()); decl.sourceEnd = end(type.astName()); decl.declarationSourceStart = jstart(type); decl.declarationSourceEnd = end(type); if (!(type instanceof AnnotationDeclaration) || !type.astModifiers().isEmpty() || type.rawJavadoc() != null) { decl.modifiersSourceStart = jstart(type.astModifiers()); } else { decl.modifiersSourceStart = -1; defaultConstructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper); defaultConstructor.modifiers = decl.modifiers & VISIBILITY_MASK; defaultConstructor.selector = toName(type.astName()); defaultConstructor.sourceStart = defaultConstructor.declarationSourceStart = defaultConstructor.constructorCall.sourceStart = start(type.astName()); defaultConstructor.sourceEnd = defaultConstructor.bodyEnd = defaultConstructor.constructorCall.sourceEnd = defaultConstructor.declarationSourceEnd = end(type.astName()); methods.add(0, defaultConstructor);
if (declaration instanceof TypeDeclaration && ((TypeDeclaration)declaration).isInterface()) { out |= Modifier.ABSTRACT; if (container != null && container.isInterface()) out |= Modifier.STATIC; if (container != null && container.isInterface() && (explicit & Modifier.STATIC) == 0) { out |= Modifier.PUBLIC | Modifier.ABSTRACT; if (container != null && container.isInterface()) { out |= Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC;
private int typeModifiersCheck(TypeDeclaration td, String desc) { int flags = modifiersCheck(td.astModifiers(), TYPE_MODIFIERS_EXCLUSIVITY, TYPE_MODIFIERS_LEGAL, desc); boolean staticWarningEmitted = false; if (td.upIfTopLevelToCompilationUnit() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Top-level types cannot be private."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Top-level types cannot be static."); } else if (td.upToBlock() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Method-local types cannot be private."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PROTECTED, "protected", "Method-local types cannot be protected."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PUBLIC, "public", "Method-local types cannot be public."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Method-local types cannot be static."); } if (!staticWarningEmitted) checkStaticChain(td.astModifiers()); return flags; }
decl.astJavadoc((lombok.ast.Comment) toTree(node.javadoc)); decl.astModifiers(toModifiers(node.modifiers, node.annotations, node.modifiersSourceStart, node.declarationSourceStart)); decl.astName(toIdentifier(node.name, node.sourceStart, node.sourceEnd)); decl.setPosition(toPosition(node.declarationSourceStart, node.declarationSourceEnd));
public void checkStaticInitializerInNonStaticType(StaticInitializer node) { TypeDeclaration parent = node.upUpToTypeDeclaration(); if (parent != null) { if (!parent.astModifiers().isStatic()) { node.addMessage(error(INITIALIZER_STATIC_IN_NON_STATIC_TYPE, "static initializers are only allowed in top-level or static types declarations.")); } } }
typeDecl.astName(new Identifier().astValue(name)); typeDecl.astModifiers((Modifiers) toTree(node.mods)); addJavadoc(typeDecl, node.mods); set(node, typeDecl);
if (c instanceof TypeDeclaration && namesMatch(name, ((TypeDeclaration) c).astName())) return false; if (stopAtSelf && c == prevN) break;
decl.astJavadoc((lombok.ast.Comment) toTree(node.javadoc)); decl.astModifiers(toModifiers(node.modifiers, node.annotations, node.modifiersSourceStart, node.declarationSourceStart)); decl.astName(toIdentifier(node.name, node.sourceStart, node.sourceEnd)); decl.setPosition(toPosition(node.declarationSourceStart, node.declarationSourceEnd));
public void checkStaticInitializerInNonStaticType(StaticInitializer node) { TypeDeclaration parent = node.upUpToTypeDeclaration(); if (parent != null) { if (!parent.astModifiers().isStatic()) { node.addMessage(error(INITIALIZER_STATIC_IN_NON_STATIC_TYPE, "static initializers are only allowed in top-level or static types declarations.")); } } }
typeDecl.astName(new Identifier().astValue(name)); typeDecl.astModifiers((Modifiers) toTree(node.mods)); addJavadoc(typeDecl, node.mods); set(node, typeDecl);
if (c instanceof TypeDeclaration && namesMatch(name, ((TypeDeclaration) c).astName())) return false; if (stopAtSelf && c == prevN) break;
decl.astJavadoc((lombok.ast.Comment) toTree(node.javadoc)); decl.astModifiers(toModifiers(node.modifiers, node.annotations, node.modifiersSourceStart, node.declarationSourceStart)); decl.astName(toIdentifier(node.name, node.sourceStart, node.sourceEnd)); decl.setPosition(toPosition(node.declarationSourceStart, node.declarationSourceEnd));
private TypeDeclaration createTypeBody(lombok.ast.StrictListAccessor<lombok.ast.TypeMember, ?> members, lombok.ast.TypeDeclaration type, boolean canHaveConstructor, int extraModifiers, FieldDeclaration... initialFields) { TypeDeclaration decl = new TypeDeclaration(compilationResult); decl.modifiers = (type == null ? 0 : toModifiers(type.astModifiers())) | extraModifiers; if (members.isEmpty() && isUndocumented(members.owner())) decl.bits |= ASTNode.UndocumentedEmptyBlock; decl.sourceStart = start(type.astName()); decl.sourceEnd = end(type.astName()); decl.declarationSourceStart = jstart(type); decl.declarationSourceEnd = end(type); if (!(type instanceof AnnotationDeclaration) || !type.astModifiers().isEmpty() || type.rawJavadoc() != null) { decl.modifiersSourceStart = jstart(type.astModifiers()); } else { decl.modifiersSourceStart = -1; defaultConstructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper); defaultConstructor.modifiers = decl.modifiers & VISIBILITY_MASK; defaultConstructor.selector = toName(type.astName()); defaultConstructor.sourceStart = defaultConstructor.declarationSourceStart = defaultConstructor.constructorCall.sourceStart = start(type.astName()); defaultConstructor.sourceEnd = defaultConstructor.bodyEnd = defaultConstructor.constructorCall.sourceEnd = defaultConstructor.declarationSourceEnd = end(type.astName()); methods.add(0, defaultConstructor);
private int typeModifiersCheck(TypeDeclaration td, String desc) { int flags = modifiersCheck(td.astModifiers(), TYPE_MODIFIERS_EXCLUSIVITY, TYPE_MODIFIERS_LEGAL, desc); boolean staticWarningEmitted = false; if (td.upIfTopLevelToCompilationUnit() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Top-level types cannot be private."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Top-level types cannot be static."); } else if (td.upToBlock() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Method-local types cannot be private."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PROTECTED, "protected", "Method-local types cannot be protected."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PUBLIC, "public", "Method-local types cannot be public."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Method-local types cannot be static."); } if (!staticWarningEmitted) checkStaticChain(td.astModifiers()); return flags; }
public void checkStaticInitializerInNonStaticType(StaticInitializer node) { TypeDeclaration parent = node.upUpToTypeDeclaration(); if (parent != null) { if (!parent.astModifiers().isStatic()) { node.addMessage(error(INITIALIZER_STATIC_IN_NON_STATIC_TYPE, "static initializers are only allowed in top-level or static types declarations.")); } } }
typeDecl.astName(new Identifier().astValue(name)); typeDecl.astModifiers((Modifiers) toTree(node.mods)); addJavadoc(typeDecl, node.mods); set(node, typeDecl);
if (c instanceof TypeDeclaration && namesMatch(name, ((TypeDeclaration) c).astName())) return false; if (stopAtSelf && c == prevN) break;
if (declaration instanceof TypeDeclaration && ((TypeDeclaration)declaration).isInterface()) { out |= Modifier.ABSTRACT; if (container != null && container.isInterface()) out |= Modifier.STATIC; if (container != null && container.isInterface() && (explicit & Modifier.STATIC) == 0) { out |= Modifier.PUBLIC | Modifier.ABSTRACT; if (container != null && container.isInterface()) { out |= Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC;
private TypeDeclaration createTypeBody(lombok.ast.StrictListAccessor<lombok.ast.TypeMember, ?> members, lombok.ast.TypeDeclaration type, boolean canHaveConstructor, int extraModifiers, FieldDeclaration... initialFields) { TypeDeclaration decl = new TypeDeclaration(compilationResult); decl.modifiers = (type == null ? 0 : toModifiers(type.astModifiers())) | extraModifiers; if (members.isEmpty() && isUndocumented(members.owner())) decl.bits |= ASTNode.UndocumentedEmptyBlock; decl.sourceStart = start(type.astName()); decl.sourceEnd = end(type.astName()); decl.declarationSourceStart = jstart(type); decl.declarationSourceEnd = end(type); if (!(type instanceof AnnotationDeclaration) || !type.astModifiers().isEmpty() || type.rawJavadoc() != null) { decl.modifiersSourceStart = jstart(type.astModifiers()); } else { decl.modifiersSourceStart = -1; defaultConstructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper); defaultConstructor.modifiers = decl.modifiers & VISIBILITY_MASK; defaultConstructor.selector = toName(type.astName()); defaultConstructor.sourceStart = defaultConstructor.declarationSourceStart = defaultConstructor.constructorCall.sourceStart = start(type.astName()); defaultConstructor.sourceEnd = defaultConstructor.bodyEnd = defaultConstructor.constructorCall.sourceEnd = defaultConstructor.declarationSourceEnd = end(type.astName()); methods.add(0, defaultConstructor);
private int typeModifiersCheck(TypeDeclaration td, String desc) { int flags = modifiersCheck(td.astModifiers(), TYPE_MODIFIERS_EXCLUSIVITY, TYPE_MODIFIERS_LEGAL, desc); boolean staticWarningEmitted = false; if (td.upIfTopLevelToCompilationUnit() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Top-level types cannot be private."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Top-level types cannot be static."); } else if (td.upToBlock() != null) { generateNotAllowedKeywordError(td.astModifiers(), flags, K_PRIVATE, "private", "Method-local types cannot be private."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PROTECTED, "protected", "Method-local types cannot be protected."); generateNotAllowedKeywordError(td.astModifiers(), flags, K_PUBLIC, "public", "Method-local types cannot be public."); staticWarningEmitted |= generateNotAllowedKeywordError(td.astModifiers(), flags, K_STATIC, "static", "Method-local types cannot be static."); } if (!staticWarningEmitted) checkStaticChain(td.astModifiers()); return flags; }