当前位置: 首页>>代码示例>>Java>>正文


Java PhpClass.getFields方法代码示例

本文整理汇总了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()]);
}
 
开发者ID:dkvashninbay,项目名称:magento2plugin,代码行数:34,代码来源:ConstantReference.java

示例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);
	}
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:38,代码来源:SetReadOnlyValueCompletionProvider.java

示例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()));
		}
	}
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:32,代码来源:SetValueCompletionProvider.java

示例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;
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:12,代码来源:GenerateActionHandler.java


注:本文中的com.jetbrains.php.lang.psi.elements.PhpClass.getFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。