本文整理汇总了Java中com.jetbrains.php.PhpIndex类的典型用法代码示例。如果您正苦于以下问题:Java PhpIndex类的具体用法?Java PhpIndex怎么用?Java PhpIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhpIndex类属于com.jetbrains.php包,在下文中一共展示了PhpIndex类的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);
}
};
}
示例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;
}
示例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);
}
};
}
示例4: getPhpClassInConfig
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
static PhpClass getPhpClassInConfig(PsiDirectory dir, ArrayCreationExpression arrayCreation) {
PhpClass phpClass = null;
if (dir != null && (dir.getName().equals("config") || dir.getName().equals("src") /* for tests */)) {
PsiElement parent = arrayCreation.getParent().getParent();
if (parent instanceof ArrayHashElement) {
ArrayHashElement hash = (ArrayHashElement) parent;
PsiElement element = hash.getKey();
if (element instanceof StringLiteralExpression) {
StringLiteralExpression literal = (StringLiteralExpression) element;
String key = literal.getContents();
phpClass = getStandardPhpClass(PhpIndex.getInstance(literal.getProject()), key);
}
}
}
return phpClass;
}
示例5: getStandardPhpClass
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
static PhpClass getStandardPhpClass(PhpIndex phpIndex, String shortName) {
switch (shortName){
// web/Application
case "request": return ClassUtils.getClass(phpIndex, "\\yii\\web\\Request");
case "response": return ClassUtils.getClass(phpIndex, "\\yii\\web\\Response");
case "session": return ClassUtils.getClass(phpIndex, "\\yii\\web\\Session");
case "user": return ClassUtils.getClass(phpIndex, "\\yii\\web\\User");
case "errorHandler": return ClassUtils.getClass(phpIndex, "\\yii\\web\\ErrorHandler");
// base/Application
case "log": return ClassUtils.getClass(phpIndex, "\\yii\\log\\Dispatcher");
case "view": return ClassUtils.getClass(phpIndex, "\\yii\\web\\View");
case "formatter": return ClassUtils.getClass(phpIndex, "yii\\i18n\\Formatter");
case "i18n": return ClassUtils.getClass(phpIndex, "yii\\i18n\\I18N");
case "mailer": return ClassUtils.getClass(phpIndex, "\\yii\\swiftmailer\\Mailer");
case "urlManager": return ClassUtils.getClass(phpIndex, "\\yii\\web\\UrlManager");
case "assetManager": return ClassUtils.getClass(phpIndex, "\\yii\\web\\AssetManager");
case "security": return ClassUtils.getClass(phpIndex, "\\yii\\base\\Security");
// custom
case "db": return ClassUtils.getClass(phpIndex, "\\yii\\db\\Connection");
}
return null;
}
示例6: getClassBySignature
import com.jetbrains.php.PhpIndex; //导入依赖的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;
}
示例7: 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;
}
示例8: findClassInSeeTags
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
@Nullable
public static PhpClass findClassInSeeTags(PhpIndex index, PhpClass phpClass, String searchClassFQN) {
if (phpClass.getDocComment() == null)
return null;
PhpClass activeRecordClass = null;
PhpDocTag[] tags = phpClass.getDocComment().getTagElementsByName("@see");
for (PhpDocTag tag : tags) {
String className = tag.getText().replace(tag.getName(), "").trim();
if (className.indexOf('\\') == -1) {
className = phpClass.getNamespaceName() + className;
}
PhpClass classInSee = getClass(index, className);
if (isClassInheritsOrEqual(classInSee, getClass(index, searchClassFQN))) {
activeRecordClass = classInSee;
break;
}
}
return activeRecordClass;
}
示例9: getClassByVariable
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
@Nullable
public static PhpClass getClassByVariable(Variable element) {
if (element == null)
return null;
PhpType type = element.getType();
String typeString = type.toString();
String[] split = typeString.split("\\|");
typeString = split[0];
Pattern pattern = Pattern.compile("\\\\[A-Za-z\\\\]+");
Matcher matcher = pattern.matcher(typeString);
if (matcher.find())
typeString = matcher.group();
Collection<PhpClass> anyByFQN = PhpIndex.getInstance(element.getProject()).getAnyByFQN(typeString);
if (anyByFQN.isEmpty())
return null;
else
return anyByFQN.iterator().next();
}
示例10: getBySignature
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String s, Set<String> set, int i, Project project) {
Collection<PhpNamedElement> elements = new HashSet<>();
PhpClass classBySignature = SignatureUtils.getClassBySignature(s, project);
boolean classInheritsFromAD = ClassUtils.isClassInherit(classBySignature, "\\yii\\db\\BaseActiveRecord", PhpIndex.getInstance(project));
if (classInheritsFromAD) {
if (s.endsWith(".one"))
elements.add(classBySignature);
else if (s.endsWith(".all")) {
Collection<? extends PhpNamedElement> bySignature = PhpIndex.getInstance(project).getBySignature(s);
if (! bySignature.isEmpty()) {
PhpNamedElement firstItem = bySignature.iterator().next();
if (firstItem instanceof Method) {
((Method)firstItem).getType().add(classBySignature.getFQN()+ "[]");
}
}
}
}
return elements;
}
示例11: getBySignature
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
@Override
public Collection<? extends PhpNamedElement> getBySignature(String s, Set<String> set, int i, Project project) {
Collection<PhpNamedElement> elements = new HashSet<>();
int trimIndex = s.indexOf(TRIM_KEY);
if (trimIndex > -1 && s.length() + 1 > trimIndex) {
String origSignature = s.substring(0, trimIndex);
if (origSignature != null && origSignature.endsWith("\\Yii.createObject")) {
String variableRef = s.substring(trimIndex + 1);
final Collection<? extends PhpNamedElement> indexedVariabled = PhpIndex.getInstance(project).getBySignature(variableRef);
for (PhpNamedElement elem : indexedVariabled) {
if (elem instanceof Field) {
Field field = (Field) elem;
if (field.getLastChild() instanceof ArrayCreationExpression) {
PhpClass classByArray = ObjectFactoryUtils.findClassByArray((ArrayCreationExpression) field.getLastChild());
elements.add(classByArray);
}
}
}
}
}
return elements;
}
示例12: 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()]);
}
示例13: 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;
}
示例14: getBySignature
import com.jetbrains.php.PhpIndex; //导入依赖的package包/类
public Collection<? extends PhpNamedElement> getBySignature(String expression, Set<String> visited, int depth, Project project) {
int endIndex = expression.lastIndexOf("%");
if (endIndex == -1) {
return Collections.emptySet();
}
// Get FQN from parameter string.
// Example (PhpStorm 8): #K#C\Foo\Bar::get()%#K#C\Bar\Baz. -> \Bar\Baz.
// Example (PhpStorm 9): #K#C\Foo\Bar::get()%#K#C\Bar\Baz.class -> \Bar\Baz.class
String parameter = expression.substring(endIndex + 5, expression.length());
if (parameter.contains(".class")) { // for PhpStorm 9
parameter = parameter.replace(".class", "");
}
if (parameter.contains(".")) {
parameter = parameter.replace(".", "");
}
return PhpIndex.getInstance(project).getAnyByFQN(parameter);
}
示例15: 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;
}