本文整理了Java中org.eclipse.jdt.core.dom.CompilationUnit.getMessages()
方法的一些代码示例,展示了CompilationUnit.getMessages()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CompilationUnit.getMessages()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.CompilationUnit
类名称:CompilationUnit
方法名:getMessages
[英]Returns the list of messages reported by the compiler during the parsing or the type checking of this compilation unit. This list might be a subset of errors detected and reported by a Java compiler.
This list of messages is suitable for simple clients that do little more than log the messages or display them to the user. Clients that need further details should call getProblems
to get compiler problem objects.
[中]返回编译器在此编译单元的分析或类型检查期间报告的消息列表。此列表可能是Java编译器检测和报告的错误的子集。
此消息列表适用于只记录消息或向用户显示消息的简单客户端。需要进一步详细信息的客户端应调用getProblems
以获取编译器问题对象。
代码示例来源:origin: ModeShape/modeshape
protected void recordCompilerMessages( final CompilationUnit unit,
final Node parentNode ) throws Exception {
final Message[] messages = unit.getMessages();
if ((messages != null) && (messages.length != 0)) {
final Node containerNode = parentNode.addNode(ClassFileSequencerLexicon.MESSAGES, ClassFileSequencerLexicon.MESSAGES);
for (final Message message : messages) {
final Node messageNode = containerNode.addNode(ClassFileSequencerLexicon.MESSAGE,
ClassFileSequencerLexicon.MESSAGE);
messageNode.setProperty(ClassFileSequencerLexicon.MESSAGE, message.getMessage());
messageNode.setProperty(ClassFileSequencerLexicon.START_POSITION, message.getStartPosition());
messageNode.setProperty(ClassFileSequencerLexicon.LENGTH, message.getLength());
}
}
}
代码示例来源:origin: org.modeshape/modeshape-sequencer-java
protected void recordCompilerMessages( final CompilationUnit unit,
final Node parentNode ) throws Exception {
final Message[] messages = unit.getMessages();
if ((messages != null) && (messages.length != 0)) {
final Node containerNode = parentNode.addNode(ClassFileSequencerLexicon.MESSAGES, ClassFileSequencerLexicon.MESSAGES);
for (final Message message : messages) {
final Node messageNode = containerNode.addNode(ClassFileSequencerLexicon.MESSAGE,
ClassFileSequencerLexicon.MESSAGE);
messageNode.setProperty(ClassFileSequencerLexicon.MESSAGE, message.getMessage());
messageNode.setProperty(ClassFileSequencerLexicon.START_POSITION, message.getStartPosition());
messageNode.setProperty(ClassFileSequencerLexicon.LENGTH, message.getLength());
}
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
public static Message[] getMessages(ASTNode node, int flags) {
ASTNode root= node.getRoot();
if (!(root instanceof CompilationUnit))
return EMPTY_MESSAGES;
Message[] messages= ((CompilationUnit)root).getMessages();
if (root == node)
return messages;
final int iterations= computeIterations(flags);
List<Message> result= new ArrayList<>(5);
for (int i= 0; i < messages.length; i++) {
Message message= messages[i];
ASTNode temp= node;
int count= iterations;
do {
int nodeOffset= temp.getStartPosition();
int messageOffset= message.getStartPosition();
if (nodeOffset <= messageOffset && messageOffset < nodeOffset + temp.getLength()) {
result.add(message);
count= 0;
} else {
count--;
}
} while ((temp= temp.getParent()) != null && count > 0);
}
return result.toArray(new Message[result.size()]);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
public static Message[] getMessages(ASTNode node, int flags) {
ASTNode root= node.getRoot();
if (!(root instanceof CompilationUnit))
return EMPTY_MESSAGES;
Message[] messages= ((CompilationUnit)root).getMessages();
if (root == node)
return messages;
final int iterations= computeIterations(flags);
List result= new ArrayList(5);
for (int i= 0; i < messages.length; i++) {
Message message= messages[i];
ASTNode temp= node;
int count= iterations;
do {
int nodeOffset= temp.getStartPosition();
int messageOffset= message.getStartPosition();
if (nodeOffset <= messageOffset && messageOffset < nodeOffset + temp.getLength()) {
result.add(message);
count= 0;
} else {
count--;
}
} while ((temp= temp.getParent()) != null && count > 0);
}
return (Message[]) result.toArray(new Message[result.size()]);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
public static Message[] getMessages(ASTNode node, int flags) {
ASTNode root= node.getRoot();
if (!(root instanceof CompilationUnit))
return EMPTY_MESSAGES;
Message[] messages= ((CompilationUnit)root).getMessages();
if (root == node)
return messages;
final int iterations= computeIterations(flags);
List<Message> result= new ArrayList<>(5);
for (int i= 0; i < messages.length; i++) {
Message message= messages[i];
ASTNode temp= node;
int count= iterations;
do {
int nodeOffset= temp.getStartPosition();
int messageOffset= message.getStartPosition();
if (nodeOffset <= messageOffset && messageOffset < nodeOffset + temp.getLength()) {
result.add(message);
count= 0;
} else {
count--;
}
} while ((temp= temp.getParent()) != null && count > 0);
}
return result.toArray(new Message[result.size()]);
}
内容来源于网络,如有侵权,请联系作者删除!