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


Java ASTNodes.getMessages方法代码示例

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


在下文中一共展示了ASTNodes.getMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkMethodSyntaxErrors

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
public static RefactoringStatus checkMethodSyntaxErrors(
    int selectionStart,
    int selectionLength,
    CompilationUnit cuNode,
    String invalidSelectionMessage) {
  SelectionAnalyzer analyzer =
      new SelectionAnalyzer(
          Selection.createFromStartLength(selectionStart, selectionLength), true);
  cuNode.accept(analyzer);
  ASTNode coveringNode = analyzer.getLastCoveringNode();
  if (!(coveringNode instanceof Block)
      || !(coveringNode.getParent() instanceof MethodDeclaration))
    return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage);
  if (ASTNodes.getMessages(coveringNode, ASTNodes.NODE_ONLY).length == 0)
    return RefactoringStatus.createFatalErrorStatus(invalidSelectionMessage);

  MethodDeclaration methodDecl = (MethodDeclaration) coveringNode.getParent();
  String message =
      Messages.format(
          RefactoringCoreMessages.CodeRefactoringUtil_error_message,
          BasicElementLabels.getJavaElementName(methodDecl.getName().getIdentifier()));
  return RefactoringStatus.createFatalErrorStatus(message);
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:CodeRefactoringUtil.java

示例2: endVisit

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
@Override
public void endVisit(CompilationUnit node) {
	postProcessSelectedNodes(internalGetSelectedNodes());
	ASTNode enclosingNode = null;
	superCall: {
		if (getStatus().hasFatalError()) {
			break superCall;
		}
		if (!hasSelectedNodes()) {
			ASTNode coveringNode = getLastCoveringNode();
			if (coveringNode instanceof Block) {
				Block block = (Block) coveringNode;
				Message[] messages = ASTNodes.getMessages(block, ASTNodes.NODE_ONLY);
				if (messages.length > 0) {
					invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_compile_errors, JavaStatusContext.create(getCompilationUnit(), block));
					break superCall;
				}
			}
			invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_doesNotCover);
			break superCall;
		}
		enclosingNode = getEnclosingNode(getFirstSelectedNode());
		boolean isValidEnclosingNode = enclosingNode instanceof MethodDeclaration || enclosingNode instanceof Initializer;
		if (fSurroundWithTryCatch) {
			isValidEnclosingNode = isValidEnclosingNode || enclosingNode instanceof MethodReference || enclosingNode.getLocationInParent() == LambdaExpression.BODY_PROPERTY;
		}
		if (!isValidEnclosingNode) {
			invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_doesNotContain);
			break superCall;
		}
		if (!validSelectedNodes()) {
			invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_onlyStatements);
		}
		fLocals = LocalDeclarationAnalyzer.perform(enclosingNode, getSelection());
	}
	super.endVisit(node);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:38,代码来源:SurroundWithAnalyzer.java

示例3: processCompilerError

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private boolean processCompilerError(RefactoringStatus result, ASTNode node) {
  Message[] messages = ASTNodes.getMessages(node, ASTNodes.INCLUDE_ALL_PARENTS);
  if (messages.length == 0) return false;
  result.addFatalError(
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_compiler_errors_field,
          new String[] {
            BasicElementLabels.getJavaElementName(fField.getElementName()),
            messages[0].getMessage()
          }));
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:SelfEncapsulateFieldRefactoring.java


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