本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.CONSTRUCTOR_INVOCATION属性的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.CONSTRUCTOR_INVOCATION属性的具体用法?Java CompletionProposal.CONSTRUCTOR_INVOCATION怎么用?Java CompletionProposal.CONSTRUCTOR_INVOCATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.CompletionProposal
的用法示例。
在下文中一共展示了CompletionProposal.CONSTRUCTOR_INVOCATION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParameterList
/**
* Creates and returns a parameter list of the given method or type proposal suitable for
* display. The list does not include parentheses. The lower bound of parameter types is
* returned.
* <p>
* Examples:
*
* <pre>
* "void method(int i, String s)" -> "int i, String s"
* "? extends Number method(java.lang.String s, ? super Number n)" -> "String s, Number n"
* </pre>
*
* </p>
*
* @param proposal the proposal to create the parameter list for
* @return the list of comma-separated parameters suitable for display
*/
public StringBuilder createParameterList(CompletionProposal proposal) {
int kind= proposal.getKind();
switch (kind) {
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
return appendUnboundedParameterList(new StringBuilder(), proposal);
case CompletionProposal.TYPE_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
return appendTypeParameterList(new StringBuilder(), proposal);
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
return appendUnboundedParameterList(new StringBuilder(), proposal);
default:
Assert.isLegal(false);
return null; // dummy
}
}
示例2: appendMethodNameReplacement
private void appendMethodNameReplacement(StringBuilder buffer, CompletionProposal proposal) {
if (proposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
String coreCompletion = String.valueOf(proposal.getCompletion());
if (client.isCompletionSnippetsSupported()) {
coreCompletion = CompletionUtils.sanitizeCompletion(coreCompletion);
}
// String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getTextViewer().getDocument());
// String replacement= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, coreCompletion, 0, lineDelimiter, fInvocationContext.getProject());
// buffer.append(replacement.substring(0, replacement.lastIndexOf('.') + 1));
buffer.append(coreCompletion);
}
if (proposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) {
String str = new String(proposal.getName());
if (client.isCompletionSnippetsSupported()) {
str = CompletionUtils.sanitizeCompletion(str);
}
buffer.append(str);
}
}
示例3: createParameterList
/**
* Creates and returns a parameter list of the given method or type proposal suitable for display.
* The list does not include parentheses. The lower bound of parameter types is returned.
*
* <p>Examples:
*
* <pre>
* "void method(int i, String s)" -> "int i, String s"
* "? extends Number method(java.lang.String s, ? super Number n)" -> "String s, Number n"
* </pre>
*
* @param proposal the proposal to create the parameter list for
* @return the list of comma-separated parameters suitable for display
*/
public String createParameterList(CompletionProposal proposal) {
String paramList;
int kind = proposal.getKind();
switch (kind) {
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
case CompletionProposal.TYPE_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
paramList = appendTypeParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
paramList = appendUnboundedParameterList(new StyledString(), proposal).getString();
return Strings.markJavaElementLabelLTR(paramList);
default:
Assert.isLegal(false);
return null; // dummy
}
}
示例4: isSupportingRequiredProposals
/**
* Tells whether required proposals are supported by this proposal.
*
* @return <code>true</code> if required proposals are supported by this proposal
* @see org.eclipse.jdt.core.CompletionProposal#getRequiredProposals()
* @since 3.3
*/
protected boolean isSupportingRequiredProposals() {
if (fInvocationContext == null) return false;
ProposalInfo proposalInfo = getProposalInfo();
if (!(proposalInfo instanceof MemberProposalInfo
|| proposalInfo instanceof AnonymousTypeProposalInfo)) return false;
CompletionProposal proposal = ((MemberProposalInfo) proposalInfo).fProposal;
return proposal != null
&& (proposal.getKind() == CompletionProposal.METHOD_REF
|| proposal.getKind() == CompletionProposal.FIELD_REF
|| proposal.getKind() == CompletionProposal.TYPE_REF
|| proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION
|| proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION);
}
示例5: computeContextInformation
@Override
protected IContextInformation computeContextInformation() {
// no context information for METHOD_NAME_REF proposals (e.g. for static imports)
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654
if ((fProposal.getKind() == CompletionProposal.METHOD_REF
|| fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION)
&& hasParameters()
&& (getReplacementString().endsWith(RPAREN)
|| getReplacementString().endsWith(SEMICOLON)
|| getReplacementString().length() == 0)) {
ProposalContextInformation contextInformation = new ProposalContextInformation(fProposal);
if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0)
contextInformation.setContextInformationPosition(fContextInformationPosition);
return contextInformation;
}
return super.computeContextInformation();
}
示例6: appendMethodNameReplacement
/**
* Appends everything up to the method name including the opening parenthesis.
*
* <p>In case of {@link org.eclipse.jdt.core.CompletionProposal#METHOD_REF_WITH_CASTED_RECEIVER}
* it add cast.
*
* @param buffer the string buffer
* @since 3.4
*/
protected void appendMethodNameReplacement(StringBuffer buffer) {
if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
String coreCompletion = String.valueOf(fProposal.getCompletion());
String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getTextViewer().getDocument());
String replacement =
CodeFormatterUtil.format(
CodeFormatter.K_EXPRESSION,
coreCompletion,
0,
lineDelimiter,
fInvocationContext.getProject());
buffer.append(replacement.substring(0, replacement.lastIndexOf('.') + 1));
}
if (fProposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION)
buffer.append(fProposal.getName());
FormatterPrefs prefs = getFormatterPrefs();
if (prefs.beforeOpeningParen) buffer.append(SPACE);
buffer.append(LPAREN);
}
示例7: isValidPrefix
@Override
protected boolean isValidPrefix(String prefix) {
if (super.isValidPrefix(prefix)) return true;
String word = TextProcessor.deprocess(getDisplayString());
if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) {
int start =
word.indexOf(JavaElementLabels.CONCAT_STRING) + JavaElementLabels.CONCAT_STRING.length();
word = word.substring(start);
return isPrefix(prefix, word) || isPrefix(prefix, new String(fProposal.getName()));
}
if (isInJavadoc()) {
int idx = word.indexOf("{@link "); // $NON-NLS-1$
if (idx == 0) {
word = word.substring(7);
} else {
idx = word.indexOf("{@value "); // $NON-NLS-1$
if (idx == 0) {
word = word.substring(8);
}
}
}
return isPrefix(prefix, word);
}
示例8: createMethodProposalDescription
/**
* Creates and returns the method signature suitable for display.
*
* @param proposal
* the proposal to create the description for
* @return the string of method signature suitable for display
*/
public StringBuilder createMethodProposalDescription(CompletionProposal proposal) {
int kind = proposal.getKind();
StringBuilder description = new StringBuilder();
switch (kind) {
case CompletionProposal.METHOD_REF:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
// method name
description.append(proposal.getName());
// parameters
description.append('(');
appendUnboundedParameterList(description, proposal);
description.append(')');
// return type
if (!proposal.isConstructor()) {
// TODO remove SignatureUtil.fix83600 call when bugs are fixed
char[] returnType = createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(proposal.getSignature()))));
description.append(RETURN_TYPE_SEPARATOR);
description.append(returnType);
}
}
return description; // dummy
}
示例9: computeSortText
/**
* Computes the relevance for a given <code>CompletionProposal</code>.
*
* @param proposal the proposal to compute the relevance for
* @return the relevance for <code>proposal</code>
*/
public static String computeSortText(CompletionProposal proposal) {
final int baseRelevance= proposal.getRelevance() * 16;
switch (proposal.getKind()) {
case CompletionProposal.LABEL_REF:
return convertRelevance( baseRelevance + 1);
case CompletionProposal.KEYWORD:
return convertRelevance(baseRelevance + 2);
case CompletionProposal.TYPE_REF:
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
return convertRelevance(baseRelevance + 3);
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
return convertRelevance(baseRelevance + 4);
case CompletionProposal.FIELD_REF:
return convertRelevance(baseRelevance + 5);
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
return convertRelevance(baseRelevance + 6);
case CompletionProposal.PACKAGE_REF://intentional fall-through
default:
return convertRelevance(baseRelevance);
}
}
示例10: isSupportingRequiredProposals
private boolean isSupportingRequiredProposals(CompletionProposal proposal) {
return proposal != null
&& (proposal.getKind() == CompletionProposal.METHOD_REF
|| proposal.getKind() == CompletionProposal.FIELD_REF
|| proposal.getKind() == CompletionProposal.TYPE_REF
|| proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION
|| proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION);
}
示例11: computeRelevance
/**
* Computes the relevance for a given <code>CompletionProposal</code>.
*
* <p>Subclasses may replace, but usually should not need to.
*
* @param proposal the proposal to compute the relevance for
* @return the relevance for <code>proposal</code>
*/
protected int computeRelevance(CompletionProposal proposal) {
final int baseRelevance = proposal.getRelevance() * 16;
switch (proposal.getKind()) {
case CompletionProposal.PACKAGE_REF:
return baseRelevance + 0;
case CompletionProposal.LABEL_REF:
return baseRelevance + 1;
case CompletionProposal.KEYWORD:
return baseRelevance + 2;
case CompletionProposal.TYPE_REF:
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
return baseRelevance + 3;
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
return baseRelevance + 4;
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
return baseRelevance + 4 /* + 99 */;
case CompletionProposal.FIELD_REF:
return baseRelevance + 5;
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
return baseRelevance + 6;
default:
return baseRelevance;
}
}
示例12: getDeclaringType
/**
* Returns the type signature of the declaring type of a <code>CompletionProposal</code>, or
* <code>null</code> for proposals that do not have a declaring type. The return value is
* <em>not</em> <code>null</code> for proposals of the following kinds:
*
* <ul>
* <li>METHOD_DECLARATION
* <li>METHOD_NAME_REFERENCE
* <li>METHOD_REF
* <li>ANNOTATION_ATTRIBUTE_REF
* <li>POTENTIAL_METHOD_DECLARATION
* <li>ANONYMOUS_CLASS_DECLARATION
* <li>FIELD_REF
* <li>PACKAGE_REF (returns the package, but no type)
* <li>TYPE_REF
* </ul>
*
* @param proposal the completion proposal to get the declaring type for
* @return the type signature of the declaring type, or <code>null</code> if there is none
* @see org.eclipse.jdt.core.Signature#toCharArray(char[])
*/
protected final char[] getDeclaringType(CompletionProposal proposal) {
switch (proposal.getKind()) {
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.JAVADOC_METHOD_REF:
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
case CompletionProposal.JAVADOC_FIELD_REF:
case CompletionProposal.JAVADOC_VALUE_REF:
char[] declaration = proposal.getDeclarationSignature();
// special methods may not have a declaring type: methods defined on arrays etc.
// Currently known: class literals don't have a declaring type - use Object
if (declaration == null) return "java.lang.Object".toCharArray(); // $NON-NLS-1$
return Signature.toCharArray(declaration);
case CompletionProposal.PACKAGE_REF:
return proposal.getDeclarationSignature();
case CompletionProposal.JAVADOC_TYPE_REF:
case CompletionProposal.TYPE_REF:
return Signature.toCharArray(proposal.getSignature());
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
case CompletionProposal.KEYWORD:
case CompletionProposal.LABEL_REF:
case CompletionProposal.JAVADOC_BLOCK_TAG:
case CompletionProposal.JAVADOC_INLINE_TAG:
case CompletionProposal.JAVADOC_PARAM_REF:
return null;
default:
Assert.isTrue(false);
return null;
}
}
示例13: computeRelevance
protected int computeRelevance() {
final int baseRelevance = fProposal.getRelevance() * 16;
switch (fProposal.getKind()) {
case CompletionProposal.PACKAGE_REF:
return baseRelevance + 0;
case CompletionProposal.LABEL_REF:
return baseRelevance + 1;
case CompletionProposal.KEYWORD:
return baseRelevance + 2;
case CompletionProposal.TYPE_REF:
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
return baseRelevance + 3;
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
return baseRelevance + 4;
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
return baseRelevance + 4 /* + 99 */;
case CompletionProposal.FIELD_REF:
return baseRelevance + 5;
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
return baseRelevance + 6;
default:
return baseRelevance;
}
}
示例14: getPrefixCompletionStart
@Override
public int getPrefixCompletionStart(IDocument document, int completionOffset) {
if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
return fProposal.getTokenStart();
} else if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION)
return fProposal.getRequiredProposals()[0].getReplaceStart();
return super.getPrefixCompletionStart(document, completionOffset);
}
示例15: getPrefixCompletionText
@Override
public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
if (hasArgumentList() || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) {
String completion = String.valueOf(fProposal.getName());
if (isCamelCaseMatching()) {
String prefix = getPrefix(document, completionOffset);
return getCamelCaseCompound(prefix, completion);
}
return completion;
}
return super.getPrefixCompletionText(document, completionOffset);
}