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


Java StructuralPropertyDescriptor类代码示例

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


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

示例1: locationNeedsParentheses

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
	if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
		// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
		return false;
	}
	if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
			|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
			|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
			|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
			|| locationInParent == ForStatement.EXPRESSION_PROPERTY
			|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
			|| locationInParent == DoStatement.EXPRESSION_PROPERTY
			|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
			|| locationInParent == AssertStatement.MESSAGE_PROPERTY
			|| locationInParent == IfStatement.EXPRESSION_PROPERTY
			|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
			|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
			|| locationInParent == ArrayAccess.INDEX_PROPERTY
			|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
			|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
			|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:NecessaryParenthesesChecker.java

示例2: handleSimpleName

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:CodeStyleFix.java

示例3: isStringNodeInPatternElement

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
public static boolean isStringNodeInPatternElement(StringLiteral node) {
	ASTNode parent = node.getParent();
	StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
	if (locationInParent.isChildProperty() && !locationInParent.isChildListProperty()) {
		return false;
	}
	if (parent instanceof MethodInvocation) {
		MethodInvocation parentMethodInvocation = (MethodInvocation) parent;
		if (isPatternPart(parentMethodInvocation)) {
			return true;
		} else if (isStringPattern(parentMethodInvocation)) {
			return true;
		} else {

		}
	} else {
		LOG.fine("not ClassInstanceCreation " + parent.getClass().getName() + " " + parent);
	}
	return false;
}
 
开发者ID:impetuouslab,项目名称:eclipse-filecompletion,代码行数:21,代码来源:FileClassFinder.java

示例4: handleTypeBinding

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private void handleTypeBinding(ASTNode node, ITypeBinding typeBinding, boolean includeTypeParameters) {
	if (typeBinding == null) {
		StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
		//System.out.println(locationInParent.getId() + " has no type binding");
	} else {
		List<ITypeBinding> rawTypes = new ArrayList<ITypeBinding>();
		Set<String> dejavu = new HashSet<String>();
		this.appendRawTypes(rawTypes, dejavu, typeBinding, includeTypeParameters);
		for (ITypeBinding rawType : rawTypes) {
			if (!this.ignoreType(rawType)) {
				this.onTypeAccess(node, rawType);
			}
		}
		
	}
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:17,代码来源:DependenciesAstVisitor.java

示例5: structuralPropertyNamesOf

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private static List<String> structuralPropertyNamesOf(final List<Class<? extends ASTNode>> nodes) {
    final List<String> names = new ArrayList<>();
    for (final Class<? extends ASTNode> node : nodes) {
        try {
            final Method m = node.getDeclaredMethod("propertyDescriptors", int.class);
            final List l = (List) m.invoke(null, AST.JLS8);
            for (final Object o : l) {
                final StructuralPropertyDescriptor d = (StructuralPropertyDescriptor) o;
                names.add(d.getId());
            }
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
            throw new RuntimeException("unexpected exception", ex);
        }
    }
    return names;
}
 
开发者ID:bblfsh,项目名称:java-driver,代码行数:17,代码来源:GoGen.java

示例6: serialize

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
@Override
public void serialize(ASTNode node, JsonGenerator jG, SerializerProvider provider) throws IOException {
    List<StructuralPropertyDescriptor> descriptorList = node.structuralPropertiesForType();
    nCount++;
    jG.writeStartObject();

    for (StructuralPropertyDescriptor descriptor : descriptorList) {
        Object child = node.getStructuralProperty(descriptor);
        if (child instanceof List) {
            serializeChildList((List<ASTNode>) child, descriptor, provider);
        } else if (child instanceof ASTNode) {
            serializeChild((ASTNode) child, descriptor, provider);
        } else if (child != null) {
            jG.writeFieldName(descriptor.getId());
            jG.writeString(child.toString());
        }
    }
    jG.writeEndObject();
}
 
开发者ID:bblfsh,项目名称:java-driver,代码行数:20,代码来源:eclipseParser.java

示例7: getBindingOfParentTypeContext

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
/**
 * Returns the type binding of the node's type context or null if the node is inside
 * an annotation, type parameter, super type declaration, or Javadoc of a top level type.
 * The result of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in the type's body.
 *
 * @param node an AST node
 * @return the type binding of the node's parent type context, or <code>null</code>
 */
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
	StructuralPropertyDescriptor lastLocation= null;

	while (node != null) {
		if (node instanceof AbstractTypeDeclaration) {
			AbstractTypeDeclaration decl= (AbstractTypeDeclaration) node;
			if (lastLocation == decl.getBodyDeclarationsProperty()
					|| lastLocation == decl.getJavadocProperty()) {
				return decl.resolveBinding();
			} else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
				return decl.resolveBinding();
			}
		} else if (node instanceof AnonymousClassDeclaration) {
			return ((AnonymousClassDeclaration) node).resolveBinding();
		}
		lastLocation= node.getLocationInParent();
		node= node.getParent();
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:Bindings.java

示例8: needsExplicitBoxing

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
/**
 * Returns whether an expression at the given location needs explicit boxing.
 *
 * @param expression the expression
 * @return <code>true</code> iff an expression at the given location needs explicit boxing
 * @since 3.6
 */
private static boolean needsExplicitBoxing(Expression expression) {
	StructuralPropertyDescriptor locationInParent= expression.getLocationInParent();
	if (locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
		return needsExplicitBoxing((ParenthesizedExpression) expression.getParent());
	}

	if (locationInParent == ClassInstanceCreation.EXPRESSION_PROPERTY
			|| locationInParent == FieldAccess.EXPRESSION_PROPERTY
			|| locationInParent == MethodInvocation.EXPRESSION_PROPERTY) {
		return true;
	}

	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:ASTNodes.java

示例9: findParent

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
public static ASTNode findParent(ASTNode node, StructuralPropertyDescriptor[][] pathes) {
	for (int p= 0; p < pathes.length; p++) {
		StructuralPropertyDescriptor[] path= pathes[p];
		ASTNode current= node;
		int d= path.length - 1;
		for (; d >= 0 && current != null; d--) {
			StructuralPropertyDescriptor descriptor= path[d];
			if (!descriptor.equals(current.getLocationInParent())) {
				break;
			}
			current= current.getParent();
		}
		if (d < 0) {
			return current;
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:ASTNodes.java

示例10: getBindingOfParentTypeContext

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
/**
 * Returns the type binding of the node's type context or null if the node is inside an
 * annotation, type parameter, super type declaration, or Javadoc of a top level type. The result
 * of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in
 * the type's body.
 *
 * @param node an AST node
 * @return the type binding of the node's parent type context, or <code>null</code>
 */
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
  StructuralPropertyDescriptor lastLocation = null;

  while (node != null) {
    if (node instanceof AbstractTypeDeclaration) {
      AbstractTypeDeclaration decl = (AbstractTypeDeclaration) node;
      if (lastLocation == decl.getBodyDeclarationsProperty()
          || lastLocation == decl.getJavadocProperty()) {
        return decl.resolveBinding();
      } else if (decl instanceof EnumDeclaration
          && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
        return decl.resolveBinding();
      }
    } else if (node instanceof AnonymousClassDeclaration) {
      return ((AnonymousClassDeclaration) node).resolveBinding();
    }
    lastLocation = node.getLocationInParent();
    node = node.getParent();
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:Bindings.java

示例11: locationNeedsParentheses

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
  if (locationInParent instanceof ChildListPropertyDescriptor
      && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
    // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation
    // ...
    return false;
  }
  if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
      || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
      || locationInParent == ReturnStatement.EXPRESSION_PROPERTY
      || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
      || locationInParent == ForStatement.EXPRESSION_PROPERTY
      || locationInParent == WhileStatement.EXPRESSION_PROPERTY
      || locationInParent == DoStatement.EXPRESSION_PROPERTY
      || locationInParent == AssertStatement.EXPRESSION_PROPERTY
      || locationInParent == AssertStatement.MESSAGE_PROPERTY
      || locationInParent == IfStatement.EXPRESSION_PROPERTY
      || locationInParent == SwitchStatement.EXPRESSION_PROPERTY
      || locationInParent == SwitchCase.EXPRESSION_PROPERTY
      || locationInParent == ArrayAccess.INDEX_PROPERTY
      || locationInParent == ThrowStatement.EXPRESSION_PROPERTY
      || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
      || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
    return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:NecessaryParenthesesChecker.java

示例12: getDeclaringNode

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private static ASTNode getDeclaringNode(ASTNode selectedNode) {
  ASTNode declaringNode = null;
  if (selectedNode instanceof MethodDeclaration) {
    declaringNode = selectedNode;
  } else if (selectedNode instanceof SimpleName) {
    StructuralPropertyDescriptor locationInParent = selectedNode.getLocationInParent();
    if (locationInParent == MethodDeclaration.NAME_PROPERTY
        || locationInParent == TypeDeclaration.NAME_PROPERTY) {
      declaringNode = selectedNode.getParent();
    } else if (locationInParent == VariableDeclarationFragment.NAME_PROPERTY) {
      declaringNode = selectedNode.getParent().getParent();
    }
  }
  return declaringNode;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:Java50Fix.java

示例13: getInlineableMethodNode

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
private static ASTNode getInlineableMethodNode(ASTNode node, IJavaElement unit) {
  if (node == null) return null;
  switch (node.getNodeType()) {
    case ASTNode.SIMPLE_NAME:
      StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
      if (locationInParent == MethodDeclaration.NAME_PROPERTY) {
        return node.getParent();
      } else if (locationInParent == MethodInvocation.NAME_PROPERTY
          || locationInParent == SuperMethodInvocation.NAME_PROPERTY) {
        return unit instanceof ICompilationUnit
            ? node.getParent()
            : null; // don't start on invocations in binary
      }
      return null;
    case ASTNode.EXPRESSION_STATEMENT:
      node = ((ExpressionStatement) node).getExpression();
  }
  switch (node.getNodeType()) {
    case ASTNode.METHOD_DECLARATION:
      return node;
    case ASTNode.METHOD_INVOCATION:
    case ASTNode.SUPER_METHOD_INVOCATION:
    case ASTNode.CONSTRUCTOR_INVOCATION:
      return unit instanceof ICompilationUnit
          ? node
          : null; // don't start on invocations in binary
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RefactoringAvailabilityTester.java

示例14: visit

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
@Override
public boolean visit(SimpleName node) {
  addReferencesToName(node);
  IBinding binding = node.resolveBinding();
  if (binding instanceof ITypeBinding) {
    ITypeBinding type = (ITypeBinding) binding;
    if (type.isTypeVariable()) {
      addTypeVariableReference(type, node);
    }
  } else if (binding instanceof IVariableBinding) {
    IVariableBinding vb = (IVariableBinding) binding;
    if (vb.isField() && !isStaticallyImported(node)) {
      Name topName = ASTNodes.getTopMostName(node);
      if (node == topName || node == ASTNodes.getLeftMostSimpleName(topName)) {
        StructuralPropertyDescriptor location = node.getLocationInParent();
        if (location != SingleVariableDeclaration.NAME_PROPERTY
            && location != VariableDeclarationFragment.NAME_PROPERTY) {
          fImplicitReceivers.add(node);
        }
      }
    } else if (!vb.isField()) {
      // we have a local. Check if it is a parameter.
      ParameterData data = fParameters.get(binding);
      if (data != null) {
        ASTNode parent = node.getParent();
        if (parent instanceof Expression) {
          int precedence = OperatorPrecedence.getExpressionPrecedence((Expression) parent);
          if (precedence != Integer.MAX_VALUE) {
            data.setOperatorPrecedence(precedence);
          }
        }
      }
    }
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:SourceAnalyzer.java

示例15: getTargetNode

import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; //导入依赖的package包/类
/**
 * Finds and returns the <code>ASTNode</code> for the given source text selection, if it is an
 * entire constructor call or the class name portion of a constructor call or constructor
 * declaration, or null otherwise.
 *
 * @param unit The compilation unit in which the selection was made
 * @param offset The textual offset of the start of the selection
 * @param length The length of the selection in characters
 * @return ClassInstanceCreation or MethodDeclaration
 */
private ASTNode getTargetNode(ICompilationUnit unit, int offset, int length) {
  ASTNode node = ASTNodes.getNormalizedNode(NodeFinder.perform(fCU, offset, length));
  if (node.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) return node;
  if (node.getNodeType() == ASTNode.METHOD_DECLARATION
      && ((MethodDeclaration) node).isConstructor()) return node;
  // we have some sub node. Make sure its the right child of the parent
  StructuralPropertyDescriptor location = node.getLocationInParent();
  ASTNode parent = node.getParent();
  if (location == ClassInstanceCreation.TYPE_PROPERTY) {
    return parent;
  } else if (location == MethodDeclaration.NAME_PROPERTY
      && ((MethodDeclaration) parent).isConstructor()) {
    return parent;
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:IntroduceFactoryRefactoring.java


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