本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionUtil类的典型用法代码示例。如果您正苦于以下问题:Java CompletionUtil类的具体用法?Java CompletionUtil怎么用?Java CompletionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionUtil类属于com.intellij.codeInsight.completion包,在下文中一共展示了CompletionUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContextTypeArguments
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
private static void addContextTypeArguments(final PsiElement context,
final PsiClassType baseType,
final Processor<PsiClass> inheritorsProcessor) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
Set<String> usedNames = ContainerUtil.newHashSet();
PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.getProject());
PsiElement each = context;
while (true) {
PsiTypeParameterListOwner typed = PsiTreeUtil.getParentOfType(each, PsiTypeParameterListOwner.class);
if (typed == null) break;
for (PsiTypeParameter parameter : typed.getTypeParameters()) {
if (baseType.isAssignableFrom(factory.createType(parameter)) && usedNames.add(parameter.getName())) {
inheritorsProcessor.process(CompletionUtil.getOriginalOrSelf(parameter));
}
}
each = typed;
}
}
});
}
示例2: MembersGetter
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
protected MembersGetter(StaticMemberProcessor processor, @NotNull final PsiElement place) {
myPlace = place;
processor.processMembersOfRegisteredClasses(PrefixMatcher.ALWAYS_TRUE, new PairConsumer<PsiMember, PsiClass>() {
@Override
public void consume(PsiMember member, PsiClass psiClass) {
myImportedStatically.add(member);
}
});
PsiClass current = PsiTreeUtil.getContextOfType(place, PsiClass.class);
while (current != null) {
current = CompletionUtil.getOriginalOrSelf(current);
myPlaceClasses.add(current);
current = PsiTreeUtil.getContextOfType(current, PsiClass.class);
}
PsiMethod eachMethod = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
while (eachMethod != null) {
eachMethod = CompletionUtil.getOriginalOrSelf(eachMethod);
myPlaceMethods.add(eachMethod);
eachMethod = PsiTreeUtil.getContextOfType(eachMethod, PsiMethod.class);
}
}
示例3: addElement
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@Override
public void addElement(LookupElement added, ProcessingContext context) {
myCount++;
for (String string : CompletionUtil.iterateLookupStrings(added)) {
if (string.length() == 0) continue;
myElements.putValue(string, added);
mySortedStrings.add(string);
final NavigableSet<String> after = mySortedStrings.tailSet(string, false);
for (String s : after) {
if (!s.startsWith(string)) {
break;
}
for (LookupElement longer : myElements.get(s)) {
updateLongerItem(added, longer);
}
}
}
super.addElement(added, context);
calculateToLift(added);
}
示例4: collectTypeVariants
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@NotNull
public List<Object> collectTypeVariants() {
final PsiFile file = myElement.getContainingFile();
final ArrayList<Object>
variants = Lists.<Object>newArrayList("str", "int", "basestring", "bool", "buffer", "bytearray", "complex", "dict",
"tuple", "enumerate", "file", "float", "frozenset", "list", "long", "set", "object");
if (file instanceof PyFile) {
variants.addAll(((PyFile)file).getTopLevelClasses());
final List<PyFromImportStatement> fromImports = ((PyFile)file).getFromImports();
for (PyFromImportStatement fromImportStatement : fromImports) {
final PyImportElement[] elements = fromImportStatement.getImportElements();
for (PyImportElement element : elements) {
final PyReferenceExpression referenceExpression = element.getImportReferenceExpression();
if (referenceExpression == null) continue;
final PyType type = TypeEvalContext.userInitiated(file.getProject(), CompletionUtil.getOriginalOrSelf(file)).getType(referenceExpression);
if (type instanceof PyClassType) {
variants.add(((PyClassType)type).getPyClass());
}
}
}
}
return variants;
}
示例5: getVariants
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
final ArrayList<Object> ret = Lists.newArrayList(super.getVariants());
PsiFile file = myElement.getContainingFile();
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myElement.getProject());
final PsiLanguageInjectionHost host = languageManager.getInjectionHost(myElement);
if (host != null) file = host.getContainingFile();
final PsiElement originalElement = CompletionUtil.getOriginalElement(myElement);
final PyQualifiedExpression element = originalElement instanceof PyQualifiedExpression ?
(PyQualifiedExpression)originalElement : myElement;
// include our own names
final CompletionVariantsProcessor processor = new CompletionVariantsProcessor(element);
if (file instanceof ScopeOwner)
PyResolveUtil.scopeCrawlUp(processor, (ScopeOwner)file, null, null);
ret.addAll(processor.getResultList());
return ret.toArray();
}
示例6: getSuperCallTypeForArguments
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@Nullable
private static PyType getSuperCallTypeForArguments(TypeEvalContext context, PyClass firstClass, PyExpression second_arg) {
// check 2nd argument, too; it should be an instance
if (second_arg != null) {
PyType second_type = context.getType(second_arg);
if (second_type instanceof PyClassType) {
// imitate isinstance(second_arg, possible_class)
PyClass secondClass = ((PyClassType)second_type).getPyClass();
if (CompletionUtil.getOriginalOrSelf(firstClass) == secondClass) {
return getSuperClassUnionType(firstClass);
}
if (secondClass.isSubclass(firstClass)) {
final Iterator<PyClass> iterator = firstClass.getAncestorClasses(context).iterator();
if (iterator.hasNext()) {
return new PyClassTypeImpl(iterator.next(), false); // super(Foo, self) has type of Foo, modulo __get__()
}
}
}
}
return null;
}
示例7: processInstanceLevelDeclarations
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@Override
public boolean processInstanceLevelDeclarations(@NotNull PsiScopeProcessor processor, @Nullable PsiElement location) {
Map<String, PyTargetExpression> declarationsInMethod = new HashMap<String, PyTargetExpression>();
PyFunction instanceMethod = PsiTreeUtil.getParentOfType(location, PyFunction.class);
final PyClass containingClass = instanceMethod != null ? instanceMethod.getContainingClass() : null;
if (instanceMethod != null && containingClass != null && CompletionUtil.getOriginalElement(containingClass) == this) {
collectInstanceAttributes(instanceMethod, declarationsInMethod);
for (PyTargetExpression targetExpression : declarationsInMethod.values()) {
if (!processor.execute(targetExpression, ResolveState.initial())) {
return false;
}
}
}
for (PyTargetExpression expr : getInstanceAttributes()) {
if (declarationsInMethod.containsKey(expr.getName())) {
continue;
}
if (!processor.execute(expr, ResolveState.initial())) return false;
}
return true;
}
示例8: registerExistingAttributes
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@NotNull
private static Set<XmlName> registerExistingAttributes(AndroidFacet facet,
XmlTag tag,
MyCallback callback,
AndroidDomElement element) {
final Set<XmlName> result = new HashSet<XmlName>();
XmlAttribute[] attrs = tag.getAttributes();
for (XmlAttribute attr : attrs) {
String localName = attr.getLocalName();
if (!localName.endsWith(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED)) {
if (!"xmlns".equals(attr.getNamespacePrefix())) {
AttributeDefinition attrDef = AndroidDomUtil.getAttributeDefinition(facet, attr);
if (attrDef != null) {
String namespace = attr.getNamespace();
result.add(new XmlName(attr.getLocalName(), attr.getNamespace()));
registerAttribute(attrDef, null, namespace.length() > 0 ? namespace : null, callback, null, element);
}
}
}
}
return result;
}
示例9: getVariants
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
List<Object> list = new ArrayList<Object>();
@NonNls String val = getValue();
int hackIndex = val.indexOf(CompletionUtil.DUMMY_IDENTIFIER);
if (hackIndex > -1) {
val = val.substring(0, hackIndex);
}
final String className = StringUtil.getPackageName(val);
PsiClass cls = getDependsClass(val);
if (cls != null) {
final PsiMethod current = PsiTreeUtil.getParentOfType(getElement(), PsiMethod.class);
final String configAnnotation = TestNGUtil.getConfigAnnotation(current);
final PsiMethod[] methods = cls.getMethods();
for (PsiMethod method : methods) {
final String methodName = method.getName();
if (current != null && methodName.equals(current.getName())) continue;
if (configAnnotation == null && TestNGUtil.hasTest(method) || configAnnotation != null && AnnotationUtil.isAnnotated(method, configAnnotation, true)) {
final String nameToInsert = StringUtil.isEmpty(className) ? methodName : StringUtil.getQualifiedName(cls.getQualifiedName(), methodName);
list.add(LookupElementBuilder.create(nameToInsert));
}
}
}
return list.toArray();
}
示例10: handleCompletionChar
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@NotNull
public static TailType handleCompletionChar(@NotNull final Editor editor, @NotNull final LookupElement lookupElement, final char completionChar) {
final TailType type = getDefaultTailType(completionChar);
if (type != null) {
return type;
}
if (lookupElement instanceof LookupItem) {
final LookupItem<?> item = (LookupItem)lookupElement;
final TailType attr = item.getAttribute(CompletionUtil.TAIL_TYPE_ATTR);
if (attr != null) {
return attr;
}
}
return TailType.NONE;
}
示例11: init
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
private static void init(final AbstractFileType abstractFileType) {
SyntaxTable table = abstractFileType.getSyntaxTable();
CompletionUtil.registerCompletionData(abstractFileType,new SyntaxTableCompletionData(table));
if (!isEmpty(table.getStartComment()) && !isEmpty(table.getEndComment()) ||
!isEmpty(table.getLineComment())) {
abstractFileType.setCommenter(new MyCommenter(abstractFileType));
}
if (table.isHasBraces() || table.isHasBrackets() || table.isHasParens()) {
BraceMatchingUtil.registerBraceMatcher(abstractFileType,new CustomFileTypeBraceMatcher());
}
TypedHandler.registerQuoteHandler(abstractFileType, new CustomFileTypeQuoteHandler());
}
示例12: addElement
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@Override
public void addElement(@Nonnull LookupElement added, @Nonnull ProcessingContext context) {
myCount++;
for (String string : CompletionUtil.iterateLookupStrings(added)) {
if (string.length() == 0) continue;
myElements.putValue(string, added);
mySortedStrings.add(string);
final NavigableSet<String> after = mySortedStrings.tailSet(string, false);
for (String s : after) {
if (!s.startsWith(string)) {
break;
}
for (LookupElement longer : myElements.get(s)) {
updateLongerItem(added, longer);
}
}
}
super.addElement(added, context);
calculateToLift(added);
}
示例13: handleCompletionChar
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
@Nonnull
public static TailType handleCompletionChar(@Nonnull final Editor editor, @Nonnull final LookupElement lookupElement, final char completionChar) {
final TailType type = getDefaultTailType(completionChar);
if (type != null) {
return type;
}
if (lookupElement instanceof LookupItem) {
final LookupItem<?> item = (LookupItem)lookupElement;
final TailType attr = item.getAttribute(CompletionUtil.TAIL_TYPE_ATTR);
if (attr != null) {
return attr;
}
}
return TailType.NONE;
}
示例14: addContextTypeArguments
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
private static void addContextTypeArguments(PsiElement context, PsiClassType baseType, Processor<PsiClass> inheritorsProcessor)
{
Set<String> usedNames = ContainerUtil.newHashSet();
PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.getProject());
PsiElement each = context;
while(true)
{
PsiTypeParameterListOwner typed = PsiTreeUtil.getParentOfType(each, PsiTypeParameterListOwner.class);
if(typed == null)
{
break;
}
for(PsiTypeParameter parameter : typed.getTypeParameters())
{
if(baseType.isAssignableFrom(factory.createType(parameter)) && usedNames.add(parameter.getName()))
{
inheritorsProcessor.process(CompletionUtil.getOriginalOrSelf(parameter));
}
}
each = typed;
}
}
示例15: MembersGetter
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
protected MembersGetter(StaticMemberProcessor processor, @NotNull final PsiElement place)
{
myPlace = place;
processor.processMembersOfRegisteredClasses(PrefixMatcher.ALWAYS_TRUE, (member, psiClass) -> myImportedStatically.add(member));
PsiClass current = PsiTreeUtil.getContextOfType(place, PsiClass.class);
while(current != null)
{
current = CompletionUtil.getOriginalOrSelf(current);
myPlaceClasses.add(current);
current = PsiTreeUtil.getContextOfType(current, PsiClass.class);
}
PsiMethod eachMethod = PsiTreeUtil.getContextOfType(place, PsiMethod.class);
while(eachMethod != null)
{
eachMethod = CompletionUtil.getOriginalOrSelf(eachMethod);
myPlaceMethods.add(eachMethod);
eachMethod = PsiTreeUtil.getContextOfType(eachMethod, PsiMethod.class);
}
}