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 RemoveMiddlemanHandler method invoke.
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
if (elements.length != 1) {
return;
}
if (elements[0] instanceof PsiField) {
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
invoke((PsiField) elements[0], editor);
}
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class MakeClassStaticRefactoringImpl method getFields.
public List<PsiField> getFields() {
final Settings settings = myProcessor.getSettings();
List<PsiField> result = new ArrayList<>();
final List<Settings.FieldParameter> parameterOrderList = settings.getParameterOrderList();
for (final Settings.FieldParameter fieldParameter : parameterOrderList) {
result.add(fieldParameter.field);
}
return result;
}
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;
}
Aggregations