本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.PhpClass.getFields方法的典型用法代码示例。如果您正苦于以下问题:Java PhpClass.getFields方法的具体用法?Java PhpClass.getFields怎么用?Java PhpClass.getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.elements.PhpClass
的用法示例。
在下文中一共展示了PhpClass.getFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multiResolve
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
PhpIndex phpIndex = PhpIndex.getInstance(getElement().getProject());
List<String> parts = StringUtil.split(
PhpLangUtil.toFQN(
StringUtil.unquoteString(getElement().getText())
),
"::"
);
if (parts.size() != 2) {
return new ResolveResult[0];
}
String className = parts.get(0);
String constantName = parts.get(1);
List<ResolveResult> fields = new ArrayList<ResolveResult>();
Collection<PhpClass> classesAndInterfaces = new ArrayList<>();
classesAndInterfaces.addAll(phpIndex.getClassesByFQN(className));
classesAndInterfaces.addAll(phpIndex.getInterfacesByFQN(className));
for (PhpClass phpClass: classesAndInterfaces) {
for(Field field: phpClass.getFields()) {
if (field.isConstant() && field.getName().equals(constantName)) {
fields.add(new PsiElementResolveResult(field));
}
}
}
return fields.toArray(new ResolveResult[fields.size()]);
}
示例2: addCompletions
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
parameters.getPosition();
PsiElement el = parameters.getPosition();
PhpClass cls = PhpPsiUtil.getParentByCondition(el, PhpClass.INSTANCEOF);
if (cls == null) {
return;
}
PhpIndex phpIndex = PhpIndex.getInstance(el.getProject());
if (!OrmUtils.OrmClass.ENTITY.is(cls, phpIndex)) {
return;
}
for (Field field : cls.getFields()) {
if (!(field instanceof PhpDocProperty) || !field.getParent().getFirstChild().getText().equals("@property-read")) {
continue;
}
LookupElementBuilder element = LookupElementBuilder.create(field.getName())
.withInsertHandler(new InsertHandler<LookupElement>()
{
@Override
public void handleInsert(InsertionContext insertionContext, LookupElement lookupElement)
{
String phpCode = "$this->setReadOnlyValue('" + lookupElement.getLookupString() + "', );";
Document document = insertionContext.getDocument();
document.replaceString(insertionContext.getStartOffset(), insertionContext.getTailOffset(), phpCode);
PsiDocumentManager.getInstance(insertionContext.getProject()).commitDocument(document);
insertionContext.getEditor().getCaretModel().moveToOffset(insertionContext.getStartOffset() + phpCode.length() - 2);
}
})
.withTypeText(field.getType().toString())
.withIcon(PhpIcons.VARIABLE_WRITE_ACCESS)
.withPresentableText(field.getName() + " = ...");
result.addElement(element);
}
}
示例3: addCompletions
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
parameters.getPosition();
PsiElement el = parameters.getPosition();
if (
el.getParent() == null
|| el.getParent().getParent() == null
|| !(el.getParent().getParent() instanceof ParameterList)
|| ((ParameterList) el.getParent().getParent()).getParameters()[0] != el.getParent()
|| el.getParent().getParent().getParent() == null
|| !(el.getParent().getParent().getParent() instanceof MethodReference)
) {
return;
}
MethodReference methodReference = (MethodReference) el.getParent().getParent().getParent();
if (!methodReference.getName().equals("setValue") && !methodReference.getName().equals("setReadOnlyValue")) {
return;
}
PhpIndex phpIndex = PhpIndex.getInstance(el.getProject());
for (PhpClass cls : PhpIndexUtils.getByType(methodReference.getClassReference().getType(), phpIndex)) {
if (!OrmUtils.OrmClass.ENTITY.is(cls, phpIndex)) {
continue;
}
for (Field field : cls.getFields()) {
if (!(field instanceof PhpDocProperty)) {
continue;
}
result.addElement(LookupElementBuilder.create(field.getName()).withTypeText(field.getType().toString()));
}
}
}
示例4: getFields
import com.jetbrains.php.lang.psi.elements.PhpClass; //导入方法依赖的package包/类
private Collection<Field> getFields(PhpClass phpClass)
{
ArrayList<Field> fields = new ArrayList<Field>();
for (Field field : phpClass.getFields()) {
if (field instanceof PhpDocPropertyImpl && GenerateActionHandler.this.canShow((PhpDocProperty) field, phpClass)) {
fields.add(field);
}
}
return fields;
}