You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "dongxuwang (via GitHub)" <gi...@apache.org> on 2023/05/21 06:55:40 UTC

[GitHub] [dubbo] dongxuwang commented on a diff in pull request #12343: feat:remove jprotoc dependency

dongxuwang commented on code in PR #12343:
URL: https://github.com/apache/dubbo/pull/12343#discussion_r1199707127


##########
dubbo-compiler/src/main/java/org/apache/dubbo/gen/AbstractGenerator.java:
##########
@@ -261,6 +261,20 @@ private List<PluginProtos.CodeGeneratorResponse.File> buildFile(ServiceContext c
         return files;
     }
 
+    protected String applyTemplate(@Nonnull String resourcePath, @Nonnull Object generatorContext) {
+        Preconditions.checkNotNull(resourcePath, "resourcePath");
+        Preconditions.checkNotNull(generatorContext, "generatorContext");
+        InputStream resource = MustacheFactory.class.getClassLoader().getResourceAsStream(resourcePath);
+        if (resource == null) {
+            throw new RuntimeException("Could not find resource " + resourcePath);
+        } else {
+            InputStreamReader resourceReader = new InputStreamReader(resource, Charsets.UTF_8);
+            Mustache template = MUSTACHE_FACTORY.compile(resourceReader, resourcePath);
+            return template.execute(new StringWriter(), generatorContext).toString();
+        }
+    }
+
+

Review Comment:
   I think this is the redundant blank line needs to be removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org