本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.PhpClass.getConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java PhpClass.getConstructor方法的具体用法?Java PhpClass.getConstructor怎么用?Java PhpClass.getConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.elements.PhpClass
的用法示例。
在下文中一共展示了PhpClass.getConstructor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: getReferencesByElement
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String parameterName = StringUtil.unquoteString(element.getText());
if (parameterName.isEmpty() || !(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
DiIndex diIndex = DiIndex.getInstance(element.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) element);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
Collection<Parameter> parameterList = new THashSet<>(Arrays.asList(constructor.getParameters()));
parameterList.removeIf(p -> !p.getName().contains(parameterName));
if (parameterList.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, parameterList)};
}
}
}
return PsiReference.EMPTY_ARRAY;
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentReferenceProvider.java
示例3: getParameters
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的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;
}
示例4: getExpectedMethods
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
@NotNull
private Method[] getExpectedMethods(@NotNull Project project, @NotNull String ClassInterfaceName, @NotNull String methodName) {
Set<Method> methods = new HashSet<>();
for (PhpClass phpClass : PhpIndex.getInstance(project).getAnyByFQN(ClassInterfaceName)) {
// handle constructor as string
if(methodName.equalsIgnoreCase("__construct")) {
Method constructor = phpClass.getConstructor();
if(constructor != null) {
methods.add(constructor);
}
continue;
}
Method method = phpClass.findMethodByName(methodName);
if(method != null) {
methods.add(method);
}
}
return methods.toArray(new Method[methods.size()]);
}