Skip to content

Commit

Permalink
refactor: Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperLorelai committed Mar 29, 2024
1 parent b0ac072 commit 098fba5
Show file tree
Hide file tree
Showing 29 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/main/java/eu/jasperlorelai/circe/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public String parse(String string) {
if (expression == null) return "";

/*
* If we want the string node to be quoteless, we have to execute the function
* If we want the string node to be unquoted, we have to execute the function
* expression manually, otherwise we'll get the right value() but of function node type.
*/
if (expression instanceof FunctionNode functionNode) {
expression = functionNode.getFunction().execute();
}
if (expression instanceof StringLiteralNode stringNode) return stringNode.quoteless();
if (expression instanceof StringLiteralNode stringNode) return stringNode.unquoted();
return expression.value();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public NodeType<StringLiteralNode> getType() {
return NodeType.STRING;
}

public String quoteless() {
public String unquoted() {
return value.substring(1, value.length() - 1).replaceAll("\\\\\"", "\"");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ExpressionNode<?> execute() {
variableMap.put(name, number.valueDouble());
});

return new NumberLiteralNode(new ExpressionBuilder(string.quoteless())
return new NumberLiteralNode(new ExpressionBuilder(string.unquoted())
.variables(variableMap.keySet())
.build()
.setVariables(variableMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return stringNode(string.quoteless().charAt(index.valueInteger()) + "");
return stringNode(string.unquoted().charAt(index.valueInteger()) + "");
} catch (IndexOutOfBoundsException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return numberNode(string.quoteless().charAt(index.valueInteger()));
return numberNode(string.unquoted().charAt(index.valueInteger()));
} catch (IndexOutOfBoundsException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
ExpressionNode<?> node = elementString == null ? elementNumber : elementString;
if (array == null) return stringFromBool(string.quoteless().contains(valueQuoteless(node)));
if (array == null) return stringFromBool(string.unquoted().contains(valueQuoteless(node)));
else return stringFromBool(array.stringArray().contains(node.value()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringFromBool(string.quoteless().endsWith(substring.quoteless()));
return stringFromBool(string.unquoted().endsWith(substring.unquoted()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ExpressionNode<?> execute() {
return stringFromBool(arrayFirst.value().equals(arraySecond.value()));
}
if (stringFirst != null && stringSecond != null) {
return stringFromBool(stringFirst.quoteless().equals(stringSecond.quoteless()));
return stringFromBool(stringFirst.unquoted().equals(stringSecond.unquoted()));
}
return stringFromBool(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
public ExpressionNode<?> execute() {
ExpressionNode<?> node = elementString == null ? elementNumber : elementString;
if (string == null) return numberNode(array.stringArray().indexOf(node.value()));
else return numberNode(string.quoteless().indexOf(valueQuoteless(node)));
else return numberNode(string.unquoted().indexOf(valueQuoteless(node)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringFromBool(string == null ? array.array().isEmpty() : string.quoteless().isEmpty());
return stringFromBool(string == null ? array.array().isEmpty() : string.unquoted().isEmpty());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ExpressionNode<?> execute() {
return stringNode(array.array()
.stream()
.map(Function::valueQuoteless)
.collect(Collectors.joining(delimiter.quoteless()))
.collect(Collectors.joining(delimiter.unquoted()))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
public ExpressionNode<?> execute() {
ExpressionNode<?> node = elementString == null ? elementNumber : elementString;
if (string == null) return numberNode(array.stringArray().lastIndexOf(node.value()));
else return numberNode(string.quoteless().lastIndexOf(valueQuoteless(node)));
else return numberNode(string.unquoted().lastIndexOf(valueQuoteless(node)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringNode(string.quoteless().toLowerCase());
return stringNode(string.unquoted().toLowerCase());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
public ExpressionNode<?> execute() {
try {
List<String> list = new ArrayList<>();
Matcher matcher = Pattern.compile(pattern.quoteless()).matcher(string.quoteless());
Matcher matcher = Pattern.compile(pattern.unquoted()).matcher(string.unquoted());
while (matcher.find()) {
for (int j = 0; j <= matcher.groupCount(); j++) {
list.add(matcher.group(j));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@NotNull
@Override
public ExpressionNode<?> execute() {
StringBuilder newString = new StringBuilder(string.quoteless());
while (minLength.valueInteger() > newString.length()) newString.append(padChar.quoteless());
StringBuilder newString = new StringBuilder(string.unquoted());
while (minLength.valueInteger() > newString.length()) newString.append(padChar.unquoted());
return stringNode(newString.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
StringBuilder newString = new StringBuilder();
String quoteless = string.quoteless();
String quoteless = string.unquoted();
int length = quoteless.length();
while (minLength.valueInteger() > newString.length() + length) newString.append(padChar.quoteless());
while (minLength.valueInteger() > newString.length() + length) newString.append(padChar.unquoted());
newString.append(quoteless);
return stringNode(newString.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return stringNode(string.quoteless().repeat(amount.valueInteger()));
return stringNode(string.unquoted().repeat(amount.valueInteger()));
} catch (IllegalArgumentException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return stringNode(string.quoteless().replaceAll(pattern.quoteless(), replacement.quoteless()));
return stringNode(string.unquoted().replaceAll(pattern.unquoted(), replacement.unquoted()));
} catch (PatternSyntaxException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return stringNode(string.quoteless().replaceFirst(pattern.quoteless(), replacement.quoteless()));
return stringNode(string.unquoted().replaceFirst(pattern.unquoted(), replacement.unquoted()));
} catch (PatternSyntaxException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringNode(new StringBuilder(string.quoteless()).reverse().toString());
return stringNode(new StringBuilder(string.unquoted()).reverse().toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return numberNode(array == null ? string.quoteless().length() : array.array().size());
return numberNode(array == null ? string.unquoted().length() : array.array().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return arrayNode(Arrays.asList(string.quoteless().split(pattern.quoteless(), limit.valueInteger())));
return arrayNode(Arrays.asList(string.unquoted().split(pattern.unquoted(), limit.valueInteger())));
} catch (PatternSyntaxException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringFromBool(string.quoteless().startsWith(substring.quoteless()));
return stringFromBool(string.unquoted().startsWith(substring.unquoted()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
try {
return stringNode(string.quoteless().substring(startIndex.valueInteger(), endIndex.valueInteger()));
return stringNode(string.unquoted().substring(startIndex.valueInteger(), endIndex.valueInteger()));
} catch (IndexOutOfBoundsException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@Override
public ExpressionNode<?> execute() {
try {
return new NumberLiteralNode(Double.parseDouble(string.quoteless()) + "");
return new NumberLiteralNode(Double.parseDouble(string.unquoted()) + "");
} catch (NumberFormatException e) {
throw formatException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringNode(string.quoteless().trim());
return stringNode(string.unquoted().trim());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void initializeArguments(@NotNull List<ExpressionNode<?>> arguments) {
@Override
public ExpressionNode<?> execute() {
List<String> list = new ArrayList<>();
list.add(elementString == null ? elementNumber.value() : elementString.quoteless());
list.add(elementString == null ? elementNumber.value() : elementString.unquoted());
array.array().forEach(item -> list.add(valueQuoteless(item)));
return arrayNode(list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void initializeTarget(@NotNull ExpressionNode<?> target) {
@NotNull
@Override
public ExpressionNode<?> execute() {
return stringNode(string.quoteless().toUpperCase());
return stringNode(string.unquoted().toUpperCase());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected ArrayNode castArray(ExpressionNode<?> node) {
}

protected static String valueQuoteless(ExpressionNode<?> node) {
return node instanceof StringLiteralNode string ? string.quoteless() : node.value();
return node instanceof StringLiteralNode string ? string.unquoted() : node.value();
}

protected static String quote(String string) {
Expand Down

0 comments on commit 098fba5

Please sign in to comment.