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

Java VariableDefinitionEntry类代码示例

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

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



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

示例1: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
    Expression initializer = node.astInitializer();
    if (initializer instanceof VariableReference) {
        JavaParser.ResolvedNode resolved = mContext.resolve(initializer);
        //noinspection SuspiciousMethodCalls
        if (resolved != null && mVariables.contains(resolved)) {
            JavaParser.ResolvedNode resolvedVariable = mContext.resolve(node);
            if (resolvedVariable instanceof JavaParser.ResolvedVariable) {
                JavaParser.ResolvedVariable variable = (JavaParser.ResolvedVariable) resolvedVariable;
                mVariables.add(variable);
            }
        }
    }
    return super.visitVariableDefinitionEntry(node);
}
 
开发者ID:massivedisaster,项目名称:ActivityFragmentManager,代码行数:17,代码来源:CommitTransaction.java


示例2: getPublicStaticFinalStringVar

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
private VariableDefinitionEntry getPublicStaticFinalStringVar(Modifiers node) {
    if (!isPublicStaticFinalField(node) && !isInterface(node))
        return null;

    Node parent = node.getParent();
    if (!(parent instanceof VariableDefinition))
        return null;

    VariableDefinition field = (VariableDefinition) parent;
    if (!field.astTypeReference().getTypeName().equals("String"))
        return null;

    StrictListAccessor<VariableDefinitionEntry, VariableDefinition> vars = field.astVariables();
    if (vars.size() != 1)
        return null;

    return vars.first();
}
 
开发者ID:tynn,项目名称:simplDb,代码行数:19,代码来源:SimplLintVisitor.java


示例3: verifyColumn

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
private boolean verifyColumn(Modifiers node) {
    VariableDefinitionEntry var = getPublicStaticFinalStringVar(node);
    if (var == null)
        return false;

    Expression initializer = var.astInitializer();
    if (!(initializer instanceof StringLiteral))
        return false;

    String name = SimplName.from(var.astName().astValue());
    String value = ((StringLiteral) initializer).astValue();

    if (!name.equals(value))
        mContext.report(COLUMN_NAME, node, mContext.getLocation(node.getParent()), "must match " + SimplName.quote(name));

    if (SqlKeywords.contain(name))
        mContext.report(SQL_KEYWORD, mContext.getLocation(var.astName()), "use quoted with ContentValues");

    return true;
}
 
开发者ID:tynn,项目名称:simplDb,代码行数:21,代码来源:SimplLintVisitor.java


示例4: verifyConstraint

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
private boolean verifyConstraint(Modifiers node) {
    VariableDefinitionEntry var = getPublicStaticFinalStringVar(node);
    if (var == null)
        return false;

    Expression initializer = var.astInitializer();
    if (!(initializer instanceof StringLiteral))
        return false;

    String name = SimplName.from(var.astName().astValue());
    String value = ((StringLiteral) initializer).astValue();

    if (!name.equals(value))
        mContext.report(CONSTRAINT_NAME, node, mContext.getLocation(node.getParent()), "must match " + SimplName.quote(name));

    return true;
}
 
开发者ID:tynn,项目名称:simplDb,代码行数:18,代码来源:SimplLintVisitor.java


示例5: getLhs

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Nullable
private static String getLhs(@NonNull MethodInvocation call) {
    Node parent = call.getParent();
    if (parent instanceof Cast) {
        parent = parent.getParent();
    }

    if (parent instanceof VariableDefinitionEntry) {
        VariableDefinitionEntry vde = (VariableDefinitionEntry) parent;
        return vde.astName().astValue();
    } else if (parent instanceof BinaryExpression) {
        BinaryExpression be = (BinaryExpression) parent;
        Expression left = be.astLeft();
        if (left instanceof VariableReference || left instanceof Select) {
            return be.astLeft().toString();
        } else if (left instanceof ArrayAccess) {
            ArrayAccess aa = (ArrayAccess) left;
            return aa.astOperand().toString();
        }
    }

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


示例6: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
    String name = node.astName().astValue();
    Expression rhs = node.astInitializer();
    Class<?> type = getType(rhs);
    if (type != null) {
        mTypes.put(name, type);
    } else {
        // Make sure we're not visiting the String.format node itself. If you have
        //    msg = String.format("%1$s", msg)
        // then we'd be wiping out the type of "msg" before visiting the
        // String.format call!
        if (rhs != mTargetNode) {
            mTypes.remove(name);
        }
    }

    return super.visitVariableDefinitionEntry(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StringFormatDetector.java


示例7: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
    Expression initializer = node.astInitializer();
    if (initializer instanceof VariableReference) {
        ResolvedNode resolved = mContext.resolve(initializer);
        //noinspection SuspiciousMethodCalls
        if (resolved != null && mVariables.contains(resolved)) {
            ResolvedNode resolvedVariable = mContext.resolve(node);
            if (resolvedVariable instanceof ResolvedVariable) {
                ResolvedVariable variable = (ResolvedVariable) resolvedVariable;
                mVariables.add(variable);
            } else if (resolvedVariable instanceof ResolvedField) {
                mEscapes = true;
            }
        }
    }
    return super.visitVariableDefinitionEntry(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CleanupDetector.java


示例8: visitConstructorDeclaration

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitConstructorDeclaration(ConstructorDeclaration node) {
	for (VariableDefinition variableDefinition : node.astParameters()) {
		if (variableDefinition.astTypeReference().isPrimitive()) {
			// Skip primitive value
			continue;
		}

		Set<String> typeNames = new HashSet<>();
		for (Annotation annotation : variableDefinition.astModifiers().astAnnotations()) {
			typeNames.add(annotation.astAnnotationTypeReference().getTypeName());
		}

		if (typeNames.contains("JsonProperty") && typeNames.contains("NonNull")) {
			VariableDefinitionEntry entry = variableDefinition.astVariables().first();
			if (node.astBody().toString().contains("checkNotNull(" + entry.astName() + ")")) {
				continue;
			}
			mContext.report(ISSUE, mContext.getLocation(variableDefinition), "Should use Precondition.checkNotNull for @NotNull parameters.");
		}
	}

	return false;
}
 
开发者ID:SangsooNam,项目名称:CustomAndroidLint,代码行数:25,代码来源:JacksonConstructorNonNullWithCheckJavaDetector.java


示例9: fieldModifiersCheck

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
public void fieldModifiersCheck(VariableDeclaration vd) {
	TypeDeclaration td = vd.upUpToTypeDeclaration();
	if (td == null) return;	//not a field.
	VariableDefinition def = vd.astDefinition();
	if (def != null) {
		Modifiers m = def.astModifiers();
		modifiersCheck(m, FIELD_MODIFIERS_EXCLUSIVITY, FIELD_MODIFIERS_LEGAL, "field declarations");
		boolean allFieldsHaveInitializers = true;
		for (VariableDefinitionEntry entry : def.astVariables()) {
			if (entry.rawInitializer() == null) {
				allFieldsHaveInitializers = false;
				break;
			}
		}
		
		if (m.isStatic() && !m.isFinal() && !allFieldsHaveInitializers) {
			// Initialized static final fields, assuming the initializer expression is a compile time constant, are 'special' and
			// do not need to adhere to the static chain rule. However, we can't determine CTC nature without resolution.
			checkStaticChain(m);
		}
	}
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:23,代码来源:KeywordChecks.java


示例10: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
	formatter.buildInline(node);
	formatter.property("arrayDimensions", node.astArrayDimensions());
	formatter.nameNextElement("varName");
	visit(node.astName());
	for (int i = 0; i < node.astArrayDimensions(); i++)
		formatter.append("[]");
	if (node.rawInitializer() != null) {
		formatter.space();
		formatter.append("=");
		formatter.space();
		visit(node.rawInitializer());
	}
	formatter.closeInline();
	
	return true;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:19,代码来源:SourcePrinter.java


示例11: testMethodLocalMaskingTypesMatch

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Test
public void testMethodLocalMaskingTypesMatch() {
	Source s = new Source(METHOD_LOCAL_MASKING_SOURCE, "MaskingTypesMatchTest.java");
	s.parseCompilationUnit();
	final AtomicInteger hit1 = new AtomicInteger();
	final AtomicInteger hit2 = new AtomicInteger();
	s.getNodes().get(0).accept(new ForwardingAstVisitor() {
		@Override public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
			if ("thisIsAUtilList".equals(node.astName().astValue())) {
				assertTrue("thisIsAUtilList isn't matched to java.util.List, but should.",
						new Resolver().typesMatch("java.util.List<?>", node.upToVariableDefinition().astTypeReference()));
				hit1.incrementAndGet();
			}
			if ("butThisIsnt".equals(node.astName().astValue())) {
				assertFalse("butThisIsnt is matched to java.util.List, but shouldn't be.",
						new Resolver().typesMatch("java.util.List<?>", node.upToVariableDefinition().astTypeReference()));
				hit2.incrementAndGet();
			}
			
			return true;
		}
	});
	assertEquals("expected 1 hit on VarDefEntry 'thisIsAUtilList'", 1, hit1.get());
	assertEquals("expected 1 hit on VarDefEntry 'butThisIsnt'", 1, hit2.get());
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:26,代码来源:TypesMatchTest.java


示例12: visitVariableDeclaration

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDeclaration(VariableDeclaration node) {
    JavaParser.ResolvedNode resolved = mContext.resolve(JavaContext.findSurroundingClass(node));
    JavaParser.ResolvedClass sorroundingClass = (JavaParser.ResolvedClass) resolved;

    if (sorroundingClass.getName().contains(".R.")
            || sorroundingClass.getName().endsWith(".BuildConfig")) {
        return true;
    }

    VariableDefinition definition = node.astDefinition();
    Modifiers modifiers = definition.astModifiers();

    if (modifiers.isStatic() && modifiers.isFinal()){
        StrictListAccessor<VariableDefinitionEntry, VariableDefinition> variableDefinition = definition.astVariables();
        String variableName = variableDefinition.first().astName().toString();
        if (!variableName.equals(variableName.toUpperCase())){
            mContext.report(ISSUE,
                    node,
                    mContext.getLocation(node),
                    "A constant should be named with only UPPER CASE letter and underline.");
        }


    }

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


示例13: createJavaVisitor

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

        @Override
        public boolean visitVariableDeclaration(VariableDeclaration node) {

            if (hasClassParent(node) && !PackageManager.isGenerated(context, node)) {

                Node classDeclaration = node.getParent();

                String nodeString = node.toString();

                VariableDefinitionEntry variableDefinition = node.astDefinition().astVariables().first();
                String name = variableDefinition.astName().astValue();

                if (!isStaticOrFinal(node) && !isModel(context, classDeclaration) && !isWidget(nodeString)) {
                    if (!instanceVariableCorrectFormat(name)) {
                        context.report(ISSUE_INSTANCE_VARIABLE_NAME, context.getLocation(node),
                                "Expecting " + name + " to begin with 'm' and be written in camelCase.");
                    }
                } else if (isStaticAndFinal(node)) {
                    if (!staticFinalCorrectFormat(name)) {
                        context.report(ISSUE_CLASS_CONSTANT_NAME, context.getLocation(node),
                                "Expecting " + name + " to be named using UPPER_SNAKE_CASE.");
                    }
                }
            }

            return super.visitVariableDeclaration(node);
        }

    };
}
 
开发者ID:inaka,项目名称:lewis,代码行数:35,代码来源:JavaVariablesDetector.java


示例14: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
    List<VisitingDetector> list = mNodeTypeDetectors.get(VariableDefinitionEntry.class);
    if (list != null) {
        for (VisitingDetector v : list) {
            v.getVisitor().visitVariableDefinitionEntry(node);
        }
    }
    return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaVisitor.java


示例15: getApplicableNodeTypes

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


示例16: visitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
    if (mCurrentMethod != null) {
        if (mLocalVars == null) {
            mLocalVars = Sets.newHashSet();
        }
        mLocalVars.add(node.astName().astValue());
    } else {
        if (mFields == null) {
            mFields = Sets.newHashSet();
        }
        mFields.add(node.astName().astValue());
    }
    return super.visitVariableDefinitionEntry(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ApiDetector.java


示例17: afterVisitVariableDefinitionEntry

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public void afterVisitVariableDefinitionEntry(VariableDefinitionEntry node) {
    Expression initializer = node.astInitializer();
    if (initializer != null) {
        ResolvedClass resolvedClass = mTypes.get(initializer);
        if (resolvedClass != null) {
            mTypes.put(node, resolvedClass);
            ResolvedNode variable = mContext.resolve(node);
            if (variable instanceof ResolvedVariable) {
                mVariableTypes.put((ResolvedVariable) variable, resolvedClass);
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaScriptInterfaceDetector.java


示例18: visitVariableReference

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Override
public boolean visitVariableReference(VariableReference node) {
    if (node.astIdentifier().astValue().equals(R_CLASS) &&   //$NON-NLS-1$
            node.getParent() instanceof Select &&
            node.getParent().getParent() instanceof Select) {

        // See if we're on the right hand side of an assignment
        lombok.ast.Node current = node.getParent().getParent();
        String reference = ((Select) current).astIdentifier().astValue();

        while (current != mTop && !(current instanceof VariableDefinitionEntry)) {
            if (current == mTargetNode) {
                mName = reference;
                mDone = true;
                return false;
            }
            current = current.getParent();
        }
        if (current instanceof VariableDefinitionEntry) {
            VariableDefinitionEntry entry = (VariableDefinitionEntry) current;
            String variable = entry.astName().astValue();
            mMap.put(variable, reference);
        }
    }

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


示例19: getNativeNode

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
@Nullable
private static Object getNativeNode(@NonNull Node node) {
    Object nativeNode = node.getNativeNode();
    if (nativeNode != null) {
        return nativeNode;
    }

    Node parent = node.getParent();
    // The ECJ native nodes are sometimes spotty; for example, for a
    // MethodInvocation node we can have a null native node, but its
    // parent expression statement will point to the real MessageSend node
    if (parent != null) {
        nativeNode = parent.getNativeNode();
        if (nativeNode != null) {
            return nativeNode;
        }
    }

    if (node instanceof VariableDefinitionEntry) {
        node = node.getParent().getParent();
    }
    if (node instanceof VariableDeclaration) {
        VariableDeclaration declaration = (VariableDeclaration) node;
        VariableDefinition definition = declaration.astDefinition();
        if (definition != null) {
            lombok.ast.TypeReference typeReference = definition.astTypeReference();
            if (typeReference != null) {
                return typeReference.getNativeNode();
            }
        }
    }

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


示例20: check

import lombok.ast.VariableDefinitionEntry; //导入依赖的package包/类
private static void check(Object expected, String source, final String targetVariable) {
    JavaContext context = LintUtilsTest.parse(source, new File("src/test/pkg/Test.java"));
    assertNotNull(context);
    CompilationUnit unit = (CompilationUnit) context.getCompilationUnit();
    assertNotNull(unit);

    // Find the expression
    final AtomicReference<Expression> reference = new AtomicReference<Expression>();
    unit.accept(new ForwardingAstVisitor() {
        @Override
        public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
            if (node.astName().astValue().equals(targetVariable)) {
                reference.set(node.astInitializer());
            }
            return super.visitVariableDefinitionEntry(node);
        }
    });
    Expression expression = reference.get();
    Object actual = ConstantEvaluator.evaluate(context, expression);
    if (expected == null) {
        assertNull(actual);
    } else {
        assertNotNull("Couldn't compute value for " + source + ", expected " + expected,
                actual);
        assertEquals(expected.getClass(), actual.getClass());
        assertEquals(expected.toString(), actual.toString());
    }
    assertEquals(expected, actual);
    if (expected instanceof String) {
        assertEquals(expected, ConstantEvaluator.evaluateString(context, expression,
                false));
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:ConstantEvaluatorTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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