本文整理汇总了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);
}
示例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);
}
示例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;
}