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

Java ConstructorInvocation类代码示例

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

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



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

示例1: createJavaVisitor

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public AstVisitor createJavaVisitor(final @NonNull JavaContext context) {
    return new ForwardingAstVisitor() {

        @Override
        public boolean visitConstructorInvocation(ConstructorInvocation node) {
            TypeReference reference = node.astTypeReference();
            String typeName = reference.astParts().last().astIdentifier().astValue();
            // TODO: Should we handle factory method constructions of HashMaps as well,
            // e.g. via Guava? This is a bit trickier since we need to infer the type
            // arguments from the calling context.
            if (typeName.equals(HASH_MAP)) {
                checkHashMap(context, node, reference);
            }
            return super.visitConstructorInvocation(node);
        }
    };
}
 
开发者ID:GavinCT,项目名称:MeituanLintDemo,代码行数:19,代码来源:HashMapForJDK7Detector.java


示例2: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
    JavaParser.ResolvedNode resolvedType = mContext.resolve(node.astTypeReference());
    JavaParser.ResolvedClass resolvedClass = (JavaParser.ResolvedClass) resolvedType;

    if (resolvedClass != null
            && resolvedClass.isSubclassOf("android.os.Message", false)){
        mContext.report(ISSUE,
                node,
                mContext.getLocation(node),
                "You should not call `new Message()` directly.");

        return true;

    }

    return super.visitConstructorInvocation(node);
}
 
开发者ID:ljfxyj2008,项目名称:CustomLintDemo,代码行数:19,代码来源:MessageObtainDetector.java


示例3: afterVisitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public void afterVisitConstructorInvocation(@NonNull ConstructorInvocation node) {
    ResolvedNode resolved = mContext.resolve(node);
    if (resolved instanceof ResolvedMethod) {
        ResolvedMethod method = (ResolvedMethod) resolved;
        mTypes.put(node, method.getContainingClass());
    } else {
        // Implicit constructor?
        TypeDescriptor type = mContext.getType(node);
        if (type != null) {
            ResolvedClass typeClass = type.getTypeClass();
            if (typeClass != null) {
                mTypes.put(node, typeClass);
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaScriptInterfaceDetector.java


示例4: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
    if (node == mTargetNode) {
        Expression arg = getTargetArgument();
        if (arg instanceof VariableReference) {
              VariableReference reference = (VariableReference) arg;
              String variable = reference.astIdentifier().astValue();
              mName = mMap.get(variable);
              mDone = true;
              return true;
        }
    }

    // Is this a getString() call? On a resource object? If so,
    // promote the resource argument up to the left hand side
    return super.visitConstructorInvocation(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:StringFormatDetector.java


示例5: createChainOfQualifiedConstructorInvocations

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
public Node createChainOfQualifiedConstructorInvocations(
		org.parboiled.Node<Node> qualifier,
		List<org.parboiled.Node<Node>> constructorInvocations) {
	Node current = qualifier.getValue();
	
	if (constructorInvocations == null) return current;
	
	for (org.parboiled.Node<Node> pNode : constructorInvocations) {
		Node n = pNode.getValue();
		if (n instanceof ConstructorInvocation) {
			current = ((ConstructorInvocation)n).rawQualifier(current);
			positionSpan(current, qualifier, pNode);
		} else DanglingNodes.addDanglingNode(current, n);
	}
	
	return current;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:18,代码来源:ExpressionsActions.java


示例6: checkHashMap

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
/**
 * Checks whether the given constructor call and type reference refers
 * to a HashMap constructor call that is eligible for replacement by a
 * SparseArray call instead
 */
private void checkHashMap(JavaContext context, ConstructorInvocation node, TypeReference reference) {
    StrictListAccessor<TypeReference, TypeReference> types = reference.getTypeArguments();
    if (types == null || types.size() != 2) {
        /*
        JDK7 新写法
        HashMap<Integer, String> map2 = new HashMap<>();
        map2.put(1, "name");
        Map<Integer, String> map3 = new HashMap<>();
        map3.put(1, "name");
         */

        Node result = node.getParent().getParent();
        if (result instanceof VariableDefinition) {
            TypeReference typeReference = ((VariableDefinition) result).astTypeReference();
            checkCore(context, result, typeReference);
            return;
        }

        if (result instanceof ExpressionStatement) {
            Expression  expression = ((ExpressionStatement) result).astExpression();
            if (expression instanceof BinaryExpression) {
                Expression left = ((BinaryExpression) expression).astLeft();
                String fullTypeName = context.getType(left).getName();
                checkCore2(context, result, fullTypeName);
            }
        }
    }
    // else --> lint本身已经检测
}
 
开发者ID:GavinCT,项目名称:MeituanLintDemo,代码行数:35,代码来源:HashMapForJDK7Detector.java


示例7: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
    Node containingMethod = JavaContext.findSurroundingMethod(node);
    if (null == containingMethod) {
        return super.visitConstructorInvocation(node);
    }

    JavaParser.ResolvedMethod resolvedMethod = NodeUtils.parseResolvedMethod(mContext, containingMethod);
    if (null == resolvedMethod) {
        return super.visitConstructorInvocation(node);
    }
    JavaParser.ResolvedClass resolvedClass = resolvedMethod.getContainingClass();
    if (null == resolvedClass) {
        return super.visitConstructorInvocation(node);
    }

    for (String observedClass : OBSERVED_METHODS.keySet()) {
        if (resolvedClass.isSubclassOf(observedClass, false) &&
                OBSERVED_METHODS.get(observedClass).contains(resolvedMethod.getName())) {
            mContext.report(
                    WrongAllocationDetector.ISSUE,
                    mContext.getLocation(node),
                    String.format("Please don't create new objects in %s : %s", resolvedClass.getName(), resolvedMethod.getName())
            );
        }
    }

    return super.visitConstructorInvocation(node);
}
 
开发者ID:squirrel-explorer,项目名称:eagleeye-android,代码行数:30,代码来源:WrongAllocationAstVisitor.java


示例8: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
    JavaParser.ResolvedClass typeClass = NodeUtils.parseContainingClass(mContext, node);
    if (null != typeClass &&
            typeClass.isSubclassOf("android.os.Message", false)) {
        mContext.report(
                NewMessageDetector.ISSUE,
                mContext.getLocation(node),
                "Please use Message.obtain() instead of new Message()"
        );
    }

    return super.visitConstructorInvocation(node);
}
 
开发者ID:squirrel-explorer,项目名称:eagleeye-android,代码行数:15,代码来源:NewMessageAstVisitor.java


示例9: visitConstructor

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@SuppressWarnings("javadoc")
public void visitConstructor(
        @NonNull JavaContext context,
        @Nullable AstVisitor visitor,
        @NonNull ConstructorInvocation node,
        @NonNull ResolvedMethod constructor) {
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:Detector.java


示例10: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
    NormalTypeBody anonymous = node.astAnonymousClassBody();
    if (anonymous != null) {
        ResolvedNode resolved = mContext.resolve(anonymous);
        if (resolved instanceof ResolvedMethod) {
            resolved = ((ResolvedMethod) resolved).getContainingClass();
        }
        if (!(resolved instanceof ResolvedClass)) {
            return true;
        }

        ResolvedClass resolvedClass = (ResolvedClass) resolved;
        ResolvedClass cls = resolvedClass;
        while (cls != null) {
            String fqcn = cls.getSignature();
            if (fqcn != null) {
                List<VisitingDetector> list = mSuperClassDetectors.get(fqcn);
                if (list != null) {
                    for (VisitingDetector v : list) {
                        v.getJavaScanner().checkClass(mContext, null, anonymous,
                                resolvedClass);
                    }
                }
            }

            cls = cls.getSuperClass();
        }
    }

    return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:JavaVisitor.java


示例11: visitConstructor

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public void visitConstructor(@NonNull JavaContext context, @Nullable AstVisitor visitor,
        @NonNull ConstructorInvocation node, @NonNull ResolvedMethod constructor) {
    if (!specifiesLocale(constructor)) {
        Location location = context.getLocation(node);
        String message =
                "To get local formatting use `getDateInstance()`, `getDateTimeInstance()`, " +
                "or `getTimeInstance()`, or use `new SimpleDateFormat(String template, " +
                "Locale locale)` with for example `Locale.US` for ASCII dates.";
        context.report(DATE_FORMAT, node, location, message);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DateFormatDetector.java


示例12: getApplicableNodeTypes

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
@Nullable
public List<Class<? extends Node>> getApplicableNodeTypes() {
    List<Class<? extends Node>> types = new ArrayList<Class<? extends Node>>(3);
    types.add(MethodDeclaration.class);
    types.add(ConstructorInvocation.class);
    return types;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IconDetector.java


示例13: getApplicableNodeTypes

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public List<Class<? extends Node>> getApplicableNodeTypes() {
    List<Class<? extends Node>> types = new ArrayList<Class<? extends Node>>(3);
    types.add(ConstructorInvocation.class);
    types.add(MethodDeclaration.class);
    types.add(MethodInvocation.class);
    return types;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaPerformanceDetector.java


示例14: checkHashMap

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
/**
 * Checks whether the given constructor call and type reference refers
 * to a HashMap constructor call that is eligible for replacement by a
 * SparseArray call instead
 */
private void checkHashMap(ConstructorInvocation node, TypeReference reference) {
    // reference.hasTypeArguments returns false where it should not
    StrictListAccessor<TypeReference, TypeReference> types = reference.getTypeArguments();
    if (types != null && types.size() == 2) {
        TypeReference first = types.first();
        String typeName = first.getTypeName();
        int minSdk = mContext.getMainProject().getMinSdk();
        if (typeName.equals(INTEGER) || typeName.equals(BYTE)) {
            String valueType = types.last().getTypeName();
            if (valueType.equals(INTEGER)) {
                mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                    "Use new `SparseIntArray(...)` instead for better performance");
            } else if (valueType.equals(LONG) && minSdk >= 18) {
                mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                        "Use `new SparseLongArray(...)` instead for better performance");
            } else if (valueType.equals(BOOLEAN)) {
                mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                        "Use `new SparseBooleanArray(...)` instead for better performance");
            } else {
                mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                    String.format(
                        "Use `new SparseArray<%1$s>(...)` instead for better performance",
                      valueType));
            }
        } else if (typeName.equals(LONG) && (minSdk >= 16 ||
                Boolean.TRUE == mContext.getMainProject().dependsOn(
                        SUPPORT_LIB_ARTIFACT))) {
            boolean useBuiltin = minSdk >= 16;
            String message = useBuiltin ?
                    "Use `new LongSparseArray(...)` instead for better performance" :
                    "Use `new android.support.v4.util.LongSparseArray(...)` instead for better performance";
            mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                    message);
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:JavaPerformanceDetector.java


示例15: checkSparseArray

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
private void checkSparseArray(ConstructorInvocation node, TypeReference reference) {
    // reference.hasTypeArguments returns false where it should not
    StrictListAccessor<TypeReference, TypeReference> types = reference.getTypeArguments();
    if (types != null && types.size() == 1) {
        TypeReference first = types.first();
        String valueType = first.getTypeName();
        if (valueType.equals(INTEGER)) {
            mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                "Use `new SparseIntArray(...)` instead for better performance");
        } else if (valueType.equals(BOOLEAN)) {
            mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
                    "Use `new SparseBooleanArray(...)` instead for better performance");
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaPerformanceDetector.java


示例16: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
	JCNewClass jcnc = setPos(node, treeMaker.NewClass(
			toExpression(node.astQualifier()), 
			toList(JCExpression.class, node.astConstructorTypeArguments()), 
			toExpression(node.astTypeReference()), 
			toList(JCExpression.class, node.astArguments()), 
			(JCClassDecl)toTree(node.astAnonymousClassBody())
	));
	if (node.astQualifier() != null) {
		int start = posOfStructure(node, "new", true);
		setPos(start, node.getPosition().getEnd(), jcnc);
	}
	return set(node, jcnc);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:16,代码来源:JcTreeBuilder.java


示例17: visitNewClass

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override public void visitNewClass(JCNewClass node) {
	ConstructorInvocation inv = new ConstructorInvocation();
	fillList(node.getArguments(), inv.rawArguments());
	fillList(node.getTypeArguments(), inv.rawConstructorTypeArguments(), FlagKey.TYPE_REFERENCE);
	inv.rawTypeReference(toTree(node.getIdentifier(), FlagKey.TYPE_REFERENCE));
	inv.rawQualifier(toTree(node.getEnclosingExpression()));
	Node n = toTree(node.getClassBody());
	if (n instanceof TypeDeclaration) {
		NormalTypeBody body = ((ClassDeclaration) n).astBody();
		if (body != null) body.unparent();
		inv.rawAnonymousClassBody(setPos(node.getClassBody(), body));
	}
	set(node, inv);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:15,代码来源:JcTreeConverter.java


示例18: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(ConstructorInvocation node) {
	parensOpen(node);
	formatter.buildInline(node);
	if (node.rawQualifier() != null) {
		formatter.nameNextElement("qualifier");
		visit(node.rawQualifier());
		formatter.append(".");
	}
	formatter.keyword("new");
	formatter.space();
	visitAll(node.rawConstructorTypeArguments(), ", ", "<", ">");
	formatter.nameNextElement("type");
	visit(node.rawTypeReference());
	formatter.append("(");
	visitAll(node.rawArguments(), ", ", "", "");
	formatter.append(")");
	if (node.rawAnonymousClassBody() != null) {
		formatter.space();
		formatter.startSuppressBlock();
		visit(node.rawAnonymousClassBody());
		formatter.endSuppressBlock();
	}
	formatter.closeInline();
	parensClose(node);
	return true;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:28,代码来源:SourcePrinter.java


示例19: visitConstructorInvocation

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public boolean visitConstructorInvocation(@NonNull ConstructorInvocation call) {
    return false;
}
 
开发者ID:massivedisaster,项目名称:ActivityFragmentManager,代码行数:5,代码来源:CommitTransaction.java


示例20: getApplicableNodeTypes

import lombok.ast.ConstructorInvocation; //导入依赖的package包/类
@Override
public List<Class<? extends Node>> getApplicableNodeTypes() {
    return Collections.<Class<? extends Node>>singletonList(ConstructorInvocation.class);
}
 
开发者ID:GavinCT,项目名称:MeituanLintDemo,代码行数:5,代码来源:HashMapForJDK7Detector.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java UriResourcePrimitiveProperty类代码示例发布时间:2022-05-22
下一篇:
Java Language类代码示例发布时间: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