use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class PsiFieldFavoriteNodeProvider method createPathFromUrl.
@Override
public Object[] createPathFromUrl(final Project project, final String url, final String moduleName) {
if (DumbService.isDumb(project))
return null;
final Module module = moduleName != null ? ModuleManager.getInstance(project).findModuleByName(moduleName) : null;
final GlobalSearchScope scope = module != null ? GlobalSearchScope.moduleScope(module) : GlobalSearchScope.allScope(project);
final String[] paths = url.split(";");
if (paths == null || paths.length != 2)
return null;
final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(paths[0], scope);
if (aClass == null)
return null;
final PsiField aField = aClass.findFieldByName(paths[1], false);
return new Object[] { aField };
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class CompositeShortNamesCache method getFieldsByNameIfNotMoreThan.
@NotNull
@Override
public PsiField[] getFieldsByNameIfNotMoreThan(@NonNls @NotNull String name, @NotNull GlobalSearchScope scope, int maxCount) {
Merger<PsiField> merger = null;
for (PsiShortNamesCache cache : myCaches) {
PsiField[] fields = cache.getFieldsByNameIfNotMoreThan(name, scope, maxCount);
if (fields.length == maxCount)
return fields;
if (fields.length != 0) {
if (merger == null)
merger = new Merger<>();
merger.add(fields);
}
}
PsiField[] result = merger == null ? null : merger.getResult();
return result == null ? PsiField.EMPTY_ARRAY : result;
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class ExtensionPointImpl method collectMissingWithTags.
@Override
public List<PsiField> collectMissingWithTags() {
PsiClass beanClass = getBeanClass().getValue();
if (beanClass == null) {
return Collections.emptyList();
}
final List<PsiField> result = new SmartList<>();
for (PsiField field : beanClass.getAllFields()) {
if (ExtensionDomExtender.isClassField(field.getName()) && ExtensionDomExtender.findWithElement(getWithElements(), field) == null) {
result.add(field);
}
}
return result;
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class AddWithTagFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
DomElement element = DomUtil.getDomElement(descriptor.getPsiElement());
if (!(element instanceof ExtensionPoint)) {
return;
}
ExtensionPoint extensionPoint = (ExtensionPoint) element;
List<PsiField> fields = extensionPoint.collectMissingWithTags();
PsiElement navTarget = null;
for (PsiField field : fields) {
With with = extensionPoint.addWith();
String tagName = PluginFieldNameConverter.getAnnotationValue(field, Tag.class);
if (tagName != null) {
with.getTag().setStringValue(tagName);
} else {
String attributeName = PluginFieldNameConverter.getAttributeAnnotationValue(field);
if (attributeName == null) {
attributeName = field.getName();
}
if (attributeName.equals("forClass")) {
continue;
}
with.getAttribute().setStringValue(attributeName);
}
String epName = extensionPoint.getName().getStringValue();
String className = "";
if (epName != null) {
int pos = epName.lastIndexOf('.');
epName = StringUtil.capitalize(pos >= 0 ? epName.substring(pos + 1) : epName);
PsiClass[] classesByName = PsiShortNamesCache.getInstance(project).getClassesByName(epName, ProjectScope.getAllScope(project));
if (classesByName.length == 1) {
className = classesByName[0].getQualifiedName();
}
}
with.getImplements().setStringValue(className);
if (navTarget == null) {
navTarget = with.getImplements().getXmlAttributeValue();
}
}
if (navTarget != null) {
PsiNavigateUtil.navigate(navTarget);
}
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class PublicFieldInspection method buildFixes.
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
final List<InspectionGadgetsFix> fixes = new ArrayList<>();
final PsiField field = (PsiField) infos[0];
fixes.add(new EncapsulateVariableFix(field.getName()));
AddToIgnoreIfAnnotatedByListQuickFix.build(field, ignorableAnnotations, fixes);
return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
}
Aggregations