IDEA-150753 Make 'Collapse empty tag' quick fix available for tags with whitespace contents

This commit is contained in:
Dmitry Avdeev
2016-02-01 14:05:15 +03:00
parent 31a540caeb
commit d3843e7688
2 changed files with 6 additions and 1 deletions
@@ -34,4 +34,9 @@ public class CollapseTagTest extends LightPlatformCodeInsightFixtureTestCase{
PsiFile file = myFixture.configureByText(XmlFileType.INSTANCE, "<a> <caret> <b/> </a>");
assertFalse(new CollapseTagIntention().isAvailable(getProject(), myFixture.getEditor(), file));
}
public void testAlreadyCollapsed() throws Exception {
PsiFile file = myFixture.configureByText(XmlFileType.INSTANCE, "<a/>");
assertFalse(new CollapseTagIntention().isAvailable(getProject(), myFixture.getEditor(), file));
}
}
@@ -72,7 +72,7 @@ public class CollapseTagIntention implements LocalQuickFix, IntentionAction {
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
XmlTag tag = getTag(editor, file);
return tag != null && tag.getSubTags().length == 0 && tag.getValue().getTrimmedText().isEmpty();
return tag != null && !tag.isEmpty() && tag.getSubTags().length == 0 && tag.getValue().getTrimmedText().isEmpty();
}
@Override