本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.Field.isConstant方法的典型用法代码示例。如果您正苦于以下问题:Java Field.isConstant方法的具体用法?Java Field.isConstant怎么用?Java Field.isConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.elements.Field
的用法示例。
在下文中一共展示了Field.isConstant方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotations
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
public static Set<String> getAnnotations(Project project, String className) {
HashSet<String> map = new HashSet<>();
PhpClass phpClass = PhpElementsUtil.getClass(project, className);
if(phpClass == null) {
return map;
}
for(Field field: phpClass.getFields()) {
if(!field.isConstant()) {
map.add(field.getName());
}
}
return map;
}
示例2: getLookupElements
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {
String modelNameInScope = DoctrineMetadataUtil.findModelNameInScope(getElement());
if(modelNameInScope == null) {
return Collections.emptyList();
}
Set<String> unique = new HashSet<>();
Collection<LookupElement> lookupElements = new ArrayList<>();
for (PhpClass phpClass : PhpElementsUtil.getClassesInterface(getProject(), modelNameInScope)) {
for (Field field : phpClass.getFields()) {
if(field.isConstant() || unique.contains(field.getName())) {
continue;
}
String name = field.getName();
unique.add(name);
lookupElements.add(LookupElementBuilder.create(name).withIcon(field.getIcon()).withTypeText(phpClass.getPresentableFQN(), true));
}
}
return lookupElements;
}
示例3: multiResolve
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
List<PsiElement> psiElements = new ArrayList<>();
String content = ((StringLiteralExpression) getElement()).getContents();
for(Field field: constraintPhpClass.getFields()) {
String name = field.getName();
if(!field.isConstant() && field.getModifier().isPublic() && content.equals(name)) {
psiElements.add(field);
}
}
return PsiElementResolveResult.createResults(psiElements);
}
示例4: getVariants
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> lookupElements = new ArrayList<>();
for(Field field: constraintPhpClass.getFields()) {
if(!field.isConstant() && field.getModifier().isPublic()) {
LookupElementBuilder lookupElement = LookupElementBuilder.create(field.getName()).withIcon(Symfony2Icons.SYMFONY);
String defaultValue = PhpElementsUtil.getStringValue(field.getDefaultValue());
if(defaultValue != null) {
lookupElement = lookupElement.withTypeText(defaultValue, true);
}
lookupElements.add(lookupElement);
}
}
return lookupElements.toArray();
}
示例5: multiResolve
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的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()]);
}
示例6: getTargetsForConstant
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
/**
* Foobar::CONST
*/
@NotNull
public static Collection<PsiElement> getTargetsForConstant(@NotNull Project project, @NotNull String contents) {
// FOO
if (!contents.contains(":")) {
if(!contents.startsWith("\\")) {
contents = "\\" + contents;
}
return new ArrayList<>(
PhpIndex.getInstance(project).getConstantsByFQN(contents)
);
}
contents = contents.replaceAll(":+", ":");
String[] split = contents.split(":");
Collection<PsiElement> psiElements = new ArrayList<>();
for (PhpClass phpClass : PhpElementsUtil.getClassesInterface(project, split[0])) {
Field fieldByName = phpClass.findFieldByName(split[1], true);
if(fieldByName != null && fieldByName.isConstant()) {
psiElements.add(fieldByName);
}
}
return psiElements;
}
示例7: getVariants
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> lookupElements = new ArrayList<>();
for(Field field: this.phpClass.getFields()) {
if(!field.isConstant()) {
LookupElementBuilder lookupElement = LookupElementBuilder.createWithIcon(field);
lookupElement = attachLookupInformation(field, lookupElement);
lookupElements.add(lookupElement);
}
}
return lookupElements.toArray();
}
示例8: getMetadata
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@Override
public DoctrineMetadataModel getMetadata(@NotNull DoctrineMappingDriverArguments args) {
PsiFile psiFile = args.getPsiFile();
if(!(psiFile instanceof PhpFile)) {
return null;
}
Collection<DoctrineModelField> fields = new ArrayList<>();
DoctrineMetadataModel model = new DoctrineMetadataModel(fields);
for (PhpClass phpClass : PhpElementsUtil.getClassesInterface(args.getProject(), args.getClassName())) {
// remove duplicate code
// @TODO: fr.adrienbrault.idea.symfony2plugin.doctrine.EntityHelper.getModelFields()
PhpDocComment docComment = phpClass.getDocComment();
if(docComment == null) {
continue;
}
// Doctrine ORM
// @TODO: external split
if(AnnotationBackportUtil.hasReference(docComment, "\\Doctrine\\ORM\\Mapping\\Entity", "\\TYPO3\\Flow\\Annotations\\Entity")) {
// @TODO: reuse annotations plugin
PhpDocTag phpDocTag = AnnotationBackportUtil.getReference(docComment, "\\Doctrine\\ORM\\Mapping\\Table");
if(phpDocTag != null) {
Matcher matcher = Pattern.compile("name[\\s]*=[\\s]*[\"|']([\\w_\\\\]+)[\"|']").matcher(phpDocTag.getText());
if (matcher.find()) {
model.setTable(matcher.group(1));
}
}
for(Field field: phpClass.getFields()) {
if(field.isConstant()) {
continue;
}
if(AnnotationBackportUtil.hasReference(field.getDocComment(), EntityHelper.ANNOTATION_FIELDS)) {
DoctrineModelField modelField = new DoctrineModelField(field.getName());
EntityHelper.attachAnnotationInformation(field, modelField.addTarget(field));
fields.add(modelField);
}
}
}
}
if(fields.size() == 0) {
return null;
}
return model;
}