private List<String> getPathElement(String imageResourcePath) { return Lists.newArrayList(imageResourcePath.split("\\.")); }
/** * In GSS, constant names are defined in upper case but a method name to access a constant in * a CssResource interface can be written in lower camel case. * <p> * This method converts all constant names in a lower camel case identifier. */ private Collection<String> renameDefs(Iterable<String> constantsNames) { return Lists.newArrayList(Iterables.transform(constantsNames, new Function<String, String>() { @Override public String apply(String constantName) { String lowerCase = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, constantName); // If we cannot revert the method name to the original constant name, use the // original constant name. // This case happens when number are used after an underscore: // CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "DEF_1") returns def1 // but CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, "def1") returns DEF1 and the // GssResourceGenerator is not able to match the name of the method with the name of the // constant . if (!constantName.equals(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, lowerCase))) { return constantName; } return lowerCase; } })); }
@Override public boolean enterConditionalBlock(CssConditionalBlockNode block) { // We have to visit all the CssConditionalRuleNode when we visit the CssConditionalBlockNode // parent node because we are going to replace CssConditionalRuleNode by another node and // unfortunately the visitController doesn't support to replace a CssConditionalRuleNode and // we have to do it manually. That implies that the new nodes won't be visited by the // visitor if we do that during the visit of the CssConditionalRuleNodes and they can contain // other CssConditionalBlockNodes that won't be visited. // Once MutatingVisitController supports replacement of CssConditionalRuleNode, // we will be able to visit CssConditionalRuleNode directly. // Make a copy in order to avoid ConcurrentModificationException List<CssConditionalRuleNode> children = Lists.newArrayList(block.getChildren()); for (CssConditionalRuleNode ruleNode : children) { visitConditionalRule(ruleNode, block); } return true; }
private void visitConditionalRule(CssConditionalRuleNode node, CssConditionalBlockNode parent) { if (node.getType() != Type.ELSE) { CssBooleanExpressionNode nodeCondition = node.getCondition(); String condition = extractRuntimeCondition(nodeCondition); if (condition != null) { CssJavaExpressionNode newNode = new CssJavaExpressionNode(condition, nodeCondition.getSourceCodeLocation()); CssRuntimeConditionalRuleNode newRuleNode = new CssRuntimeConditionalRuleNode(node, newNode); // Unfortunately visitController.replaceCurrentBlockChildWith doesn't work with // CssConditionnalRuleNode int index = parent.getChildren().indexOf(node); parent.replaceChildAt(index, Lists.newArrayList(newRuleNode)); } } }
visitController.replaceCurrentBlockChildWith(Lists.newArrayList(newNode), true);
@Override public void prepare(TreeLogger logger, ResourceContext context, ClientBundleRequirements requirements, JMethod method) throws UnableToCompleteException { if (method.getReturnType().isInterface() == null) { logger.log(TreeLogger.ERROR, "Return type must be an interface"); throw new UnableToCompleteException(); } URL[] resourceUrls = findResources(logger, context, method, gssOptions.isEnabled()); if (resourceUrls.length == 0) { logger.log(TreeLogger.ERROR, "At least one source must be specified"); throw new UnableToCompleteException(); } CssParsingResult cssParsingResult = parseResources(Lists.newArrayList(resourceUrls), context, logger); cssParsingResultMap.put(method, cssParsingResult); for (String permutationAxis : cssParsingResult.permutationAxes) { try { context.getRequirements().addPermutationAxis(permutationAxis); } catch (BadPropertyValueException e) { logger.log(TreeLogger.ERROR, "Unknown deferred-binding property " + permutationAxis, e); throw new UnableToCompleteException(); } } }
private List<String> getPathElement(String imageResourcePath) { return Lists.newArrayList(imageResourcePath.split("\\.")); }
private List<String> getPathElement(String imageResourcePath) { return Lists.newArrayList(imageResourcePath.split("\\.")); }
/** * Returns the list of known module names (after renaming). */ Collection<String> getOutputModuleNames() { List<String> result = Lists.newArrayList(); for (Outbox box : outboxes.values()) { result.add(box.getOutputModuleName()); } return result; }
/** * Returns the list of known module names (after renaming). */ Collection<String> getOutputModuleNames() { List<String> result = Lists.newArrayList(); for (Outbox box : outboxes.values()) { result.add(box.getOutputModuleName()); } return result; }
@Override public boolean enterConditionalBlock(CssConditionalBlockNode block) { // We have to visit all the CssConditionalRuleNode when we visit the CssConditionalBlockNode // parent node because we are going to replace CssConditionalRuleNode by another node and // unfortunately the visitController doesn't support to replace a CssConditionalRuleNode and // we have to do it manually. That implies that the new nodes won't be visited by the // visitor if we do that during the visit of the CssConditionalRuleNodes and they can contain // other CssConditionalBlockNodes that won't be visited. // Once MutatingVisitController supports replacement of CssConditionalRuleNode, // we will be able to visit CssConditionalRuleNode directly. // Make a copy in order to avoid ConcurrentModificationException List<CssConditionalRuleNode> children = Lists.newArrayList(block.getChildren()); for (CssConditionalRuleNode ruleNode : children) { visitConditionalRule(ruleNode, block); } return true; }
@Override public boolean enterConditionalBlock(CssConditionalBlockNode block) { // We have to visit all the CssConditionalRuleNode when we visit the CssConditionalBlockNode // parent node because we are going to replace CssConditionalRuleNode by another node and // unfortunately the visitController doesn't support to replace a CssConditionalRuleNode and // we have to do it manually. That implies that the new nodes won't be visited by the // visitor if we do that during the visit of the CssConditionalRuleNodes and they can contain // other CssConditionalBlockNodes that won't be visited. // Once MutatingVisitController supports replacement of CssConditionalRuleNode, // we will be able to visit CssConditionalRuleNode directly. // Make a copy in order to avoid ConcurrentModificationException List<CssConditionalRuleNode> children = Lists.newArrayList(block.getChildren()); for (CssConditionalRuleNode ruleNode : children) { visitConditionalRule(ruleNode, block); } return true; }
public ValidatorCreator(JClassType validatorType, // GwtValidation gwtValidation, // TreeLogger logger, // GeneratorContext context, BeanHelperCache cache) throws UnableToCompleteException { super(context, logger, validatorType, cache); this.gwtValidation = gwtValidation; List<BeanHelper> temp = Lists.newArrayList(); for (Class<?> clazz : gwtValidation.value()) { BeanHelper helper = createBeanHelper(clazz); temp.add(helper); } beansToValidate = Util.sortMostSpecificFirst(temp, BeanHelper.TO_CLAZZ); }
public ValidatorCreator(JClassType validatorType, // GwtValidation gwtValidation, // TreeLogger logger, // GeneratorContext context, BeanHelperCache cache) throws UnableToCompleteException { super(context, logger, validatorType, cache); this.gwtValidation = gwtValidation; List<BeanHelper> temp = Lists.newArrayList(); for (Class<?> clazz : gwtValidation.value()) { BeanHelper helper = createBeanHelper(clazz); temp.add(helper); } beansToValidate = Util.sortMostSpecificFirst(temp, BeanHelper.TO_CLAZZ); }
private List<Subtype> getPossibleTypes(JsonTypeInfo typeInfo, boolean isLeaf) throws UnableToCompleteException { if (typeInfo == null) { return Lists.newArrayList(new Subtype(null, source)); } Collection<Type> subTypes = findJsonSubTypes(source); if (subTypes.isEmpty()) { JsonSubTypes foundAnnotation = getAnnotation(source, JsonSubTypes.class); if (foundAnnotation != null) { Type[] value = foundAnnotation.value(); subTypes = Arrays.asList(value); } } PossibleTypesVisitor v = new PossibleTypesVisitor(context, source, isLeaf, getLogger(), subTypes); return v.visit(typeInfo.use()); }
private List<Subtype> getPossibleTypes(JsonTypeInfo typeInfo, boolean isLeaf) throws UnableToCompleteException { if (typeInfo == null) { return Lists.newArrayList(new Subtype(null, source)); } Collection<Type> subTypes = findJsonSubTypes(source); if (subTypes.isEmpty()) { JsonSubTypes foundAnnotation = getAnnotation(source, JsonSubTypes.class); if (foundAnnotation != null) { Type[] value = foundAnnotation.value(); subTypes = Arrays.asList(value); } } PossibleTypesVisitor v = new PossibleTypesVisitor(context, source, isLeaf, getLogger(), subTypes); return v.visit(typeInfo.use()); }
private void visitConditionalRule(CssConditionalRuleNode node, CssConditionalBlockNode parent) { if (node.getType() != Type.ELSE) { CssBooleanExpressionNode nodeCondition = node.getCondition(); String condition = extractRuntimeCondition(nodeCondition); if (condition != null) { CssJavaExpressionNode newNode = new CssJavaExpressionNode(condition, nodeCondition.getSourceCodeLocation()); CssRuntimeConditionalRuleNode newRuleNode = new CssRuntimeConditionalRuleNode(node, newNode); // Unfortunately visitController.replaceCurrentBlockChildWith doesn't work with // CssConditionnalRuleNode int index = parent.getChildren().indexOf(node); parent.replaceChildAt(index, Lists.newArrayList(newRuleNode)); } } }
private void visitConditionalRule(CssConditionalRuleNode node, CssConditionalBlockNode parent) { if (node.getType() != Type.ELSE) { CssBooleanExpressionNode nodeCondition = node.getCondition(); String condition = extractRuntimeCondition(nodeCondition); if (condition != null) { CssJavaExpressionNode newNode = new CssJavaExpressionNode(condition, nodeCondition.getSourceCodeLocation()); CssRuntimeConditionalRuleNode newRuleNode = new CssRuntimeConditionalRuleNode(node, newNode); // Unfortunately visitController.replaceCurrentBlockChildWith doesn't work with // CssConditionnalRuleNode int index = parent.getChildren().indexOf(node); parent.replaceChildAt(index, Lists.newArrayList(newRuleNode)); } } }
CompilerOptionsImpl(CompileDir compileDir, String moduleName, Options options) { this.compileDir = compileDir; this.incremental = options.isIncrementalCompileEnabled(); this.moduleNames = Lists.newArrayList(moduleName); this.sourceLevel = options.getSourceLevel(); this.failOnError = options.isFailOnError(); this.strictSourceResources = options.enforceStrictResources(); this.strictPublicResources = options.enforceStrictResources(); this.logLevel = options.getLogLevel(); this.jsInteropMode = options.getJsInteropMode(); this.methodNameDisplayMode = options.getMethodNameDisplayMode(); this.properties = LinkedListMultimap.create(options.getProperties()); this.closureFormattedOutput = options.isClosureFormattedOutput(); }
CompilerOptionsImpl(CompileDir compileDir, String moduleName, Options options) { this.compileDir = compileDir; this.incremental = options.isIncrementalCompileEnabled(); this.moduleNames = Lists.newArrayList(moduleName); this.sourceLevel = options.getSourceLevel(); this.failOnError = options.isFailOnError(); this.logLevel = options.getLogLevel(); this.generateJsInteropExports = options.shouldGenerateJsInteropExports(); this.jsInteropExportFilter = new WhitelistRegexFilter(); this.jsInteropExportFilter.addAll(options.getJsInteropExportFilter()); this.methodNameDisplayMode = options.getMethodNameDisplayMode(); this.properties = LinkedListMultimap.create(options.getProperties()); this.closureFormattedOutput = options.isClosureFormattedOutput(); this.output = options.getOutput(); }