Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
9f77f11d
Commit
9f77f11d
authored
12 years ago
by
Alexander Zolotov
1
Browse files
Options
Download
Email Patches
Plain Diff
WEB-6827 Emmet "Surround with Live Template" creating wrong element
parent
a456f777
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java
+4
-1
...m/intellij/codeInsight/template/emmet/XmlEmmetParser.java
xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+5
-5
...ntellij/codeInsight/template/emmet/ZenCodingTemplate.java
xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java
+5
-2
...Insight/template/emmet/generators/ZenCodingGenerator.java
with
14 additions
and
8 deletions
+14
-8
xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java
+
4
-
1
View file @
9f77f11d
...
@@ -75,10 +75,13 @@ public class XmlEmmetParser extends EmmetParser {
...
@@ -75,10 +75,13 @@ public class XmlEmmetParser extends EmmetParser {
public
XmlEmmetParser
(
List
<
ZenCodingToken
>
tokens
,
public
XmlEmmetParser
(
List
<
ZenCodingToken
>
tokens
,
CustomTemplateCallback
callback
,
CustomTemplateCallback
callback
,
ZenCodingGenerator
generator
)
{
ZenCodingGenerator
generator
,
boolean
surroundWithTemplate
)
{
super
(
tokens
,
callback
,
generator
);
super
(
tokens
,
callback
,
generator
);
PsiElement
context
=
callback
.
getContext
();
PsiElement
context
=
callback
.
getContext
();
XmlTag
parentTag
=
PsiTreeUtil
.
getParentOfType
(
context
,
XmlTag
.
class
);
XmlTag
parentTag
=
PsiTreeUtil
.
getParentOfType
(
context
,
XmlTag
.
class
);
if
(
surroundWithTemplate
&&
parentTag
!=
null
)
{
parentTag
=
PsiTreeUtil
.
getParentOfType
(
parentTag
,
XmlTag
.
class
);
}
if
(
parentTag
!=
null
)
{
if
(
parentTag
!=
null
)
{
hasTagContext
=
true
;
hasTagContext
=
true
;
tagLevel
.
push
(
parentTag
.
getName
());
tagLevel
.
push
(
parentTag
.
getName
());
...
...
This diff is collapsed.
Click to expand it.
xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+
5
-
5
View file @
9f77f11d
...
@@ -67,7 +67,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
...
@@ -67,7 +67,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
@Nullable
@Nullable
private
static
ZenCodingNode
parse
(
@NotNull
String
text
,
private
static
ZenCodingNode
parse
(
@NotNull
String
text
,
@NotNull
CustomTemplateCallback
callback
,
@NotNull
CustomTemplateCallback
callback
,
@NotNull
ZenCodingGenerator
generator
)
{
@NotNull
ZenCodingGenerator
generator
,
@Nullable
String
surroundedText
)
{
List
<
ZenCodingToken
>
tokens
=
new
EmmetLexer
().
lex
(
text
);
List
<
ZenCodingToken
>
tokens
=
new
EmmetLexer
().
lex
(
text
);
if
(
tokens
==
null
)
{
if
(
tokens
==
null
)
{
return
null
;
return
null
;
...
@@ -75,7 +75,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
...
@@ -75,7 +75,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
if
(!
validate
(
tokens
,
generator
))
{
if
(!
validate
(
tokens
,
generator
))
{
return
null
;
return
null
;
}
}
EmmetParser
parser
=
generator
.
createParser
(
tokens
,
callback
,
generator
);
EmmetParser
parser
=
generator
.
createParser
(
tokens
,
callback
,
generator
,
surroundedText
!=
null
);
ZenCodingNode
node
=
parser
.
parse
();
ZenCodingNode
node
=
parser
.
parse
();
if
(
parser
.
getIndex
()
!=
tokens
.
size
()
||
node
instanceof
TextNode
)
{
if
(
parser
.
getIndex
()
!=
tokens
.
size
()
||
node
instanceof
TextNode
)
{
return
null
;
return
null
;
...
@@ -93,7 +93,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
...
@@ -93,7 +93,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
}
}
public
static
boolean
checkTemplateKey
(
@NotNull
String
key
,
CustomTemplateCallback
callback
,
@NotNull
ZenCodingGenerator
generator
)
{
public
static
boolean
checkTemplateKey
(
@NotNull
String
key
,
CustomTemplateCallback
callback
,
@NotNull
ZenCodingGenerator
generator
)
{
return
parse
(
key
,
callback
,
generator
)
!=
null
;
return
parse
(
key
,
callback
,
generator
,
null
)
!=
null
;
}
}
public
void
expand
(
String
key
,
@NotNull
CustomTemplateCallback
callback
)
{
public
void
expand
(
String
key
,
@NotNull
CustomTemplateCallback
callback
)
{
...
@@ -158,7 +158,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
...
@@ -158,7 +158,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
@NotNull
CustomTemplateCallback
callback
,
@NotNull
CustomTemplateCallback
callback
,
String
surroundedText
,
String
surroundedText
,
@NotNull
ZenCodingGenerator
defaultGenerator
)
{
@NotNull
ZenCodingGenerator
defaultGenerator
)
{
ZenCodingNode
node
=
parse
(
key
,
callback
,
defaultGenerator
);
ZenCodingNode
node
=
parse
(
key
,
callback
,
defaultGenerator
,
surroundedText
);
assert
node
!=
null
;
assert
node
!=
null
;
if
(
surroundedText
==
null
)
{
if
(
surroundedText
==
null
)
{
if
(
node
instanceof
TemplateNode
)
{
if
(
node
instanceof
TemplateNode
)
{
...
@@ -298,7 +298,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
...
@@ -298,7 +298,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
CommandProcessor
.
getInstance
().
executeCommand
(
callback
.
getProject
(),
new
Runnable
()
{
CommandProcessor
.
getInstance
().
executeCommand
(
callback
.
getProject
(),
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
callback
.
fixInitialState
(
true
);
callback
.
fixInitialState
(
true
);
ZenCodingNode
node
=
parse
(
abbreviation
,
callback
,
defaultGenerator
);
ZenCodingNode
node
=
parse
(
abbreviation
,
callback
,
defaultGenerator
,
selection
);
assert
node
!=
null
;
assert
node
!=
null
;
PsiElement
context
=
callback
.
getContext
();
PsiElement
context
=
callback
.
getContext
();
ZenCodingGenerator
generator
=
findApplicableGenerator
(
node
,
context
,
true
);
ZenCodingGenerator
generator
=
findApplicableGenerator
(
node
,
context
,
true
);
...
...
This diff is collapsed.
Click to expand it.
xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java
+
5
-
2
View file @
9f77f11d
...
@@ -159,7 +159,10 @@ public abstract class ZenCodingGenerator {
...
@@ -159,7 +159,10 @@ public abstract class ZenCodingGenerator {
}
}
@NotNull
@NotNull
public
EmmetParser
createParser
(
List
<
ZenCodingToken
>
tokens
,
CustomTemplateCallback
callback
,
ZenCodingGenerator
generator
)
{
public
EmmetParser
createParser
(
List
<
ZenCodingToken
>
tokens
,
return
new
XmlEmmetParser
(
tokens
,
callback
,
generator
);
CustomTemplateCallback
callback
,
ZenCodingGenerator
generator
,
boolean
surroundWithTemplate
)
{
return
new
XmlEmmetParser
(
tokens
,
callback
,
generator
,
surroundWithTemplate
);
}
}
}
}
This diff is collapsed.
Click to expand it.
小 白蛋
@baidan
mentioned in commit
44cbeb0e
·
2 years ago
mentioned in commit
44cbeb0e
mentioned in commit 44cbeb0e43a983672ff583c250c7a3ad3540a72e
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment