当前位置: 首页>>代码示例>>Java>>正文


Java ModifierSet类代码示例

本文整理汇总了Java中japa.parser.ast.body.ModifierSet的典型用法代码示例。如果您正苦于以下问题:Java ModifierSet类的具体用法?Java ModifierSet怎么用?Java ModifierSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModifierSet类属于japa.parser.ast.body包,在下文中一共展示了ModifierSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJavaMethods

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private void getJavaMethods (ArrayList<JavaMethod> methods, TypeDeclaration type) {
	classStack.push(type);
	if (type.getMembers() != null) {
		for (BodyDeclaration member : type.getMembers()) {
			if (member instanceof ClassOrInterfaceDeclaration || member instanceof EnumDeclaration) {
				getJavaMethods(methods, (TypeDeclaration)member);
			} else {
				if (member instanceof MethodDeclaration) {
					MethodDeclaration method = (MethodDeclaration)member;
					if (!ModifierSet.hasModifier(((MethodDeclaration)member).getModifiers(), ModifierSet.NATIVE)) continue;
					methods.add(createMethod(method));
				}
			}
		}
	}
	classStack.pop();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:RobustJavaMethodParser.java

示例2: isGetterMethod

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private boolean isGetterMethod(MethodDeclaration method)
{
    if ((method.getBody() != null) && (method.getBody().getStmts() != null))
    {
        LinkedList<String> attNames = getAttributesNames();
        
        if (attNames.size() == 0)
            return false;
        
        List<Statement> stmts = method.getBody().getStmts();        

        for (Statement stmt : stmts)
            for (String name : attNames)
                if ((stmt.toString().matches("(.*)return(\\s+)" + name + "(\\s*);")) && (method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() == null))
                    return true;
    }
    
    return false;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:NumberOfAccessorMethods.java

示例3: isSetterMethod

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private boolean isSetterMethod(MethodDeclaration method)
{
    if ((method.getBody() != null) && (method.getBody().getStmts() != null))
    {
        LinkedList<String> attNames = getAttributesNames();
        
        if (attNames.size() == 0)
            return false;
        
        List<Statement> stmts = method.getBody().getStmts();        

        for (Statement stmt : stmts)
            for (String name : attNames)
                if ((method.getModifiers() == ModifierSet.PUBLIC) && (method.getParameters() != null) && (method.getParameters().size() == 1) && (method.getType().equals(new VoidType())) && (stmt.toString().matches("(.*)"+name+"(\\s*)=(.*)"+method.getParameters().get(0).getId().getName()+"(.*);")))
                    return true;
    }
    
    return false;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:NumberOfAccessorMethods.java

示例4: addAttachSkeleton

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private void addAttachSkeleton() {
	List<Parameter> params = Collections.emptyList();
	MethodDeclaration method = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), "attach", params);
	AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
	method.setAnnotations(Collections.singletonList(override));
	
	BlockStmt block = new BlockStmt();
	Expression e = new MethodCallExpr(new SuperExpr(), "attach");
	List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
	block.setStmts(sts);
	method.setBody(block);
	
	if (getType().getMembers()==null) {
		getType().setMembers(new LinkedList<BodyDeclaration>());
	}
	getType().getMembers().add(method);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:19,代码来源:ControllerCode.java

示例5: addOnBecomingVisibleMethod

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
@SuppressWarnings("unused")
private void addOnBecomingVisibleMethod() {
	List<Parameter> params = Collections.emptyList();
	MethodDeclaration method = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), "onBecomingVisible", params);
	AnnotationExpr override = new MarkerAnnotationExpr(new NameExpr("Override"));
	method.setAnnotations(Collections.singletonList(override));
	
	BlockStmt block = new BlockStmt();
	Expression e = new MethodCallExpr(new SuperExpr(), "onBecomingVisible");
	List<Statement> sts = Collections.singletonList((Statement)new ExpressionStmt(e));
	block.setStmts(sts);
	method.setBody(block);
	
	if (getType().getMembers()==null) {
		getType().setMembers(new LinkedList<BodyDeclaration>());
	}
	getType().getMembers().add(method);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:20,代码来源:ControllerCode.java

示例6: addClaraHandler

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private MethodDeclaration addClaraHandler(String id, String className) {
	ensureImport(className);
	String shortName = className.substring(className.lastIndexOf(".")+1);
	String handlerName = generateHandlerNameFor(id, shortName);
	
	Parameter p = new Parameter(new ClassOrInterfaceType(shortName), new VariableDeclaratorId("event"));
	MethodDeclaration handler = new MethodDeclaration(
			ModifierSet.PUBLIC, new VoidType(), handlerName, Collections.singletonList(p));
	handler.setBody(new BlockStmt());
	handler.setAnnotations(createClaraHandlerAnnotations(id));
	
	addNotification(handler, shortName+" on "+id);		
	
	addMember(handler);
	return handler;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:ControllerCode.java

示例7: getJdkModifier

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
/**
 * Converts a Java Parser modifier integer into a JDK {@link Modifier}
 * integer.
 * 
 * @param modifiers the Java Parser int
 * @return the equivalent JDK int
 */
public static int getJdkModifier(final int modifiers) {
    int result = 0;
    if (ModifierSet.isAbstract(modifiers)) {
        result |= Modifier.ABSTRACT;
    }
    if (ModifierSet.isFinal(modifiers)) {
        result |= Modifier.FINAL;
    }
    if (ModifierSet.isNative(modifiers)) {
        result |= Modifier.NATIVE;
    }
    if (ModifierSet.isPrivate(modifiers)) {
        result |= Modifier.PRIVATE;
    }
    if (ModifierSet.isProtected(modifiers)) {
        result |= Modifier.PROTECTED;
    }
    if (ModifierSet.isPublic(modifiers)) {
        result |= Modifier.PUBLIC;
    }
    if (ModifierSet.isStatic(modifiers)) {
        result |= Modifier.STATIC;
    }
    if (ModifierSet.isStrictfp(modifiers)) {
        result |= Modifier.STRICT;
    }
    if (ModifierSet.isSynchronized(modifiers)) {
        result |= Modifier.SYNCHRONIZED;
    }
    if (ModifierSet.isTransient(modifiers)) {
        result |= Modifier.TRANSIENT;
    }
    if (ModifierSet.isVolatile(modifiers)) {
        result |= Modifier.VOLATILE;
    }
    return result;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:45,代码来源:JavaParserUtils.java

示例8: canFieldBeAnnotated

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
public static boolean canFieldBeAnnotated(FieldDeclaration node) {
    final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();
    if (!ModifierSet.isStatic(node.getModifiers()) && dclr.getParentNode() instanceof CompilationUnit) {
        //handling nested classes
        return true;
    }
    return false;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:ResolverUtil.java

示例9: buildUnit

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
public static void buildUnit() {
    CompilationUnit compUnit = new CompilationUnit();
    
    compUnit.setPackage(new PackageDeclaration(ASTHelper
                                               .createNameExpr("compiladores.aula")));
    
    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(
                                                                       ModifierSet.PUBLIC, false, "AulaJavaParser");
    ASTHelper.addTypeDeclaration(compUnit, type);
    
    // create a method
    MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC,
                                                     ASTHelper.VOID_TYPE, "main");
    method.setModifiers(ModifierSet.addModifier(method.getModifiers(),
                                                ModifierSet.STATIC));
    ASTHelper.addMember(type, method);
    
    // add a parameter to the method
    Parameter param = ASTHelper.createParameter(
                                                ASTHelper.createReferenceType("String", 0), "args");
    param.setVarArgs(true); //makes the parameter a ",,," array
    ASTHelper.addParameter(method, param);
    
    // add a body to the method
    BlockStmt block = new BlockStmt();
    method.setBody(block);
    
    // add a statement do the method body
    NameExpr clazz = new NameExpr("System");
    FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
    MethodCallExpr call = new MethodCallExpr(field, "println");
    ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
    ASTHelper.addStmt(block, call);
    
    System.out.println(compUnit.toString());
}
 
开发者ID:damorim,项目名称:compilers-cin,代码行数:38,代码来源:ParserExample.java

示例10: createMethod

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private JavaMethod createMethod (MethodDeclaration method) {
	String className = classStack.peek().getName();
	String name = method.getName();
	boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC);
	String returnType = method.getType().toString();
	ArrayList<Argument> arguments = new ArrayList<Argument>();

	if (method.getParameters() != null) {
		for (Parameter parameter : method.getParameters()) {
			arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName()));
		}
	}

	return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:16,代码来源:RobustJavaMethodParser.java

示例11: visit

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
@Override
public void visit(MethodDeclaration n, Scope arg) {
    String name = Scope.computeMethodName(n);
    if (arg.methods.containsKey(name)) {
        throw new SemanticException("attempting to redefine method " + name + " on line " + n.getBeginLine());
    }
    // Create a sub-scope then put this method in scope.
    Scope subScope = new Scope(ModifierSet.isStatic(n.getModifiers()) ?
                               Scope.Type.STATIC :
                               Scope.Type.INSTANCE);
    subScope.backs.add(arg);
    arg.methods.put(name, n.getType().toString());
    super.visit(n, subScope);
    n.setData(arg);
}
 
开发者ID:rfw,项目名称:genja,代码行数:16,代码来源:ScopeCollector.java

示例12: printModifiers

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private void printModifiers(int modifiers) {
    if (ModifierSet.isPrivate(modifiers)) {
        printer.print("private ");
    }
    if (ModifierSet.isProtected(modifiers)) {
        printer.print("protected ");
    }
    if (ModifierSet.isPublic(modifiers)) {
        printer.print("public ");
    }
    if (ModifierSet.isAbstract(modifiers)) {
        printer.print("abstract ");
    }
    if (ModifierSet.isStatic(modifiers)) {
        printer.print("static ");
    }
    if (ModifierSet.isFinal(modifiers)) {
        printer.print("final ");
    }
    if (ModifierSet.isNative(modifiers)) {
        printer.print("native ");
    }
    if (ModifierSet.isStrictfp(modifiers)) {
        printer.print("strictfp ");
    }
    if (ModifierSet.isSynchronized(modifiers)) {
        printer.print("synchronized ");
    }
    if (ModifierSet.isTransient(modifiers)) {
        printer.print("transient ");
    }
    if (ModifierSet.isVolatile(modifiers)) {
        printer.print("volatile ");
    }
}
 
开发者ID:rfw,项目名称:genja,代码行数:36,代码来源:DumpVisitor.java

示例13: isRootField

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private static boolean isRootField(FieldDeclaration field) {
    if (field.getVariables().size() != 1
            || !"root"
                    .equals(field.getVariables().get(0).getId().getName())) {
        return false;
    }
    field.getModifiers();

    return ModifierSet.hasModifier(field.getModifiers(),
            ModifierSet.PRIVATE) && hasAnnotation(field, "AutoGenerated");
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:12,代码来源:JavaUtil.java

示例14: createClass

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private void createClass(String name) {
	ensureImport("org.vaadin.mideaas.MideaasComponent");
	ClassOrInterfaceDeclaration decl =
			new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, name);
	decl.setExtends(Collections.singletonList(new ClassOrInterfaceType("MideaasComponent")));
	cu.setTypes(Collections.singletonList((TypeDeclaration)decl));
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:8,代码来源:ControllerCode.java

示例15: createClassTouchkit

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
@SuppressWarnings("unused")
private void createClassTouchkit(String name) {
	ensureImport("org.vaadin.mideaas.MideaasNavigationView");
	ClassOrInterfaceDeclaration decl =
			new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, name);
	decl.setExtends(Collections.singletonList(new ClassOrInterfaceType("MideaasNavigationView")));
	cu.setTypes(Collections.singletonList((TypeDeclaration)decl));
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:9,代码来源:ControllerCode.java


注:本文中的japa.parser.ast.body.ModifierSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。