⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nameoccurrence.java

📁 检查Java程序漏洞
💻 JAVA
字号:
/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html*/package net.sourceforge.pmd.symboltable;import net.sourceforge.pmd.ast.ASTAssignmentOperator;import net.sourceforge.pmd.ast.ASTPrimaryExpression;import net.sourceforge.pmd.ast.SimpleNode;public class NameOccurrence {    private SimpleNode location;    private String image;    private NameOccurrence qualifiedName;    private boolean isMethodOrConstructorInvocation;    public NameOccurrence(SimpleNode location, String image) {        this.location = location;        this.image = image;    }    public void setIsMethodOrConstructorInvocation() {        isMethodOrConstructorInvocation = true;    }    public boolean isMethodOrConstructorInvocation() {        return isMethodOrConstructorInvocation;    }    public void setNameWhichThisQualifies(NameOccurrence qualifiedName) {        this.qualifiedName = qualifiedName;    }    public NameOccurrence getNameForWhichThisIsAQualifier() {        return qualifiedName;    }    public SimpleNode getLocation() {      return location;    }    public boolean isOnLeftHandSide() {        SimpleNode primaryExpression;        if (location.jjtGetParent() instanceof ASTPrimaryExpression) {            primaryExpression = (SimpleNode) location.jjtGetParent().jjtGetParent();        } else if (location.jjtGetParent().jjtGetParent() instanceof ASTPrimaryExpression) {            primaryExpression = (SimpleNode) location.jjtGetParent().jjtGetParent().jjtGetParent();        } else {            throw new RuntimeException("Found a NameOccurrence that didn't have an ASTPrimary Expression as parent or grandparent.  Parent = " + location.jjtGetParent() + " and grandparent = " + location.jjtGetParent().jjtGetParent());        }        return primaryExpression.jjtGetNumChildren() > 1 && primaryExpression.jjtGetChild(1) instanceof ASTAssignmentOperator;    }    public Scope getScope() {        return location.getScope();    }    public int getBeginLine() {        return location.getBeginLine();    }    public boolean isThisOrSuper() {        return image.equals("this") || image.equals("super");    }    public boolean equals(Object o) {        NameOccurrence n = (NameOccurrence) o;        return n.getImage().equals(getImage());    }    public String getImage() {        return image;    }    public int hashCode() {        return getImage().hashCode();    }    public String toString() {        return getImage() + ":" + location.getBeginLine() + ":" + location.getClass();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -