-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #10 Parsing Less Functions containing default values gets interpr…
…eted as Pseudo-Elements
- Loading branch information
Showing
34 changed files
with
405 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
...s/src/test/resources/checks/common/experimental-pseudo-usage/experimentalPseudoUsage.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#fullscreen:fullscreen > h1 { /* Noncompliant ![sc=13;ec=23;el=+0]! !{Remove this usage of the experimental "fullscreen" pseudo.}! */ | ||
color: red; | ||
} | ||
|
||
#id:-moz-abc { /* Noncompliant ![sc=5;ec=13;el=+0]! !{Remove this usage of the experimental "abc" pseudo.}! */ | ||
color: red; | ||
} | ||
|
||
p:dir(ltr) { /* Noncompliant ![sc=3;ec=6;el=+0]! !{Remove this usage of the experimental "dir" pseudo.}! */ | ||
color: red; | ||
} | ||
|
||
p:-moz-abc(ltr) { /* Noncompliant ![sc=3;ec=11;el=+0]! !{Remove this usage of the experimental "abc" pseudo.}! */ | ||
color: red; | ||
} | ||
|
||
:host { /* Noncompliant ![sc=2;ec=6;el=+0]! !{Remove this usage of the experimental "host" pseudo.}! */ | ||
color: red; | ||
} | ||
|
||
p:empty { | ||
color: red; | ||
} | ||
|
||
p:not(.mybox) { | ||
color: red; | ||
} | ||
|
||
.animation (@animation-name, @animation-count: infinte, @timing-function:linear) { | ||
color: #000000; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...nd/src/main/java/org/sonar/css/tree/impl/less/LessMixinParameterDefaultValueTreeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* SonarQube CSS / SCSS / Less Analyzer | ||
* Copyright (C) 2013-2017 David RACODON | ||
* mailto: [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.css.tree.impl.less; | ||
|
||
import com.google.common.collect.Iterators; | ||
import org.sonar.css.tree.impl.TreeImpl; | ||
import org.sonar.plugins.css.api.tree.Tree; | ||
import org.sonar.plugins.css.api.tree.css.SyntaxToken; | ||
import org.sonar.plugins.css.api.tree.css.ValueTree; | ||
import org.sonar.plugins.css.api.tree.less.LessMixinParameterDefaultValueTree; | ||
import org.sonar.plugins.css.api.visitors.DoubleDispatchVisitor; | ||
|
||
import java.util.Iterator; | ||
|
||
public class LessMixinParameterDefaultValueTreeImpl extends TreeImpl implements LessMixinParameterDefaultValueTree { | ||
|
||
private final SyntaxToken colon; | ||
private final ValueTree value; | ||
|
||
public LessMixinParameterDefaultValueTreeImpl(SyntaxToken colon, ValueTree value) { | ||
this.colon = colon; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Kind getKind() { | ||
return Kind.LESS_MIXIN_PARAMETER_DEFAULT_VALUE; | ||
} | ||
|
||
@Override | ||
public Iterator<Tree> childrenIterator() { | ||
return Iterators.forArray(colon, value); | ||
} | ||
|
||
@Override | ||
public void accept(DoubleDispatchVisitor visitor) { | ||
visitor.visitLessMixinParameterDefaultValue(this); | ||
} | ||
|
||
@Override | ||
public SyntaxToken colon() { | ||
return colon; | ||
} | ||
|
||
@Override | ||
public ValueTree value() { | ||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...src/main/java/org/sonar/plugins/css/api/tree/less/LessMixinParameterDefaultValueTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SonarQube CSS / SCSS / Less Analyzer | ||
* Copyright (C) 2013-2017 David RACODON | ||
* mailto: [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.plugins.css.api.tree.less; | ||
|
||
import org.sonar.plugins.css.api.tree.Tree; | ||
import org.sonar.plugins.css.api.tree.css.SyntaxToken; | ||
import org.sonar.plugins.css.api.tree.css.ValueTree; | ||
|
||
public interface LessMixinParameterDefaultValueTree extends Tree { | ||
|
||
SyntaxToken colon(); | ||
|
||
ValueTree value(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ntend/src/test/java/org/sonar/css/parser/less/LessMixinParameterDefaultValueTreeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SonarQube CSS / SCSS / Less Analyzer | ||
* Copyright (C) 2013-2017 David RACODON | ||
* mailto: [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.css.parser.less; | ||
|
||
import org.junit.Test; | ||
import org.sonar.css.parser.LexicalGrammar; | ||
import org.sonar.plugins.css.api.tree.less.LessMixinParameterDefaultValueTree; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class LessMixinParameterDefaultValueTreeTest extends LessTreeTest { | ||
|
||
public LessMixinParameterDefaultValueTreeTest() { | ||
super(LexicalGrammar.LESS_MIXIN_PARAMETER_DEFAULT_VALUE); | ||
} | ||
|
||
@Test | ||
public void lessMixinParameterDefaultValue() { | ||
checkParsed(":abc"); | ||
checkParsed(": abc"); | ||
checkParsed(" : abc"); | ||
} | ||
|
||
private LessMixinParameterDefaultValueTree checkParsed(String toParse) { | ||
LessMixinParameterDefaultValueTree tree = (LessMixinParameterDefaultValueTree) parser().parse(toParse); | ||
assertThat(tree.colon()).isNotNull(); | ||
assertThat(tree.value()).isNotNull(); | ||
return tree; | ||
} | ||
|
||
} |
Oops, something went wrong.