use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class PushDownMultifileTest method testUsagesInXml.
public void testUsagesInXml() throws Exception {
try {
doTest((rootDir, rootAfter) -> {
final PsiClass srcClass = myJavaFacade.findClass("a.A", GlobalSearchScope.allScope(myProject));
assertTrue("Source class not found", srcClass != null);
final PsiClass targetClass = myJavaFacade.findClass("b.B", GlobalSearchScope.allScope(myProject));
assertTrue("Target class not found", targetClass != null);
final PsiField[] fields = srcClass.getFields();
assertTrue("No methods found", fields.length > 0);
final MemberInfo memberInfo = new MemberInfo(fields[0]);
memberInfo.setChecked(true);
new PushDownProcessor<>(srcClass, Collections.singletonList(memberInfo), new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
//LocalFileSystem.getInstance().refresh(false);
//FileDocumentManager.getInstance().saveAllDocuments();
});
} catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
assertEquals(e.getMessage(), "Class <b><code>b.B</code></b> is package-private and will not be accessible from file <b><code>A.form</code></b>.");
return;
}
fail("Conflict was not detected");
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class FieldDependenciesManager method getRoots.
@NotNull
public List<ArrangementEntryDependencyInfo> getRoots() {
List<ArrangementEntryDependencyInfo> list = ContainerUtil.newArrayList();
for (Map.Entry<PsiField, Set<PsiField>> entry : myFieldDependencies.entrySet()) {
ArrangementEntryDependencyInfo currentInfo = myFieldInfosMap.get(entry.getKey());
for (PsiField usedInInitialization : entry.getValue()) {
ArrangementEntryDependencyInfo fieldInfo = myFieldInfosMap.get(usedInInitialization);
if (fieldInfo != null)
currentInfo.addDependentEntryInfo(fieldInfo);
}
list.add(currentInfo);
}
return list;
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class MakeMethodStaticRefactoringImpl 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 RemoveMiddlemanHandler method invoke.
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (!(element instanceof PsiField)) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("the.caret.should.be.positioned.at.the.name.of.the.field.to.be.refactored"), REFACTORING_NAME, getHelpID());
return;
}
invoke((PsiField) element, editor);
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class LightUnusedHighlightingFixtureTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new UnusedDeclarationInspection(true));
PlatformTestUtil.registerExtension(ImplicitUsageProvider.EP_NAME, new ImplicitUsageProvider() {
@Override
public boolean isImplicitUsage(PsiElement element) {
return isImplicitWrite(element);
}
@Override
public boolean isImplicitRead(PsiElement element) {
return false;
}
@Override
public boolean isImplicitWrite(PsiElement element) {
return element instanceof PsiField && "implicitWrite".equals(((PsiNamedElement) element).getName());
}
}, getTestRootDisposable());
}
Aggregations