summaryrefslogtreecommitdiff
path: root/xml/impl/src/com/intellij
diff options
context:
space:
mode:
Diffstat (limited to 'xml/impl/src/com/intellij')
-rw-r--r--xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java2
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetException.java22
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java4
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewUtil.java17
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java38
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/generators/LoremGenerator.java5
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java7
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/AddOperationNode.java5
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ClimbUpOperationNode.java7
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/FilterNode.java8
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/LoremNode.java9
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java9
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MulOperationNode.java8
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TemplateNode.java29
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TextNode.java21
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/UnaryMulOperationNode.java10
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenCodingNode.java5
-rw-r--r--xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenEmptyNode.java8
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java14
-rw-r--r--xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java8
-rw-r--r--xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java10
-rw-r--r--xml/impl/src/com/intellij/xml/util/UserColorLookup.java3
22 files changed, 200 insertions, 49 deletions
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 6781db72e93a..91fcf3944d89 100644
--- a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
+++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
@@ -44,7 +44,7 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp
private boolean myBemFilterEnabledByDefault = false;
private boolean myEmmetEnabled = true;
private int myEmmetExpandShortcut = TemplateSettings.TAB_CHAR;
- private boolean myFuzzySearchEnabled = true;
+ private boolean myFuzzySearchEnabled = false;
private boolean myAutoInsertCssPrefixedEnabled = true;
private boolean myPreviewEnabled = false;
private Set<String> myFiltersEnabledByDefault = ContainerUtil.newHashSet();
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetException.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetException.java
new file mode 100644
index 000000000000..0105408ea790
--- /dev/null
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetException.java
@@ -0,0 +1,22 @@
+/*
+ * 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 com.intellij.codeInsight.template.emmet;
+
+public class EmmetException extends Exception {
+ public EmmetException() {
+ super("Cannot expand emmet abbreviation: output is too big");
+ }
+}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java
index edde5a83a6d6..f9777958e689 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java
@@ -147,7 +147,7 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable {
EditorFactory editorFactory = EditorFactory.getInstance();
Document document = editorFactory.createDocument(templateText);
final EditorEx previewEditor = (EditorEx)editorFactory.createEditor(document, parentEditor.getProject(), fileType, true);
- EditorSettings settings = previewEditor.getSettings();
+ final EditorSettings settings = previewEditor.getSettings();
settings.setLineNumbersShown(false);
settings.setAdditionalLinesCount(1);
settings.setAdditionalColumnsCount(1);
@@ -172,7 +172,7 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable {
int maxWidth = (int)parentEditorSize.getWidth() / 3;
int maxHeight = (int)parentEditorSize.getHeight() / 2;
Dimension contentSize = previewEditor.getContentSize();
- return new Dimension(maxWidth > contentSize.getWidth() ? (int)size.getWidth() : maxWidth,
+ return new Dimension(maxWidth > contentSize.getWidth() && !settings.isUseSoftWraps() ? (int)size.getWidth() : maxWidth,
maxHeight > contentSize.getHeight() ? (int)size.getHeight() : maxHeight);
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewUtil.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewUtil.java
index af106929bcea..a82ab071846b 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewUtil.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewUtil.java
@@ -61,12 +61,19 @@ public class EmmetPreviewUtil {
if (generator != null && generator instanceof XmlZenCodingGenerator) {
final String templatePrefix = new ZenCodingTemplate().computeTemplateKeyWithoutContextChecking(callback);
if (templatePrefix != null) {
- ZenCodingTemplate.expand(templatePrefix, callback, generator, Collections.<ZenCodingFilter>emptyList(), expandPrimitiveAbbreviations, 0);
- TemplateImpl template = generatedTemplate.get();
- String templateText = template != null ? template.getTemplateText() : null;
- if (!StringUtil.isEmpty(templateText)) {
- return template.isToReformat() ? reformatTemplateText(file, templateText) : templateText;
+ try {
+ ZenCodingTemplate.expand(templatePrefix, callback, generator, Collections.<ZenCodingFilter>emptyList(),
+ expandPrimitiveAbbreviations, 0);
+ TemplateImpl template = generatedTemplate.get();
+ String templateText = template != null ? template.getTemplateText() : null;
+ if (!StringUtil.isEmpty(templateText)) {
+ return template.isToReformat() ? reformatTemplateText(file, templateText) : templateText;
+ }
}
+ catch (EmmetException e) {
+ return e.getMessage();
+ }
+
}
}
}
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 b0d623683912..f27903a49b5b 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
@@ -52,6 +52,7 @@ import com.intellij.patterns.StandardPatterns;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.ui.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlBundle;
@@ -124,7 +125,12 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
public void expand(@NotNull String key, @NotNull CustomTemplateCallback callback) {
ZenCodingGenerator defaultGenerator = findApplicableDefaultGenerator(callback.getContext(), false);
assert defaultGenerator != null;
- expand(key, callback, defaultGenerator, Collections.<ZenCodingFilter>emptyList(), true, Registry.intValue("emmet.segments.limit"));
+ try {
+ expand(key, callback, defaultGenerator, Collections.<ZenCodingFilter>emptyList(), true, Registry.intValue("emmet.segments.limit"));
+ }
+ catch (EmmetException e) {
+ CommonRefactoringUtil.showErrorHint(callback.getProject(), callback.getEditor(), e.getMessage(), "Emmet error", "");
+ }
}
@Nullable
@@ -182,7 +188,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
public static void expand(@NotNull String key, @NotNull CustomTemplateCallback callback,
@NotNull ZenCodingGenerator defaultGenerator,
@NotNull Collection<? extends ZenCodingFilter> extraFilters,
- boolean expandPrimitiveAbbreviations, int segmentsLimit) {
+ boolean expandPrimitiveAbbreviations, int segmentsLimit) throws EmmetException {
final ZenCodingNode node = parse(key, callback, defaultGenerator, null);
if (node == null) {
return;
@@ -204,6 +210,8 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
List<ZenCodingFilter> filters = getFilters(node, context);
filters.addAll(extraFilters);
+ checkTemplateOutputLength(node, callback);
+
callback.deleteTemplateKey(key);
expand(node, generator, filters, null, callback, expandPrimitiveAbbreviations, segmentsLimit);
}
@@ -212,7 +220,10 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
ZenCodingGenerator generator,
List<ZenCodingFilter> filters,
String surroundedText,
- CustomTemplateCallback callback, boolean expandPrimitiveAbbreviations, int segmentsLimit) {
+ CustomTemplateCallback callback, boolean expandPrimitiveAbbreviations, int segmentsLimit) throws EmmetException {
+
+ checkTemplateOutputLength(node, callback);
+
if (surroundedText != null) {
surroundedText = surroundedText.trim();
}
@@ -282,6 +293,13 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
});
}
+ private static void checkTemplateOutputLength(ZenCodingNode node, CustomTemplateCallback callback) throws EmmetException {
+ int predictedOutputLength = node.getApproximateOutputLength(callback);
+ if (predictedOutputLength > 15 * 1024) {
+ throw new EmmetException();
+ }
+ }
+
private static boolean isPrimitiveNode(@NotNull ZenCodingNode node) {
if (node instanceof TemplateNode) {
final TemplateToken token = ((TemplateNode)node).getTemplateToken();
@@ -434,7 +452,12 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
EditorModificationUtil.deleteSelectedText(callback.getEditor());
PsiDocumentManager.getInstance(callback.getProject()).commitAllDocuments();
- expand(node, generator, filters, selection, callback, true, Registry.intValue("emmet.segments.limit"));
+ try {
+ expand(node, generator, filters, selection, callback, true, Registry.intValue("emmet.segments.limit"));
+ }
+ catch (EmmetException e) {
+ CommonRefactoringUtil.showErrorHint(callback.getProject(), callback.getEditor(), e.getMessage(), "Emmet error", "");
+ }
}
}
});
@@ -509,7 +532,12 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase {
if (!regularTemplateWithSamePrefixExists) {
// exclude perfect matches with existing templates because LiveTemplateCompletionContributor handles it
final Collection<SingleLineEmmetFilter> extraFilters = ContainerUtil.newLinkedList(new SingleLineEmmetFilter());
- expand(templatePrefix, callback, generator, extraFilters, false, 0);
+ try {
+ expand(templatePrefix, callback, generator, extraFilters, false, 0);
+ }
+ catch (EmmetException e) {
+ generatedTemplate.set(null);
+ }
if (!generatedTemplate.isNull()) {
final TemplateImpl template = generatedTemplate.get();
template.setKey(templatePrefix);
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/LoremGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/LoremGenerator.java
index a5f4aeef5f0d..37b6d4b15b53 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/LoremGenerator.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/LoremGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.template.emmet.generators;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ArrayUtil;
import java.util.*;
@@ -145,7 +146,7 @@ public class LoremGenerator {
result.add(words[i]);
}
- return result.toArray(new String[result.size()]);
+ return ArrayUtil.toStringArray(result);
}
private char choice(String values) {
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java
index ef57f5ed4e49..c1732a306120 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java
@@ -19,6 +19,8 @@ import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.codeInsight.template.emmet.ZenCodingTemplate;
import com.intellij.codeInsight.template.emmet.tokens.TemplateToken;
import com.intellij.codeInsight.template.impl.TemplateImpl;
+import com.intellij.diagnostic.AttachmentFactory;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.TextRange;
@@ -109,6 +111,11 @@ public abstract class XmlZenCodingGenerator extends ZenCodingGenerator {
prevVisibleLeaf = PsiTreeUtil.prevVisibleLeaf(prevVisibleLeaf);
}
+ if (startOffset < 0 || currentOffset > documentText.length() || currentOffset < startOffset) {
+ Logger.getInstance(getClass()).error("Error while calculating emmet abbreviation. Offset: " + currentOffset + "; Start: " + startOffset,
+ AttachmentFactory.createAttachment(editor.getDocument()));
+ return null;
+ }
String key = computeKey(documentText.subSequence(startOffset, currentOffset));
return !StringUtil.isEmpty(key) && ZenCodingTemplate.checkTemplateKey(key, callback, this) ? key : null;
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/AddOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/AddOperationNode.java
index c63375ef6808..12f2610962c4 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/AddOperationNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/AddOperationNode.java
@@ -65,4 +65,9 @@ public class AddOperationNode extends ZenCodingNode {
public String toString() {
return "+";
}
+
+ @Override
+ public int getApproximateOutputLength(CustomTemplateCallback callback) {
+ return myLeftOperand.getApproximateOutputLength(callback) + myRightOperand.getApproximateOutputLength(callback);
+ }
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ClimbUpOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ClimbUpOperationNode.java
index 1648a36f6408..28cc0a8c1533 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ClimbUpOperationNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ClimbUpOperationNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -71,4 +71,9 @@ public class ClimbUpOperationNode extends ZenCodingNode {
public String toString() {
return "^";
}
+
+ @Override
+ public int getApproximateOutputLength(CustomTemplateCallback callback) {
+ return myLeftOperand.getApproximateOutputLength(callback) + myRightOperand.getApproximateOutputLength(callback);
+ }
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/FilterNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/FilterNode.java
index 2de1c998e140..2ac50c7438aa 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/FilterNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/FilterNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * 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.
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -50,6 +51,11 @@ public class FilterNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ return myNode.getApproximateOutputLength(callback);
+ }
+
+ @Override
public String toString() {
return "Filter(" + myFilter + ")";
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/LoremNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/LoremNode.java
index 7beab3c721b4..542af14d8ec0 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/LoremNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/LoremNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.template.emmet.tokens.TemplateToken;
import com.intellij.codeInsight.template.impl.TemplateImpl;
import com.intellij.openapi.util.Couple;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
@@ -54,6 +55,12 @@ public class LoremNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+
+ return myWordsCount * 7;
+ }
+
+ @Override
public String toString() {
return "Lorem(" + myWordsCount + ")";
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java
index fa8021565511..0a1bea140d6b 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * 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.
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.openapi.util.text.LineTokenizer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -49,6 +50,12 @@ public class MoreOperationNode extends ZenCodingNode {
return ContainerUtil.newLinkedList(myLeftOperand, myRightOperand);
}
+ @Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ int mul = myLeftOperand instanceof MulOperationNode ? ((MulOperationNode)myLeftOperand).getRightOperand() : 1;
+ return myLeftOperand.getApproximateOutputLength(callback) + (myRightOperand.getApproximateOutputLength(callback) * mul);
+ }
+
@NotNull
@Override
public List<GenerationNode> expand(int numberInIteration,
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MulOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MulOperationNode.java
index ec9eee193c80..1934d9e07099 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MulOperationNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MulOperationNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * 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.
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -55,6 +56,11 @@ public class MulOperationNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ return myLeftOperand.getApproximateOutputLength(callback) * myRightOperand;
+ }
+
+ @Override
public String toString() {
return "*";
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TemplateNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TemplateNode.java
index 685f0b396899..28871e1069d6 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TemplateNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TemplateNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -60,21 +60,19 @@ public class TemplateNode extends ZenCodingNode {
String templateKey = templateToken.getKey();
if (myGenerator != null && StringUtil.containsChar(templateKey, '$') && callback.findApplicableTemplate(templateKey) == null) {
String newTemplateKey = ZenCodingUtil.replaceMarkers(templateKey, numberInIteration, totalIterations, surroundedText);
- TemplateToken newTemplateToken = new TemplateToken(newTemplateKey,
- templateToken.getAttribute2Value());
-
+ TemplateToken newTemplateToken = new TemplateToken(newTemplateKey, templateToken.getAttribute2Value());
TemplateImpl template = myGenerator.createTemplateByKey(newTemplateKey);
if (template != null) {
template.setDeactivated(true);
newTemplateToken.setTemplate(template, callback);
templateToken = newTemplateToken;
}
- }
+ }
- GenerationNode node = new GenerationNode(templateToken, numberInIteration, totalIterations,
- surroundedText, insertSurroundedTextAtTheEnd, parent);
- return Arrays.asList(node);
-}
+ GenerationNode node = new GenerationNode(templateToken, numberInIteration, totalIterations,
+ surroundedText, insertSurroundedTextAtTheEnd, parent);
+ return Arrays.asList(node);
+ }
@Override
public String toString() {
@@ -85,4 +83,17 @@ public class TemplateNode extends ZenCodingNode {
}
return "Template(" + result + ")";
}
+
+ @Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ TemplateImpl template = myTemplateToken.getTemplate();
+ if (template != null) {
+ int result = template.getTemplateText().length();
+ for (Couple<String> attribute : myTemplateToken.getAttribute2Value()) {
+ result += attribute.first.length() + attribute.second.length() + 4; //plus space, eq, quotes
+ }
+ return result;
+ }
+ return 0;
+ }
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TextNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TextNode.java
index e47de7a937cc..d619387ecf31 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TextNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/TextNode.java
@@ -1,3 +1,18 @@
+/*
+ * 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 com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
@@ -6,6 +21,7 @@ import com.intellij.codeInsight.template.emmet.tokens.TemplateToken;
import com.intellij.codeInsight.template.emmet.tokens.TextToken;
import com.intellij.codeInsight.template.impl.TemplateImpl;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
@@ -45,6 +61,11 @@ public class TextNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ return myText.length();
+ }
+
+ @Override
public String toString() {
return "Text(" + myText + ")";
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/UnaryMulOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/UnaryMulOperationNode.java
index 78eb446d1f59..96e1e2ec99ba 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/UnaryMulOperationNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/UnaryMulOperationNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * 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.
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.openapi.util.text.LineTokenizer;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -43,7 +44,7 @@ public class UnaryMulOperationNode extends ZenCodingNode {
CustomTemplateCallback callback,
boolean insertSurroundedTextAtTheEnd, GenerationNode parent) {
if (surroundedText == null) {
- return myOperand.expand(numberInIteration, totalIterations, surroundedText, callback, insertSurroundedTextAtTheEnd, parent);
+ return myOperand.expand(numberInIteration, totalIterations, null, callback, insertSurroundedTextAtTheEnd, parent);
}
String[] lines = LineTokenizer.tokenize(surroundedText, false);
List<GenerationNode> result = new ArrayList<GenerationNode>();
@@ -54,6 +55,11 @@ public class UnaryMulOperationNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ return myOperand.getApproximateOutputLength(callback);
+ }
+
+ @Override
public String toString() {
return "*";
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenCodingNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenCodingNode.java
index 550d05d5d186..d246f40007f4 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenCodingNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenCodingNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * 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.
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
@@ -35,4 +36,6 @@ public abstract class ZenCodingNode {
public List<ZenCodingNode> getChildren() {
return Collections.emptyList();
}
+
+ public abstract int getApproximateOutputLength(@Nullable CustomTemplateCallback callback);
}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenEmptyNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenEmptyNode.java
index 9b92681068cd..9282d36f1927 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenEmptyNode.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/ZenEmptyNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.emmet.nodes;
import com.intellij.codeInsight.template.CustomTemplateCallback;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
@@ -39,6 +40,11 @@ public class ZenEmptyNode extends ZenCodingNode {
}
@Override
+ public int getApproximateOutputLength(@Nullable CustomTemplateCallback callback) {
+ return 0;
+ }
+
+ @Override
public String toString() {
return "EMPTY_NODE";
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java
index a2d78ccb898b..ce51ee07eebc 100644
--- a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java
+++ b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java
@@ -17,7 +17,10 @@ package com.intellij.ide.browsers;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.SimpleModificationTracker;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SmartList;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
@@ -325,15 +328,6 @@ public class WebBrowserManager extends SimpleModificationTracker implements Pers
}
@NotNull
- @Deprecated
- /**
- * @deprecated Use {@link #getFirstBrowser(BrowserFamily)}
- */
- public WebBrowser getBrowser(@NotNull BrowserFamily family) {
- return getFirstBrowser(family);
- }
-
- @NotNull
public WebBrowser getFirstBrowser(@NotNull BrowserFamily family) {
for (ConfigurableWebBrowser browser : browsers) {
if (browser.isActive() && family.equals(browser.getFamily())) {
diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java
index 5dd70c03ec77..482828c24c5e 100644
--- a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java
+++ b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java
@@ -30,6 +30,7 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup
protected OpenInBrowserBaseGroupAction(boolean popup) {
super(popup);
+
Presentation p = getTemplatePresentation();
p.setText("Open in _Browser");
p.setDescription("Open selected file in browser");
@@ -76,9 +77,10 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup
public OpenInBrowserEditorContextBarGroupAction() {
super(false);
}
- }
- public void update(@NotNull AnActionEvent e) {
- e.getPresentation().setVisible(!ActionGroupUtil.isGroupEmpty(this, e));
+ @Override
+ public void update(@NotNull AnActionEvent e) {
+ e.getPresentation().setVisible(!WebBrowserManager.getInstance().getBrowsers().isEmpty());
+ }
}
} \ No newline at end of file
diff --git a/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java b/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java
index b774c8e9e82f..d5a8f7fa77f4 100644
--- a/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java
+++ b/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java
@@ -84,8 +84,14 @@ public class XMLColorsPage implements ColorSettingsPage {
" <indexitem text=\"rename\" target=\"refactoring.rename\"/>\n" +
" <indexitem text=\"move\" target=\"refactoring.move\"/>\n" +
" <indexitem text=\"migrate\" target=\"refactoring.migrate\"/>\n" +
- " <indexitem text=\"usage search\" target=\"find.findUsages\"/>\n&amp; &#x00B7;" +
- " <indexitem text=\"project\" target=\"project.management\"/>" +
+ " <indexitem text=\"usage search\" target=\"find.findUsages\"/>\n" +
+ " <someTextWithEntityRefs>&amp; &#x00B7;</someTextWithEntityRefs>\n" +
+ " <withCData><![CDATA[\n" +
+ " <object class=\"MyClass\" key=\"constant\">\n" +
+ " </object>\n" +
+ " ]]>\n" +
+ " </withCData>\n" +
+ " <indexitem text=\"project\" target=\"project.management\"/>\n" +
" <<bg><np>pf</np></bg>:foo <bg><np>pf</np></bg>:bar=\"bar\"/>\n" +
"</index>";
}
diff --git a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java
index 46c82f243787..ac6f473e5be2 100644
--- a/xml/impl/src/com/intellij/xml/util/UserColorLookup.java
+++ b/xml/impl/src/com/intellij/xml/util/UserColorLookup.java
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
+import java.util.List;
/**
* @author maxim
@@ -79,7 +80,7 @@ public class UserColorLookup extends LookupElementDecorator<LookupElement> {
context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
- ColorPickerListener[] listeners = ColorPickerListenerFactory.createListenersFor(element);
+ List<ColorPickerListener> listeners = ColorPickerListenerFactory.createListenersFor(element);
Color color = ColorChooser.chooseColor(WindowManager.getInstance().suggestParentWindow(context.getProject()),
XmlBundle.message("choose.color.dialog.title"), myColorAtCaret, true, listeners, true);