Tabnine Logo
CompletionProposal.getReplaceEnd
Code IndexAdd Tabnine to your IDE (free)

How to use
getReplaceEnd
method
in
org.eclipse.jdt.core.CompletionProposal

Best Java code snippets using org.eclipse.jdt.core.CompletionProposal.getReplaceEnd (Showing top 20 results out of 315)

origin: org.eclipse.recommenders.completion/rcp

public ProcessableGetterSetterCompletionProposal(CompletionProposal coreProposal, IField field, boolean isGetter,
    int relevance) throws JavaModelException {
  super(field, coreProposal.getReplaceStart(), coreProposal.getReplaceEnd() - coreProposal.getReplaceStart(),
      isGetter, relevance);
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * Gets the replacement length.
 * @return Returns a int
 */
@Override
public final int getReplacementLength() {
  if (!fReplacementLengthComputed)
    setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart());
  return super.getReplacementLength();
}
origin: org.eclipse/org.eclipse.jdt.ui

/**
 * Gets the replacement length.
 * @return Returns a int
 */
public final int getReplacementLength() {
  if (!fReplacementLengthComputed)
    setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart());
  return super.getReplacementLength();
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * Gets the replacement length.
 * @return Returns a int
 */
@Override
public final int getReplacementLength() {
  if (!fReplacementLengthComputed)
    setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart());
  return super.getReplacementLength();
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
 * 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;
}
origin: org.eclipse/org.eclipse.jdt.ui

/**
 * 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;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
 * 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;
}
origin: eclipse/eclipse.jdt.ls

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;
origin: eclipse/eclipse.jdt.ls

private Range toReplacementRange(CompletionProposal proposal){
  try {
    return JDTUtils.toRange(compilationUnit, proposal.getReplaceStart(), proposal.getReplaceEnd()-proposal.getReplaceStart());
  } catch (JavaModelException e) {
    JavaLanguageServerPlugin.logException(e.getMessage(), e);
  }
  return null;
}
origin: org.eclipse.jdt/org.eclipse.jdt.core

buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$
int start = proposal.getReplaceStart();
int end = proposal.getReplaceEnd();
printDebugTab(tab, buffer);
buffer.append("\tReplaceStart[").append(start).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
origin: org.eclipse.recommenders.completion/rcp

public static ProcessableMethodDeclarationCompletionProposal newProposal(CompletionProposal proposal, IType type,
    int relevance) throws CoreException {
  String prefix = String.valueOf(proposal.getName());
  int offset = proposal.getReplaceStart();
  int length = proposal.getReplaceEnd() - offset;
  IMethod[] methods = type.getMethods();
  if (!type.isInterface()) {
    String constructorName = type.getElementName();
    if (constructorName.length() > 0 && constructorName.startsWith(prefix)
        && !hasMethod(methods, constructorName)) {
      return new ProcessableMethodDeclarationCompletionProposal(type, constructorName, null, offset, length,
          relevance + 500);
    }
  }
  if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix)) {
    if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR))
      return new ProcessableMethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset,
          length, relevance);
  }
  return null;
}
origin: org.eclipse/org.eclipse.jdt.ui

new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
JavaPluginImages.DESC_OBJS_PACKAGE);
new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
JavaElementImageProvider.getTypeImageDescriptor(false, false, proposal.getFlags(), false),
  new String(proposal.getCompletion()),
  proposal.getReplaceStart(),
  proposal.getReplaceEnd(),
  proposal.getRelevance(),
  null);
origin: eclipse/eclipse.jdt.ls

try{
  IDocument document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer());
  IRegion region= document.getLineInformationOfOffset(proposal.getReplaceEnd());
  prefix =  document.get(region.getOffset(), proposal.getReplaceEnd() -region.getOffset()).trim();
}catch(BadLocationException | JavaModelException e){
origin: org.eclipse.jdt/org.eclipse.jdt.ui

new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
JavaPluginImages.DESC_OBJS_PACKAGE);
new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
typeImageDescriptor,
  new String(proposal.getCompletion()),
  proposal.getReplaceStart(),
  proposal.getReplaceEnd(),
  proposal.getRelevance(),
  null);
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
JavaPluginImages.DESC_OBJS_PACKAGE);
new String(proposal.getCompletion()),
proposal.getReplaceStart(),
proposal.getReplaceEnd(),
proposal.getRelevance(),
typeImageDescriptor,
  new String(proposal.getCompletion()),
  proposal.getReplaceStart(),
  proposal.getReplaceEnd(),
  proposal.getRelevance(),
  null);
origin: org.eclipse/org.eclipse.jdt.ui

private void acceptPotentialMethodDeclaration(CompletionProposal proposal) {
  if (fCompilationUnit == null)
    return;
  String prefix= String.valueOf(proposal.getName());
  int completionStart= proposal.getReplaceStart();
  int completionEnd= proposal.getReplaceEnd();
  int relevance= computeRelevance(proposal);
  try {
    IJavaElement element= fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1);
    if (element != null) {
      IType type= (IType) element.getAncestor(IJavaElement.TYPE);
      if (type != null) {
        GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 1, fSuggestedMethodNames, fJavaProposals);
        MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals);
      }
    }
  } catch (CoreException e) {
    JavaPlugin.log(e);
  }
}
origin: eclipse/eclipse.jdt.ls

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);
  }
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

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);
  }
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

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);
  }
}
origin: eclipse/eclipse.jdt.ls

if (!completionOverwrite && (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.LOCAL_VARIABLE_REF || proposal.getKind() == CompletionProposal.FIELD_REF)) {
  int end = proposal.getReplaceEnd();
  if (end > offset) {
    proposal.setReplaceRange(proposal.getReplaceStart(), offset);
org.eclipse.jdt.coreCompletionProposalgetReplaceEnd

Javadoc

Returns the character index of the end of the subrange in the source file buffer to be replaced by the completion string. If the subrange is empty (getReplaceEnd() == getReplaceStart()), the completion string is to be inserted at this index.

Popular methods of CompletionProposal

  • getKind
    Returns the kind of completion being proposed. The set of different kinds of completion proposals is
  • getName
    Returns the simple name of the method, field, member, or variable relevant in the context, ornull if
  • getSignature
    Returns the signature of the method or type relevant in the context, or null if none. This field is
  • findParameterNames
    Finds the method parameter names. This information is relevant to method reference (and method decla
  • getCompletion
    Returns the proposed sequence of characters to insert into the source file buffer, replacing the cha
  • getDeclarationSignature
    Returns the type signature or package name of the relevant declaration in the context, or null if no
  • getReplaceStart
    Returns the character index of the start of the subrange in the source file buffer to be replaced by
  • create
    Creates a basic completion proposal. All instance field have plausible default values unless otherwi
  • getDeclarationKey
    Returns the key of the relevant declaration in the context, or null if none. This field is availabl
  • getRelevance
    Returns the relative relevance rating of this proposal.
  • getCompletionLocation
    Returns the character index in the source file buffer where source completion was requested (theoffs
  • getFlags
    Returns the modifier flags relevant in the context, orFlags.AccDefault if none. This field is avail
  • getCompletionLocation,
  • getFlags,
  • getRequiredProposals,
  • setCompletion,
  • setDeclarationSignature,
  • setRelevance,
  • setReplaceRange,
  • setSignature,
  • setFlags

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now