summaryrefslogtreecommitdiff
path: root/xml
diff options
context:
space:
mode:
Diffstat (limited to 'xml')
-rw-r--r--xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java4
-rw-r--r--xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java8
-rw-r--r--xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java1
-rw-r--r--xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java9
-rw-r--r--xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java5
-rw-r--r--xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java24
-rw-r--r--xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java44
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/HtmlContextType.java4
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/XmlContextType.java8
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java10
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java37
-rw-r--r--xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java8
-rw-r--r--xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java8
-rw-r--r--xml/tests/src/com/intellij/codeInsight/editorActions/HtmlSelectWordTest.java44
-rw-r--r--xml/tests/testData/selectWord/selectClassNames/after1.html1
-rw-r--r--xml/tests/testData/selectWord/selectClassNames/after2.html1
-rw-r--r--xml/tests/testData/selectWord/selectClassNames/after3.html1
-rw-r--r--xml/tests/testData/selectWord/selectClassNames/after4.html1
-rw-r--r--xml/tests/testData/selectWord/selectClassNames/before.html1
-rw-r--r--xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java1
-rw-r--r--xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java33
21 files changed, 198 insertions, 55 deletions
diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java
index eee6ed52e305..635420098b6e 100644
--- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java
+++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
+import com.intellij.util.xml.Required;
import com.intellij.util.xml.XmlName;
import com.intellij.util.xml.impl.DomInvocationHandler;
import com.intellij.util.xml.impl.DomManagerImpl;
@@ -43,7 +44,8 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc
}
public boolean isRequired() {
- return false;
+ final Required required = myDescription.getAnnotation(Required.class);
+ return required != null && required.value();
}
public boolean isFixed() {
diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java
index 018de44b522d..d5894851bf93 100644
--- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java
+++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java
@@ -15,6 +15,7 @@
*/
package com.intellij.xml.impl.dom;
+import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightingAwareElementDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
@@ -36,7 +37,7 @@ import java.util.List;
/**
* @author mike
*/
-public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor {
+public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor implements XmlHighlightingAwareElementDescriptor {
private final DomChildrenDescription myChildrenDescription;
public DomElementXmlDescriptor(@NotNull final DomElement domElement) {
@@ -82,6 +83,11 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor {
return name;
}
+ @Override
+ public boolean shouldCheckRequiredAttributes() {
+ return false;
+ }
+
private static class MyRootDomChildrenDescription implements DomChildrenDescription {
private final DomElement myDomElement;
diff --git a/xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java b/xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java
index 0541efe026b1..651c71e7ee7d 100644
--- a/xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java
+++ b/xml/impl/src/com/intellij/application/options/XmlLanguageCodeStyleSettingsProvider.java
@@ -44,6 +44,7 @@ public class XmlLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSetti
public CommonCodeStyleSettings getDefaultCommonSettings() {
CommonCodeStyleSettings xmlSettings = new CommonCodeStyleSettings(getLanguage());
CommonCodeStyleSettings.IndentOptions indentOptions = xmlSettings.initIndentOptions();
+ xmlSettings.setForceArrangeMenuAvailable(true);
// HACK [yole]
if (PlatformUtils.isRubyMine()) {
indentOptions.INDENT_SIZE = 2;
diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
index d41799aab632..01f0e5d84428 100644
--- a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
+++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
@@ -18,6 +18,7 @@ package com.intellij.application.options.emmet;
import com.intellij.application.options.editor.WebEditorOptions;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.intellij.xml.XmlBundle;
import org.jetbrains.annotations.NotNull;
@@ -43,8 +44,8 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp
private int myEmmetExpandShortcut = WebEditorOptions.getInstance().getZenCodingExpandShortcut();
private boolean myFuzzySearchEnabled = true;
private boolean myAutoInsertCssPrefixedEnabled = true;
- @Nullable
- private Map<String, Integer> prefixes = null;
+ @NotNull
+ private Map<String, Integer> prefixes = ContainerUtil.newHashMap();
public boolean isBemFilterEnabledByDefault() {
@@ -121,7 +122,7 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp
return ServiceManager.getService(EmmetOptions.class);
}
- @Nullable
+ @NotNull
@Deprecated
//use {@link CssEmmetOptions}
public Map<String, Integer> getPrefixes() {
@@ -131,7 +132,7 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp
@SuppressWarnings("UnusedDeclaration")
@Deprecated
//use {@link CssEmmetOptions}
- public void setPrefixes(@Nullable Map<String, Integer> prefixes) {
+ public void setPrefixes(@NotNull Map<String, Integer> prefixes) {
this.prefixes = prefixes;
}
}
diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
index ed7102fd314b..d56b27def7ba 100644
--- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
+++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
@@ -289,7 +289,10 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
}
}
- checkRequiredAttributes(tag, name, elementDescriptor);
+ if (!(elementDescriptor instanceof XmlHighlightingAwareElementDescriptor) ||
+ ((XmlHighlightingAwareElementDescriptor)elementDescriptor).shouldCheckRequiredAttributes()) {
+ checkRequiredAttributes(tag, name, elementDescriptor);
+ }
if (elementDescriptor instanceof Validator) {
//noinspection unchecked
diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java
new file mode 100644
index 000000000000..2ef2f498151c
--- /dev/null
+++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightingAwareElementDescriptor.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2013 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 com.intellij.codeInsight.daemon.impl.analysis;
+
+/**
+ * @author Eugene.Kudelevsky
+ */
+public interface XmlHighlightingAwareElementDescriptor {
+
+ boolean shouldCheckRequiredAttributes();
+}
diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java
index 8cc670ecc513..cae403a9d85a 100644
--- a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java
+++ b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -41,11 +41,21 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.util.HtmlUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import java.util.LinkedList;
import java.util.List;
public class HtmlSelectioner extends AbstractWordSelectioner {
+ private static final SelectWordUtil.CharCondition JAVA_IDENTIFIER_AND_HYPHEN_CONDITION = new SelectWordUtil.CharCondition() {
+ @Override
+ public boolean value(char ch) {
+ return Character.isJavaIdentifierPart(ch) || ch == '-';
+ }
+ };
+
public boolean canSelect(PsiElement e) {
return canSelectElement(e);
}
@@ -57,7 +67,7 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
return false;
}
- public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
+ public List<TextRange> select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) {
List<TextRange> result;
if (!(e instanceof XmlToken) ||
@@ -77,11 +87,11 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
PsiFile psiFile = e.getContainingFile();
FileType fileType = psiFile.getVirtualFile().getFileType();
- addAttributeSelection(result, e);
+ addAttributeSelection(result, editor, editorText, e);
final FileViewProvider fileViewProvider = psiFile.getViewProvider();
for (Language lang : fileViewProvider.getLanguages()) {
final PsiFile langFile = fileViewProvider.getPsi(lang);
- if (langFile != psiFile) addAttributeSelection(result, fileViewProvider.findElementAt(cursorOffset, lang));
+ if (langFile != psiFile) addAttributeSelection(result, editor, editorText, fileViewProvider.findElementAt(cursorOffset, lang));
}
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(e.getProject(), psiFile.getVirtualFile());
@@ -92,11 +102,8 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
return result;
}
- private static void addTagSelection(CharSequence editorText,
- int cursorOffset,
- FileType fileType,
- EditorHighlighter highlighter,
- List<TextRange> result) {
+ private static void addTagSelection(CharSequence editorText, int cursorOffset, FileType fileType,
+ @NotNull EditorHighlighter highlighter, @NotNull List<TextRange> result) {
int start = cursorOffset;
while (true) {
@@ -136,7 +143,8 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
}
}
- private static void addAttributeSelection(List<TextRange> result, PsiElement e) {
+ private static void addAttributeSelection(@NotNull List<TextRange> result, @NotNull Editor editor,
+ @NotNull CharSequence editorText, @Nullable PsiElement e) {
final XmlAttribute attribute = PsiTreeUtil.getParentOfType(e, XmlAttribute.class);
if (attribute != null) {
@@ -144,6 +152,9 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
final XmlAttributeValue value = attribute.getValueElement();
if (value != null) {
+ if ("class".equalsIgnoreCase(attribute.getName())) {
+ addClassAttributeRanges(result, editor, editorText, value);
+ }
final TextRange range = value.getTextRange();
result.add(range);
if (value.getFirstChild() != null &&
@@ -153,4 +164,17 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
}
}
}
+
+ private static void addClassAttributeRanges(@NotNull List<TextRange> result, @NotNull Editor editor,
+ @NotNull CharSequence editorText, @NotNull XmlAttributeValue attributeValue) {
+ final TextRange attributeValueTextRange = attributeValue.getTextRange();
+ final LinkedList<TextRange> wordRanges = ContainerUtil.newLinkedList();
+ SelectWordUtil.addWordSelection(editor.getSettings().isCamelWords(), editorText, editor.getCaretModel().getOffset(), wordRanges,
+ JAVA_IDENTIFIER_AND_HYPHEN_CONDITION);
+ for (TextRange range : wordRanges) {
+ if (attributeValueTextRange.contains(range)) {
+ result.add(range);
+ }
+ }
+ }
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/HtmlContextType.java b/xml/impl/src/com/intellij/codeInsight/template/HtmlContextType.java
index 566309103d25..8dc1f1abfb4f 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/HtmlContextType.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/HtmlContextType.java
@@ -21,7 +21,7 @@ import com.intellij.lang.html.HTMLLanguage;
import com.intellij.lang.xhtml.XHTMLLanguage;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
import org.jetbrains.annotations.NotNull;
/**
@@ -34,7 +34,7 @@ public class HtmlContextType extends FileTypeBasedContextType {
@Override
public boolean isInContext(@NotNull PsiFile file, int offset) {
- return isMyLanguage(PsiUtilBase.getLanguageAtOffset(file, offset)) && !XmlContextType.isEmbeddedContent(file, offset);
+ return isMyLanguage(PsiUtilCore.getLanguageAtOffset(file, offset)) && !XmlContextType.isEmbeddedContent(file, offset);
}
static boolean isMyLanguage(Language language) {
diff --git a/xml/impl/src/com/intellij/codeInsight/template/XmlContextType.java b/xml/impl/src/com/intellij/codeInsight/template/XmlContextType.java
index 478fc007f063..7e9eb9cb8c3f 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/XmlContextType.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/XmlContextType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -20,7 +20,7 @@ import com.intellij.lang.Language;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
import org.jetbrains.annotations.NotNull;
/**
@@ -34,12 +34,12 @@ public class XmlContextType extends TemplateContextType {
@Override
public boolean isInContext(@NotNull PsiFile file, int offset) {
return file.getLanguage().isKindOf(XMLLanguage.INSTANCE) && !isEmbeddedContent(file, offset) &&
- !HtmlContextType.isMyLanguage(PsiUtilBase.getLanguageAtOffset(file, offset)) &&
+ !HtmlContextType.isMyLanguage(PsiUtilCore.getLanguageAtOffset(file, offset)) &&
file.getFileType() != StdFileTypes.JSPX && file.getFileType() != StdFileTypes.JSP;
}
public static boolean isEmbeddedContent(@NotNull final PsiFile file, final int offset) {
- Language languageAtOffset = PsiUtilBase.getLanguageAtOffset(file, offset);
+ Language languageAtOffset = PsiUtilCore.getLanguageAtOffset(file, offset);
return !(languageAtOffset.isKindOf(XMLLanguage.INSTANCE) || languageAtOffset instanceof XMLLanguage);
}
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
index f259f1741cf4..6fc27d723a62 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
@@ -248,9 +248,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
});
}
- public void wrap(final String selection,
- @NotNull final CustomTemplateCallback callback
- ) {
+ public void wrap(final String selection, @NotNull final CustomTemplateCallback callback) {
InputValidatorEx validator = new InputValidatorEx() {
public String getErrorText(String inputString) {
if (!checkTemplateKey(inputString, callback)) {
@@ -267,9 +265,9 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
return checkInput(inputString);
}
};
- final String abbreviation = Messages
- .showInputDialog(callback.getProject(), XmlBundle.message("zen.coding.enter.abbreviation.dialog.label"),
- XmlBundle.message("zen.coding.title"), Messages.getQuestionIcon(), "", validator);
+ final String abbreviation = Messages.showInputDialog(callback.getProject(),
+ XmlBundle.message("zen.coding.enter.abbreviation.dialog.label"),
+ XmlBundle.message("zen.coding.title"), Messages.getQuestionIcon(), "", validator);
if (abbreviation != null) {
doWrap(selection, abbreviation, callback);
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java
index 69b1adf67d8f..de39319a1726 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java
@@ -29,6 +29,8 @@ import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -36,6 +38,7 @@ import java.util.regex.Pattern;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.Iterables.*;
+import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.newLinkedList;
/**
@@ -53,15 +56,17 @@ public class BemEmmetFilter extends ZenCodingFilter {
private static final String MODIFIER_SEPARATOR = "_";
private static final String SHORT_ELEMENT_PREFIX = "-";
+ private static final Joiner ELEMENTS_JOINER = Joiner.on(ELEMENT_SEPARATOR).skipNulls();
private static final Splitter ELEMENTS_SPLITTER = Splitter.on(ELEMENT_SEPARATOR);
private static final Splitter MODIFIERS_SPLITTER = Splitter.on(MODIFIER_SEPARATOR).limit(2);
private static final Splitter CLASS_NAME_SPLITTER = Splitter.on(' ').trimResults().omitEmptyStrings();
private static final Joiner CLASS_NAME_JOINER = Joiner.on(' ');
private static final Function<String, String> CLASS_NAME_NORMALIZER = new Function<String, String>() {
+ @NotNull
@Override
public String apply(@NotNull String input) {
- if(!input.startsWith(SHORT_ELEMENT_PREFIX)) {
+ if (!input.startsWith(SHORT_ELEMENT_PREFIX)) {
return input;
}
@@ -122,7 +127,7 @@ public class BemEmmetFilter extends ZenCodingFilter {
return node;
}
- private static Iterable<String> processClassName(String className, GenerationNode node) {
+ private static Iterable<String> processClassName(String className, @NotNull GenerationNode node) {
className = fillWithBemElements(className, node);
className = fillWithBemModifiers(className, node);
@@ -155,20 +160,29 @@ public class BemEmmetFilter extends ZenCodingFilter {
@NotNull
private static BemState extractBemStateFromClassName(@NotNull String className) {
- BemState result = new BemState();
+ final BemState result = new BemState();
if (className.contains(ELEMENT_SEPARATOR)) {
- List<String> blockElements = newLinkedList(ELEMENTS_SPLITTER.split(className));
- result.setBlock(getFirst(blockElements, ""));
- if (blockElements.size() > 1) {
- List<String> elementModifiers = newLinkedList(MODIFIERS_SPLITTER.split(blockElements.get(1)));
- result.setElement(getFirst(elementModifiers, ""));
- if (elementModifiers.size() > 1) {
- result.setModifier(getLast(elementModifiers, ""));
+ final Iterator<String> elementsIterator = ELEMENTS_SPLITTER.split(className).iterator();
+ result.setBlock(elementsIterator.next());
+
+ final Collection<String> elementParts = newLinkedList();
+ while (elementsIterator.hasNext()) {
+ final String elementPart = elementsIterator.next();
+ if (!elementsIterator.hasNext()) {
+ final List<String> elementModifiers = newArrayList(MODIFIERS_SPLITTER.split(elementPart));
+ elementParts.add(getFirst(elementModifiers, null));
+ if (elementModifiers.size() > 1) {
+ result.setModifier(getLast(elementModifiers, ""));
+ }
+ }
+ else {
+ elementParts.add(elementPart);
}
}
+ result.setElement(ELEMENTS_JOINER.join(elementParts));
}
else if (className.contains(MODIFIER_SEPARATOR)) {
- Iterable<String> blockModifiers = MODIFIERS_SPLITTER.split(className);
+ final Iterable<String> blockModifiers = MODIFIERS_SPLITTER.split(className);
result.setBlock(getFirst(blockModifiers, ""));
result.setModifier(getLast(blockModifiers, ""));
}
@@ -322,6 +336,7 @@ public class BemEmmetFilter extends ZenCodingFilter {
return isNullOrEmpty(block) && isNullOrEmpty(element) && isNullOrEmpty(modifier);
}
+ @Nullable
public BemState copy() {
return new BemState(block, element, modifier);
}
diff --git a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java
index ed4c271996f2..ed0538bf6820 100644
--- a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java
+++ b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java
@@ -24,9 +24,7 @@ import com.intellij.lexer.XHtmlHighlightingLexer;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
-import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.util.containers.HashMap;
@@ -98,11 +96,7 @@ public class Html5CustomAttributesIndex extends ScalarIndexExtension<String> {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.HTML, StdFileTypes.XHTML) {
@Override
public boolean acceptInput(final VirtualFile file) {
- if (file.getFileSystem() != LocalFileSystem.getInstance() && !(file.getFileSystem() instanceof TempFileSystem)) {
- return false;
- }
-
- return true;
+ return file.isInLocalFileSystem();
}
};
}
diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java
index 10ef18756a18..d913b72782d3 100644
--- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java
+++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -27,8 +27,6 @@ import com.intellij.ide.TitledHandler;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -36,7 +34,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
-import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.refactoring.actions.BaseRefactoringAction;
@@ -115,7 +113,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler {
return file.getViewProvider().findElementAt(offset);
}
if (file != null) {
- final Language language = PsiUtilBase.getLanguageAtOffset(file, offset);
+ final Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
if (language != file.getLanguage()) {
final PsiFile psiAtOffset = file.getViewProvider().getPsi(language);
if (psiAtOffset instanceof XmlFile) {
diff --git a/xml/tests/src/com/intellij/codeInsight/editorActions/HtmlSelectWordTest.java b/xml/tests/src/com/intellij/codeInsight/editorActions/HtmlSelectWordTest.java
new file mode 100644
index 000000000000..5246b416fb58
--- /dev/null
+++ b/xml/tests/src/com/intellij/codeInsight/editorActions/HtmlSelectWordTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2013 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 com.intellij.codeInsight.editorActions;
+
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.TestDataPath;
+import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+
+import java.io.File;
+
+/**
+ * User: zolotov
+ * Date: 10/9/13
+ */
+@TestDataPath("$CONTENT_ROOT/testData/selectWord")
+public class HtmlSelectWordTest extends LightCodeInsightFixtureTestCase {
+
+ public void testSelectClassNames() {
+ doTest();
+ }
+
+ private void doTest() {
+ CodeInsightTestUtil.doWordSelectionTestOnDirectory(myFixture, getTestName(true), "html");
+ }
+
+ @Override
+ protected String getTestDataPath() {
+ return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/selectWord";
+ }
+}
diff --git a/xml/tests/testData/selectWord/selectClassNames/after1.html b/xml/tests/testData/selectWord/selectClassNames/after1.html
new file mode 100644
index 000000000000..d3c3e6a4116d
--- /dev/null
+++ b/xml/tests/testData/selectWord/selectClassNames/after1.html
@@ -0,0 +1 @@
+<div class="table <selection>table</selection>-condensed table-bordered"></div> \ No newline at end of file
diff --git a/xml/tests/testData/selectWord/selectClassNames/after2.html b/xml/tests/testData/selectWord/selectClassNames/after2.html
new file mode 100644
index 000000000000..01350eaa3647
--- /dev/null
+++ b/xml/tests/testData/selectWord/selectClassNames/after2.html
@@ -0,0 +1 @@
+<div class="table <selection>table-condensed</selection> table-bordered"></div> \ No newline at end of file
diff --git a/xml/tests/testData/selectWord/selectClassNames/after3.html b/xml/tests/testData/selectWord/selectClassNames/after3.html
new file mode 100644
index 000000000000..5f00748b7dd4
--- /dev/null
+++ b/xml/tests/testData/selectWord/selectClassNames/after3.html
@@ -0,0 +1 @@
+<div class="<selection>table table-condensed table-bordered</selection>"></div> \ No newline at end of file
diff --git a/xml/tests/testData/selectWord/selectClassNames/after4.html b/xml/tests/testData/selectWord/selectClassNames/after4.html
new file mode 100644
index 000000000000..5867b96596ad
--- /dev/null
+++ b/xml/tests/testData/selectWord/selectClassNames/after4.html
@@ -0,0 +1 @@
+<div class=<selection>"table table-condensed table-bordered"</selection>></div> \ No newline at end of file
diff --git a/xml/tests/testData/selectWord/selectClassNames/before.html b/xml/tests/testData/selectWord/selectClassNames/before.html
new file mode 100644
index 000000000000..5a9bb3ee5c50
--- /dev/null
+++ b/xml/tests/testData/selectWord/selectClassNames/before.html
@@ -0,0 +1 @@
+<div class="table tab<caret>le-condensed table-bordered"></div> \ No newline at end of file
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java b/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java
index 1759c8dccd99..2a29eea055f2 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java
@@ -55,6 +55,7 @@ public class DefaultXmlExtension extends XmlExtension {
for (int i = 0; i < descriptors.size(); i++) {
final XmlElementDescriptor descriptor = descriptors.get(i);
String qualifiedName = descriptor.getName(context);
+ LOG.assertTrue(qualifiedName != null, descriptor + " returned null name");
final int pos = qualifiedName.indexOf(':');
final String name = pos >= 0 ? qualifiedName.substring(pos + 1) : qualifiedName;
set.add(new TagInfo(name, nsInfo.get(i)) {
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
index b6e1f2f7720c..712cf2053f32 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
@@ -785,9 +785,8 @@ public class XmlUtil {
if (docType == null) {
final String publicId = doctype.getPublicId();
if (PsiTreeUtil.getParentOfType(doctype, XmlDocument.class) instanceof HtmlDocumentImpl &&
- publicId != null &&
- publicId.indexOf("-//W3C//DTD HTML") != -1) {
- return HTML4_LOOSE_URI;
+ publicId != null && publicId.contains("-//W3C//DTD ")) {
+ return guessDtdByPublicId(publicId);
}
else if (HtmlUtil.isHtml5Doctype(doctype)) {
docType = doctype.getLanguage() instanceof HTMLLanguage
@@ -800,6 +799,34 @@ public class XmlUtil {
return null;
}
+ private static String guessDtdByPublicId(String id) {
+ if (id.contains("XHTML")) {
+ if (id.contains("1.1")) {
+ if (id.contains("Basic")) {
+ return "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd";
+ }
+ return "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
+ } else {
+ if (id.contains("Strict")) {
+ return "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
+ } else if (id.contains("Frameset")) {
+ return "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";
+ } else if (id.contains("Transitional")) {
+ return "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
+ }
+ }
+ } else if (id.contains("HTML")) {
+ if (id.contains("Strict")) {
+ return "http://www.w3.org/TR/html4/strict.dtd";
+ }
+ else if (id.contains("Frameset")) {
+ return "http://www.w3.org/TR/html4/frameset.dtd";
+ }
+ return HTML4_LOOSE_URI;
+ }
+ return null;
+ }
+
private static void computeTag(XmlTag tag,
final Map<String, List<String>> tagsMap,
final Map<String, List<MyAttributeInfo>> attributesMap,