• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ModifierSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: addClaraField

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private FieldDeclaration addClaraField(String id, String className) {
	ensureImport(className);
	String fieldName = generateFieldNameLike(id);
	VariableDeclarator var = new VariableDeclarator(
			new VariableDeclaratorId(fieldName));
	Type type = new ClassOrInterfaceType(className.substring(className.lastIndexOf('.') + 1));
	FieldDeclaration field = new FieldDeclaration(ModifierSet.PRIVATE, type, var);
	field.setAnnotations(createClaraFieldAnnotations(id));
	if (getType().getMembers()==null) {
		getType().setMembers(new LinkedList<BodyDeclaration>());
	}
	getType().getMembers().add(getFirstMethodIndex(), field);
	return field;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:15,代码来源:ControllerCode.java


示例17: getJavaParserModifier

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


示例18: visit

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
@Override
public MethodDeclaration visit(MethodDeclaration n, Void arg) {
    if (!n.isGenerator()) {
        throw new UnsupportedOperationException("cannot transform non-generator");
    }

    // Desugar ALL the loops!
    n.accept(new LoopDesugarTransform(), null);
    if (CompilerSettings.dumpDesugar) {
        System.err.println(n);
    }

    Generator g = new Generator();
    Map<String, TypedVariableDeclarator> vars = new HashMap<String, TypedVariableDeclarator>();

    // Mangle all our scope variables.
    n.accept(new ScopeMangleTransform(), vars);
    if (CompilerSettings.dumpMangle) {
        System.err.println(n);
    }

    // Generate the body.
    n.accept(new LinearizeTransform(), g);

    List<BodyDeclaration> generatorBody = new ArrayList<BodyDeclaration>();

    // Add the fields to the generator body.
    for (Map.Entry<String, TypedVariableDeclarator> kv : vars.entrySet()) {
        VariableDeclarator decl = new VariableDeclarator(new VariableDeclaratorId(kv.getKey()), null);
        generatorBody.add(new FieldDeclaration(ModifierSet.PRIVATE, kv.getValue().type, decl));
    }

    // Add the moveNext method to the generator body.
    generatorBody.add(new MethodDeclaration(0, 0, 0, 0, null, ModifierSet.PROTECTED,
                                            null, null, new PrimitiveType(Primitive.Boolean),
                                            "moveNext", null, 0, null, false,
                                            new BlockStmt(g.generate())));

    ObjectCreationExpr o = new ObjectCreationExpr(0, 0, 0, 0, null, makeRtGeneratorType(n.getType()), null, null, generatorBody);
    List<Statement> methodBody = new ArrayList<Statement>();
    methodBody.add(new ReturnStmt(o));
    MethodDeclaration n2 = new MethodDeclaration(n.getBeginLine(),
            n.getBeginColumn(),
            n.getEndLine(),
            n.getEndColumn(),
            n.getJavaDoc(),
            n.getModifiers(),
            n.getAnnotations(),
            n.getTypeParameters(),
            makeRtGeneratorType(n.getType()),
            n.getName(),
            n.getParameters(),
            n.getArrayCount(),
            n.getThrows(),
            false,
            new BlockStmt(methodBody));

    return n2;
}
 
开发者ID:rfw,项目名称:genja,代码行数:60,代码来源:GeneratorTransform.java


示例19: addClaraDataSourceMethod

import japa.parser.ast.body.ModifierSet; //导入依赖的package包/类
private MethodDeclaration addClaraDataSourceMethod(String id, String returnType) {
	String handlerName = generateDataSourceNameFor(id);
	
	Type type = createDataSourceReturnType(returnType);

	List<Parameter> params = Collections.emptyList();
	MethodDeclaration source = new MethodDeclaration(
			ModifierSet.PUBLIC, type, handlerName, params);
	
	source.setBody(new BlockStmt());
	source.setAnnotations(createClaraDataSourceAnnotations(id));
	
	setTestMethodBodyFor(source, returnType);
	
	addMember(source);
	
	return source;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:19,代码来源:ControllerCode.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReceiveTimeout类代码示例发布时间:2022-05-22
下一篇:
Java MacroCallNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap