本文整理汇总了Java中org.eclipse.jdt.core.search.SearchMatch.isImplicit方法的典型用法代码示例。如果您正苦于以下问题:Java SearchMatch.isImplicit方法的具体用法?Java SearchMatch.isImplicit怎么用?Java SearchMatch.isImplicit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.search.SearchMatch
的用法示例。
在下文中一共展示了SearchMatch.isImplicit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createReplaceEdit
import org.eclipse.jdt.core.search.SearchMatch; //导入方法依赖的package包/类
protected final ReplaceEdit createReplaceEdit(SearchMatch searchResult, ICompilationUnit cu) {
if (searchResult.isImplicit()) { // handle Annotation Element references, see bug 94062
StringBuffer sb = new StringBuffer(getNewElementName());
if (JavaCore.INSERT.equals(
cu.getJavaProject()
.getOption(
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR,
true))) sb.append(' ');
sb.append('=');
if (JavaCore.INSERT.equals(
cu.getJavaProject()
.getOption(
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR,
true))) sb.append(' ');
return new ReplaceEdit(searchResult.getOffset(), 0, sb.toString());
} else {
return new ReplaceEdit(
searchResult.getOffset(), searchResult.getLength(), getNewElementName());
}
}
示例2: collectMatch
import org.eclipse.jdt.core.search.SearchMatch; //导入方法依赖的package包/类
private TextEdit collectMatch(SearchMatch match, IJavaElement element, ICompilationUnit unit, String newName) throws IndexOutOfBoundsException, JavaModelException {
if (match instanceof MethodReferenceMatch && ((MethodReferenceMatch) match).isSuperInvocation() && match.getAccuracy() == SearchMatch.A_INACCURATE) {
return null;
}
if (!(element instanceof IMethod) || match.isImplicit()) {
return new ReplaceEdit(match.getOffset(), match.getLength(), newName);
}
int start = match.getOffset();
int length = match.getLength();
String matchText = unit.getBuffer().getText(start, length);
//direct match:
if (newName.equals(matchText)) {
return new ReplaceEdit(match.getOffset(), match.getLength(), newName);
}
// lambda expression
if (match instanceof MethodDeclarationMatch && match.getElement() instanceof IMethod && ((IMethod) match.getElement()).isLambdaMethod()) {
// don't touch the lambda
return null;
}
//Not a standard reference -- use scanner to find last identifier token before left parenthesis:
IScanner scanner = getScanner(unit);
scanner.setSource(matchText.toCharArray());
int simpleNameStart = -1;
int simpleNameEnd = -1;
try {
int token = scanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF && token != ITerminalSymbols.TokenNameLPAREN) { // reference in code includes arguments in parentheses
if (token == ITerminalSymbols.TokenNameIdentifier) {
simpleNameStart = scanner.getCurrentTokenStartPosition();
simpleNameEnd = scanner.getCurrentTokenEndPosition();
}
token = scanner.getNextToken();
}
} catch (InvalidInputException e) {
//ignore
}
if (simpleNameStart != -1) {
match.setOffset(start + simpleNameStart);
match.setLength(simpleNameEnd + 1 - simpleNameStart);
}
return new ReplaceEdit(match.getOffset(), match.getLength(), newName);
}
示例3: acceptSearchMatch
import org.eclipse.jdt.core.search.SearchMatch; //导入方法依赖的package包/类
@Override
public void acceptSearchMatch(ICompilationUnit unit, SearchMatch match) throws CoreException {
if (match instanceof MethodReferenceMatch
&& ((MethodReferenceMatch) match).isSuperInvocation()
&& match.getAccuracy() == SearchMatch.A_INACCURATE) {
return; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491
}
if (match.isImplicit()) { // see bug 94062
collectMatch(match);
return;
}
int start = match.getOffset();
int length = match.getLength();
String matchText = unit.getBuffer().getText(start, length);
// direct match:
if (fName.equals(matchText)) {
collectMatch(match);
return;
}
// lambda expression
if (match instanceof MethodDeclarationMatch
&& match.getElement() instanceof IMethod
&& ((IMethod) match.getElement()).isLambdaMethod()) {
// don't touch the lambda
return;
}
// Not a standard reference -- use scanner to find last identifier token before left
// parenthesis:
IScanner scanner = getScanner(unit);
scanner.setSource(matchText.toCharArray());
int simpleNameStart = -1;
int simpleNameEnd = -1;
try {
int token = scanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF
&& token
!= ITerminalSymbols
.TokenNameLPAREN) { // reference in code includes arguments in parentheses
if (token == ITerminalSymbols.TokenNameIdentifier) {
simpleNameStart = scanner.getCurrentTokenStartPosition();
simpleNameEnd = scanner.getCurrentTokenEndPosition();
}
token = scanner.getNextToken();
}
} catch (InvalidInputException e) {
// ignore
}
if (simpleNameStart != -1) {
match.setOffset(start + simpleNameStart);
match.setLength(simpleNameEnd + 1 - simpleNameStart);
}
collectMatch(match);
}