本文整理汇总了Java中org.eclipse.jdt.core.CompletionProposal.PACKAGE_REF属性的典型用法代码示例。如果您正苦于以下问题:Java CompletionProposal.PACKAGE_REF属性的具体用法?Java CompletionProposal.PACKAGE_REF怎么用?Java CompletionProposal.PACKAGE_REF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.CompletionProposal
的用法示例。
在下文中一共展示了CompletionProposal.PACKAGE_REF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newUrnImportProposalComputer
/**
* Creates a proposal computer for autocompleting the UiBinder root element
* URN import scheme. For example, <ui:UiBinder
* xmlns:g="urn:import:com.google.gwt._" />
*/
public static IProposalComputer newUrnImportProposalComputer(
ContentAssistRequest contentAssistRequest, IJavaProject javaProject) {
IDOMAttr attribute = XmlContentAssistUtilities.getAttribute(contentAssistRequest);
if (attribute == null) {
return null;
}
String attrValue = XmlContentAssistUtilities.getAttributeValueUsingMatchString(contentAssistRequest);
if (!UiBinderXmlModelUtilities.isUrnImportAttribute(attribute)) {
return null;
}
int urnImportLength = UiBinderConstants.URN_IMPORT_NAMESPACE_BEGINNING.length();
if (attrValue.length() < urnImportLength) {
return null;
}
String replaceText = attrValue.substring(urnImportLength);
int replaceOffset = XmlContentAssistUtilities.getAttributeValueOffset(contentAssistRequest)
+ urnImportLength;
return new CodeCompleteProposalComputer(
new int[]{CompletionProposal.PACKAGE_REF}, javaProject, replaceText,
replaceOffset, replaceText.length(), null, false);
}
示例2: ignoreAll
private void ignoreAll() {
int[] ignoredKinds = new int[] {
CompletionProposal.ANONYMOUS_CLASS_DECLARATION,
CompletionProposal.FIELD_REF, CompletionProposal.KEYWORD,
CompletionProposal.LABEL_REF, CompletionProposal.LOCAL_VARIABLE_REF,
CompletionProposal.METHOD_REF, CompletionProposal.METHOD_DECLARATION,
CompletionProposal.PACKAGE_REF, CompletionProposal.TYPE_REF,
CompletionProposal.VARIABLE_DECLARATION,
CompletionProposal.POTENTIAL_METHOD_DECLARATION,
CompletionProposal.METHOD_NAME_REFERENCE,
CompletionProposal.ANNOTATION_ATTRIBUTE_REF,
CompletionProposal.JAVADOC_FIELD_REF,
CompletionProposal.JAVADOC_METHOD_REF,
CompletionProposal.JAVADOC_TYPE_REF,
CompletionProposal.JAVADOC_VALUE_REF,
CompletionProposal.JAVADOC_PARAM_REF,
CompletionProposal.JAVADOC_BLOCK_TAG,
CompletionProposal.JAVADOC_INLINE_TAG, CompletionProposal.FIELD_IMPORT,
CompletionProposal.METHOD_IMPORT, CompletionProposal.TYPE_IMPORT};
for (int kind : ignoredKinds) {
setIgnored(kind, true);
}
}
示例3: createReplaceString
private String createReplaceString() {
switch (wrappedProposal.getKind()) {
case CompletionProposal.PACKAGE_REF:
return computePackageCompletion();
case CompletionProposal.TYPE_REF:
return computeTypeCompletion();
case CompletionProposal.FIELD_REF:
return computeFieldCompletion();
case CompletionProposal.METHOD_REF:
if (wrappedProposal.isConstructor()) {
return computeCtorCompletion();
} else {
return computeMethodCompletion();
}
default:
return "";
}
}
示例4: accept
@Override
public void accept(CompletionProposal proposal) {
if (!isIgnored(proposal.getKind())) {
if (proposal.getKind() == CompletionProposal.POTENTIAL_METHOD_DECLARATION) {
acceptPotentialMethodDeclaration(proposal);
} else {
if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) {
// Hacky way to boost relevance of current package, for package completions, until
// https://bugs.eclipse.org/518140 is fixed
proposal.setRelevance(proposal.getRelevance() + 1);
}
proposals.add(proposal);
}
}
}
示例5: 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);
}
}
示例6: accept
@Override
public void accept(CompletionProposal proposal) {
if (!isIgnored(proposal.getKind())) {
if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) {
// Hacky way to boost relevance of current package, for package completions, until
// https://bugs.eclipse.org/518140 is fixed
proposal.setRelevance(proposal.getRelevance() + 1);
}
proposals.add(proposal);
}
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: 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;
}
}
示例10: newUiImportFieldProposalComputer
/**
* Creates a proposal computer for autocompleting the java classes for the
* <ui:import field="___" />
*/
public static IProposalComputer newUiImportFieldProposalComputer(
ContentAssistRequest contentAssistRequest, IJavaProject javaProject,
String packageName) {
IDOMAttr attribute = XmlContentAssistUtilities.getAttribute(contentAssistRequest);
if (attribute == null || attribute.getOwnerElement() == null) {
return null;
}
// Ensure we are autocompleting an 'ui:import' element attribute
if (!UiBinderConstants.UI_BINDER_IMPORT_ELEMENT_NAME.equals(attribute.getOwnerElement().getLocalName())) {
return null;
}
// Ensure we are autocompleting the 'field' attribute
if (!attribute.equals(UiBinderXmlModelUtilities.getFieldAttribute(attribute.getOwnerElement()))) {
return null;
}
String attrValue = XmlContentAssistUtilities.getAttributeValueUsingMatchString(contentAssistRequest);
CodeCompleteProposalComputer ccpc = new CodeCompleteProposalComputer(
new int[] {
CompletionProposal.TYPE_REF, CompletionProposal.PACKAGE_REF,
CompletionProposal.FIELD_IMPORT, CompletionProposal.FIELD_REF},
javaProject,
attrValue,
XmlContentAssistUtilities.getAttributeValueOffset(contentAssistRequest),
attrValue.length(), packageName, true);
return ccpc;
}
示例11: newWithTypeProposalComputer
/**
* Creates a proposal computer for autocompleting the java classes for the
* <ui:with ui:type="___" />
*/
public static IProposalComputer newWithTypeProposalComputer(
ContentAssistRequest contentAssistRequest, IJavaProject javaProject) {
IDOMAttr attribute = XmlContentAssistUtilities.getAttribute(contentAssistRequest);
if (attribute == null || attribute.getOwnerElement() == null) {
return null;
}
// Ensure we are autocompleting the 'type' attribute
if (!attribute.equals(UiBinderXmlModelUtilities.getTypeAttribute(attribute.getOwnerElement()))) {
return null;
}
String attrValue = XmlContentAssistUtilities.getAttributeValueUsingMatchString(contentAssistRequest);
/*
* Even though only types are valid, we must also propose packages to get to
* fully qualified types if the user has typed e.g. "com.".
*/
return new CodeCompleteProposalComputer(
new int[]{CompletionProposal.TYPE_REF, CompletionProposal.PACKAGE_REF},
javaProject,
attrValue,
XmlContentAssistUtilities.getAttributeValueOffset(contentAssistRequest),
attrValue.length(), null, false);
}
示例12: create
/**
* Return proposals only for references to a package, type, field, method or
* constructor (and nothing else).
*/
public static IJavaCompletionProposal create(
IJavaCompletionProposal jdtProposal, CompletionProposal wrappedProposal,
IJavaProject javaProject, int replaceOffset, int replaceLength) {
switch (wrappedProposal.getKind()) {
case CompletionProposal.PACKAGE_REF:
case CompletionProposal.TYPE_REF:
case CompletionProposal.FIELD_REF:
case CompletionProposal.METHOD_REF:
return new JsniCompletionProposal(jdtProposal, wrappedProposal,
javaProject, replaceOffset, replaceLength);
default:
return null;
}
}
示例13: createJavaCompletionProposal
@Override
protected IJavaCompletionProposal createJavaCompletionProposal(
CompletionProposal proposal) {
if (collectMethods) {
if (CompletionProposal.METHOD_REF == proposal.getKind()
&& Flags.isPublic(proposal.getFlags())) {
char[] sig = proposal.getSignature();
char[] declSig = proposal.getDeclarationSignature();
// collect methods suitable for action methods ignoring Object
// methods
if (sig != null && declSig != null
&& ACTION_METHOD_SIGNATURE.equals(String.valueOf(sig))
&& !OBJECT_SIGNATURE.equals(String.valueOf(declSig))) {
return new SimpleJavaCompletionProposal(proposal,
getInvocationContext(), getImage(getLabelProvider()
.createImageDescriptor(proposal)));
}
}
} else {
// collect packages and classes suitable for actions
if ((CompletionProposal.PACKAGE_REF == proposal.getKind() || CompletionProposal.TYPE_REF == proposal
.getKind())
&& !Flags.isAbstract(proposal.getFlags())
&& !Flags.isInterface(proposal.getFlags())
&& !Flags.isEnum(proposal.getFlags())) {
return new SimpleJavaCompletionProposal(proposal,
getInvocationContext(), getImage(getLabelProvider()
.createImageDescriptor(proposal)));
}
}
return null;
}
示例14: updateDescription
/**
* Updates the description fields of the item.
*
* @param proposal
* @param item
*/
public void updateDescription(CompletionProposal proposal, CompletionItem item) {
switch (proposal.getKind()) {
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
if (fContext != null && fContext.isInJavadoc()) {
createJavadocMethodProposalLabel(proposal, item);
break;
}
createMethodProposalLabel(proposal, item);
break;
case CompletionProposal.METHOD_DECLARATION:
createOverrideMethodProposalLabel(proposal, item);
break;
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
createAnonymousTypeLabel(proposal, item);
break;
case CompletionProposal.TYPE_REF:
createTypeProposalLabel(proposal, item);
break;
case CompletionProposal.JAVADOC_TYPE_REF:
createJavadocTypeProposalLabel(proposal, item);
break;
case CompletionProposal.JAVADOC_FIELD_REF:
case CompletionProposal.JAVADOC_VALUE_REF:
case CompletionProposal.JAVADOC_BLOCK_TAG:
case CompletionProposal.JAVADOC_INLINE_TAG:
case CompletionProposal.JAVADOC_PARAM_REF:
createJavadocSimpleProposalLabel(proposal, item);
break;
case CompletionProposal.JAVADOC_METHOD_REF:
createJavadocMethodProposalLabel(proposal, item);
break;
case CompletionProposal.PACKAGE_REF:
case CompletionProposal.MODULE_DECLARATION:
case CompletionProposal.MODULE_REF:
createPackageProposalLabel(proposal, item);
break;
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
createLabelWithTypeAndDeclaration(proposal, item);
break;
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
createSimpleLabelWithType(proposal, item);
break;
case CompletionProposal.KEYWORD:
case CompletionProposal.LABEL_REF:
item.setLabel(createSimpleLabel(proposal).toString());
break;
default:
JavaLanguageServerPlugin.logInfo(new String(proposal.getName()) + " is of type " + getProposal(proposal));
Assert.isTrue(false);
}
}
示例15: mapKind
private CompletionItemKind mapKind(final int kind) {
switch (kind) {
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
return CompletionItemKind.Constructor;
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.TYPE_REF:
return CompletionItemKind.Class;
case CompletionProposal.FIELD_IMPORT:
case CompletionProposal.METHOD_IMPORT:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.PACKAGE_REF:
case CompletionProposal.TYPE_IMPORT:
return CompletionItemKind.Module;
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
return CompletionItemKind.Field;
case CompletionProposal.KEYWORD:
return CompletionItemKind.Keyword;
case CompletionProposal.LABEL_REF:
return CompletionItemKind.Reference;
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
return CompletionItemKind.Variable;
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.METHOD_REF:
case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
return CompletionItemKind.Function;
//text
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.JAVADOC_BLOCK_TAG:
case CompletionProposal.JAVADOC_FIELD_REF:
case CompletionProposal.JAVADOC_INLINE_TAG:
case CompletionProposal.JAVADOC_METHOD_REF:
case CompletionProposal.JAVADOC_PARAM_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
case CompletionProposal.JAVADOC_VALUE_REF:
default:
return CompletionItemKind.Text;
}
}