Skip to content

Commit 62ccda7

Browse files
[DQL] Added toggle button for external DQL validations
1 parent 238ffdf commit 62ccda7

File tree

18 files changed

+127
-27
lines changed

18 files changed

+127
-27
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
or open a new DQL query console with the execution context.
2020
- Switched to a new Inlay provider. The user can now change inlay settings in `Settings` > `Editor` > `Inlay hints` >
2121
`Other` > `DQL`.
22+
- Added an option to toggle validating the DQL query on Dynatrace tenant after each change to the file. Previously
23+
only available globally in the plugin's settings, not the option will appear on the DQL Execution Toolbar and allows
24+
the user to easily toggle the validation for each file separately.
2225
- The "Show DQL query" option when executing DQL will now try to show the parsed query instead of the raw one, if
2326
possible.
2427
- Adding support for "Expression DQL" file (with `.dqlexpr` extension), which allows to define a DQL expression without

src/main/java/pl/thedeem/intellij/common/sdk/errors/DQLDetailedErrorException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public DQLErrorResponse getResponse() {
1818
}
1919

2020
public Map<String, Object> getErrorDetails() {
21-
return response != null && response.error != null ? Objects.requireNonNullElse(response.error.details(), Map.of()) : Map.of();
21+
return response != null && response.error != null ?
22+
Objects.requireNonNullElse(response.error.details(), Map.of())
23+
: Map.of();
2224
}
2325

2426
protected String getResponseMessage() {

src/main/java/pl/thedeem/intellij/common/sdk/errors/DQLInvalidResponseException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public DQLInvalidResponseException(String message) {
88
}
99

1010
public String getApiMessage() {
11-
return Objects.requireNonNullElse(getResponseMessage(), getMessage());
11+
return Objects.requireNonNullElseGet(getResponseMessage(), this::getMessage);
1212
}
1313

1414
protected abstract String getResponseMessage();

src/main/java/pl/thedeem/intellij/dpl/definition/DPLDefinitionServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public void invalidateCache() {
6666
}
6767

6868
private @NotNull DPLDefinition loadDefinition() {
69-
return Objects.requireNonNullElse(DefinitionUtils.loadDefinitionFromFile(DEFINITION_FILE, DPLDefinition.class), DPLDefinition.empty());
69+
return Objects.requireNonNullElse(
70+
DefinitionUtils.loadDefinitionFromFile(DEFINITION_FILE, DPLDefinition.class),
71+
DPLDefinition.empty()
72+
);
7073
}
7174

7275
private @NotNull Map<String, ExpressionDescription> loadCommands() {

src/main/java/pl/thedeem/intellij/dpl/documentation/providers/DPLConfigurationParameterDocumentationProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public DPLConfigurationParameterDocumentationProvider(@NotNull DPLParameterName
3535

3636
List<HtmlChunk> sections = new ArrayList<>();
3737
sections.add(HtmlChunk.p().child(tagElement().addText(parameterDefinition.type())));
38-
sections.add(buildDescription(Objects.requireNonNullElse(parameterDefinition.description(), DPLBundle.message("documentation.configuration.unknownParameter"))));
38+
sections.add(buildDescription(Objects.requireNonNullElseGet(
39+
parameterDefinition.description(),
40+
() -> DPLBundle.message("documentation.configuration.unknownParameter"))
41+
));
3942

4043
Set<String> names = parameterDefinition.names();
4144
if (names.size() > 1) {

src/main/java/pl/thedeem/intellij/dpl/inspections/configuration/ConfigurationNotSupportedInspection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public void visitExpressionDefinition(@NotNull DPLExpressionDefinition expressio
2828
return;
2929
}
3030
ExpressionDescription description = expression.getDefinition();
31-
Map<String, Configuration> configurationDefinition = description != null ? Objects.requireNonNullElse(description.configuration(), Map.of()) : Map.of();
31+
Map<String, Configuration> configurationDefinition = description != null ?
32+
Objects.requireNonNullElse(description.configuration(), Map.of())
33+
: Map.of();
3234
if (configurationDefinition.isEmpty()) {
3335
holder.registerProblem(
3436
configuration.getConfigurationContent(),

src/main/java/pl/thedeem/intellij/dpl/psi/elements/impl/ExpressionElementImpl.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ public ExpressionElementImpl(@NotNull ASTNode node) {
3737
parameters = group.getParameters();
3838
} else {
3939
DPLConfigurationExpression configuration = getConfiguration();
40-
parameters = List.of(Objects.requireNonNullElse(PsiTreeUtil.getChildrenOfType(configuration, DPLParameterExpression.class), new DPLParameterExpression[0]));
40+
parameters = List.of(Objects.requireNonNullElse(
41+
PsiTreeUtil.getChildrenOfType(configuration, DPLParameterExpression.class),
42+
new DPLParameterExpression[0]
43+
));
4144
}
4245

4346
ExpressionDescription description = getDefinition();
44-
Map<String, Configuration> configurationDefinition = description != null ? Objects.requireNonNullElse(description.configuration(), Map.of()) : Map.of();
47+
Map<String, Configuration> configurationDefinition = description != null ?
48+
Objects.requireNonNullElse(description.configuration(), Map.of())
49+
: Map.of();
4550

4651
Set<String> result = new HashSet<>();
4752
for (DPLParameterExpression parameter : parameters) {
@@ -63,7 +68,9 @@ public ExpressionElementImpl(@NotNull ASTNode node) {
6368
public @NotNull Set<Configuration> getAvailableConfiguration(@NotNull DPLGroupExpression group) {
6469
Set<String> definedParameters = getDefinedParameters(group);
6570
ExpressionDescription description = getDefinition();
66-
Map<String, Configuration> allParameters = description != null ? Objects.requireNonNullElse(description.configuration(), Map.of()) : Map.of();
71+
Map<String, Configuration> allParameters = description != null ?
72+
Objects.requireNonNullElse(description.configuration(), Map.of())
73+
: Map.of();
6774

6875
Set<Configuration> result = new HashSet<>();
6976
for (Configuration parameter : allParameters.values()) {

src/main/java/pl/thedeem/intellij/dql/actions/ExecuteDQLQueryAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void actionPerformed(@NotNull AnActionEvent original) {
6363
DQLExecutionService service = new DQLExecutionService(
6464
DQLBundle.message(
6565
"services.executeDQL.serviceName",
66-
Objects.requireNonNullElse(e.getData(PREFERRED_EXECUTION_NAME), file.getName())
66+
Objects.requireNonNullElseGet(e.getData(PREFERRED_EXECUTION_NAME), file::getName)
6767
),
6868
configuration,
6969
project,

src/main/java/pl/thedeem/intellij/dql/documentation/providers/BaseDocumentationProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public BaseDocumentationProvider(@NotNull T element) {
3232
}
3333

3434
public @Nullable String generateDocumentation() {
35-
return Objects.requireNonNullElse(super.generateDocumentation(), DQLBundle.message("documentation.missingDocs"));
35+
return Objects.requireNonNullElseGet(super.generateDocumentation(), () -> DQLBundle.message("documentation.missingDocs"));
3636
}
3737

3838
protected @NotNull HtmlChunk buildSyntaxSection(@NotNull String syntax) {
@@ -66,7 +66,9 @@ public BaseDocumentationProvider(@NotNull T element) {
6666
return HtmlChunk.span().addText(DQLBundle.message("documentation.parameter.unknown"));
6767
}
6868
List<HtmlChunk> sections = new ArrayList<>();
69-
sections.add(HtmlChunk.span().addText(Objects.requireNonNullElse(parameter.description(), DQLBundle.message("documentation.parameter.noDescription"))));
69+
sections.add(HtmlChunk.span().addText(Objects.requireNonNullElseGet(
70+
parameter.description(), () -> DQLBundle.message("documentation.parameter.noDescription")
71+
)));
7072
HtmlChunk values = prepareValuesDescription(parameter.valueTypes(), project);
7173
if (!values.isEmpty()) {
7274
sections.add(main ?

src/main/java/pl/thedeem/intellij/dql/editor/actions/QueryConfigurationAction.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class QueryConfigurationAction extends AnAction implements CustomComponen
1717
public static final DataKey<Boolean> SHOW_QUERY_EXECUTE_BUTTON = DataKey.create("DQL_SHOW_QUERY_EXECUTE_BUTTON");
1818
public static final DataKey<Boolean> SHOW_TENANT_SELECTION = DataKey.create("DQL_SHOW_TENANT_SELECTION");
1919
public static final DataKey<Boolean> SHOW_RUN_CONFIG_CREATOR = DataKey.create("DQL_SHOW_RUN_CONFIG_CREATOR");
20+
public static final DataKey<Boolean> SHOW_QUERY_VALIDATION_OPTION = DataKey.create("DQL_SHOW_QUERY_VALIDATION_OPTION");
2021

2122
private JComponent component;
2223

@@ -74,6 +75,13 @@ public void update(@NotNull AnActionEvent e) {
7475
e.getPresentation().setEnabledAndVisible(!Boolean.FALSE.equals(e.getData(SHOW_QUERY_EXECUTE_BUTTON)));
7576
}
7677
});
78+
group.add(new ToggleExternalValidationAction() {
79+
@Override
80+
public void update(@NotNull AnActionEvent e) {
81+
super.update(e);
82+
e.getPresentation().setEnabledAndVisible(!Boolean.FALSE.equals(e.getData(SHOW_QUERY_VALIDATION_OPTION)));
83+
}
84+
});
7785
group.addAction(new QueryConfigurationTimeframeAction() {
7886
@Override
7987
public void update(@NotNull AnActionEvent e) {

0 commit comments

Comments
 (0)