Skip to content

Commit

Permalink
Begin Work on Removing Lombok Dep From Project
Browse files Browse the repository at this point in the history
This is a massive annoyance as I never should've had a lombok dep in the first place. It was worth experimenting with but didn't turn out to be particularly useful to me. I'm particularly removing this now because after the migration to the latest Bazel version I suddenly need to use the --nojava_header_compilation flag on all of my bazel build/run commands simply because Lombok has some obnoxious failure mode w/o it. Lombok's not fully removed in this CL but this required a ton of manual refactoring so I'm checking this in now.
  • Loading branch information
JasonSteving99 committed Jul 11, 2023
1 parent 7f7964d commit 247f42d
Show file tree
Hide file tree
Showing 15 changed files with 746 additions and 729 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.2.1
6 changes: 3 additions & 3 deletions src/java/com/claro/ClaroLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import java.util.concurrent.atomic.AtomicReference;
private <T> Symbol symbol(int type, int lines, int columns, T value) {
addToLine(value);
final StringBuilder currentInputLineBuilder = currentInputLine.get();
Symbol res = new Symbol(type, yycolumn, yyline, new LexedValue<T>(value, () -> currentInputLineBuilder.toString(), columns));
Symbol res = new Symbol(type, yycolumn, yyline, LexedValue.create(value, () -> currentInputLineBuilder.toString(), columns));
yyline += lines;
yycolumn += columns;
return res;
Expand Down Expand Up @@ -338,7 +338,7 @@ PrivilegedInlineJava = [^]*\$\$END_JAVA
string.setLength(0);
addToLine("\"");
final StringBuilder currentInputLineBuilder = currentInputLine.get();
return new Symbol(Tokens.STRING, ++yycolumn - matchedString.length() - 2 , yyline, new LexedValue(matchedString, () -> currentInputLineBuilder.toString(), matchedString.length() + 2));
return new Symbol(Tokens.STRING, ++yycolumn - matchedString.length() - 2 , yyline, LexedValue.create(matchedString, () -> currentInputLineBuilder.toString(), matchedString.length() + 2));
}
[^\n\r\"\\{]+ {
String parsed = yytext();
Expand Down Expand Up @@ -368,7 +368,7 @@ PrivilegedInlineJava = [^]*\$\$END_JAVA
yycolumn++;
addToLine("{");
final StringBuilder currentInputLineBuilder = currentInputLine.get();
return new Symbol(Tokens.FMT_STRING_PART, yycolumn, yyline, new LexedValue<String>(fmtStringPart, () -> currentInputLineBuilder.toString(), fmtStringPart.length() + 1));
return new Symbol(Tokens.FMT_STRING_PART, yycolumn, yyline, LexedValue.create(fmtStringPart, () -> currentInputLineBuilder.toString(), fmtStringPart.length() + 1));
}
}

Expand Down
1,068 changes: 534 additions & 534 deletions src/java/com/claro/ClaroParser.cup

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions src/java/com/claro/LexedValue.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.claro;

import lombok.AllArgsConstructor;
import lombok.Data;
import com.google.auto.value.AutoValue;

import java.util.function.Supplier;

@Data
@AllArgsConstructor
public class LexedValue<T> {
public final T val;
public final Supplier<String> currentInputLine;
public final int len;
@AutoValue
public abstract class LexedValue<T> {
public abstract T getVal();

public abstract Supplier<String> getCurrentInputLine();

public abstract int getLen();

public static <T> LexedValue<T> create(T val, Supplier<String> currentInputLine, int len) {
return new AutoValue_LexedValue<>(val, currentInputLine, len);
}
}
4 changes: 2 additions & 2 deletions src/java/com/claro/claro_build_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def claro_library(name, src, module_api_file = None, java_name = None, claro_com
DEFAULT_PACKAGE_PREFIX, # --package
# Here, construct a totally unique name for this particular module. Since we're using Bazel, I have the
# guarantee that this RULEDIR+target name is globally unique across the entire project.
"--unique_module_name=$$(echo $(RULEDIR) | cut -c $$(($$(echo $(GENDIR) | wc -c ) - 1))- | tr '/' '$$')\$$" + name if isModule else ""
"--unique_module_name=$$(echo $(RULEDIR) | cut -c $$(($$(echo $(GENDIR) | wc -c ) - 1))- | tr '/' '$$')\\$$" + name if isModule else ""
),
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], # Gives the above cmd access to $(JAVA).
tools = [
Expand Down Expand Up @@ -199,6 +199,6 @@ def gen_claro_compiler(name = DEFAULT_CLARO_NAME):
name = "lexed_value",
srcs = ["LexedValue.java"],
deps = [
"//:lombok",
"//:autovalue",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public ConsumerFunctionDefinitionStmt(
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public FunctionDefinitionStmt(
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ private ProcedureDefinitionStmt generateProcedureDefStmt(String canonicalProcedu
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down Expand Up @@ -319,7 +320,8 @@ private ProcedureDefinitionStmt generateProcedureDefStmt(String canonicalProcedu
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down Expand Up @@ -355,7 +357,8 @@ private ProcedureDefinitionStmt generateProcedureDefStmt(String canonicalProcedu
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public void registerProcedureTypeProvider(ScopedHeap scopedHeap) {
.collect(
ImmutableMap.toImmutableMap(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)),
injectedKey -> injectedKey.optionalAlias
new Key(injectedKey.getName(), injectedKey.getTypeProvider().resolveType(scopedHeap)),
injectedKey -> injectedKey.getOptionalAlias()
)));

// Validate that this is not a redeclaration of an identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public ProviderFunctionDefinitionStmt(
injectedKeysTypes.stream()
.map(
injectedKey ->
new Key(injectedKey.name, injectedKey.typeProvider.resolveType(scopedHeap)))
new Key(injectedKey.getName(), injectedKey.getTypeProvider()
.resolveType(scopedHeap)))
.collect(Collectors.toSet())
)
.orElse(Sets.newHashSet()),
Expand Down
2 changes: 1 addition & 1 deletion src/java/com/claro/module_system/ModuleApiLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import java.util.concurrent.atomic.AtomicReference;
private <T> Symbol symbol(int type, int lines, int columns, T value) {
addToLine(value);
final StringBuilder currentInputLineBuilder = currentInputLine.get();
Symbol res = new Symbol(type, yycolumn, yyline, new LexedValue<T>(value, () -> currentInputLineBuilder.toString(), columns));
Symbol res = new Symbol(type, yycolumn, yyline, LexedValue.create(value, () -> currentInputLineBuilder.toString(), columns));
yyline += lines;
yycolumn += columns;
return res;
Expand Down
Loading

0 comments on commit 247f42d

Please sign in to comment.