当前位置: 首页>>代码示例>>Java>>正文


Java PhpIndex.getInstance方法代码示例

本文整理汇总了Java中com.jetbrains.php.PhpIndex.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PhpIndex.getInstance方法的具体用法?Java PhpIndex.getInstance怎么用?Java PhpIndex.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jetbrains.php.PhpIndex的用法示例。


在下文中一共展示了PhpIndex.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildVisitor

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass clazz) {
            PhpIndex index = PhpIndex.getInstance(problemsHolder.getProject());
            if (DatabaseUtils.HasConnections(problemsHolder.getProject()) &&
                    ClassUtils.isClassInheritsOrEqual(clazz, ClassUtils.getClass(index, "\\yii\\db\\ActiveRecord"))) {
                String table = DatabaseUtils.getTableByActiveRecordClass(clazz);
                if (table == null) {
                    problemsHolder.registerProblem(clazz.getFirstChild(), "Can not detect database table for class " + clazz.getFQN(), ProblemHighlightType.WEAK_WARNING);
                } else if (! DatabaseUtils.isTableExists(table, problemsHolder.getProject())) {
                    problemsHolder.registerProblem(clazz.getFirstChild(), "Table '" + table + "' not found in database connections", ProblemHighlightType.WEAK_WARNING);

                }
            }
            super.visitPhpClass(clazz);
        }
    };
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:22,代码来源:UndetectableTableInspection.java

示例2: invokeAutoPopup

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
    if ((typeChar == '\'' || typeChar == '"' || typeChar == '.')  ) {
        MethodReference methodRef = ClassUtils.getMethodRef(position, 10);
        if (methodRef != null) {
            Method method = (Method)methodRef.resolve();
            if (method != null) {
                Object possibleClass = method.getParent();
                if (possibleClass instanceof PhpClass) {
                    PhpIndex index = PhpIndex.getInstance(method.getProject());
                    if (ClassUtils.isClassInheritsOrEqual((PhpClass)possibleClass, ClassUtils.getClass(index, "\\yii\\db\\Query")) ||
                            ClassUtils.isClassInheritsOrEqual((PhpClass)possibleClass, ClassUtils.getClass(index, "\\yii\\db\\Command")) ||
                            ClassUtils.isClassInherit((PhpClass)possibleClass, ClassUtils.getClass(index, "\\yii\\db\\BaseActiveRecord")) ||
                            ClassUtils.isClassInheritsOrEqual((PhpClass)possibleClass, ClassUtils.getClass(index, "\\yii\\db\\Migration"))
                            ) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:25,代码来源:QueryCompletionContributor.java

示例3: buildVisitor

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass clazz) {
            if (clazz.getSuperClass() != null && clazz.getSuperClass().getFQN().equals("\\yii\\db\\ActiveQuery")) {
                PhpIndex index = PhpIndex.getInstance(clazz.getProject());

                PhpClass activeRecordClass = ClassUtils.findClassInSeeTags(index, clazz, "\\yii\\db\\BaseActiveRecord");
                if (activeRecordClass == null) {
                    problemsHolder.registerProblem(clazz.getFirstChild(),
                            "Can not find connected ActiveRecord class.\nYou should add @see tag with linked ActiveRecord",
                            ProblemHighlightType.WEAK_WARNING);
                }
            }
            super.visitPhpClass(clazz);

        }
    };
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:22,代码来源:MissingActiveRecordInActiveQueryInspection.java

示例4: getPhpClassUniversal

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Nullable
public static PhpClass getPhpClassUniversal(Project project, PhpPsiElement value) {
    if (value instanceof MethodReference && (value.getName().equals("className") || value.getName().equals("tableName"))) {
        MethodReference methodRef = (MethodReference) value;
        return getPhpClass(methodRef.getClassReference());
    }
    if (value instanceof ClassConstantReference || value instanceof ConstantReference) {
        return getPhpClass(value);
    }

    if (value instanceof StringLiteralExpression) {
        StringLiteralExpression str = (StringLiteralExpression) value;
        PhpIndex phpIndex = PhpIndex.getInstance(project);
        return getClass(phpIndex, str.getContents());
    }
    return null;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:18,代码来源:ClassUtils.java

示例5: getTargetMethods

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
private static PsiElement[] getTargetMethods(@NotNull Project project, @NotNull String routeName) {
    List<PsiElement> result = new ArrayList<>();
    List<RouteStub> values = FileBasedIndex.getInstance().getValues(RouteIndex.KEY, routeName, GlobalSearchScope.allScope(project));
    PhpIndex phpIndex = PhpIndex.getInstance(project);

    for (RouteStub routeStub : values) {
        String fqn = routeStub.getController();

        Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(fqn);
        classesByFQN.forEach(c -> {
            if (c.findMethodByName(routeStub.getMethod()) != null) {
                result.add(c.findMethodByName(routeStub.getMethod()));
            }
        });
    }

    return result.toArray(new PsiElement[result.size()]);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:20,代码来源:RouteHelper.java

示例6: getBySignature

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {

    Collection<PhpNamedElement> phpNamedElementCollections = new ArrayList<>();
    PhpIndex phpIndex = PhpIndex.getInstance(project);
    CoreServiceParser serviceParser = new CoreServiceParser();
    serviceParser.collect(project);

    List<TYPO3ServiceDefinition> resolvedServices = serviceParser.resolve(project, expression);
    if (resolvedServices == null || resolvedServices.isEmpty()) {
        return phpNamedElementCollections;
    }

    resolvedServices.forEach(serviceDefinition -> {
        Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(serviceDefinition.getClassName());
        phpNamedElementCollections.addAll(classesByFQN);
    });

    return phpNamedElementCollections;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:21,代码来源:GeneralUtilityServiceTypeProvider.java

示例7: getPhpClassOfArgument

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Nullable
public PhpClass getPhpClassOfArgument(XmlElement psiArgumentValueElement) {

    XmlTag typeTag = XmlPsiTreeUtil.getTypeTagOfArgument(psiArgumentValueElement);
    if (null == typeTag) {
        return null;
    }

    String className = typeTag.getAttributeValue("name");
    if (null == className) {
        return null;
    }
    className = getTopTypeOfVirtualType(className);

    PhpIndex phpIndex = PhpIndex.getInstance(psiArgumentValueElement.getProject());
    Collection<PhpClass> phpClasses = phpIndex.getAnyByFQN(className);

    if (phpClasses.size() > 0) {
        return phpClasses.iterator().next();
    }

    return null;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:24,代码来源:DiIndex.java

示例8: getPluginsForClass

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
List<PhpClass> getPluginsForClass(@NotNull PhpClass phpClass, @NotNull String classFQN) {
    List<PhpClass> results = new ArrayList<>();

    if (classPluginsMap.containsKey(classFQN)) {
        return classPluginsMap.get(classFQN);
    }

    List<Set<String>> plugins = FileBasedIndex.getInstance()
        .getValues(PluginIndex.KEY, classFQN, GlobalSearchScope.allScope(phpClass.getProject()));

    if (plugins.size() == 0) {
        classPluginsMap.put(classFQN, results);
        return results;
    }

    PhpIndex phpIndex = PhpIndex.getInstance(phpClass.getProject());

    for (Set<String> pluginClassNames: plugins) {
        for (String pluginClassName: pluginClassNames) {
            results.addAll(phpIndex.getClassesByFQN(pluginClassName));
        }
    }
    classPluginsMap.put(classFQN, results);
    return results;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PluginLineMarkerProvider.java

示例9: assertPhpReferenceSignatureEquals

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
protected void assertPhpReferenceSignatureEquals(LanguageFileType languageFileType, @NotNull Class aClass, String configureByText, String typeSignature) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, aClass);

    if (!(psiElement instanceof PhpReference)) {
        fail("Element is not PhpReference.");
    }

    PhpIndex phpIndex = PhpIndex.getInstance(myFixture.getProject());
    Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(((PhpReference)psiElement).getSignature(), null, 0);
    assertNotEmpty(collection);

    for (String type : collection.iterator().next().getType().getTypes()) {
        if (type.equals(typeSignature)) {
            return;
        }
    }

    fail("Can't find type: "+typeSignature+", found:"+collection.iterator().next().getType().toString());
}
 
开发者ID:Sorien,项目名称:silex-idea-plugin,代码行数:23,代码来源:CodeInsightFixtureTestCase.java

示例10: getLookupElements

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) {
    PhpIndex instance = PhpIndex.getInstance(parameter.getProject());

    Collection<LookupElement> lookupElements = new ArrayList<>();
    for (String className : getClasses(parameter)) {
        // strip double backslash
        className = className.replaceAll("\\\\+", "\\\\");

        for (PhpClass phpClass : getPhpClassesForLookup(instance, className)) {
            lookupElements.add(
                LookupElementBuilder.create(phpClass.getPresentableFQN()).withIcon(phpClass.getIcon())
            );
        }
    }

    return lookupElements;
}
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:19,代码来源:PhpIndexAbstractProviderAbstract.java

示例11: getReferencesByElement

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    if (!isApplicable(psiElement)) {
        return new PsiReference[]{};
    }

    PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
    Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(OuzoUtils.OUZO_MODEL_NAMESPACE + PsiUtils.getContent(psiElement));
    PhpClass phpClass = Iterables.getLast(phpClasses, null);

    if (phpClass == null) {
        return new PsiReference[]{};
    }

    PsiReferenceBase.Immediate reference = new PsiReferenceBase.Immediate(psiElement, phpClass);
    return new PsiReference[]{reference};
}
 
开发者ID:letsdrink,项目名称:ouzo-phpstorm-plugin,代码行数:19,代码来源:RelationClassReferenceProvider.java

示例12: fillCompletionVariants

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
	Logger.getInstance("x").warn("ct" + parameters.getCompletionType());
	if (parameters.getCompletionType() == CompletionType.BASIC && parameters.getPosition().getParent() instanceof StringLiteralExpression) {
		Project project = parameters.getPosition().getProject();
		Object x = PhpIndex.getInstance(project);

		Logger.getInstance("x").warn("foo" + x.getClass().getName());
		for (Object a : PhpIndex.getInstance(project).getAnyByFQN(null)) {
			Logger.getInstance("x").warn("foobar");
		}
		for (String className : PhpIndex.getInstance(project).getAllClassNames(PrefixMatcher.ALWAYS_TRUE)) {
			Logger.getInstance("x").warn(className);
			result.addElement(LookupElementBuilder.create(className));
		}
	}
	super.fillCompletionVariants(parameters, result);
}
 
开发者ID:sandstorm,项目名称:FlowStorm,代码行数:19,代码来源:StringClassNameCompletionContributor.java

示例13: addCompletions

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {

        if(!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
            return;
        }

        PhpIndex phpIndex = PhpIndex.getInstance(parameters.getOriginalFile().getProject());
        Map<String, String> entityNamespaces = ServiceXmlParserFactory.getInstance(parameters.getOriginalFile().getProject(), EntityNamesServiceParser.class).getEntityNameMap();

        // copied from PhpCompletionUtil::addClassesInNamespace looks the official way to find classes in namespaces
        // its a really performance nightmare

        Collection<String> names = phpIndex.getAllClassNames(new CamelHumpMatcher(resultSet.getPrefixMatcher().getPrefix()));
        for (String name : names) {
            Collection<PhpClass> classes = phpIndex.getClassesByName(name);

            for(Map.Entry<String, String> entry: entityNamespaces.entrySet()) {
                String namespaceFqn = PhpLangUtil.toFQN(entry.getValue());
                Collection<PhpClass> filtered = PhpCompletionUtil.filterByNamespace(classes, namespaceFqn);
                for (PhpClass phpClass : filtered) {
                    resultSet.addElement(new PhpClassLookupElement(phpClass, true, PhpClassReferenceInsertHandler.getInstance()));
                }
            }
        }
    }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:PhpEntityClassCompletionProvider.java

示例14: getSubscribedEventsProxy

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
private static Collection<EventDispatcherSubscribedEvent> getSubscribedEventsProxy(@NotNull Project project) {

    Collection<EventDispatcherSubscribedEvent> events = new ArrayList<>();

    // http://symfony.com/doc/current/components/event_dispatcher/introduction.html
    PhpIndex phpIndex = PhpIndex.getInstance(project);
    Collection<PhpClass> phpClasses = phpIndex.getAllSubclasses("\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface");

    for(PhpClass phpClass: phpClasses) {

        if(PhpElementsUtil.isTestClass(phpClass)) {
            continue;
        }

        Method method = phpClass.findMethodByName("getSubscribedEvents");
        if(method != null) {
            PhpReturn phpReturn = PsiTreeUtil.findChildOfType(method, PhpReturn.class);
            if(phpReturn != null) {
                attachSubscriberEventNames(events, phpClass, phpReturn);
            }
        }
    }

   return events;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:27,代码来源:EventDispatcherSubscriberUtil.java

示例15: multiResolve

import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {

    List<ResolveResult> results = new ArrayList<>();
    PhpIndex phpIndex = PhpIndex.getInstance(getElement().getProject());

    if(this.useClasses) {
        this.attachPhpClassResolveResults(phpIndex.getClassesByFQN(classFQN), results);
    }

    if(this.useInterfaces) {
        this.attachPhpClassResolveResults(phpIndex.getInterfacesByFQN(classFQN.startsWith("\\") ? classFQN : "\\" + classFQN), results);
    }

    return results.toArray(new ResolveResult[results.size()]);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:18,代码来源:PhpClassReference.java


注:本文中的com.jetbrains.php.PhpIndex.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。