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


Java VariableDefinitionEntry类代码示例

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


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


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