本文整理汇总了Java中org.eclipse.jdt.core.dom.SuperFieldAccess类的典型用法代码示例。如果您正苦于以下问题:Java SuperFieldAccess类的具体用法?Java SuperFieldAccess怎么用?Java SuperFieldAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuperFieldAccess类属于org.eclipse.jdt.core.dom包,在下文中一共展示了SuperFieldAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSimpleName
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private void handleSimpleName(SimpleName node) {
ASTNode firstExpression = node.getParent();
if (firstExpression instanceof FieldAccess) {
while (firstExpression instanceof FieldAccess) {
firstExpression = ((FieldAccess) firstExpression).getExpression();
}
if (!(firstExpression instanceof SimpleName)) return;
node = (SimpleName) firstExpression;
} else if (firstExpression instanceof SuperFieldAccess) return;
StructuralPropertyDescriptor parentDescription = node.getLocationInParent();
if (parentDescription == VariableDeclarationFragment.NAME_PROPERTY
|| parentDescription == SwitchCase.EXPRESSION_PROPERTY) return;
IBinding binding = node.resolveBinding();
if (!(binding instanceof IVariableBinding)) return;
handleVariable(node, (IVariableBinding) binding);
}
示例2: getAssignedVariable
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
/**
* Returns the binding of the variable written in an Assignment.
* @param assignment The assignment
* @return The binding or <code>null</code> if no bindings are available.
*/
public static IVariableBinding getAssignedVariable(Assignment assignment) {
Expression leftHand = assignment.getLeftHandSide();
switch (leftHand.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
case ASTNode.QUALIFIED_NAME:
return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
case ASTNode.FIELD_ACCESS:
return ((FieldAccess) leftHand).resolveFieldBinding();
case ASTNode.SUPER_FIELD_ACCESS:
return ((SuperFieldAccess) leftHand).resolveFieldBinding();
default:
return null;
}
}
示例3: isLeftHandSideOfAssignment
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
static boolean isLeftHandSideOfAssignment(ASTNode node) {
Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
if (assignment != null) {
Expression leftHandSide = assignment.getLeftHandSide();
if (leftHandSide == node) {
return true;
}
if (ASTNodes.isParent(node, leftHandSide)) {
switch (leftHandSide.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return true;
case ASTNode.FIELD_ACCESS:
return node == ((FieldAccess) leftHandSide).getName();
case ASTNode.QUALIFIED_NAME:
return node == ((QualifiedName) leftHandSide).getName();
case ASTNode.SUPER_FIELD_ACCESS:
return node == ((SuperFieldAccess) leftHandSide).getName();
default:
return false;
}
}
}
return false;
}
示例4: getAssignedVariable
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
/**
* Returns the binding of the variable written in an Assignment.
*
* @param assignment The assignment
* @return The binding or <code>null</code> if no bindings are available.
*/
public static IVariableBinding getAssignedVariable(Assignment assignment) {
Expression leftHand = assignment.getLeftHandSide();
switch (leftHand.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
case ASTNode.QUALIFIED_NAME:
return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
case ASTNode.FIELD_ACCESS:
return ((FieldAccess) leftHand).resolveFieldBinding();
case ASTNode.SUPER_FIELD_ACCESS:
return ((SuperFieldAccess) leftHand).resolveFieldBinding();
default:
return null;
}
}
示例5: isLeftHandSideOfAssignment
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
Assignment assignment = (Assignment) ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
if (assignment != null) {
Expression leftHandSide = assignment.getLeftHandSide();
if (leftHandSide == node) {
return true;
}
if (ASTNodes.isParent(node, leftHandSide)) {
switch (leftHandSide.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return true;
case ASTNode.FIELD_ACCESS:
return node == ((FieldAccess) leftHandSide).getName();
case ASTNode.QUALIFIED_NAME:
return node == ((QualifiedName) leftHandSide).getName();
case ASTNode.SUPER_FIELD_ACCESS:
return node == ((SuperFieldAccess) leftHandSide).getName();
default:
return false;
}
}
}
return false;
}
示例6: resolveBinding
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
public static IBinding resolveBinding(Expression expression) {
if (expression instanceof Name) return ((Name) expression).resolveBinding();
if (expression instanceof ParenthesizedExpression)
return resolveBinding(((ParenthesizedExpression) expression).getExpression());
else if (expression instanceof Assignment)
return resolveBinding(((Assignment) expression).getLeftHandSide()); // TODO ???
else if (expression instanceof MethodInvocation)
return ((MethodInvocation) expression).resolveMethodBinding();
else if (expression instanceof SuperMethodInvocation)
return ((SuperMethodInvocation) expression).resolveMethodBinding();
else if (expression instanceof FieldAccess)
return ((FieldAccess) expression).resolveFieldBinding();
else if (expression instanceof SuperFieldAccess)
return ((SuperFieldAccess) expression).resolveFieldBinding();
else if (expression instanceof ConditionalExpression)
return resolveBinding(((ConditionalExpression) expression).getThenExpression());
return null;
}
示例7: getProposal
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private static ChangeCorrectionProposal getProposal(
ICompilationUnit cu, SimpleName sn, IVariableBinding variableBinding, int relevance) {
Expression accessNode = sn;
Expression qualifier = null;
boolean useSuper = false;
ASTNode parent = sn.getParent();
switch (parent.getNodeType()) {
case ASTNode.QUALIFIED_NAME:
accessNode = (Expression) parent;
qualifier = ((QualifiedName) parent).getQualifier();
break;
case ASTNode.SUPER_FIELD_ACCESS:
accessNode = (Expression) parent;
qualifier = ((SuperFieldAccess) parent).getQualifier();
useSuper = true;
break;
}
ASTRewrite rewrite = ASTRewrite.create(sn.getAST());
ProposalParameter gspc =
new ProposalParameter(useSuper, cu, rewrite, accessNode, qualifier, variableBinding);
if (ASTResolving.isWriteAccess(sn)) return addSetterProposal(gspc, relevance);
else return addGetterProposal(gspc, relevance);
}
示例8: generateQualifier
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private Expression generateQualifier(String paramName, AST ast, boolean useSuper, Expression qualifier) {
SimpleName paramSimpleName= ast.newSimpleName(paramName);
if (useSuper) {
SuperFieldAccess sf= ast.newSuperFieldAccess();
sf.setName(paramSimpleName);
if (qualifier instanceof Name) {
sf.setQualifier((Name) qualifier);
}
return sf;
}
if (qualifier != null) {
FieldAccess parameterAccess= ast.newFieldAccess();
parameterAccess.setExpression(qualifier);
parameterAccess.setName(paramSimpleName);
return parameterAccess;
}
return paramSimpleName;
}
示例9: updateSimpleName
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private void updateSimpleName(ASTRewrite rewriter, ParameterInfo pi, SimpleName node, List<SingleVariableDeclaration> enclosingParameters, IJavaProject project) {
AST ast= rewriter.getAST();
IBinding binding= node.resolveBinding();
Expression replacementNode= fParameterObjectFactory.createFieldReadAccess(pi, getParameterName(), ast, project, false, null);
if (binding instanceof IVariableBinding) {
IVariableBinding variable= (IVariableBinding) binding;
if (variable.isParameter() && variable.getName().equals(getNameInScope(pi, enclosingParameters))) {
rewriter.replace(node, replacementNode, null);
}
} else {
ASTNode parent= node.getParent();
if (!(parent instanceof QualifiedName || parent instanceof FieldAccess || parent instanceof SuperFieldAccess)) {
if (node.getIdentifier().equals(getNameInScope(pi, enclosingParameters))) {
rewriter.replace(node, replacementNode, null);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:IntroduceParameterObjectProcessor.java
示例10: isLeftHandSideOfAssignment
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private static boolean isLeftHandSideOfAssignment(ASTNode node) {
Assignment assignment= (Assignment)ASTNodes.getParent(node, ASTNode.ASSIGNMENT);
if (assignment != null) {
Expression leftHandSide= assignment.getLeftHandSide();
if (leftHandSide == node) {
return true;
}
if (ASTNodes.isParent(node, leftHandSide)) {
switch (leftHandSide.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return true;
case ASTNode.FIELD_ACCESS:
return node == ((FieldAccess)leftHandSide).getName();
case ASTNode.QUALIFIED_NAME:
return node == ((QualifiedName)leftHandSide).getName();
case ASTNode.SUPER_FIELD_ACCESS:
return node == ((SuperFieldAccess)leftHandSide).getName();
default:
return false;
}
}
}
return false;
}
示例11: resolveBinding
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
public static IBinding resolveBinding(Expression expression){
if (expression instanceof Name)
return ((Name)expression).resolveBinding();
if (expression instanceof ParenthesizedExpression)
return resolveBinding(((ParenthesizedExpression)expression).getExpression());
else if (expression instanceof Assignment)
return resolveBinding(((Assignment)expression).getLeftHandSide());//TODO ???
else if (expression instanceof MethodInvocation)
return ((MethodInvocation)expression).resolveMethodBinding();
else if (expression instanceof SuperMethodInvocation)
return ((SuperMethodInvocation)expression).resolveMethodBinding();
else if (expression instanceof FieldAccess)
return ((FieldAccess)expression).resolveFieldBinding();
else if (expression instanceof SuperFieldAccess)
return ((SuperFieldAccess)expression).resolveFieldBinding();
else if (expression instanceof ConditionalExpression)
return resolveBinding(((ConditionalExpression)expression).getThenExpression());
return null;
}
示例12: getAssignedVariable
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
/**
* Returns the binding of the variable written in an Assignment.
* @param assignment The assignment
* @return The binding or <code>null</code> if no bindings are available.
*/
public static IVariableBinding getAssignedVariable(Assignment assignment) {
Expression leftHand = assignment.getLeftHandSide();
switch (leftHand.getNodeType()) {
case ASTNode.SIMPLE_NAME:
return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
case ASTNode.QUALIFIED_NAME:
return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
case ASTNode.FIELD_ACCESS:
return ((FieldAccess) leftHand).resolveFieldBinding();
case ASTNode.SUPER_FIELD_ACCESS:
return ((SuperFieldAccess) leftHand).resolveFieldBinding();
default:
return null;
}
}
示例13: handleSimpleName
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private void handleSimpleName(SimpleName node) {
ASTNode firstExpression= node.getParent();
if (firstExpression instanceof FieldAccess) {
while (firstExpression instanceof FieldAccess) {
firstExpression= ((FieldAccess)firstExpression).getExpression();
}
if (!(firstExpression instanceof SimpleName))
return;
node= (SimpleName)firstExpression;
} else if (firstExpression instanceof SuperFieldAccess)
return;
StructuralPropertyDescriptor parentDescription= node.getLocationInParent();
if (parentDescription == VariableDeclarationFragment.NAME_PROPERTY || parentDescription == SwitchCase.EXPRESSION_PROPERTY)
return;
IBinding binding= node.resolveBinding();
if (!(binding instanceof IVariableBinding))
return;
handleVariable(node, (IVariableBinding) binding);
}
示例14: getProposal
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
private static ChangeCorrectionProposal getProposal(ICompilationUnit cu, SimpleName sn, IVariableBinding variableBinding, int relevance) {
Expression accessNode= sn;
Expression qualifier= null;
boolean useSuper= false;
ASTNode parent= sn.getParent();
switch (parent.getNodeType()) {
case ASTNode.QUALIFIED_NAME:
accessNode= (Expression) parent;
qualifier= ((QualifiedName) parent).getQualifier();
break;
case ASTNode.SUPER_FIELD_ACCESS:
accessNode= (Expression) parent;
qualifier= ((SuperFieldAccess) parent).getQualifier();
useSuper= true;
break;
}
ASTRewrite rewrite= ASTRewrite.create(sn.getAST());
ProposalParameter gspc= new ProposalParameter(useSuper, cu, rewrite, accessNode, qualifier, variableBinding);
if (ASTResolving.isWriteAccess(sn))
return addSetterProposal(gspc, relevance);
else
return addGetterProposal(gspc, relevance);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:GetterSetterCorrectionSubProcessor.java
示例15: resolveExpression
import org.eclipse.jdt.core.dom.SuperFieldAccess; //导入依赖的package包/类
/**
* Always called from the statement visitor, therefore, all variables are top-level.
*/
public IResolvedData resolveExpression(final Expression expression, final ASTNode node,
final IResolvedNode qualifierOf, final boolean isLHS, final boolean isDef)
{
IResolvedData rv = null;
if (expression instanceof Name)
{
final IBinding binding = ((Name) expression).resolveBinding();
if (binding instanceof IVariableBinding)
{
rv = newResolvedVariable(expression, ASTTools.enclosingScope(node), qualifierOf, isLHS,
false, isDef);
}
}
else if (expression instanceof FieldAccess)
{
rv = newResolvedVariable(expression, ASTTools.enclosingScope(node), qualifierOf, isLHS,
false, isDef);
}
else if (expression instanceof SuperFieldAccess)
{
rv = newResolvedVariable(expression, ASTTools.enclosingScope(node), qualifierOf, isLHS,
false, isDef);
}
return rv;
}