List of usage examples for com.google.common.css.compiler.ast GssError GssError
public GssError(String message, SourceCodeLocation location)
From source file:com.google.gwt.resources.gss.DisallowDefInsideRuntimeConditionalNode.java
@Override public boolean enterDefinition(CssDefinitionNode node) { if (inConditionalRule()) { errorManager.report(new GssError( "You cannot define a constant inside a ConditionalNode " + "that will be evaluated at runtime.", node.getSourceCodeLocation())); }/*from w w w. j a v a 2 s. co m*/ return false; }
From source file:com.google.gwt.resources.gss.ValidateRuntimeConditionalNode.java
@Override public boolean enterDefinition(CssDefinitionNode node) { if (inConditionalRule()) { if (lenient) { errorManager.reportWarning(new GssError("You should not define a constant inside a " + "ConditionalNode that will be evaluated at runtime. This will be disallowed in " + "GWT 3.0", node.getSourceCodeLocation())); } else {/*from w w w. j a va 2s . c o m*/ errorManager.report(new GssError("You cannot define a constant inside a ConditionalNode " + "that will be evaluated at runtime.", node.getSourceCodeLocation())); } } return false; }
From source file:com.google.gwt.resources.gss.ValidateRuntimeConditionalNode.java
@Override public boolean enterUnknownAtRule(CssUnknownAtRuleNode node) { if (inConditionalRule() && "external".equals(node.getName().getValue())) { if (lenient) { errorManager.reportWarning(new GssError("You should not define a external at-rule inside" + " a ConditionalNode that will be evaluated at runtime. This will be disallowed in " + "GWT 3.0", node.getSourceCodeLocation())); } else {/* w ww.j a v a 2 s . c o m*/ errorManager.report(new GssError( "You cannot define a external at-rule inside a " + "ConditionalNode that will be evaluated at runtime.", node.getSourceCodeLocation())); } } return super.enterUnknownAtRule(node); }
From source file:com.google.gwt.resources.gss.PermutationsCollector.java
private void visitBooleanExpression(CssBooleanExpressionNode booleanExpressionNode) { if (booleanExpressionNode.getType() == Type.CONSTANT && booleanExpressionNode.getValue() != null) { Matcher m = IS_FUNCTION.matcher(booleanExpressionNode.getValue()); if (m.matches()) { String permutationName = m.group(1); String permutationValue = m.group(2); if (permutationValue == null) { permutationValue = permutationName; permutationName = USER_AGENT_PERMUTATION; }/*ww w. ja va2 s . com*/ booleanExpressionNode.setValue(permutationName + ":" + permutationValue); permutationAxesListBuilder.add(permutationName); } else { // TODO warning or error ? GssError warning = new GssError( "The expression [" + booleanExpressionNode.getValue() + "] cannot be evaluated. It will be considered as false.", booleanExpressionNode.getSourceCodeLocation()); errorManager.reportWarning(warning); } } }
From source file:com.google.gwt.resources.gss.ResourceUrlFunction.java
private void assertMethodIsValidResource(SourceCodeLocation location, List<String> pathElements, ErrorManager errorManager) throws GssFunctionException { JType methodType;//from w w w.j a v a 2 s.co m try { methodType = ResourceGeneratorUtil.getMethodByPath(context.getClientBundleType(), pathElements, null) .getReturnType(); } catch (NotFoundException e) { String message = e.getMessage(); errorManager.report(new GssError(message, location)); throw new GssFunctionException(message, e); } if (!dataResourceType.isAssignableFrom((JClassType) methodType) && !imageResourceType.isAssignableFrom((JClassType) methodType)) { String message = "Invalid method type for url substitution: " + methodType + ". " + "Only DataResource and ImageResource are supported."; errorManager.report(new GssError(message, location)); throw new GssFunctionException(message); } }
From source file:com.google.gwt.resources.gss.ImageSpriteCreator.java
private void createSprite(CssDeclarationNode declaration) { List<CssValueNode> valuesNodes = declaration.getPropertyValue().getChildren(); if (valuesNodes.size() != 1) { errorManager.report(new GssError(SPRITE_PROPERTY_NAME + " must have exactly one value", declaration.getSourceCodeLocation())); }// w w w . j av a 2 s . com String imageResource = valuesNodes.get(0).getValue(); JMethod imageMethod; try { imageMethod = ResourceGeneratorUtil.getMethodByPath(context.getClientBundleType(), getPathElement(imageResource), imageResourceType); } catch (NotFoundException e) { errorManager.report(new GssError( "Unable to find ImageResource method " + imageResource + " in " + context.getClientBundleType().getQualifiedSourceName() + " : " + e.getMessage(), declaration.getSourceCodeLocation())); return; } ImageOptions options = imageMethod.getAnnotation(ImageOptions.class); RepeatStyle repeatStyle = options != null ? options.repeatStyle() : RepeatStyle.None; Builder<CssDeclarationNode> listBuilder = ImmutableList.builder(); SourceCodeLocation sourceCodeLocation = declaration.getSourceCodeLocation(); String repeatText; switch (repeatStyle) { case None: repeatText = " no-repeat"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Horizontal: repeatText = " repeat-x"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); break; case Vertical: repeatText = " repeat-y"; listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Both: repeatText = " repeat"; break; default: errorManager.report(new GssError("Unknown repeatStyle " + repeatStyle, sourceCodeLocation)); return; } listBuilder.add(buildOverflowDeclaration(sourceCodeLocation)); listBuilder.add(buildBackgroundDeclaration(imageResource, repeatText, sourceCodeLocation)); visitController.replaceCurrentBlockChildWith(listBuilder.build(), false); }