本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionUtil类的典型用法代码示例。如果您正苦于以下问题:Java CompletionUtil类的具体用法?Java CompletionUtil怎么用?Java CompletionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionUtil类属于com.intellij.codeInsight.completion包,在下文中一共展示了CompletionUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CodeInsightUtil.java
示例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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MembersGetter.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LiftShorterItemsClassifier.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DocStringTypeReference.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyDocReference.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyCallExpressionHelper.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyClassImpl.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidDomExtender.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TestNGReferenceContributor.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:LookupItem.java
示例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());
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:StandardFileTypeRegistrator.java
示例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);
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:LiftShorterItemsClassifier.java
示例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;
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:LookupItem.java
示例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;
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:CodeInsightUtil.java
示例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);
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:MembersGetter.java
示例16: parsePsiElement
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
/**
* Parse the PSI text {@link CompletionUtil#DUMMY_IDENTIFIER} and " character and remove them.
* <p/>
* This implementation support Java literal expressions and XML attributes where you can define Camel endpoints.
*
* @param parameters - completion parameter to parse
* @return new string stripped for any {@link CompletionUtil#DUMMY_IDENTIFIER} and " character
*/
@NotNull
private static String[] parsePsiElement(@NotNull CompletionParameters parameters) {
PsiElement element = parameters.getPosition();
String val = getIdeaUtils().extractTextFromElement(element, true, true, true);
if (val == null || val.isEmpty()) {
return new String[]{"", ""};
}
String valueAtPosition = getIdeaUtils().extractTextFromElement(element, true, false, true);
String suffix = "";
// okay IDEA folks its not nice, in groovy the dummy identifier is using lower case i in intellij
// so we need to lower case it all
String hackVal = valueAtPosition.toLowerCase();
int len = CompletionUtil.DUMMY_IDENTIFIER.length();
int hackIndex = hackVal.indexOf(CompletionUtil.DUMMY_IDENTIFIER.toLowerCase());
//let's scrup the data for any Intellij stuff
val = val.replace(CompletionUtil.DUMMY_IDENTIFIER, "");
if (hackIndex == -1) {
val = val.replace(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED, "");
hackIndex = hackVal.indexOf(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.toLowerCase());
len = CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.length();
}
if (hackIndex > -1) {
suffix = valueAtPosition.substring(hackIndex + len);
valueAtPosition = valueAtPosition.substring(0, hackIndex);
}
return new String[]{val, suffix, valueAtPosition};
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:42,代码来源:CamelContributor.java
示例17: getCaretPositionInsidePsiElement
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
private int getCaretPositionInsidePsiElement(String stringLiteral) {
String hackVal = stringLiteral.toLowerCase();
int hackIndex = hackVal.indexOf(CompletionUtil.DUMMY_IDENTIFIER.toLowerCase());
if (hackIndex == -1) {
hackIndex = hackVal.indexOf(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.toLowerCase());
}
return hackIndex;
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:10,代码来源:IdeaUtils.java
示例18: isCaretAtEndOfLine
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
public boolean isCaretAtEndOfLine(PsiElement element) {
String value = extractTextFromElement(element).trim();
if (value != null) {
value = value.toLowerCase();
return value.endsWith(CompletionUtil.DUMMY_IDENTIFIER.toLowerCase())
|| value.endsWith(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.toLowerCase());
}
return false;
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:12,代码来源:IdeaUtils.java
示例19: isInitializedImplicitly
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
private static boolean isInitializedImplicitly(PsiField field) {
field = CompletionUtil.getOriginalOrSelf(field);
for(ImplicitUsageProvider provider: ImplicitUsageProvider.EP_NAME.getExtensions()) {
if (provider.isImplicitWrite(field)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaCompletionProcessor.java
示例20: processMembers
import com.intellij.codeInsight.completion.CompletionUtil; //导入依赖的package包/类
public void processMembers(final Consumer<LookupElement> results, @Nullable final PsiClass where,
final boolean acceptMethods, final boolean searchInheritors) {
if (where == null || isPrimitiveClass(where)) return;
final boolean searchFactoryMethods = searchInheritors &&
!CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName()) &&
!isPrimitiveClass(where);
final Project project = myPlace.getProject();
final GlobalSearchScope scope = myPlace.getResolveScope();
final PsiClassType baseType = JavaPsiFacade.getElementFactory(project).createType(where);
Consumer<PsiType> consumer = new Consumer<PsiType>() {
@Override
public void consume(PsiType psiType) {
PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
if (psiClass == null) {
return;
}
psiClass = CompletionUtil.getOriginalOrSelf(psiClass);
if (mayProcessMembers(psiClass)) {
final FilterScopeProcessor<PsiElement> declProcessor = new FilterScopeProcessor<PsiElement>(TrueFilter.INSTANCE);
psiClass.processDeclarations(declProcessor, ResolveState.initial(), null, myPlace);
doProcessMembers(acceptMethods, results, psiType == baseType, declProcessor.getResults());
String name = psiClass.getName();
if (name != null && searchFactoryMethods) {
Collection<PsiMember> factoryMethods = JavaStaticMemberTypeIndex.getInstance().getStaticMembers(name, project, scope);
doProcessMembers(acceptMethods, results, false, factoryMethods);
}
}
}
};
consumer.consume(baseType);
if (searchInheritors && !CommonClassNames.JAVA_LANG_OBJECT.equals(where.getQualifiedName())) {
CodeInsightUtil.processSubTypes(baseType, myPlace, true, PrefixMatcher.ALWAYS_TRUE, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:MembersGetter.java
注:本文中的com.intellij.codeInsight.completion.CompletionUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论