本文整理汇总了Java中com.jetbrains.php.PhpIndex.getClassesByFQN方法的典型用法代码示例。如果您正苦于以下问题:Java PhpIndex.getClassesByFQN方法的具体用法?Java PhpIndex.getClassesByFQN怎么用?Java PhpIndex.getClassesByFQN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.PhpIndex
的用法示例。
在下文中一共展示了PhpIndex.getClassesByFQN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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()]);
}
示例2: getParameters
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private List<Parameter> getParameters() {
List<Parameter> parameterList = new ArrayList<Parameter>();
PhpIndex phpIndex = PhpIndex.getInstance(getElement().getProject());
Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(typeName);
for (PhpClass phpClass: classesByFQN) {
Method constructor = phpClass.getConstructor();
if (constructor == null) {
continue;
}
Parameter[] parameters = constructor.getParameters();
Collections.addAll(parameterList, parameters);
}
return parameterList;
}
示例3: annotate
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (CodePattern.insideAnnotationPointcut().accepts(element)) {
NamespaceName nameHolder = PsiTreeUtil.getParentOfType(element, NamespaceName.class);
if (nameHolder == null) {
return;
}
String classFQN = nameHolder.getFQN();
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
Collection<PhpClass> classInstances = phpIndex.getClassesByFQN(classFQN);
if (classInstances.isEmpty()) {
holder.createErrorAnnotation(
nameHolder.getTextRange(),
"Class " + nameHolder.getText() + " is not defined in the project"
);
return;
}
if (!AnnotationUtil.isAnnotationClass(classInstances.iterator().next())) {
holder.createErrorAnnotation(nameHolder.getTextRange(), "Unknown annotation " + nameHolder.getText());
}
}
}
示例4: 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};
}
示例5: getClassInterfaceResolveResult
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
static public List<ResolveResult> getClassInterfaceResolveResult(Project project, String FQNClassOrInterfaceName) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(FQNClassOrInterfaceName);
Collection<PhpClass> phpInterfaces = phpIndex.getInterfacesByFQN(FQNClassOrInterfaceName);
List<ResolveResult> results = new ArrayList<ResolveResult>();
for (PhpClass phpClass : phpClasses) {
results.add(new PsiElementResolveResult(phpClass));
}
for (PhpClass phpInterface : phpInterfaces) {
results.add(new PsiElementResolveResult(phpInterface));
}
return results;
}
示例6: allExtendedClasses
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public static List<PhpClass> allExtendedClasses(PhpClass phpClass) {
List<PhpClass> classReferences = new ArrayList<>();
PhpIndex index = PhpIndex.getInstance(phpClass.getProject());
List<ClassReference> referenceElements = phpClass.getExtendsList().getReferenceElements();
for (ClassReference reference : referenceElements) {
Collection<PhpClass> classesByFQN = index.getClassesByFQN(reference.getFQN());
for (PhpClass phpClass1 : classesByFQN) {
classReferences.add(phpClass);
classReferences.addAll(allExtendedClasses(phpClass1));
}
}
return classReferences;
}
示例7: getControllerFieldClasses
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
public static Collection<PhpClass> getControllerFieldClasses(@NotNull String fieldName, @NotNull Project project) {
Collection<PhpClass> result = new ArrayList<>();
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<PhpClass> modelClasses = phpIndex.getClassesByFQN(fieldName);
Collection<PhpClass> componentClasses = phpIndex.getClassesByFQN(fieldName + "Component");
result.addAll(modelClasses);
result.addAll(componentClasses);
return result;
}
示例8: fillResolveResults
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public void fillResolveResults(PsiElement psiElement, List<ResolveResult> results, String typeName) {
PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
for (PhpClass phpClass : phpIndex.getClassesByFQN(PhpLangUtil.toFQN(typeName))) {
addResult(results, phpClass);
}
}
示例9: collectNavigationMarkers
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, Collection<? super RelatedItemLineMarkerInfo> result)
{
if (!(element instanceof PhpDocMethod)) {
return;
}
PhpDocMethod method = (PhpDocMethod) element;
PhpClass containingClass = method.getContainingClass();
PhpIndex index = PhpIndex.getInstance(method.getProject());
if (!OrmUtils.OrmClass.REPOSITORY.is(containingClass, index)) {
return;
}
if (baseMethods.contains(method.getName())) {
return;
}
String repositoryClass = containingClass.getFQN();
String mapperClass = repositoryClass.substring(0, repositoryClass.length() - 10) + "Mapper";
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
Collection<Method> methods = new ArrayList<Method>();
for (PhpClass cls : phpIndex.getClassesByFQN(mapperClass)) {
if (!OrmUtils.OrmClass.MAPPER.is(cls, phpIndex)) {
continue;
}
final Method mapperMethod = cls.findMethodByName(method.getName());
if (mapperMethod == null) {
continue;
}
methods.add(mapperMethod);
}
result.add(NavigationGutterIconBuilder.create(PhpIcons.METHOD)
.setTargets(methods)
.setTooltipText("Navigate to mapper method")
.createLineMarkerInfo(method)
);
}
示例10: getBySignature
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String expression, Project project) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
Signature signature = new Signature(expression);
// try to resolve service type
if(ProjectComponent.isEnabled(project) && signature.hasParameter()) {
ArrayList<String> parameters = new ArrayList<String>();
if (Utils.findPimpleContainer(phpIndex, expression, parameters)) {
return phpIndex.getClassesByFQN(getClassNameFromParameters(phpIndex, project, parameters));
}
}
// if it's not a service try to get original type
Collection<? extends PhpNamedElement> collection = phpIndex.getBySignature(signature.base, null, 0);
if (collection.size() == 0) {
return Collections.emptySet();
}
// original type can be array (#C\ClassType[]) resolve to proper value type
PhpNamedElement element = collection.iterator().next();
for (String type : element.getType().getTypes()) {
if (type.endsWith("[]")) {
Collection<? extends PhpNamedElement> result = phpIndex.getClassesByFQN(type.substring(0, type.length() - 2));
if (result.size() != 0) {
return result;
}
}
}
return collection;
}
示例11: getClassMethod
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public static Method getClassMethod(Project project, String phpClassName, String methodName) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(phpClassName);
for (PhpClass phpClass : phpClasses) {
Optional<Method> method = getClassMethod(phpClass, methodName);
if (method.isPresent()) {
return method.get();
}
}
return null;
}
示例12: getControllerAction
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public static PsiElement getControllerAction(Project project, String controller, String action) {
String controllerFQN = Settings.getInstance(project).useLegacyNamespaces ? "Controller\\" + controller : "Application\\Controller\\" + controller;
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(controllerFQN);
PhpClass phpClass = Iterables.getLast(phpClasses, null);
if (phpClass == null) {
return null;
}
Optional<Method> classMethod = PhpIndexUtils.getClassMethod(phpClass, action);
return classMethod.isPresent() ? classMethod.get() : phpClass;
}
示例13: addCompletion
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private void addCompletion(CompletionResultSet result, PsiElement element, String fqn) {
ArrayCreationExpression arrayCreation = PsiTreeUtil.getParentOfType(element, ArrayCreationExpression.class);
if (arrayCreation != null && canBecomeKey(element)) {
Set<String> existingKeys = PsiUtils.getKeys(arrayCreation);
PhpIndex phpIndex = PhpIndex.getInstance(element.getProject());
Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(fqn);
for (PhpClass phpClass : classesByFQN) {
if (PsiUtils.isInstanceOf(phpClass, OuzoUtils.OUZO_MODEL_FQN)) {
addCompletionForModelClass(phpClass, existingKeys, result);
}
}
}
}
示例14: findAvailableRenderTypes
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
private static Set<PsiElement> findAvailableRenderTypes(Project project) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
PsiFile[] extLocalConfFiles = FilenameIndex.getFilesByName(project, EXT_LOCALCONF_FILENAME, GlobalSearchScope.allScope(project));
Collection<PhpClass> nodeRegistries = phpIndex.getClassesByFQN(NODE_FACTORY_CLASS);
Set<PsiElement> elements = new HashSet<>();
for (PhpClass registry : nodeRegistries) {
Collections.addAll(
elements,
PsiTreeUtil.collectElements(registry, element -> PlatformPatterns
.psiElement(StringLiteralExpression.class)
.withParent(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
.withAncestor(
3,
PlatformPatterns.psiElement(PhpElementTypes.CLASS_FIELD).withName("nodeTypes")
)
)
.accepts(element)
)
);
}
for (PsiFile file : extLocalConfFiles) {
Collections.addAll(
elements,
PsiTreeUtil.collectElements(file, element -> PlatformPatterns
.psiElement(StringLiteralExpression.class)
.withParent(
PlatformPatterns
.psiElement(PhpElementTypes.ARRAY_VALUE)
.withParent(
PlatformPatterns
.psiElement(PhpElementTypes.HASH_ARRAY_ELEMENT)
.withChild(
PlatformPatterns
.psiElement(PhpElementTypes.ARRAY_KEY)
.withText("'nodeName'")
)
)
).accepts(element))
);
}
return elements;
}
示例15: getViewHelperClasses
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@NotNull
public static Collection<PhpClass> getViewHelperClasses(@NotNull String fieldName, @NotNull Project project) {
PhpIndex phpIndex = PhpIndex.getInstance(project);
return phpIndex.getClassesByFQN(fieldName + "Helper");
}