Skip to content

Commit

Permalink
feat: Remove convertJSONToGrammar_lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
travisstebbins committed Oct 25, 2024
1 parent 221acba commit 52feb73
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public interface FunctionExecutionSupport
String EXECUTE_QUERY_ID = "legend.query.execute";
String GENERATE_EXECUTION_PLAN_ID = "legend.executionPlan.generate";
String GRAMMAR_TO_JSON_LAMBDA_ID = "legend.grammarToJson.lambda";
String JSON_TO_GRAMMAR_LAMBDA_ID = "legend.jsonToGrammar.lambda";
String JSON_TO_GRAMMAR_LAMBDA_BATCH_ID = "legend.jsonToGrammar.lambda.batch";
String GET_LAMBDA_RETURN_TYPE_ID = "legend.lambda.returnType";

Expand Down Expand Up @@ -386,35 +385,6 @@ static Iterable<? extends LegendExecutionResult> convertGrammarToJSON_lambda(Fun
return results;
}

static Iterable<? extends LegendExecutionResult> convertJSONToGrammar_lambda(FunctionExecutionSupport executionSupport, SectionState section, String entityPath, Map<String, String> executableArgs, Map<String, Object> inputParameters)
{
AbstractLSPGrammarExtension extension = executionSupport.getExtension();

MutableList<LegendExecutionResult> results = Lists.mutable.empty();
try
{
Lambda lambda = objectMapper.readValue(executableArgs.get("lambda"), Lambda.class);
RenderStyle renderStyle = RenderStyle.valueOf(executableArgs.get("renderStyle"));
String grammar = lambda.accept(DEPRECATED_PureGrammarComposerCore.Builder.newInstance().withRenderStyle(renderStyle).build());
results.add(
FunctionLegendExecutionResult.newResult(
entityPath,
LegendExecutionResult.Type.SUCCESS,
grammar,
null,
section.getDocumentState().getDocumentId(),
section.getSectionNumber(),
inputParameters
)
);
}
catch (Exception e)
{
results.add(extension.errorResult(e, entityPath));
}
return results;
}

static Iterable<? extends LegendExecutionResult> convertJSONToGrammar_lambda_batch(FunctionExecutionSupport executionSupport, SectionState section, String entityPath, Map<String, String> executableArgs, Map<String, Object> inputParameters)
{
AbstractLSPGrammarExtension extension = executionSupport.getExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ public Iterable<? extends LegendExecutionResult> execute(SectionState section, S
{
return FunctionExecutionSupport.convertGrammarToJSON_lambda(this, section, entityPath, executableArgs, inputParams);
}
case FunctionExecutionSupport.JSON_TO_GRAMMAR_LAMBDA_ID:
{
return FunctionExecutionSupport.convertJSONToGrammar_lambda(this, section, entityPath, executableArgs, inputParams);
}
case FunctionExecutionSupport.JSON_TO_GRAMMAR_LAMBDA_BATCH_ID:
{
return FunctionExecutionSupport.convertJSONToGrammar_lambda_batch(this, section, entityPath, executableArgs, inputParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,41 +1096,6 @@ public void testConvertGrammarToJSON_lambda()
Assertions.assertEquals(expected, result.getMessage());
}

@Test
public void testConvertJSONToGrammar_lambda()
{
MutableMap<String, String> codeFiles = this.getCodeFilesThatParseCompile();
MutableList<SectionState> sectionStates = newSectionStates(codeFiles);
SectionState sectionState =
sectionStates.select(x -> x.getExtension() instanceof ServiceLSPGrammarExtension).getOnly();
String lambdaString =
"{" +
" \"_type\": \"lambda\"," +
" \"body\": [" +
" {" +
" \"_type\": \"string\"," +
" \"value\": \"testValue\"" +
" }" +
" ]," +
" \"parameters\": [" +
" {" +
" \"_type\": \"var\"," +
" \"name\": \"x\"" +
" }" +
" ]" +
"}";
Map<String, String> executableArgs = Map.of("lambda", lambdaString, "renderStyle", "STANDARD");

String expected = "x|'testValue'";
Iterable<? extends LegendExecutionResult> actual = testCommand(sectionState, "vscodelsp::test::TestService2",
JSON_TO_GRAMMAR_LAMBDA_ID, executableArgs);

Assertions.assertEquals(1, Iterate.sizeOf(actual));
LegendExecutionResult result = actual.iterator().next();
Assertions.assertEquals(LegendExecutionResult.Type.SUCCESS, result.getType(), result.getMessage());
Assertions.assertEquals(expected, result.getMessage());
}

@Test
public void testConvertJSONToGrammar_lambda_batch()
{
Expand Down

0 comments on commit 52feb73

Please sign in to comment.