use of com.intellij.codeInsight.intention.IntentionAction in project kotlin by JetBrains.
the class AbstractIntentionTest method createIntention.
private IntentionAction createIntention(File testDataFile) throws Exception {
List<File> candidateFiles = Lists.newArrayList();
File current = testDataFile.getParentFile();
while (current != null) {
File candidate = new File(current, intentionFileName());
if (candidate.exists()) {
candidateFiles.add(candidate);
}
current = current.getParentFile();
}
if (candidateFiles.isEmpty()) {
throw new AssertionError(".intention file is not found for " + testDataFile + "\nAdd it to base directory of test data. It should contain fully-qualified name of intention class.");
}
if (candidateFiles.size() > 1) {
throw new AssertionError("Several .intention files are available for " + testDataFile + "\nPlease remove some of them\n" + candidateFiles);
}
String className = FileUtil.loadFile(candidateFiles.get(0)).trim();
return (IntentionAction) Class.forName(className).newInstance();
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-plugins by JetBrains.
the class PackageAccessibilityInspectionTest method doTestFix.
private void doTestFix(String classText, String manifestText, String expected) {
myFixture.enableInspections(new PackageAccessibilityInspection());
PsiFile manifest = myFixture.addFileToProject("META-INF/MANIFEST.MF", manifestText);
myFixture.configureByText("C.java", classText);
IntentionAction intention = myFixture.findSingleIntention(OsmorcBundle.message("PackageAccessibilityInspection.fix"));
myFixture.launchAction(intention);
assertEquals(expected, manifest.getText());
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-plugins by JetBrains.
the class StrutsFileSetCheckingAnnotatorTest method testStrutsXmlNoFacetSetup.
public void testStrutsXmlNoFacetSetup() throws Throwable {
final IntentionAction intention = myFixture.getAvailableIntention("Edit Struts 2 facet settings", "struts-simple.xml");
assertIntentionFound(intention);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-plugins by JetBrains.
the class StrutsIntentionTest method testCreateActionMethodIntention.
/**
* Check {@link com.intellij.struts2.dom.struts.action.ActionMethodConverter}.
*
* @throws Throwable Any exceptions.
*/
public void testCreateActionMethodIntention() throws Throwable {
createStrutsFileSet("struts-action-method.xml");
final List<IntentionAction> list = myFixture.getAllQuickFixes("struts-action-method.xml");
final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, "Create action-method 'unknownMethod'");
assertNotNull(action);
// myFixture.launchAction(action);
// myFixture.checkResultByFile("/src/MyClass.java", "/src/MyClassAfterCreateActionMethod.java", false);
}
use of com.intellij.codeInsight.intention.IntentionAction in project intellij-plugins by JetBrains.
the class TsLintExternalAnnotator method apply.
@Override
public void apply(@NotNull PsiFile file, @Nullable JSLinterAnnotationResult<TsLintState> annotationResult, @NotNull AnnotationHolder holder) {
if (annotationResult == null)
return;
TsLintConfigurable configurable = new TsLintConfigurable(file.getProject(), true);
final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
IntentionAction fixAllFileIntention = new TsLintFileFixAction().asIntentionAction();
JSLinterStandardFixes fixes = new JSLinterStandardFixes() {
@Override
public List<IntentionAction> createListForError(@Nullable VirtualFile configFile, @NotNull UntypedJSLinterConfigurable configurable, @NotNull JSLinterErrorBase errorBase) {
List<IntentionAction> defaultIntentions = super.createListForError(configFile, configurable, errorBase);
if (errorBase instanceof TsLinterError && ((TsLinterError) errorBase).hasFix()) {
ArrayList<IntentionAction> result = ContainerUtil.newArrayList();
if (document != null && myOnTheFly) {
result.add(new TsLintErrorFixAction((TsLinterError) errorBase, document));
}
result.add(fixAllFileIntention);
result.addAll(defaultIntentions);
return result;
}
return defaultIntentions;
}
};
new JSLinterAnnotationsBuilder<>(file, annotationResult, holder, TsLintInspection.getHighlightDisplayKey(), configurable, TsLintBundle.message("tslint.framework.title") + ": ", getInspectionClass(), fixes).setHighlightingGranularity(HighlightingGranularity.element).apply(document);
}
Aggregations