本文整理汇总了Java中org.eclipse.jdt.core.compiler.IScanner.resetTo方法的典型用法代码示例。如果您正苦于以下问题:Java IScanner.resetTo方法的具体用法?Java IScanner.resetTo怎么用?Java IScanner.resetTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.compiler.IScanner
的用法示例。
在下文中一共展示了IScanner.resetTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import org.eclipse.jdt.core.compiler.IScanner; //导入方法依赖的package包/类
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) {
char[] characters = scanner.getSource();
selection = adjustSelection(characters, selection, end);
scanner.resetTo(start, end);
int token = 0;
try {
loop: while (token != ITerminalSymbols.TokenNameEOF) {
token = scanner.getNextToken();
switch (token) {
case ITerminalSymbols.TokenNameCOMMENT_LINE:
case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
if (checkStart(scanner, selection.getOffset())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment);
break loop;
}
if (checkEnd(scanner, selection.getInclusiveEnd())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment);
break loop;
}
break;
}
}
} catch (InvalidInputException e) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error);
}
}
示例2: check
import org.eclipse.jdt.core.compiler.IScanner; //导入方法依赖的package包/类
private void check(
RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) {
char[] characters = scanner.getSource();
selection = adjustSelection(characters, selection, end);
scanner.resetTo(start, end);
int token = 0;
try {
loop:
while (token != ITerminalSymbols.TokenNameEOF) {
token = scanner.getNextToken();
switch (token) {
case ITerminalSymbols.TokenNameCOMMENT_LINE:
case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
if (checkStart(scanner, selection.getOffset())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment);
break loop;
}
if (checkEnd(scanner, selection.getInclusiveEnd())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment);
break loop;
}
break;
}
}
} catch (InvalidInputException e) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error);
}
}
示例3: check
import org.eclipse.jdt.core.compiler.IScanner; //导入方法依赖的package包/类
private void check(RefactoringStatus result, Selection selection, IScanner scanner, int start, int end) {
char[] characters= scanner.getSource();
selection= adjustSelection(characters, selection, end);
scanner.resetTo(start, end);
int token= 0;
try {
loop: while (token != ITerminalSymbols.TokenNameEOF) {
token= scanner.getNextToken();
switch(token) {
case ITerminalSymbols.TokenNameCOMMENT_LINE:
case ITerminalSymbols.TokenNameCOMMENT_BLOCK:
case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
if (checkStart(scanner, selection.getOffset())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_starts_inside_comment);
break loop;
}
if (checkEnd(scanner, selection.getInclusiveEnd())) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_ends_inside_comment);
break loop;
}
break;
}
}
} catch (InvalidInputException e) {
result.addFatalError(RefactoringCoreMessages.CommentAnalyzer_internal_error);
}
}
示例4: perform
import org.eclipse.jdt.core.compiler.IScanner; //导入方法依赖的package包/类
/**
* A visitor that maps a selection to a given ASTNode. The result node is
* determined as follows:
* <ul>
* <li>first the visitor tries to find a node that is covered by <code>start</code> and
* <code>length</code> where either <code>start</code> and <code>length</code> exactly
* matches the node or where the text covered before and after the node only consists
* of white spaces or comments.</li>
* <li>if no such node exists than the node that encloses the range defined by
* start and end is returned.</li>
* <li>if the length is zero than also nodes are considered where the node's
* start or end position matches <code>start</code>.</li>
* <li>otherwise <code>null</code> is returned.</li>
* </ul>
*
* @param root the root node from which the search starts
* @param start the start offset
* @param length the length
* @param source the source of the compilation unit
*
* @return the result node
* @throws JavaModelException if an error occurs in the Java model
*
* @since 3.0
*/
public static ASTNode perform(ASTNode root, int start, int length, ITypeRoot source) throws JavaModelException {
NodeFinder finder= new NodeFinder(start, length);
root.accept(finder);
ASTNode result= finder.getCoveredNode();
if (result == null)
return null;
Selection selection= Selection.createFromStartLength(start, length);
if (selection.covers(result)) {
IBuffer buffer= source.getBuffer();
if (buffer != null) {
IScanner scanner= ToolFactory.createScanner(false, false, false, false);
scanner.setSource(buffer.getText(start, length).toCharArray());
try {
int token= scanner.getNextToken();
if (token != ITerminalSymbols.TokenNameEOF) {
int tStart= scanner.getCurrentTokenStartPosition();
if (tStart == result.getStartPosition() - start) {
scanner.resetTo(tStart + result.getLength(), length - 1);
token= scanner.getNextToken();
if (token == ITerminalSymbols.TokenNameEOF)
return result;
}
}
} catch (InvalidInputException e) {
}
}
}
return finder.getCoveringNode();
}
示例5: computeHeaderComment
import org.eclipse.jdt.core.compiler.IScanner; //导入方法依赖的package包/类
private IRegion computeHeaderComment(FoldingStructureComputationContext ctx) throws JavaModelException {
// search at most up to the first type
ISourceRange range= ctx.getFirstType().getSourceRange();
if (range == null)
return null;
int start= 0;
int end= range.getOffset();
/* code adapted from CommentFormattingStrategy:
* scan the header content up to the first type. Once a comment is
* found, accumulate any additional comments up to the stop condition.
* The stop condition is reaching a package declaration, import container,
* or the end of the input.
*/
IScanner scanner= ctx.getScanner();
scanner.resetTo(start, end);
int headerStart= -1;
int headerEnd= -1;
try {
boolean foundComment= false;
int terminal= scanner.getNextToken();
while (terminal != ITerminalSymbols.TokenNameEOF && !(terminal == ITerminalSymbols.TokenNameclass || terminal == ITerminalSymbols.TokenNameinterface || terminal == ITerminalSymbols.TokenNameenum || (foundComment && (terminal == ITerminalSymbols.TokenNameimport || terminal == ITerminalSymbols.TokenNamepackage)))) {
if (terminal == ITerminalSymbols.TokenNameCOMMENT_JAVADOC || terminal == ITerminalSymbols.TokenNameCOMMENT_BLOCK || terminal == ITerminalSymbols.TokenNameCOMMENT_LINE) {
if (!foundComment)
headerStart= scanner.getCurrentTokenStartPosition();
headerEnd= scanner.getCurrentTokenEndPosition();
foundComment= true;
}
terminal= scanner.getNextToken();
}
} catch (InvalidInputException ex) {
return null;
}
if (headerEnd != -1) {
return new Region(headerStart, headerEnd - headerStart);
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:DefaultJavaFoldingStructureProvider.java