本文整理汇总了Java中com.google.common.css.SourceCodeLocation类的典型用法代码示例。如果您正苦于以下问题:Java SourceCodeLocation类的具体用法?Java SourceCodeLocation怎么用?Java SourceCodeLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SourceCodeLocation类属于com.google.common.css包,在下文中一共展示了SourceCodeLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CssForLoopRuleNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
public CssForLoopRuleNode(CssLiteralNode name,
CssAbstractBlockNode block,
@Nullable List<CssCommentNode> comments,
CssValueNode from,
CssValueNode to,
CssValueNode step,
String variableName,
int loopId,
@Nullable SourceCodeLocation sourceCodeLocation) {
super(CssAtRuleNode.Type.FOR, name, block, comments);
this.from = from;
this.to = to;
this.step = step;
this.variableName = variableName;
this.loopId = loopId;
setSourceCodeLocation(sourceCodeLocation);
}
示例2: collect
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
/**
* Agglomerate each id sequence into a space-separated literal value,
* leaving strings as they were and fixing up comments and
* SourceCodeLocations as best we can.
*/
private void collect(List<CssValueNode> alternatives, CssValueNode item) {
if (isString(item)) {
alternatives.add(item);
} else {
CssValueNode stump;
if (alternatives.size() > 0
&& !isString(alternatives.get(alternatives.size() - 1))) {
// concatenate onto previous node
stump = alternatives.get(alternatives.size() - 1);
stump.setValue(stump.getValue() + " ");
} else {
// start a new node
stump = new CssLiteralNode("", getSourceCodeLocation(item));
alternatives.add(stump);
}
stump.setValue(stump.getValue() + item.getValue());
stump.setSourceCodeLocation(
SourceCodeLocation.merge(stump.getSourceCodeLocation(), item.getSourceCodeLocation()));
for (CssCommentNode c : item.getComments()) {
stump.appendComment(c);
}
}
}
示例3: enter
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Override
public void enter(CssNode n) {
SourceCodeLocation loc = n.getSourceCodeLocation();
if (loc == null || loc.isUnknown()) {
return;
}
if (result == null || result.isUnknown()) {
result = loc;
} else {
Ordering<SourceCodePoint> o = Ordering.natural();
SourceCodePoint lowerBound = o.min(result.getBegin(), loc.getBegin());
SourceCodePoint upperBound = o.max(result.getEnd(), loc.getEnd());
result = new SourceCodeLocationBuilder()
.setSourceCode(result.getSourceCode())
.setBeginLocation(lowerBound)
.setEndLocation(upperBound)
.getSourceCodeLocation();
}
}
示例4: enterRuleset
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Override
public boolean enterRuleset(CssRulesetNode node) {
for (CssNode child : node.getDeclarations().childIterable()) {
// CssPropertyNodes don't get their location set, so just use the
// location of the containing parent.
SourceCodeLocation location = node.getSourceCodeLocation();
if (location == null && !node.getSelectors().isEmpty()) {
// If the ruleset doesn't have a location set, then use location in the selector within.
location = node.getSelectors().getChildAt(0).getSourceCodeLocation();
}
processDeclaration((CssDeclarationNode) child, location);
}
// Clear the map for future re-use
propertyNames.clear();
return true;
}
示例5: enter
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Override
public void enter(CssNode node) {
if (includeHashCodes) {
buffer.append(String.format("(%[email protected]%d ", node.getClass().getName(), node.hashCode()));
} else {
buffer.append(String.format("(%s ", node.getClass().getName()));
}
if (withLocationAnnotation) {
SourceCodeLocation loc = node.getSourceCodeLocation();
if (loc == null) {
loc = SourceCodeLocation.getUnknownLocation();
}
buffer.append(String.format(":scl-unknown %s ", loc.isUnknown()));
}
}
示例6: addValuesToMap
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
/**
* Adds the given values to the map that maps argument names to their values.
*/
private boolean addValuesToMap(Map<String, List<CssValueNode>> refMap,
Iterator<CssValueNode> definitionArgumentIterator,
List<CssValueNode> values, SourceCodeLocation location) {
if (values.isEmpty() || !definitionArgumentIterator.hasNext()) {
// There is no value between two commas or the mixin provides more
// arguments than the definition takes.
errorManager.report(new GssError(
ARGUMENT_MISMATCH_ERROR_MESSAGE,
location));
return false;
}
CssValueNode argument = definitionArgumentIterator.next();
// Commas are skipped.
if (",".equals(argument.getValue())) {
if (values.isEmpty() || !definitionArgumentIterator.hasNext()) {
errorManager.report(new GssError(
ARGUMENT_MISMATCH_ERROR_MESSAGE,
location));
return false;
}
argument = definitionArgumentIterator.next();
}
refMap.put(argument.getValue(), ImmutableList.copyOf(values));
return true;
}
示例7: testDeepEquals4
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Test
public void testDeepEquals4() throws Exception {
CssCombinatorNode parent1 = new CssCombinatorNode(
Combinator.DESCENDANT,
new SourceCodeLocation(
new SourceCode("filename1", null), 1, 1, 1, 1, 1, 1));
CssCombinatorNode parent2 = new CssCombinatorNode(
Combinator.DESCENDANT,
null);
CssSelectorNode node1 = new CssSelectorNode("selector");
CssSelectorNode node2 = new CssSelectorNode("selector");
BackDoorNodeMutation.setParent(node1, parent1);
BackDoorNodeMutation.setParent(node2, parent2);
try {
deepEquals(parent1, parent2);
Assert.fail("FAIL: Parent1 and Parent2 should not be equal.");
} catch (AssertionError e) {
if (e.getMessage().startsWith("FAIL")) {
throw e;
}
}
}
示例8: testDeepCopy
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Test
public void testDeepCopy() {
SourceCode sourceCode = new SourceCode("foo", null);
SourceCodeLocation location =
new SourceCodeLocation(sourceCode, 1, 1, 1, 2, 1, 1);
CssSelectorNode node = new CssSelectorNode("a", location);
node.setChunk("baz");
CssClassSelectorNode refiner = new CssClassSelectorNode("c", location);
node.getRefiners().addChildToBack(refiner);
refiner.appendComment(new CssCommentNode("/* @noflip */", null));
CssSelectorNode copy = node.deepCopy();
assertThat(copy.getChunk()).isEqualTo(node.getChunk());
assertThat(copy.getSelectorName()).isEqualTo(node.getSelectorName());
assertThat(copy.getSourceCodeLocation()).isEqualTo(node.getSourceCodeLocation());
assertThat(copy.getRefiners().getChildAt(0).getComments())
.isEqualTo(node.getRefiners().getChildAt(0).getComments());
}
示例9: testNumericNodeLocation
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Test
public void testNumericNodeLocation() throws GssParserException {
CssTree tree = new GssParser(new SourceCode(null, "div{width:99px;}")).parse();
final CssNumericNode[] resultHolder = new CssNumericNode[1];
tree.getVisitController()
.startVisit(
new DefaultTreeVisitor() {
@Override
public boolean enterValueNode(CssValueNode value) {
if (value instanceof CssNumericNode) {
assertThat(resultHolder[0]).isNull();
resultHolder[0] = (CssNumericNode) value;
}
return true;
}
});
assertThat(resultHolder[0]).isNotNull();
SourceCodeLocation location = resultHolder[0].getSourceCodeLocation();
assertThat(location.getEndCharacterIndex() - location.getBeginCharacterIndex())
.isEqualTo("99px".length());
}
示例10: testUnknown
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
@Test
public void testUnknown() throws Exception {
parseAndRun("div { color: red; }");
CssTreeVisitor eraseLocations =
UniformVisitor.Adapters.asVisitor(
new UniformVisitor() {
@Override
public void enter(CssNode n) {
n.setSourceCodeLocation(SourceCodeLocation.getUnknownLocation());
}
@Override
public void leave(CssNode node) {}
});
tree.getMutatingVisitController().startVisit(eraseLocations);
SourceCodeLocation actual = LocationBoundingVisitor.bound(tree.getRoot());
assertWithMessage(new com.google.common.css.compiler.ast.GssError("boo", actual).format())
.that(actual)
.isEqualTo(SourceCodeLocation.getUnknownLocation());
}
示例11: CssCombinatorNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
/**
* Constructor of a combinator node.
*
* @param selector
* @param type
* @param sourceCodeLocation
*/
public CssCombinatorNode(CssSelectorNode selector,
Combinator type,
SourceCodeLocation sourceCodeLocation) {
super(sourceCodeLocation);
this.selector = selector;
becomeParentForNode(this.selector);
this.type = type;
}
示例12: CssDefinitionNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
/**
* Constructor of a definition.
*/
public CssDefinitionNode(List<CssValueNode> parameters, CssLiteralNode name,
SourceCodeLocation sourceCodeLocation) {
super(CssAtRuleNode.Type.DEF, name);
setParameters(parameters);
setSourceCodeLocation(sourceCodeLocation);
}
示例13: CssMixinDefinitionNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
public CssMixinDefinitionNode(String name, CssFunctionArgumentsNode arguments,
CssDeclarationBlockNode declarations, SourceCodeLocation location) {
super(Type.DEFMIXIN, new CssLiteralNode("defmixin"), declarations);
this.setSourceCodeLocation(location);
this.name = name;
this.declarations = declarations;
becomeParentForNode(declarations);
this.arguments = arguments;
}
示例14: CssDeclarationNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
/** Constructor of a node representing a CSS declaration. */
public CssDeclarationNode(
CssPropertyNode propertyName,
List<CssCommentNode> comments,
@Nullable SourceCodeLocation sourceCodeLocation) {
this(propertyName, new CssPropertyValueNode(), comments, sourceCodeLocation);
}
示例15: CssAttributeSelectorNode
import com.google.common.css.SourceCodeLocation; //导入依赖的package包/类
public CssAttributeSelectorNode(MatchType matchType, String attributeName,
CssValueNode value, SourceCodeLocation sourceCodeLocation) {
super(Refiner.ATTRIBUTE, "", sourceCodeLocation);
this.matchType = matchType;
this.attributeName = attributeName;
this.value = value;
}