@Override public void run(Model model) { if (model.getServiceConfig().hasConfigVersion() && model.getConfigVersion() != Model.getDefaultConfigVersion()) { warning( MessageLocationContext.create(model.getServiceConfig().getConfigVersion(), "value"), "Specified config_version value '%s' is not equal to " + "the current default value '%s'. Consider changing this value " + "to the default config version.", model.getConfigVersion(), Model.getDefaultConfigVersion()); } } }
@Override public void run(Model model) { if (model.getServiceConfig().hasConfigVersion() && model.getConfigVersion() != Model.getDefaultConfigVersion()) { warning( MessageLocationContext.create(model.getServiceConfig().getConfigVersion(), "value"), "Specified config_version value '%s' is not equal to " + "the current default value '%s'. Consider changing this value " + "to the default config version.", model.getConfigVersion(), Model.getDefaultConfigVersion()); } } }
static RestMethod createCustomMethod( Method method, HttpAttribute httpConfig, String customNamePrefix) { ImmutableList<PathSegment> path = httpConfig.getFlatPath(); PathSegment lastSegment = path.get(path.size() - 1); // Determine base name. String customName = ""; if (lastSegment instanceof LiteralSegment) { customName = ((LiteralSegment) lastSegment).getLiteral(); path = path.subList(0, path.size() - 1); } else { if (method.getModel().getConfigVersion() > 1) { // From version 2 on, we generate a meaningful name here. customName = method.getSimpleName(); } else if (customNamePrefix.isEmpty()){ // Older versions use the prefix or derive from the http method. customName = httpConfig.getMethodKind().toString().toLowerCase(); } } // Prepend prefix. if (!customNamePrefix.isEmpty() && !customName.toLowerCase().startsWith(customNamePrefix.toLowerCase())) { customName = customNamePrefix + ensureUpperCase(customName); } // Ensure effective start is lower case. customName = ensureLowerCase(customName); String restMethodName = ""; CollectionName collectionName = RestAnalyzer.buildCollectionName(path, method.getModel()); return RestMethod.create( method, RestKind.CUSTOM, collectionName, customName, restMethodName); }
static RestMethod createCustomMethod( Method method, HttpAttribute httpConfig, String customNamePrefix) { ImmutableList<PathSegment> path = httpConfig.getFlatPath(); PathSegment lastSegment = path.get(path.size() - 1); // Determine base name. String customName = ""; if (lastSegment instanceof LiteralSegment) { customName = ((LiteralSegment) lastSegment).getLiteral(); path = path.subList(0, path.size() - 1); } else { if (method.getModel().getConfigVersion() > 1) { // From version 2 on, we generate a meaningful name here. customName = method.getSimpleName(); } else if (customNamePrefix.isEmpty()){ // Older versions use the prefix or derive from the http method. customName = httpConfig.getMethodKind().toString().toLowerCase(); } } // Prepend prefix. if (!customNamePrefix.isEmpty() && !customName.toLowerCase().startsWith(customNamePrefix.toLowerCase())) { customName = customNamePrefix + ensureUpperCase(customName); } // Ensure effective start is lower case. customName = ensureLowerCase(customName); String restMethodName = ""; CollectionName collectionName = RestAnalyzer.buildCollectionName(path, method.getModel()); return RestMethod.create( method, RestKind.CUSTOM, collectionName, customName, restMethodName); }
private void errorSince(int version, Element elem, String message, Object... params) { if (!errorContext.isEmpty()) { message = message + " " + errorContext + "."; } Diag diag = elem.getModel().getConfigVersion() >= version ? Diag.error(elem.getLocation(), message, params) : Diag.warning( elem.getLocation(), message + String.format( " Note: this will be an error for config version %s and later.", version), params); elem.getModel().getDiagReporter().report(diag); }
private void errorSince(int version, Element elem, String message, Object... params) { if (!errorContext.isEmpty()) { message = message + " " + errorContext + "."; } Diag diag = elem.getModel().getConfigVersion() >= version ? Diag.error(elem.getLocation(), message, params) : Diag.warning( elem.getLocation(), message + String.format( " Note: this will be an error for config version %s and later.", version), params); elem.getModel().getDiagReporter().report(diag); }
@Override public void startMerging() { // Load the roots here since roots in the model was empty when VersionConfigAspect was created. for (ProtoElement root: getModel().getRoots()) { roots.add(root); } // Verify the config_version is explicitly specified in the service config. if (!getModel().getServiceConfig().hasConfigVersion()) { error(SimpleLocation.TOPLEVEL, "config_version is not specified in the service config file."); } // Detect config version location. LocationContext configVersionLocation = MessageLocationContext.create(getModel().getServiceConfig().getConfigVersion(), "value"); if (getModel().getConfigVersion() > Model.getDevConfigVersion()) { error( configVersionLocation, String.format("config_version %s is invalid, the latest config_version is %s.", getModel().getConfigVersion(), Model.getDevConfigVersion())); } }
private List<Endpoint> populateDefaults(List<Endpoint> sourceEndpoints) { ImmutableList.Builder<Endpoint> results = ImmutableList.builder(); for (Endpoint sourceEndpoint : sourceEndpoints) { if (!validate(sourceEndpoint)) { continue; } Endpoint.Builder builder = sourceEndpoint.toBuilder(); if (sourceEndpoint.getName().endsWith(GOOGLEAPIS_DNS_SUFFIX)) { // Use a set to prevent duplicates (this can happen when the service config contains // on of the google api aliases). Use a LinkedHashSet for deterministic order that // can be depended on in tests. LinkedHashSet<String> aliases = Sets.newLinkedHashSet(createGoogleapisAliases(sourceEndpoint.getName())); aliases.addAll(builder.getAliasesList()); builder.clearAliases(); builder.addAllAliases(aliases); } builder.clearFeatures(); builder.addAllFeatures( ENDPOINT_FEATURES.evaluate( sourceEndpoint.getFeaturesList(), getModel().getConfigVersion(), getModel().getDiagReporter(), MessageLocationContext.create(sourceEndpoint, "name"))); results.add(builder.build()); } return results.build(); }
@Override public void startMerging() { // Load the roots here since roots in the model was empty when VersionConfigAspect was created. for (ProtoElement root: getModel().getRoots()) { roots.add(root); } // Verify the config_version is explicitly specified in the service config. if (!getModel().getServiceConfig().hasConfigVersion()) { error(SimpleLocation.TOPLEVEL, "config_version is not specified in the service config file."); } // Detect config version location. LocationContext configVersionLocation = MessageLocationContext.create(getModel().getServiceConfig().getConfigVersion(), "value"); if (getModel().getConfigVersion() > Model.getDevConfigVersion()) { error( configVersionLocation, String.format("config_version %s is invalid, the latest config_version is %s.", getModel().getConfigVersion(), Model.getDevConfigVersion())); } }
private List<Endpoint> populateDefaults(List<Endpoint> sourceEndpoints) { ImmutableList.Builder<Endpoint> results = ImmutableList.builder(); for (Endpoint sourceEndpoint : sourceEndpoints) { if (!validate(sourceEndpoint)) { continue; } Endpoint.Builder builder = sourceEndpoint.toBuilder(); if (sourceEndpoint.getName().endsWith(GOOGLEAPIS_DNS_SUFFIX)) { // Use a set to prevent duplicates (this can happen when the service config contains // on of the google api aliases). Use a LinkedHashSet for deterministic order that // can be depended on in tests. LinkedHashSet<String> aliases = Sets.newLinkedHashSet(createGoogleapisAliases(sourceEndpoint.getName())); aliases.addAll(builder.getAliasesList()); builder.clearAliases(); builder.addAllAliases(aliases); } builder.clearFeatures(); builder.addAllFeatures( ENDPOINT_FEATURES.evaluate( sourceEndpoint.getFeaturesList(), getModel().getConfigVersion(), getModel().getDiagReporter(), MessageLocationContext.create(sourceEndpoint, "name"))); results.add(builder.build()); } return results.build(); }
asDiagCollector(), method.getLocation(), path, method.getModel().getConfigVersion()) .parse(); if (parsedPath == null) {
asDiagCollector(), method.getLocation(), path, method.getModel().getConfigVersion()) .parse(); if (parsedPath == null) {