use of com.intellij.codeInspection.ex.ProblemDescriptorImpl in project google-cloud-intellij by GoogleCloudPlatform.
the class ConstructorInspectionTest method testQuickFix_noConstructor.
public void testQuickFix_noConstructor() {
ProblemDescriptorImpl problemDescriptorMock = mock(ProblemDescriptorImpl.class);
MockitoAnnotations.initMocks(this);
PsiClass psiClass = JavaPsiFacade.getInstance(myFixture.getProject()).getElementFactory().createClass(getName());
ConstructorInspection constructorInspection = new ConstructorInspection();
ConstructorInspection.MyQuickFix myQuickFix = constructorInspection.new MyQuickFix(psiClass);
myQuickFix.applyFix(myFixture.getProject(), problemDescriptorMock);
Assert.assertEquals(1, psiClass.getConstructors().length);
Assert.assertTrue(EndpointUtilities.isPublicNullaryConstructor(psiClass.getConstructors()[0]));
}
use of com.intellij.codeInspection.ex.ProblemDescriptorImpl in project intellij-community by JetBrains.
the class UnsupportedFeatures method createIntention.
@NotNull
private static IntentionAction createIntention(@NotNull PsiElement node, @Nullable TextRange range, @NotNull String message, @NotNull LocalQuickFix localQuickFix) {
final LocalQuickFix[] quickFixes = { localQuickFix };
final CommonProblemDescriptorImpl descr = new ProblemDescriptorImpl(node, node, message, quickFixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, range, true);
return QuickFixWrapper.wrap((ProblemDescriptor) descr, 0);
}
use of com.intellij.codeInspection.ex.ProblemDescriptorImpl in project google-cloud-intellij by GoogleCloudPlatform.
the class ConstructorInspectionTest method testQuickFix_classWithNullaryConstructor.
public void testQuickFix_classWithNullaryConstructor() {
ProblemDescriptorImpl problemDescriptorMock = mock(ProblemDescriptorImpl.class);
MockitoAnnotations.initMocks(this);
PsiElementFactory factory = JavaPsiFacade.getInstance(myFixture.getProject()).getElementFactory();
PsiClass psiClass = factory.createClass(getName());
PsiMethod nullaryConstructor = factory.createMethodFromText("public " + psiClass.getName() + "() { }", psiClass);
psiClass.addAfter(nullaryConstructor, null);
ConstructorInspection constructorInspection = new ConstructorInspection();
ConstructorInspection.MyQuickFix myQuickFix = constructorInspection.new MyQuickFix(psiClass);
myQuickFix.applyFix(myFixture.getProject(), problemDescriptorMock);
Assert.assertEquals(1, psiClass.getConstructors().length);
Assert.assertTrue(EndpointUtilities.isPublicNullaryConstructor(psiClass.getConstructors()[0]));
}
use of com.intellij.codeInspection.ex.ProblemDescriptorImpl in project google-cloud-intellij by GoogleCloudPlatform.
the class ConstructorInspectionTest method testQuickFix_classWithNonNullaryConstructor.
public void testQuickFix_classWithNonNullaryConstructor() {
ProblemDescriptorImpl problemDescriptorMock = mock(ProblemDescriptorImpl.class);
MockitoAnnotations.initMocks(this);
PsiElementFactory factory = JavaPsiFacade.getInstance(myFixture.getProject()).getElementFactory();
PsiClass psiClass = factory.createClass(getName());
PsiMethod nullaryConstructor = factory.createMethodFromText("public " + psiClass.getName() + "(String param) { }", psiClass);
psiClass.addAfter(nullaryConstructor, null);
ConstructorInspection constructorInspection = new ConstructorInspection();
ConstructorInspection.MyQuickFix myQuickFix = constructorInspection.new MyQuickFix(psiClass);
myQuickFix.applyFix(myFixture.getProject(), problemDescriptorMock);
Assert.assertEquals(2, psiClass.getConstructors().length);
Assert.assertTrue(EndpointUtilities.isPublicNullaryConstructor(psiClass.getConstructors()[0]));
}
Aggregations