本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.getReplaceEnd方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.getReplaceEnd方法的具体用法?Java CompletionProposal.getReplaceEnd怎么用?Java CompletionProposal.getReplaceEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.CompletionProposal
的用法示例。
在下文中一共展示了CompletionProposal.getReplaceEnd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acceptPotentialMethodDeclaration
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) {
try {
IJavaElement enclosingElement = null;
if (response.getContext().isExtended()) {
enclosingElement = response.getContext().getEnclosingElement();
} else if (unit != null) {
// kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005)
enclosingElement = unit.getElementAt(proposal.getCompletionLocation() + 1);
}
if (enclosingElement == null) {
return;
}
IType type = (IType) enclosingElement.getAncestor(IJavaElement.TYPE);
if (type != null) {
String prefix = String.valueOf(proposal.getName());
int completionStart = proposal.getReplaceStart();
int completionEnd = proposal.getReplaceEnd();
int relevance = proposal.getRelevance() + 6;
GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, proposals);
}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Accept potential method declaration failed for completion ", e);
}
}
示例2: getLength
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
* Returns the replacement length of a given completion proposal. The replacement length is
* usually the difference between the return values of <code>proposal.getReplaceEnd</code> and
* <code>proposal.getReplaceStart</code>, but this behavior may be overridden by calling {@link
* #setReplacementLength(int)}.
*
* @param proposal the completion proposal to get the replacement length for
* @return the replacement length for <code>proposal</code>
*/
protected final int getLength(CompletionProposal proposal) {
int start = proposal.getReplaceStart();
int end = proposal.getReplaceEnd();
int length;
if (fUserReplacementLength == -1) {
length = end - start;
} else {
length = fUserReplacementLength;
// extend length to begin at start
int behindCompletion = proposal.getCompletionLocation() + 1;
if (start < behindCompletion) {
length += behindCompletion - start;
}
}
return length;
}
示例3: acceptPotentialMethodDeclaration
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) {
try {
IJavaElement enclosingElement = null;
// if (getContext().isExtended()) {
// enclosingElement= getContext().getEnclosingElement();
// } else if (fCompilationUnit != null) {
// kept for backward compatibility: CU is not reconciled at this moment, information is
// missing (bug 70005)
enclosingElement = fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1);
// }
if (enclosingElement == null) return;
IType type = (IType) enclosingElement.getAncestor(IJavaElement.TYPE);
if (type != null) {
String prefix = String.valueOf(proposal.getName());
int completionStart = proposal.getReplaceStart();
int completionEnd = proposal.getReplaceEnd();
int relevance = computeRelevance(proposal);
GetterSetterCompletionProposal.evaluateProposals(
type,
prefix,
completionStart,
completionEnd - completionStart,
relevance + 2,
fSuggestedMethodNames,
fJavaProposals);
MethodDeclarationCompletionProposal.evaluateProposals(
type,
prefix,
completionStart,
completionEnd - completionStart,
relevance,
fSuggestedMethodNames,
fJavaProposals);
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
示例4: shouldAppendArguments
import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private boolean shouldAppendArguments(CompletionProposal proposal,
char trigger) {
/*
* No argument list if there were any special triggers (for example a
* period to qualify an inner type).
*/
if (trigger != '\0' && trigger != '<' && trigger != LPAREN) {
return false;
}
/*
* No argument list if the completion is empty (already within the
* argument list).
*/
char[] completion = proposal.getCompletion();
if (completion.length == 0) {
return false;
}
/*
* No argument list if there already is a generic signature behind the
* name.
*/
try {
IDocument document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer());
IRegion region= document.getLineInformationOfOffset(proposal.getReplaceEnd());
String line= document.get(region.getOffset(),region.getLength());
int index= proposal.getReplaceEnd() - region.getOffset();
while (index != line.length() && Character.isUnicodeIdentifierPart(line.charAt(index))) {
++index;
}
if (index == line.length()) {
return true;
}
char ch= line.charAt(index);
return ch != '<';
} catch (BadLocationException | JavaModelException e) {
return true;
}
}