private List<String> getPathElement(String imageResourcePath) { return Lists.newArrayList(imageResourcePath.split("\\.")); }
/** * Build the code for the parameters of a method call. * * @param builder the code builder * @param parameters the parameters * * @return the code */ private CodeBlock methodCallCodeWithJMapperTypeParameters( CodeBlock.Builder builder, ImmutableList<? extends JMapperType> parameters ) { return methodCallParametersCode( builder, Lists.transform( parameters, new Function<JMapperType, CodeBlock>() { @Override public CodeBlock apply( JMapperType jMapperType ) { return jMapperType.getInstance(); } } ) ); }
/** * Build the code for the parameters of a method call. * * @param builder the code builder * @param parameters the parameters * * @return the code */ private CodeBlock methodCallCodeWithJParameterizedMapperParameters( CodeBlock.Builder builder, ImmutableList<? extends JParameterizedMapper> parameters ) { return methodCallParametersCode( builder, Lists.transform( parameters, new Function<JParameterizedMapper, CodeBlock>() { @Override public CodeBlock apply( JParameterizedMapper jMapperType ) { return jMapperType.getInstance(); } } ) ); }
/** * 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; } })); }
/** * Build the code to create a mapper. * * @param instance the class to call * @param parameters the parameters of the method * * @return the code to create the mapper */ private CodeBlock methodCallCodeWithClassParameters( MapperInstance instance, ImmutableList<? extends JType> parameters ) { CodeBlock.Builder builder = initMethodCallCode( instance ); return methodCallParametersCode( builder, Lists.transform( parameters, new Function<JType, CodeBlock>() { @Override public CodeBlock apply( JType jType ) { return CodeBlock.builder().add( "$T.class", typeName( jType ) ).build(); } } ) ); }
@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; }
/** * Reads a GWT-RPC serialization policy manifest in this directory. * @return a PolicyFile record for each entry in the policy file. If the policy file isn't there, * returns the empty list. * @throws java.io.IOException if the file exists but we can't read it. */ List<PolicyFile> readRpcPolicyManifest(String outputModuleName) throws IOException { File manifest = new File(getExtraDir(), outputModuleName + "/rpcPolicyManifest/manifest.txt"); if (!manifest.isFile()) { return Lists.newArrayList(); } String text = Files.toString(manifest, Charsets.UTF_8); List<PolicyFile> result = Lists.newArrayList(); for (String line : text.split("\n")) { line = line.trim(); if (line.isEmpty() || line.startsWith("#")) { continue; } String[] fields = line.split(", "); if (fields.length < 2) { continue; } String serviceName = fields[0]; String policyFileName = fields[1]; PolicyFile policy = new PolicyFile(policyFileName, serviceName, outputModuleName); result.add(policy); } return result; }
/** * Reads a GWT-RPC serialization policy manifest in this directory. * @return a PolicyFile record for each entry in the policy file. If the policy file isn't there, * returns the empty list. * @throws java.io.IOException if the file exists but we can't read it. */ List<PolicyFile> readRpcPolicyManifest(String outputModuleName) throws IOException { File manifest = new File(getExtraDir(), outputModuleName + "/rpcPolicyManifest/manifest.txt"); if (!manifest.isFile()) { return Lists.newArrayList(); } String text = Files.toString(manifest, Charsets.UTF_8); List<PolicyFile> result = Lists.newArrayList(); for (String line : text.split("\n")) { line = line.trim(); if (line.isEmpty() || line.startsWith("#")) { continue; } String[] fields = line.split(", "); if (fields.length < 2) { continue; } String serviceName = fields[0]; String policyFileName = fields[1]; PolicyFile policy = new PolicyFile(policyFileName, serviceName, outputModuleName); result.add(policy); } return result; }
List<T> working = Lists.newArrayList(); List<T> sorted = Lists.newArrayList(); Predicate<T> mostSpecific = createMostSpecificMatchPredicate(working, toClass);
List<T> working = Lists.newArrayList(); List<T> sorted = Lists.newArrayList(); Predicate<T> mostSpecific = createMostSpecificMatchPredicate(working, toClass);
static <T> ImmutableList<T> sortMostSpecificFirst(final Iterable<T> classes, final Function<T, Class<?>> toClass) { final List<T> working = Lists.newArrayList(); final List<T> sorted = Lists.newArrayList(); final Predicate<T> mostSpecific = createMostSpecificMatchPredicate(working, toClass); boolean changed = false;
@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; }