summaryrefslogtreecommitdiff
path: root/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-07-25 13:10:36 -0700
committerTor Norbye <tnorbye@google.com>2014-07-25 13:10:36 -0700
commite5266e2343c8d275d79fa0be725180d0fe3a993c (patch)
tree0ba72f5de1949e0527874a799baa224cbe1537e0 /xml/impl/src/com/intellij/codeInsight/template/emmet/nodes
parentb03a5855292feb8c331815f883fe64372aacd872 (diff)
parent2e5965e996aad62ab1338b09d54caaf99ff3dd6a (diff)
downloadidea-e5266e2343c8d275d79fa0be725180d0fe3a993c.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into merge
Conflicts: .idea/modules.xml Change-Id: I5e3d04bc83cdc26b2b56fca66b44b1dd8941b143
Diffstat (limited to 'xml/impl/src/com/intellij/codeInsight/template/emmet/nodes')
-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
11 files changed, 101 insertions, 18 deletions
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";
}