本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.PhpClass类的典型用法代码示例。如果您正苦于以下问题:Java PhpClass类的具体用法?Java PhpClass怎么用?Java PhpClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhpClass类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了PhpClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildVisitor
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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);
}
};
}
示例2: buildVisitor
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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);
}
};
}
示例3: resolve
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
@Nullable
@Override
public PsiElement resolve() {
PsiElement possibleArrayCreation = myElement.getParent().getParent().getParent();
if (possibleArrayCreation instanceof ArrayCreationExpression) {
ArrayCreationExpression arrayCreation = (ArrayCreationExpression)possibleArrayCreation;
PsiDirectory dir = myElement.getContainingFile().getContainingDirectory();
PhpClass phpClass = ObjectFactoryUtils.findClassByArrayCreation(arrayCreation, dir);
if (phpClass != null) {
PsiElement field = ClassUtils.findWritableField(phpClass, myElement.getText());
return field;
}
}
return null;
}
示例4: getClassBySignature
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
@Nullable
public static PhpClass getClassBySignature(String signature, Project project) {
int beginClassIndex = signature.indexOf("\\");
int endClassIndex = signature.indexOf(".");
if (endClassIndex < 0) {
endClassIndex = signature.length() - 1;
}
if (beginClassIndex > -1 && beginClassIndex < endClassIndex) {
String className = signature.substring(beginClassIndex, endClassIndex);
Collection<PhpClass> classesByFQN = PhpIndex.getInstance(project).getClassesByFQN(className);
if (! classesByFQN.isEmpty()) {
return classesByFQN.iterator().next();
}
}
return null;
}
示例5: processClass
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
private static void processClass(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
if (clazz.isInterface()) {
throw new InvalidParameterException("Interface shall not be provided");
}
processed.add(clazz);
/* re-delegate interface handling */
for (PhpClass anInterface : clazz.getImplementedInterfaces()) {
processInterface(anInterface, processed);
}
/* handle parent class */
if (null != clazz.getSuperClass()) {
processClass(clazz.getSuperClass(), processed);
}
}
示例6: getTargetMethods
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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()]);
}
示例7: getBySignature
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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;
}
示例8: reportRelationship
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
static void reportRelationship(
@NotNull final ProblemsHolder problemsHolder,
@NotNull final Function method,
@NotNull final PhpClass methodClass
) {
final PhpType methodReturnType = PhpFunctionUtil.getReturnType(method);
if (!isRelationship(methodReturnType.getTypes())) {
return;
}
final PsiElement methodIdentifier = method.getNameIdentifier();
assert methodIdentifier != null;
validatePropertyAnnotation(problemsHolder, methodClass, methodIdentifier, CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.getName()), "mixed");
}
示例9: testFindSuperOfType
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
public void testFindSuperOfType() {
final PsiFile fileSample = getResourceFile("utils/PhpClassUtil.superClasses.php");
final PhpClass classFirstClass = (PhpClass) getElementByName(fileSample, "FirstClass");
final PhpClass classSecondClass = (PhpClass) getElementByName(fileSample, "SecondClass");
final PhpClass classThirdClass = (PhpClass) getElementByName(fileSample, "ThirdClass");
// Bogus assertions...
Assert.assertNull(PhpClassUtil.findSuperOfType(classFirstClass, "\\ThisClassDontHaveParent"));
Assert.assertNull(PhpClassUtil.findSuperOfType(classSecondClass, "\\ThisDoesButNotThat"));
Assert.assertNull(PhpClassUtil.findSuperOfType(classThirdClass, "\\ThisDoesButNotThat"));
// FirstClass is parent of SecondClass.
Assert.assertNotNull(PhpClassUtil.findSuperOfType(classSecondClass, "\\FirstClass"));
// FirstClass and SecondClass are parent of ThirdClass.
Assert.assertNotNull(PhpClassUtil.findSuperOfType(classThirdClass, "\\SecondClass"));
Assert.assertNotNull(PhpClassUtil.findSuperOfType(classThirdClass, "\\FirstClass"));
final PhpClass classCC_ChildClass = (PhpClass) getElementByName(fileSample, "CC_ChildClass");
// CC_UnresolvableParentClass is parent of CC_ChildClass (case #1).
// CC_UnresolvableParentClass is unresolvable, then we can't try search after that (case #2).
Assert.assertNotNull(PhpClassUtil.findSuperOfType(classCC_ChildClass, "\\CC_UnresolvableParentClass"));
Assert.assertNull(PhpClassUtil.findSuperOfType(classCC_ChildClass, "\\CC_ThereIsNothingAfterUnresolvableParentClass"));
}
示例10: getPhpClassOfArgument
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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;
}
示例11: addCompletions
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null || !(position instanceof XmlElement)) {
return;
}
DiIndex diIndex = DiIndex.getInstance(position.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) position);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
for (Parameter parameter : constructor.getParameters()) {
result.addElement(
LookupElementBuilder
.create(parameter.getName())
.withIcon(parameter.getIcon())
);
}
}
}
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentCompletionProvider.java
示例12: addCompletions
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) position);
if (phpClass != null) {
for (Method method : phpClass.getMethods()) {
result.addElement(
LookupElementBuilder
.create(method.getName())
.withIcon(method.getIcon())
);
}
}
}
示例13: getClassConfigurations
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
public static List<XmlTag> getClassConfigurations(PhpClass phpClass) {
String classFqn = phpClass.getPresentableFQN();
Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
.getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject())
);
PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
List<XmlTag> tags = new ArrayList<XmlTag>();
for (VirtualFile virtualFile: containingFiles) {
XmlFile file = (XmlFile)psiManager.findFile(virtualFile);
if (file == null) {
continue;
}
XmlTag rootTag = file.getRootTag();
fillRelatedTags(classFqn, rootTag, tags);
}
return tags;
}
示例14: getWebApiRoutes
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的package包/类
/**
* Get list of Web API routes associated with the provided method.
*
* Parent classes are not taken into account.
*/
public static List<XmlTag> getWebApiRoutes(Method method) {
List<XmlTag> tags = new ArrayList<>();
if (!method.getAccess().isPublic()) {
return tags;
}
PhpClass phpClass = method.getContainingClass();
String methodFqn = method.getName();
if (phpClass == null) {
return tags;
}
String classFqn = phpClass.getPresentableFQN();
Collection<VirtualFile> containingFiles = FileBasedIndex
.getInstance().getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject()));
PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
for (VirtualFile virtualFile : containingFiles) {
XmlFile file = (XmlFile) psiManager.findFile(virtualFile);
if (file == null) {
continue;
}
XmlTag rootTag = file.getRootTag();
fillRelatedTags(classFqn, methodFqn, rootTag, tags);
}
return tags;
}
示例15: getPluginsForClass
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入依赖的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;
}