当前位置: 首页>>代码示例>>Java>>正文


Java CompletionProposal.getCompletion方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.getCompletion方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.getCompletion方法的具体用法?Java CompletionProposal.getCompletion怎么用?Java CompletionProposal.getCompletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.CompletionProposal的用法示例。


在下文中一共展示了CompletionProposal.getCompletion方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendMethodOverrideReplacement

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * @param completionBuffer
 * @param proposal
 */
private void appendMethodOverrideReplacement(StringBuilder completionBuffer, CompletionProposal proposal) {
	IDocument document;
	try {
		document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer());
		String signature = String.valueOf(proposal.getSignature());
		String[] types = Stream.of(Signature.getParameterTypes(signature)).map(t -> Signature.toString(t))
				.toArray(String[]::new);
		String methodName = String.valueOf(proposal.getName());
		int offset = proposal.getReplaceStart();
		String completion = new String(proposal.getCompletion());
		OverrideCompletionProposal overrider = new OverrideCompletionProposal(compilationUnit, methodName, types,
				completion);
		String replacement = overrider.updateReplacementString(document, offset, importRewrite,
				client.isCompletionSnippetsSupported());
		completionBuffer.append(replacement);
	} catch (BadLocationException | CoreException e) {
		JavaLanguageServerPlugin.logException("Failed to compute override replacement", e);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:CompletionProposalReplacementProvider.java

示例2: createTypeProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
IJavaCompletionProposal createTypeProposal(CompletionProposal typeProposal) {
  final ICompilationUnit cu = getCompilationUnit();
  if (cu == null || getContext() != null && getContext().isInJavadoc())
    return super.createJavaCompletionProposal(typeProposal);

  IJavaProject project = cu.getJavaProject();
  if (!shouldProposeGenerics(project)) return super.createJavaCompletionProposal(typeProposal);

  char[] completion = typeProposal.getCompletion();
  // don't add parameters for import-completions nor for proposals with an empty completion (e.g.
  // inside the type argument list)
  if (completion.length > 0
      && (completion[completion.length - 1] == ';' || completion[completion.length - 1] == '.'))
    return super.createJavaCompletionProposal(typeProposal);

  LazyJavaCompletionProposal newProposal =
      new LazyGenericTypeProposal(typeProposal, getInvocationContext());
  return newProposal;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:FillArgumentNamesCompletionProposalCollector.java

示例3: computeContextInformation

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
protected IContextInformation computeContextInformation() {
  try {
    fContextInformationPosition = getReplacementOffset() - 1;

    CompletionProposal proposal = ((MemberProposalInfo) getProposalInfo()).fProposal;
    // no context information for METHOD_NAME_REF proposals (e.g. for static imports)
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654
    if (hasParameters()
        && (getReplacementString().endsWith(")")
            || getReplacementString().length() == 0)) { // $NON-NLS-1$
      ProposalContextInformation contextInformation = new ProposalContextInformation(proposal);
      fContextInformationPosition = getReplacementOffset() + getCursorPosition();
      if (fContextInformationPosition != 0 && proposal.getCompletion().length == 0)
        contextInformation.setContextInformationPosition(fContextInformationPosition);
      return contextInformation;
    }
    return null;
  } finally {
    fIsContextInformationComputed = true;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:AnonymousTypeCompletionProposal.java

示例4: createProposal

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
protected ICompletionProposal createProposal(CompletionProposal javaProposal) {
  String completion = String.valueOf(javaProposal.getCompletion());
  int kind = javaProposal.getKind();
  if (kind == CompletionProposal.TYPE_REF) {
    // Make sure it is fully qualified
    completion = JavaContentAssistUtilities.getFullyQualifiedTypeName(javaProposal);
  }

  if (forceFullyQualifiedFieldNames
      && (kind == CompletionProposal.FIELD_IMPORT || kind == CompletionProposal.FIELD_REF)) {
    char[] decSig = javaProposal.getDeclarationSignature();
    if (decSig != null && decSig.length > 2) {
      // declaration signatures for objects are like Ljava.lang.String;, so lop off first
      // and last chars
      completion = new String(decSig, 1, decSig.length - 2) + "."
          + new String(javaProposal.getCompletion());
      completion = completion.replace('$', '.');
    }
  }

  ICompletionProposal jdtCompletionProposal = JavaContentAssistUtilities.getJavaCompletionProposal(
      javaProposal, context, javaProject);
  return ReplacementCompletionProposal.fromExistingCompletionProposal(completion,
      replaceOffset, replaceLength, jdtCompletionProposal);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:26,代码来源:ProposalGeneratingCompletionRequestor.java

示例5: createLabelWithTypeAndDeclaration

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private void createLabelWithTypeAndDeclaration(CompletionProposal proposal, CompletionItem item) {
	char[] name= proposal.getCompletion();
	if (!isThisPrefix(name)) {
		name= proposal.getName();
	}
	StringBuilder buf= new StringBuilder();

	buf.append(name);
	item.setInsertText(buf.toString());
	char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature());
	if (typeName.length > 0) {
		buf.append(VAR_TYPE_SEPARATOR);
		buf.append(typeName);
	}
	item.setLabel(buf.toString());

	char[] declaration= proposal.getDeclarationSignature();
	if (declaration != null) {
		setDeclarationSignature(item, String.valueOf(declaration));
		StringBuilder declBuf = new StringBuilder();
		declaration= Signature.getSignatureSimpleName(declaration);
		if (declaration.length > 0) {
			if (proposal.getRequiredProposals() != null) {
				String declaringType= extractDeclaringTypeFQN(proposal);
				String qualifier= Signature.getQualifier(declaringType);
				if (qualifier.length() > 0) {
					declBuf.append(qualifier);
					declBuf.append('.');
				}
			}
			declBuf.append(declaration);
			item.setDetail(declBuf.toString());
		}
	}
	setName(item,String.valueOf(name));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:CompletionProposalDescriptionProvider.java

示例6: hasArgumentList

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
protected boolean hasArgumentList(CompletionProposal proposal) {
	if (CompletionProposal.METHOD_NAME_REFERENCE == proposal.getKind()) {
		return false;
	}
	char[] completion= proposal.getCompletion();
	return !isInJavadoc() && completion.length > 0 && completion[completion.length - 1] == RPAREN;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:CompletionProposalReplacementProvider.java

示例7: isImportCompletion

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
private boolean isImportCompletion(CompletionProposal proposal) {
	char[] completion = proposal.getCompletion();
	if (completion.length == 0) {
		return false;
	}

	char last = completion[completion.length - 1];
	/*
	 * Proposals end in a semicolon when completing types in normal imports
	 * or when completing static members, in a period when completing types
	 * in static imports.
	 */
	return last == SEMICOLON || last == '.';
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:15,代码来源:CompletionProposalReplacementProvider.java

示例8: createLabelWithTypeAndDeclaration

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
StyledString createLabelWithTypeAndDeclaration(CompletionProposal proposal) {
  char[] name = proposal.getCompletion();
  if (!isThisPrefix(name)) name = proposal.getName();

  StyledString buf = new StyledString();
  buf.append(name);
  char[] typeName = Signature.getSignatureSimpleName(proposal.getSignature());
  if (typeName.length > 0) {
    buf.append(VAR_TYPE_SEPARATOR);
    buf.append(typeName);
  }
  char[] declaration = proposal.getDeclarationSignature();
  if (declaration != null) {
    declaration = Signature.getSignatureSimpleName(declaration);
    if (declaration.length > 0) {
      buf.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER);
      if (proposal.getRequiredProposals() != null) {
        String declaringType = extractDeclaringTypeFQN(proposal);
        String qualifier = Signature.getQualifier(declaringType);
        if (qualifier.length() > 0) {
          buf.append(qualifier, StyledString.QUALIFIER_STYLER);
          buf.append('.', StyledString.QUALIFIER_STYLER);
        }
      }
      buf.append(declaration, StyledString.QUALIFIER_STYLER);
    }
  }

  return Strings.markJavaElementLabelLTR(buf);
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:CompletionProposalLabelProvider.java

示例9: ProposalContextInformation

import org.eclipse.jdt.core.CompletionProposal; //导入方法依赖的package包/类
/**
 * Creates a new context information.
 *
 * @param proposal the JDT Core completion proposal
 */
public ProposalContextInformation(CompletionProposal proposal) {
  // don't cache the core proposal because the ContentAssistant might
  // hang on to the context info.
  CompletionProposalLabelProvider labelProvider = new CompletionProposalLabelProvider();
  fInformationDisplayString = labelProvider.createParameterList(proposal);
  ImageDescriptor descriptor = labelProvider.createImageDescriptor(proposal);
  if (descriptor != null) fImage = JavaPlugin.getImageDescriptorRegistry().get(descriptor);
  else fImage = null;
  if (proposal.getCompletion().length == 0) fPosition = proposal.getCompletionLocation() + 1;
  else fPosition = -1;
  fContextDisplayString = labelProvider.createLabel(proposal);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ProposalContextInformation.java

示例10: 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;
	}

}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:46,代码来源:CompletionProposalReplacementProvider.java


注:本文中的org.eclipse.jdt.core.CompletionProposal.getCompletion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。