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


Java VariableDefinitionEntry.astInitializer方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: checkId

import lombok.ast.VariableDefinitionEntry; //导入方法依赖的package包/类
private boolean checkId(Annotation node, String id) {
    IssueRegistry registry = mContext.getDriver().getRegistry();
    Issue issue = registry.getIssue(id);
    // Special-case the ApiDetector issue, since it does both source file analysis
    // only on field references, and class file analysis on the rest, so we allow
    // annotations outside of methods only on fields
    if (issue != null && !issue.getImplementation().getScope().contains(Scope.JAVA_FILE)
            || issue == ApiDetector.UNSUPPORTED) {
        // Ensure that this isn't a field
        Node parent = node.getParent();
        while (parent != null) {
            if (parent instanceof MethodDeclaration
                    || parent instanceof ConstructorDeclaration
                    || parent instanceof Block) {
                break;
            } else if (parent instanceof TypeBody) { // It's a field
                return true;
            } else if (issue == ApiDetector.UNSUPPORTED
                    && parent instanceof VariableDefinition) {
                VariableDefinition definition = (VariableDefinition) parent;
                for (VariableDefinitionEntry entry : definition.astVariables()) {
                    Expression initializer = entry.astInitializer();
                    if (initializer instanceof Select) {
                        return true;
                    }
                }
            }
            parent = parent.getParent();
            if (parent == null) {
                return true;
            }
        }

        // This issue doesn't have AST access: annotations are not
        // available for local variables or parameters
        mContext.report(ISSUE, node, mContext.getLocation(node), String.format(
            "The `@SuppressLint` annotation cannot be used on a local " +
            "variable with the lint check '%1$s': move out to the " +
            "surrounding method", id));
        return false;
    }

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


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