Skip to content

Commit

Permalink
Indent the whole block
Browse files Browse the repository at this point in the history
  • Loading branch information
ndefrancesco committed Nov 26, 2019
1 parent e99640d commit 6e34bfb
Showing 1 changed file with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,40 +339,40 @@ private void appendMacroSpecificCompletions(String input, List<Completion> resul
String[] textArray = text.split("\n");
for (String line : textArray){
if(carPos<charcount || carPos>charcount+line.length() + 1) { // the caret is not in the current line
String trimmedline = line.trim();
String lcaseline = trimmedline.toLowerCase();
if (lcaseline.startsWith("function ")) {
String command = trimmedline.substring(8).trim().replace("{", "").trim();
String lcasecommand = command.toLowerCase();
if (lcasecommand.contains(lcaseinput) && command.matches("[_a-zA-Z]+[_a-zA-Z0-9]*\\(.*\\)")) { // the function name is valid and the statement includes parenthesis
Boolean isAdditional = !(charcount < codeLength); // function is outside user code block (in additional functions)
String description = "<b>" + command + "</b><br>" + findDescription(textArray, linecount, "<i>User defined " + (isAdditional?"additional ":"") + "function" + (isAdditional?"":" as specified in line " + (linecount + 1)) + ".</i>");

completions.add(new BasicCompletion(this, command, null, description));
}
}
if ((lcaseline.contains("=") || trimmedline.startsWith("var ")) && (charcount < codeLength)) { // possible variable assignment (= OR var) AND within user code block (not in additional functions)
String command = trimmedline;
if(command.contains("=")) command=command.substring(0, lcaseline.indexOf("=")).trim();
boolean globalVar = false;
if(command.startsWith("var ")) {
command = command.substring(4).trim().replace(";", ""); // in case of var declaration w/o assignment the trailing semicolon will be removed
globalVar= true;
String trimmedline = line.trim();
String lcaseline = trimmedline.toLowerCase();
if (lcaseline.startsWith("function ")) {
String command = trimmedline.substring(8).trim().replace("{", "").trim();
String lcasecommand = command.toLowerCase();
if (lcasecommand.contains(lcaseinput) && command.matches("[_a-zA-Z]+[_a-zA-Z0-9]*\\(.*\\)")) { // the function name is valid and the statement includes parenthesis
Boolean isAdditional = !(charcount < codeLength); // function is outside user code block (in additional functions)
String description = "<b>" + command + "</b><br>" + findDescription(textArray, linecount, "<i>User defined " + (isAdditional?"additional ":"") + "function" + (isAdditional?"":" as specified in line " + (linecount + 1)) + ".</i>");

completions.add(new BasicCompletion(this, command, null, description));
}
}
String lcasecommand = command.toLowerCase();
if (lcasecommand.contains(lcaseinput) && command.matches("[_a-zA-Z]+[_a-zA-Z0-9]*")) { // First character cannot be a digit ([_a-zA-Z]+), while the rest can be any valid character ([_a-zA-Z0-9]*)
if (!userVariables.contains(command)) {
userVariables.add(command);
varLines.add(String.valueOf(linecount + 1));
globalVarStatus.add(globalVar);
} else {
int index=userVariables.indexOf(command);
varLines.set(index, varLines.get(index) + ", " + String.valueOf(linecount + 1));
globalVarStatus.set(index, globalVarStatus.get(index) || globalVar);
if ((lcaseline.contains("=") || trimmedline.startsWith("var ")) && (charcount < codeLength)) { // possible variable assignment (= OR var) AND within user code block (not in additional functions)
String command = trimmedline;
if(command.contains("=")) command=command.substring(0, lcaseline.indexOf("=")).trim();
boolean globalVar = false;
if(command.startsWith("var ")) {
command = command.substring(4).trim().replace(";", ""); // in case of var declaration w/o assignment the trailing semicolon will be removed
globalVar= true;
}
String lcasecommand = command.toLowerCase();
if (lcasecommand.contains(lcaseinput) && command.matches("[_a-zA-Z]+[_a-zA-Z0-9]*")) { // First character cannot be a digit ([_a-zA-Z]+), while the rest can be any valid character ([_a-zA-Z0-9]*)
if (!userVariables.contains(command)) {
userVariables.add(command);
varLines.add(String.valueOf(linecount + 1));
globalVarStatus.add(globalVar);
} else {
int index=userVariables.indexOf(command);
varLines.set(index, varLines.get(index) + ", " + String.valueOf(linecount + 1));
globalVarStatus.set(index, globalVarStatus.get(index) || globalVar);
}
}
}
}
}
linecount++;
charcount += line.length() + 1;
}
Expand Down

0 comments on commit 6e34bfb

Please sign in to comment.