本文整理汇总了Java中com.intellij.codeInsight.completion.JavaClassNameCompletionContributor类的典型用法代码示例。如果您正苦于以下问题:Java JavaClassNameCompletionContributor类的具体用法?Java JavaClassNameCompletionContributor怎么用?Java JavaClassNameCompletionContributor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaClassNameCompletionContributor类属于com.intellij.codeInsight.completion包,在下文中一共展示了JavaClassNameCompletionContributor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processVariantsImpl
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
private void processVariantsImpl() {
processRefInAnnotationImpl();
getVariantsImpl();
final GroovyResolveResult[] candidates = myProcessor.getCandidates();
List<LookupElement> results =
GroovyCompletionUtil.getCompletionVariants(candidates,
JavaClassNameCompletionContributor.AFTER_NEW.accepts(myRefExpr), myMatcher, myRefExpr);
if (myProcessor.isEmpty() && results.isEmpty()) {
results = GroovyCompletionUtil.getCompletionVariants(myProcessor.getInapplicableResults(),
JavaClassNameCompletionContributor.AFTER_NEW.accepts(myRefExpr), myMatcher,
myRefExpr);
}
for (LookupElement o : results) {
myConsumer.consume(o);
}
}
示例2: processVariants
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
public static void processVariants(PrefixMatcher matcher,
final Consumer<LookupElement> consumer,
GrReferenceExpressionImpl refExpr,
CompletionParameters parameters) {
processRefInAnnotation(refExpr, matcher, consumer);
final int[] count = new int[]{0};
final CompleteReferenceProcessor processor = new CompleteReferenceProcessor(refExpr, new Consumer<LookupElement>() {
@Override
public void consume(LookupElement element) {
count[0]++;
consumer.consume(element);
}
}, matcher, parameters);
getVariantsImpl(refExpr, processor);
final GroovyResolveResult[] candidates = processor.getCandidates();
List<LookupElement> results =
GroovyCompletionUtil.getCompletionVariants(candidates,
JavaClassNameCompletionContributor.AFTER_NEW.accepts(refExpr), matcher, refExpr);
if (count[0] == 0 && results.size() == 0) {
results = GroovyCompletionUtil.getCompletionVariants(processor.getInapplicableResults(),
JavaClassNameCompletionContributor.AFTER_NEW.accepts(refExpr), matcher, refExpr);
}
for (LookupElement o : results) {
consumer.consume(o);
}
}
示例3: objectToLookupItem
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
/**
* @deprecated
* @see LookupElementBuilder
*/
@NotNull
public static LookupElement objectToLookupItem(Object object) {
if (object instanceof LookupElement) return (LookupElement)object;
if (object instanceof PsiClass) {
return JavaClassNameCompletionContributor.createClassLookupItem((PsiClass)object, true);
}
if (object instanceof PsiMethod) {
return new JavaMethodCallElement((PsiMethod)object);
}
if (object instanceof PsiVariable) {
return new VariableLookupItem((PsiVariable)object);
}
if (object instanceof PsiExpression) {
return new ExpressionLookupItem((PsiExpression) object);
}
if (object instanceof PsiType) {
return PsiTypeLookupItem.createLookupItem((PsiType)object, null);
}
if (object instanceof PsiPackage) {
return new PackageLookupItem((PsiPackage)object);
}
String s = null;
LookupItem item = new LookupItem(object, "");
if (object instanceof PsiElement){
s = PsiUtilCore.getName((PsiElement)object);
}
TailType tailType = TailType.NONE;
if (object instanceof PsiMetaData) {
s = ((PsiMetaData)object).getName();
}
else if (object instanceof String) {
s = (String)object;
}
else if (object instanceof Template) {
s = ((Template) object).getKey();
}
else if (object instanceof PresentableLookupValue) {
s = ((PresentableLookupValue)object).getPresentation();
}
if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
if (s == null) {
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
item.setLookupString(s);
item.setTailType(tailType);
return item;
}
示例4: objectToLookupItem
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
/**
* @deprecated
* @see LookupElementBuilder
*/
public static LookupElement objectToLookupItem(Object object) {
if (object instanceof LookupElement) return (LookupElement)object;
if (object instanceof PsiClass) {
return JavaClassNameCompletionContributor.createClassLookupItem((PsiClass)object, true);
}
if (object instanceof PsiMethod) {
return new JavaMethodCallElement((PsiMethod)object);
}
if (object instanceof PsiVariable) {
return new VariableLookupItem((PsiVariable)object);
}
if (object instanceof PsiKeyword) {
return new KeywordLookupItem((PsiKeyword)object, (PsiKeyword)object);
}
if (object instanceof PsiExpression) {
return new ExpressionLookupItem((PsiExpression) object);
}
if (object instanceof PsiType) {
return PsiTypeLookupItem.createLookupItem((PsiType)object, null);
}
if (object instanceof PsiPackage) {
return new PackageLookupItem((PsiPackage)object);
}
String s = null;
LookupItem item = new LookupItem(object, "");
if (object instanceof PsiElement){
s = PsiUtilCore.getName((PsiElement)object);
}
TailType tailType = TailType.NONE;
if (object instanceof PsiMetaData) {
s = ((PsiMetaData)object).getName();
}
else if (object instanceof String) {
s = (String)object;
}
else if (object instanceof Template) {
s = ((Template) object).getKey();
}
else if (object instanceof PresentableLookupValue) {
s = ((PresentableLookupValue)object).getPresentation();
}
if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
if (s == null) {
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
if (object instanceof LookupValueWithTail) {
item.setAttribute(LookupItem.TAIL_TEXT_ATTR, " " + ((LookupValueWithTail)object).getTailText());
}
item.setLookupString(s);
item.setTailType(tailType);
return item;
}
示例5: createLookupElements
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
public static List<? extends LookupElement> createLookupElements(GroovyResolveResult candidate,
boolean afterNew,
PrefixMatcher matcher,
@Nullable PsiElement position) {
final PsiElement element = candidate.getElement();
final PsiElement context = candidate.getCurrentFileResolveContext();
if (context instanceof GrImportStatement && element != null) {
if (element instanceof PsiPackage) {
return Collections.emptyList();
}
final String importedName = ((GrImportStatement)context).getImportedName();
if (importedName != null) {
if (!(matcher.prefixMatches(importedName) ||
element instanceof PsiMethod && getterMatches(matcher, (PsiMethod)element, importedName) ||
element instanceof PsiMethod && setterMatches(matcher, (PsiMethod)element, importedName))
) {
return Collections.emptyList();
}
final GrCodeReferenceElement importReference = ((GrImportStatement)context).getImportReference();
if (importReference != null) {
boolean alias = ((GrImportStatement)context).isAliasedImport();
for (GroovyResolveResult r : importReference.multiResolve(false)) {
final PsiElement resolved = r.getElement();
if (context.getManager().areElementsEquivalent(resolved, element) && (alias || !(element instanceof PsiClass))) {
return generateLookupForImportedElement(candidate, importedName, alias);
}
else {
if (resolved instanceof PsiField && element instanceof PsiMethod && isAccessorFor((PsiMethod)element, (PsiField)resolved)) {
return generateLookupForImportedElement(candidate, getAccessorPrefix((PsiMethod)element) + capitalize(importedName), alias);
}
}
}
}
}
}
String name = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName() : element.getText();
if (name == null || !matcher.prefixMatches(name)) {
return Collections.emptyList();
}
if (element instanceof PsiClass) {
return JavaClassNameCompletionContributor
.createClassLookupItems((PsiClass)element, afterNew, new GroovyClassNameInsertHandler(), Condition.TRUE);
}
LookupElementBuilder builder = LookupElementBuilder.create(element instanceof PsiPackage ? element : candidate, name);
return Arrays.asList(setupLookupBuilder(element, candidate.getSubstitutor(), builder, position));
}
示例6: objectToLookupItem
import com.intellij.codeInsight.completion.JavaClassNameCompletionContributor; //导入依赖的package包/类
/**
* @see LookupElementBuilder
* @deprecated
*/
@NotNull
public static LookupElement objectToLookupItem(Object object)
{
if(object instanceof LookupElement)
{
return (LookupElement) object;
}
if(object instanceof PsiClass)
{
return JavaClassNameCompletionContributor.createClassLookupItem((PsiClass) object, true);
}
if(object instanceof PsiMethod)
{
return new JavaMethodCallElement((PsiMethod) object);
}
if(object instanceof PsiVariable)
{
return new VariableLookupItem((PsiVariable) object);
}
if(object instanceof PsiExpression)
{
return new ExpressionLookupItem((PsiExpression) object);
}
if(object instanceof PsiType)
{
return PsiTypeLookupItem.createLookupItem((PsiType) object, null);
}
if(object instanceof PsiJavaPackage)
{
return new PackageLookupItem((PsiJavaPackage) object);
}
String s = null;
LookupItem item = new LookupItem(object, "");
if(object instanceof PsiElement)
{
s = PsiUtilCore.getName((PsiElement) object);
}
TailType tailType = TailType.NONE;
if(object instanceof PsiMetaData)
{
s = ((PsiMetaData) object).getName();
}
else if(object instanceof String)
{
s = (String) object;
}
else if(object instanceof Template)
{
s = ((Template) object).getKey();
}
else if(object instanceof PresentableLookupValue)
{
s = ((PresentableLookupValue) object).getPresentation();
}
if(object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold())
{
item.setBold();
}
if(s == null)
{
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
item.setLookupString(s);
item.setTailType(tailType);
return item;
}