Skip to content

Commit 59edc56

Browse files
committed
Fixed #41 Add a service to call semantic browser queries.
1 parent 7426022 commit 59edc56

File tree

8 files changed

+390
-28
lines changed

8 files changed

+390
-28
lines changed

plugins/org.obeonetwork.capella.m2doc.aql.queries/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
44
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
55
<classpathentry kind="src" path="src"/>
66
<classpathentry kind="src" path="src-utils"/>

plugins/org.obeonetwork.capella.m2doc.aql.queries/.settings/org.eclipse.jdt.core.prefs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4-
org.eclipse.jdt.core.compiler.compliance=1.6
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
4+
org.eclipse.jdt.core.compiler.compliance=11
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
67
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7-
org.eclipse.jdt.core.compiler.source=1.6
8+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
9+
org.eclipse.jdt.core.compiler.release=enabled
10+
org.eclipse.jdt.core.compiler.source=11
811
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
912
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
13+
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=20
1014
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
1115
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=20
1216
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
1317
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
1418
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
1519
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
1620
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
17-
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=20
21+
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=20
1822
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
1923
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
2024
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
2125
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
2226
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
27+
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=20
2328
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
2429
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
2530
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
31+
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=20
2632
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
2733
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
2834
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
2935
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
3036
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
37+
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=20
3138
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
3239
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
3340
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
@@ -117,11 +124,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
117124
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
118125
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
119126
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
127+
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
120128
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
121129
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
122130
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
123131
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
124-
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
132+
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
125133
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
126134
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
127135
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
@@ -152,6 +160,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
152160
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
153161
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
154162
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
163+
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
164+
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
155165
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
156166
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
157167
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
@@ -176,13 +186,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
176186
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
177187
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
178188
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
189+
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
179190
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
180191
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
192+
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
193+
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
181194
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
195+
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
182196
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
183197
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
184198
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
185-
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
199+
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
186200
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
187201
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
188202
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
@@ -230,6 +244,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no
230244
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
231245
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
232246
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
247+
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
248+
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
233249
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
234250
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
235251
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
@@ -266,9 +282,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
266282
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
267283
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
268284
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
285+
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
269286
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
270287
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
271288
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
289+
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
290+
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
272291
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
273292
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
274293
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@@ -304,9 +323,13 @@ org.eclipse.jdt.core.formatter.tabulation.char=space
304323
org.eclipse.jdt.core.formatter.tabulation.size=4
305324
org.eclipse.jdt.core.formatter.use_on_off_tags=true
306325
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
326+
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
307327
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
308-
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
328+
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
309329
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
330+
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
331+
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
310332
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
333+
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
311334
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
312335
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter

plugins/org.obeonetwork.capella.m2doc.aql.queries/META-INF/MANIFEST.MF

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ Require-Bundle: org.eclipse.core.runtime,
2020
org.polarsys.capella.core.sirius.analysis;bundle-version="[7.0.0,7.1.0)",
2121
org.polarsys.capella.common.re.ui;bundle-version="[7.0.0,7.1.0)",
2222
org.polarsys.capella.core.semantic.queries;bundle-version="[7.0.0,7.1.0)",
23-
org.polarsys.capella.common.re.gen;bundle-version="[7.0.0,7.1.0)"
23+
org.polarsys.capella.common.re.gen;bundle-version="[7.0.0,7.1.0)",
24+
org.polarsys.capella.common.ui.toolkit.browser;bundle-version="[7.0.0,7.1.0)",
25+
org.polarsys.capella.common.ui.massactions;bundle-version="[7.0.0,7.1.0)",
26+
org.polarsys.capella.common.ui.massactions.core;bundle-version="[7.0.0,7.1.0)"
2427
Bundle-ActivationPolicy: lazy
25-
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
28+
Bundle-RequiredExecutionEnvironment: JavaSE-11
2629
Bundle-Vendor: %providerName
2730
Export-Package: org.obeonetwork.capella.m2doc.aql.queries
2831
Automatic-Module-Name: org.obeonetwork.capella.m2doc.aql.queries

plugins/org.obeonetwork.capella.m2doc.aql.queries/src/org/obeonetwork/capella/m2doc/aql/queries/M2DocGenServices.java

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2022 Obeo.
2+
* Copyright (c) 2017, 2025 Obeo.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@
1313
import java.lang.reflect.Method;
1414
import java.util.ArrayList;
1515
import java.util.Collection;
16+
import java.util.Collections;
1617
import java.util.HashSet;
1718
import java.util.LinkedHashSet;
1819
import java.util.List;
@@ -59,6 +60,8 @@
5960
import org.obeonetwork.m2doc.element.MTable.MCell;
6061
import org.obeonetwork.m2doc.element.MTable.MRow;
6162
import org.polarsys.capella.common.data.modellingcore.ModelElement;
63+
import org.polarsys.capella.common.ui.massactions.core.shared.helper.SemanticBrowserHelper;
64+
import org.polarsys.capella.common.ui.toolkit.browser.category.ICategory;
6265
import org.polarsys.capella.core.data.cs.Component;
6366
import org.polarsys.capella.core.data.cs.InterfacePkg;
6467
import org.polarsys.capella.core.data.fa.ComponentExchange;
@@ -628,11 +631,65 @@ public boolean isVisibleInLM(DRepresentation rep) {
628631
return res;
629632
}
630633

631-
/**
632-
* {@inheritDoc}
633-
*
634-
* @see org.eclipse.acceleo.query.runtime.impl.AbstractServiceProvider#getService(java.lang.reflect.Method)
635-
*/
634+
// @formatter:off
635+
@Documentation(
636+
value = "Gets the list of available semantic browser query names for the given EObject.",
637+
params = {
638+
@Param(name = "eObj", value = "The EObject")
639+
},
640+
result = "the list of available semantic browser queries for the given EObject",
641+
examples = {
642+
@Example(expression = "myCapellaElement.availableSBQueries()", result = "Sequence{'query1', 'query2', ...}"),
643+
}
644+
)
645+
// @formatter:on
646+
public List<String> availableSBQueries(EObject eObj) {
647+
final List<String> res = new ArrayList<String>();
648+
649+
final Set<ICategory> queries = SemanticBrowserHelper.getCommonObjectCategories(Collections.singleton(eObj));
650+
for (ICategory query : queries) {
651+
res.add(query.getName());
652+
}
653+
Collections.sort(res);
654+
655+
return res;
656+
}
657+
658+
// @formatter:off
659+
@Documentation(
660+
value = "Gets the semantic browser query result for the given query name on the given EObject.",
661+
params = {
662+
@Param(name = "eObj", value = "The EObject"),
663+
@Param(name = "queryName", value = "The semantic query name")
664+
},
665+
result = "the list of EObject",
666+
examples = {
667+
@Example(expression = "myCapellaElement.getSBQuery('query1')", result = "Sequence{eObject1, eObject1, ...}"),
668+
}
669+
)
670+
// @formatter:on
671+
public List<EObject> getSBQuery(EObject eObj, String queryName) {
672+
List<EObject> res = new ArrayList<EObject>();
673+
674+
final Set<ICategory> queries = SemanticBrowserHelper.getCommonObjectCategories(Collections.singleton(eObj));
675+
ICategory foundQuery = null;
676+
for (ICategory query : queries) {
677+
if (query.getName().equals(queryName)) {
678+
foundQuery = query;
679+
break;
680+
}
681+
}
682+
if (foundQuery != null) {
683+
for (Object object : foundQuery.compute(eObj)) {
684+
if (object instanceof EObject) {
685+
res.add((EObject) object);
686+
}
687+
}
688+
}
689+
690+
return res;
691+
}
692+
636693
@Override
637694
protected IService getService(Method publicMethod) {
638695
final IService result;

0 commit comments

Comments
 (0)