本文整理汇总了Java中com.jetbrains.php.PhpIndex.getAllClassNames方法的典型用法代码示例。如果您正苦于以下问题:Java PhpIndex.getAllClassNames方法的具体用法?Java PhpIndex.getAllClassNames怎么用?Java PhpIndex.getAllClassNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.PhpIndex
的用法示例。
在下文中一共展示了PhpIndex.getAllClassNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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()));
}
}
}
}
示例2: collectCompletionResult
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
public List<LookupElement> collectCompletionResult(PsiElement psiElement, @Nullable PsiContextMatcherI<PsiElement> context) {
List<LookupElement> result = new ArrayList<>();
PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
String prefix = StringUtil.unquoteString(psiElement.getText());
Collection<String> classNames = phpIndex.getAllClassNames(new CamelHumpMatcher(prefix));
for (String className: classNames) {
Collection<PhpClass> classesByName = phpIndex.getClassesByName(className);
for (PhpClass phpClass: classesByName) {
if (context != null && !context.match(phpClass)) {
continue;
}
String classFqn = phpClass.getPresentableFQN();
result.add(
LookupElementBuilder
.create(classFqn)
.withIcon(PhpIcons.CLASS_ICON)
);
}
}
return result;
}
示例3: getOverloadAbleClasses
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
public static Collection<LookupElement> getOverloadAbleClasses(@NotNull Project project, @NotNull String contents) {
Collection<LookupElement> elements = new ArrayList<LookupElement>();
// @TODO: is there a class filter on oxid, so we provide completion only for
// "extends" classes
PhpIndex phpIndex = PhpIndex.getInstance(project);
for (String name : phpIndex.getAllClassNames(new CamelHumpMatcher(contents))) {
for (PhpClass phpClass : phpIndex.getClassesByName(name)) {
elements.add(new PhpClassLookupElement(phpClass, true, PhpClassReferenceInsertHandler.getInstance()));
}
}
return elements;
}
示例4: addCompletions
import com.jetbrains.php.PhpIndex; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Matcher matcher = Pattern.compile(PHP_CLASS_COMPLETION_REGEX).matcher(prefix);
if (!matcher.matches()) {
return;
}
String className = prefix.lastIndexOf(92) < 0 ? prefix : prefix.substring(prefix.lastIndexOf(92) + 1);
String namespace = prefix.lastIndexOf(92) < 0 ? "" : prefix.substring(0, prefix.lastIndexOf(92));
PhpIndex phpIndex = PhpIndex.getInstance(parameters.getPosition().getProject());
final Collection<PhpClass> phpClasses = new THashSet<>();
Collection<String> namespaceNames = new ArrayList<>();
if (!className.isEmpty()) {
// case for input: "SomeClassOrNamespace"
// add classes
Collection<String> classNames = phpIndex.getAllClassNames(new CamelHumpMatcher(className));
for (String cName: classNames) {
phpClasses.addAll(phpIndex.getClassesByName(cName));
}
// add interfaces
Collection<String> interfaceNames = phpIndex.getAllInterfaceNames();
interfaceNames.removeIf(i -> !i.contains(className));
for (String iName: interfaceNames) {
phpClasses.addAll(phpIndex.getInterfacesByName(iName));
}
if (!namespace.isEmpty()) {
phpClasses.removeIf(c -> !c.getPresentableFQN().startsWith(namespace));
} else {
namespaceNames = phpIndex.getChildNamespacesByParentName("\\");
namespaceNames.removeIf(n -> !n.contains(prefix));
}
} else {
// case for input: "Some\Namespace\ + ^+<Space>"
// add namespaces
Collection<PhpNamespace> namespaces = phpIndex.getNamespacesByName(("\\" + namespace).toLowerCase());
for (PhpNamespace nsp: namespaces) {
phpClasses.addAll(PsiTreeUtil.getChildrenOfTypeAsList(nsp.getStatements(), PhpClass.class));
}
// add namespaces and classes (string representation)
namespaceNames
= phpIndex.getChildNamespacesByParentName("\\".concat(namespace).concat("\\").toLowerCase());
namespaceNames
= namespaceNames.stream().map(n -> namespace.concat("\\").concat(n)).collect(Collectors.toList());
}
// add all above founded items to lookup builder
// order is important (items with the same name override each other), add classes first
for (PhpClass phpClass : phpClasses) {
result.addElement(
LookupElementBuilder
.create(phpClass.getPresentableFQN())
.withIcon(phpClass.getIcon())
);
}
for (String nsName : namespaceNames) {
result.addElement(
LookupElementBuilder
.create(nsName)
.withIcon(PhpIcons.NAMESPACE)
);
}
}