Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-05-06 16:17:49 +04:00
17 changed files with 471 additions and 154 deletions
@@ -66,6 +66,13 @@
bundle="org.jetbrains.idea.devkit.DevKitBundle"
groupKey="inspections.group.name" enabledByDefault="true" level="WARNING"
implementationClass="org.jetbrains.idea.devkit.inspections.IntentionDescriptionNotFoundInspection"/>
<localInspection language="JAVA"
key="inspections.component.postfix.template.not.found.description.name"
bundle="org.jetbrains.idea.devkit.DevKitBundle"
groupKey="inspections.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="org.jetbrains.idea.devkit.inspections.PostfixTemplateDescriptionNotFoundInspection"/>
<localInspection shortName="ComponentRegistrationProblems"
bundle="org.jetbrains.idea.devkit.DevKitBundle" key="inspections.registration.problems.name"
groupKey="inspections.group.name"
@@ -0,0 +1,5 @@
<html>
<body>
Checks if postfix template (completion) has a description.
</body>
</html>
@@ -147,6 +147,9 @@ inspections.component.not.registered.option.ignore.non.public=Ignore non-public
inspections.component.not.registered.quickfix.family=Register Component
inspections.component.not.registered.quickfix.name=Register {0}
inspections.component.not.registered.quickfix.error=Cannot Register {0}
inspections.component.postfix.template.not.found.description.name=Postfix template Description Checker
InspectionUseGrayColor=Use Gray
ant.build.jar.comment=Build archive for plugin ''{0}''
ant.build.jar.description=Build plugin archive for module ''{0}''
@@ -0,0 +1,135 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.devkit.inspections;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix;
import org.jetbrains.idea.devkit.util.PsiUtil;
abstract class DescriptionNotFoundInspectionBase extends DevKitInspectionBase {
@Override
public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
final Project project = aClass.getProject();
final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
final Module module = ModuleUtilCore.findModuleForPsiElement(aClass);
if (nameIdentifier == null || module == null || !PsiUtil.isInstantiable(aClass)) return null;
final PsiClass base = JavaPsiFacade.getInstance(project).findClass(getClassName(), GlobalSearchScope.allScope(project));
if (base == null || !aClass.isInheritor(base, true)) return null;
String descriptionDir = getDescriptionDirName(aClass);
if (StringUtil.isEmptyOrSpaces(descriptionDir)) {
return null;
}
for (PsiDirectory description : getDescriptionsDirs(module)) {
PsiDirectory dir = description.findSubdirectory(descriptionDir);
if (dir == null) continue;
final PsiFile descr = dir.findFile("description.html");
if (descr != null) {
if (!hasBeforeAndAfterTemplate(dir.getVirtualFile())) {
PsiElement problem = aClass.getNameIdentifier();
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(problem == null ? nameIdentifier : problem,
getHasNotBeforeAfterError(),
isOnTheFly,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
return new ProblemDescriptor[]{problemDescriptor};
}
return null;
}
}
final PsiElement problem = aClass.getNameIdentifier();
final ProblemDescriptor problemDescriptor = manager
.createProblemDescriptor(problem == null ? nameIdentifier : problem,
getHasNotDescriptionError(), isOnTheFly, new LocalQuickFix[]{getFix(module, descriptionDir)},
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return new ProblemDescriptor[]{problemDescriptor};
}
protected CreateHtmlDescriptionFix getFix(Module module, String descriptionDir) {
return new CreateHtmlDescriptionFix(descriptionDir, module, true);
}
@Nullable
private static String getDescriptionDirName(PsiClass aClass) {
String descriptionDir = "";
PsiClass each = aClass;
while (each != null) {
String name = each.getName();
if (StringUtil.isEmptyOrSpaces(name)) {
return null;
}
descriptionDir = name + descriptionDir;
each = each.getContainingClass();
}
return descriptionDir;
}
private static boolean hasBeforeAndAfterTemplate(@NotNull VirtualFile dir) {
boolean hasBefore = false;
boolean hasAfter = false;
for (VirtualFile file : dir.getChildren()) {
String name = file.getName();
if (name.endsWith(".template")) {
if (name.startsWith("before.")) {
hasBefore = true;
}
else if (name.startsWith("after.")) {
hasAfter = true;
}
}
}
return hasBefore && hasAfter;
}
@Override
public boolean isEnabledByDefault() {
return true;
}
@NotNull
protected abstract String getClassName();
@NotNull
protected abstract String getHasNotDescriptionError();
@NotNull
protected abstract String getHasNotBeforeAfterError();
@NotNull
protected abstract PsiDirectory[] getDescriptionsDirs(@NotNull Module module);
}
@@ -15,118 +15,57 @@
*/
package org.jetbrains.idea.devkit.inspections;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix;
import org.jetbrains.idea.devkit.util.PsiUtil;
/**
* @author Konstantin Bulenkov
*/
public class IntentionDescriptionNotFoundInspection extends DevKitInspectionBase{
public class IntentionDescriptionNotFoundInspection extends DescriptionNotFoundInspectionBase {
@NonNls private static final String INTENTION = "com.intellij.codeInsight.intention.IntentionAction";
@NonNls private static final String INSPECTION_DESCRIPTIONS = "intentionDescriptions";
@Override
public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
final Project project = aClass.getProject();
final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
final Module module = ModuleUtil.findModuleForPsiElement(aClass);
if (nameIdentifier == null || module == null || !PsiUtil.isInstantiable(aClass)) return null;
final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INTENTION, GlobalSearchScope.allScope(project));
if (base == null || ! aClass.isInheritor(base, true)) return null;
String descriptionDir = getDescriptionDirName(aClass);
if (StringUtil.isEmptyOrSpaces(descriptionDir)) {
return null;
}
for (PsiDirectory description : getIntentionDescriptionsDirs(module)) {
PsiDirectory dir = description.findSubdirectory(descriptionDir);
if (dir == null) continue;
final PsiFile descr = dir.findFile("description.html");
if (descr != null) {
if (!hasBeforeAndAfterTemplate(dir.getVirtualFile())) {
PsiElement problem = aClass.getNameIdentifier();
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(problem == null ? nameIdentifier : problem,
"Intention must have 'before.*.template' and 'after.*.template' beside 'description.html'",
isOnTheFly,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
return new ProblemDescriptor[]{problemDescriptor};
}
return null;
}
}
final PsiElement problem = aClass.getNameIdentifier();
final ProblemDescriptor problemDescriptor = manager
.createProblemDescriptor(problem == null ? nameIdentifier : problem,
"Intention does not have a description", isOnTheFly, new LocalQuickFix[]{new CreateHtmlDescriptionFix(descriptionDir, module, true)},
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return new ProblemDescriptor[]{problemDescriptor};
protected CreateHtmlDescriptionFix getFix(Module module, String descriptionDir) {
return new CreateHtmlDescriptionFix(descriptionDir, module, true);
}
@Nullable
private static String getDescriptionDirName(PsiClass aClass) {
String descriptionDir = "";
PsiClass each = aClass;
while (each != null) {
String name = each.getName();
if (StringUtil.isEmptyOrSpaces(name)) {
return null;
}
descriptionDir = name + descriptionDir;
each = each.getContainingClass();
}
return descriptionDir;
@NotNull
protected String getClassName() {
return INTENTION;
}
private static boolean hasBeforeAndAfterTemplate(@NotNull VirtualFile dir) {
boolean hasBefore = false;
boolean hasAfter = false;
@NotNull
protected String getHasNotDescriptionError() {
return "Intention does not have a description";
}
for (VirtualFile file : dir.getChildren()) {
String name = file.getName();
if (name.endsWith(".template")) {
if (name.startsWith("before.")) {
hasBefore = true;
}
else if (name.startsWith("after.")) {
hasAfter = true;
}
}
}
return hasBefore && hasAfter;
@NotNull
protected String getHasNotBeforeAfterError() {
return "Intention must have 'before.*.template' and 'after.*.template' beside 'description.html'";
}
public static PsiDirectory[] getIntentionDescriptionsDirs(Module module) {
final PsiPackage aPackage = JavaPsiFacade.getInstance(module.getProject()).findPackage(INSPECTION_DESCRIPTIONS);
if (aPackage != null) {
return aPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
} else {
}
else {
return PsiDirectory.EMPTY_ARRAY;
}
}
@NotNull
protected PsiDirectory[] getDescriptionsDirs(@NotNull Module module) {
return getIntentionDescriptionsDirs(module);
}
@Nls
@NotNull
public String getDisplayName() {
@@ -137,9 +76,4 @@ public class IntentionDescriptionNotFoundInspection extends DevKitInspectionBase
public String getShortName() {
return "IntentionDescriptionNotFoundInspection";
}
@Override
public boolean isEnabledByDefault() {
return true;
}
}
@@ -0,0 +1,86 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.devkit.inspections;
import com.intellij.openapi.module.Module;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.devkit.DevKitBundle;
import org.jetbrains.idea.devkit.inspections.quickfix.CreateHtmlDescriptionFix;
import org.jetbrains.idea.devkit.inspections.quickfix.CreatePostfixTemplateHtmlDescriptionFix;
public class PostfixTemplateDescriptionNotFoundInspection extends DescriptionNotFoundInspectionBase {
private static final String POSTFIX_TEMPLATES = "postfixTemplates";
@NotNull
@Override
protected PsiDirectory[] getDescriptionsDirs(@NotNull Module module) {
return getPostfixTemplateDirectories(module);
}
@Override
protected CreateHtmlDescriptionFix getFix(Module module, String descriptionDir) {
return new CreatePostfixTemplateHtmlDescriptionFix(descriptionDir, module);
}
@NotNull
public static PsiDirectory[] getPostfixTemplateDirectories(Module module) {
final PsiPackage aPackage = JavaPsiFacade.getInstance(module.getProject()).findPackage(POSTFIX_TEMPLATES);
if (aPackage != null) {
return aPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
}
else {
return PsiDirectory.EMPTY_ARRAY;
}
}
@NotNull
@Override
protected String getHasNotDescriptionError() {
return "Postfix template does not have a description";
}
@NotNull
@Override
protected String getHasNotBeforeAfterError() {
return "Postfix template must have 'before.*.template' and 'after.*.template' beside 'description.html'";
}
@NotNull
@Override
protected String getClassName() {
return "com.intellij.codeInsight.template.postfix.templates.PostfixTemplate";
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return DevKitBundle.message("inspections.component.postfix.template.not.found.description.name");
}
@NotNull
@Override
public String getShortName() {
return "PostfixTemplateDescriptionNotFound";
}
}
@@ -57,75 +57,15 @@ import java.util.List;
* @author Konstantin Bulenkov
*/
public class CreateHtmlDescriptionFix implements LocalQuickFix, Iconable {
private final String myFilename;
private final Module myModule;
@NonNls private static final String TEMPLATE_NAME = "InspectionDescription.html";
private final String myFilename;
protected final Module myModule;
private final boolean isIntention;
public CreateHtmlDescriptionFix(String filename, Module module, boolean isIntention) {
myModule = module;
this.isIntention = isIntention;
myFilename = isIntention ? filename : filename + ".html";
}
@NotNull
public String getName() {
return DevKitBundle.message("create.description.file");
}
@NotNull
public String getFamilyName() {
return "DevKit";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiDirectory[] dirs;
if (isIntention) {
dirs = IntentionDescriptionNotFoundInspection.getIntentionDescriptionsDirs(myModule);
}
else {
dirs = InspectionDescriptionNotFoundInspection.getInspectionDescriptionsDirs(myModule);
}
final List<VirtualFile> virtualFiles = getPotentialRoots(myModule, dirs);
final VirtualFile[] roots = prepare(VfsUtil.toVirtualFileArray(virtualFiles));
if (roots.length == 1) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
createDescription(roots[0]);
}
});
}
else {
List<String> options = new ArrayList<String>();
for (VirtualFile file : roots) {
String path = file.getPresentableUrl() + File.separator + getDescriptionFolderName() + File.separator + myFilename;
if (isIntention) {
path += File.separator + "description.html";
}
options.add(path);
}
final JBList files = new JBList(ArrayUtil.toStringArray(options));
files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JBPopup popup = JBPopupFactory.getInstance()
.createListPopupBuilder(files)
.setTitle(DevKitBundle.message("select.target.location.of.description", myFilename))
.setItemChoosenCallback(new Runnable() {
public void run() {
final int index = files.getSelectedIndex();
if (0 <= index && index < roots.length) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
createDescription(roots[index]);
}
});
}
}
}).createPopup();
final Editor editor = FileEditorManager.getInstance(myModule.getProject()).getSelectedTextEditor();
if (editor == null) return;
popup.showInBestPositionFor(editor);
}
myFilename = getNormalizedFileName(filename);
}
private static List<VirtualFile> getPotentialRoots(Module module, PsiDirectory[] dirs) {
@@ -147,6 +87,80 @@ public class CreateHtmlDescriptionFix implements LocalQuickFix, Iconable {
}
}
private String getNormalizedFileName(String filename) {
return isIntention ? filename : filename + ".html";
}
@NotNull
public String getName() {
return DevKitBundle.message("create.description.file");
}
@NotNull
public String getFamilyName() {
return "DevKit";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiDirectory[] dirs;
dirs = getDirectories();
final List<VirtualFile> virtualFiles = getPotentialRoots(myModule, dirs);
final VirtualFile[] roots = prepare(VfsUtil.toVirtualFileArray(virtualFiles));
if (roots.length == 1) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
createDescription(roots[0]);
}
});
}
else {
List<String> options = new ArrayList<String>();
for (VirtualFile file : roots) {
String path = getPath(file);
options.add(path);
}
final JBList files = new JBList(ArrayUtil.toStringArray(options));
files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JBPopup popup = JBPopupFactory.getInstance()
.createListPopupBuilder(files)
.setTitle(DevKitBundle.message("select.target.location.of.description", myFilename))
.setItemChoosenCallback(new Runnable() {
public void run() {
final int index = files.getSelectedIndex();
if (0 <= index && index < roots.length) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
createDescription(roots[index]);
}
});
}
}
}).createPopup();
final Editor editor = FileEditorManager.getInstance(myModule.getProject()).getSelectedTextEditor();
if (editor == null) return;
popup.showInBestPositionFor(editor);
}
}
private String getPath(VirtualFile file) {
String path = file.getPresentableUrl() + File.separator + getDescriptionFolderName() + File.separator + myFilename;
if (isIntention) {
path += File.separator + "description.html";
}
return path;
}
protected PsiDirectory[] getDirectories() {
PsiDirectory[] dirs;
if (isIntention) {
dirs = IntentionDescriptionNotFoundInspection.getIntentionDescriptionsDirs(myModule);
}
else {
dirs = InspectionDescriptionNotFoundInspection.getInspectionDescriptionsDirs(myModule);
}
return dirs;
}
private void createDescription(VirtualFile root) {
if (!root.isDirectory()) return;
final PsiManager psiManager = PsiManager.getInstance(myModule.getProject());
@@ -169,7 +183,8 @@ public class CreateHtmlDescriptionFix implements LocalQuickFix, Iconable {
}
}
final FileTemplate descrTemplate = FileTemplateManager.getInstance().getJ2eeTemplate(TEMPLATE_NAME);
final PsiElement template = FileTemplateUtil.createFromTemplate(descrTemplate, isIntention? "description.html" : myFilename, null, descrRoot);
final PsiElement template =
FileTemplateUtil.createFromTemplate(descrTemplate, getNewFileName(), null, descrRoot);
if (template instanceof PsiFile) {
final VirtualFile file = ((PsiFile)template).getVirtualFile();
if (file != null) {
@@ -181,6 +196,10 @@ public class CreateHtmlDescriptionFix implements LocalQuickFix, Iconable {
}
}
private String getNewFileName() {
return isIntention ? "description.html" : myFilename;
}
public Icon getIcon(int flags) {
return new LayeredIcon(AllIcons.FileTypes.Html, AllIcons.Actions.New);
}
@@ -205,7 +224,7 @@ public class CreateHtmlDescriptionFix implements LocalQuickFix, Iconable {
return false;
}
private String getDescriptionFolderName() {
protected String getDescriptionFolderName() {
return isIntention ? "intentionDescriptions" : "inspectionDescriptions";
}
}
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.devkit.inspections.quickfix;
import com.intellij.openapi.module.Module;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.idea.devkit.inspections.PostfixTemplateDescriptionNotFoundInspection;
public class CreatePostfixTemplateHtmlDescriptionFix extends CreateHtmlDescriptionFix {
public CreatePostfixTemplateHtmlDescriptionFix(String filename, Module module) {
super(filename, module, true);
}
@Override
protected PsiDirectory[] getDirectories() {
return PostfixTemplateDescriptionNotFoundInspection.getPostfixTemplateDirectories(myModule);
}
@Override
protected String getDescriptionFolderName() {
return "postfixTemplates";
}
}
@@ -0,0 +1,6 @@
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
public class <caret>MyQuickFixTemplate extends PostfixTemplate {
}
@@ -0,0 +1,6 @@
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
public class <warning descr="Postfix template does not have a description">MyTemplate</warning> extends PostfixTemplate {
}
@@ -0,0 +1,6 @@
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
public class MyTemplateWithDescription extends PostfixTemplate {
}
@@ -0,0 +1,6 @@
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
public class <warning descr="Postfix template must have 'before.*.template' and 'after.*.template' beside 'description.html'">MyTemplateWithoutBeforeAfter</warning> extends PostfixTemplate{
}
@@ -0,0 +1,61 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.devkit.codeInsight;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import org.jetbrains.idea.devkit.inspections.PostfixTemplateDescriptionNotFoundInspection;
public class PostfixTemplateInspectionTest extends JavaCodeInsightFixtureTestCase {
@Override
protected String getBasePath() {
return PluginPathManager.getPluginHomePathRelative("devkit") + "/testData/codeInsight/postfixTemplates";
}
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(PostfixTemplateDescriptionNotFoundInspection.class);
myFixture.addClass("package com.intellij.codeInsight.template.postfix.templates; public class PostfixTemplate {}");
}
public void testHighlightingForDescription() {
myFixture.testHighlighting("MyTemplate.java");
}
public void testNoHighlighting() {
myFixture.copyDirectoryToProject("postfixTemplates", "postfixTemplates");
myFixture.testHighlighting("MyTemplateWithDescription.java");
}
public void testHighlightingForBeforeAfter() {
myFixture.copyDirectoryToProject("postfixTemplates", "postfixTemplates");
myFixture.testHighlighting("MyTemplateWithoutBeforeAfter.java");
}
public void testQuickFix() {
myFixture.configureByFiles("MyQuickFixTemplate.java");
IntentionAction item = myFixture.findSingleIntention("Create Description File");
myFixture.launchAction(item);
VirtualFile path = myFixture.findFileInTempDir("postfixTemplates/MyQuickFixTemplate/description.html");
assertNotNull(path);
assertTrue(path.exists());
}
}