jomarko commented on code in PR #2422:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2422#discussion_r1643773539


##########
packages/vscode-java-code-completion-extension-plugin/vscode-java-code-completion-extension-plugin-core/src/main/java/org/kogito/core/internal/engine/JavaEngine.java:
##########
@@ -77,9 +75,35 @@ public BuildInformation buildPublicContent(Path filePath, 
String fqcn, String co
         return new BuildInformation(filePath, getContent(filePath), content, 
5, getEndOfLinePosition(content, 5));
     }
 
+    public BuildInformation buildVarTypePublicContent(Path filePath, String 
fqcn, String completeText) {
+
+        TemplateParameters item = new TemplateParameters();
+        item.setClassName(getClassName(filePath));
+        item.setQuery(completeText);
+        item.setFqcn(fqcn);
+
+        String content = this.evaluate(Templates.TEMPLATE_ACCESSORS, item);
+
+        return new BuildInformation(filePath, getContent(filePath), content, 
5, getFirstCharInLinePosition(content, 5) + 2);
+    }
+
+    protected int getFirstCharInLinePosition(String content, int lineNumber) {
+        String[] split = content.split("\n");
+        String line = split[lineNumber];
+        int index = 0;
+
+        for (int i = 0; i < line.length(); i++) {
+            if (line.charAt(i) != ' ') {
+                index = i;
+                break;
+            }
+        }
+
+        return index + 1;

Review Comment:
   ```suggestion
           int index = line.indexOf(line.trim());
   
           return index + 1;
   ```
   
   Was doing some quick 'googling' for the task of searching the first 
non-empty character in string, and found this proposal, that I quite like for 
its shortness, what do you think?



##########
packages/vscode-java-code-completion-extension-plugin/vscode-java-code-completion-extension-plugin-core/src/main/java/org/kogito/core/internal/engine/JavaEngine.java:
##########
@@ -77,9 +75,35 @@ public BuildInformation buildPublicContent(Path filePath, 
String fqcn, String co
         return new BuildInformation(filePath, getContent(filePath), content, 
5, getEndOfLinePosition(content, 5));
     }
 
+    public BuildInformation buildVarTypePublicContent(Path filePath, String 
fqcn, String completeText) {
+
+        TemplateParameters item = new TemplateParameters();
+        item.setClassName(getClassName(filePath));
+        item.setQuery(completeText);
+        item.setFqcn(fqcn);
+
+        String content = this.evaluate(Templates.TEMPLATE_ACCESSORS, item);
+
+        return new BuildInformation(filePath, getContent(filePath), content, 
5, getFirstCharInLinePosition(content, 5) + 2);

Review Comment:
   what are these numbers `5` and `2`, maybe we could store them as constant 
with some name?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to