@abaplint/core 2.120.63 → 2.120.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abaplint.d.ts +2 -154
- package/build/src/abap/2_statements/statements/create_data.js +1 -1
- package/build/src/abap/2_statements/statements/loop.js +1 -1
- package/build/src/abap/5_syntax/_type_utils.js +1 -0
- package/build/src/abap/5_syntax/basic_types.js +40 -1
- package/build/src/abap/5_syntax/expressions/_check_text_symbol.js +56 -0
- package/build/src/abap/5_syntax/expressions/method_call_param.js +4 -0
- package/build/src/abap/5_syntax/expressions/method_parameters.js +4 -0
- package/build/src/abap/5_syntax/expressions/select.js +7 -0
- package/build/src/abap/5_syntax/statements/create_data.js +3 -0
- package/build/src/abap/5_syntax/statements/loop.js +10 -3
- package/build/src/abap/5_syntax/statements/move.js +28 -0
- package/build/src/abap/artifacts.js +33 -36
- package/build/src/ddic.js +1 -1
- package/build/src/objects/_abstract_object.js +3 -0
- package/build/src/objects/_unknown_object.js +0 -3
- package/build/src/objects/abap_query_functional_area.js +0 -4
- package/build/src/objects/abap_query_query.js +0 -4
- package/build/src/objects/activation_variant.js +0 -4
- package/build/src/objects/api_release_state.js +0 -4
- package/build/src/objects/application_descriptors_fiori.js +0 -4
- package/build/src/objects/application_job_catalog_entry.js +0 -4
- package/build/src/objects/application_job_template.js +0 -4
- package/build/src/objects/application_log_object.js +0 -4
- package/build/src/objects/assignment_service_to_authorization_group.js +0 -4
- package/build/src/objects/atc_check_category.js +0 -4
- package/build/src/objects/atc_check_object.js +0 -4
- package/build/src/objects/atc_check_variant.js +0 -4
- package/build/src/objects/authorization_check_field.js +0 -4
- package/build/src/objects/authorization_group.js +0 -4
- package/build/src/objects/authorization_object.js +0 -4
- package/build/src/objects/authorization_object_class.js +0 -4
- package/build/src/objects/authorization_object_extension.js +0 -4
- package/build/src/objects/badi_definition.js +0 -4
- package/build/src/objects/behavior_definition.js +0 -4
- package/build/src/objects/brf_plus_system_application.js +0 -4
- package/build/src/objects/bsp_application.js +0 -4
- package/build/src/objects/business_add_in_implementation.js +0 -4
- package/build/src/objects/business_catalog.js +0 -4
- package/build/src/objects/business_catalog_app_assignment.js +0 -4
- package/build/src/objects/business_configuration_maintenance_object.js +0 -4
- package/build/src/objects/business_configuration_set.js +0 -4
- package/build/src/objects/business_function_assignment.js +0 -4
- package/build/src/objects/business_function_set_assignment.js +0 -4
- package/build/src/objects/business_object_model.js +0 -4
- package/build/src/objects/business_object_type.js +0 -4
- package/build/src/objects/cds_entity_buffer.js +0 -4
- package/build/src/objects/cds_metadata_extension.js +5 -4
- package/build/src/objects/cds_type.js +0 -4
- package/build/src/objects/change_document.js +0 -4
- package/build/src/objects/chapter_of_book_structure.js +0 -4
- package/build/src/objects/checkpoint_group.js +0 -4
- package/build/src/objects/classification.js +0 -4
- package/build/src/objects/communication_scenario.js +0 -4
- package/build/src/objects/composite_enhancement_implementation.js +0 -4
- package/build/src/objects/composite_enhancement_spot.js +0 -4
- package/build/src/objects/concepts_of_package.js +0 -4
- package/build/src/objects/custom_data_browser_object.js +0 -4
- package/build/src/objects/customer_enhancement_project.js +0 -4
- package/build/src/objects/customizing_attributes.js +0 -4
- package/build/src/objects/customizing_img_activity.js +0 -4
- package/build/src/objects/customizing_transaction.js +0 -4
- package/build/src/objects/data_control.js +0 -4
- package/build/src/objects/datastore_object.js +0 -4
- package/build/src/objects/dialog_module.js +0 -4
- package/build/src/objects/documentation.js +0 -4
- package/build/src/objects/domain.js +2 -0
- package/build/src/objects/ecatt_test_configuration.js +0 -4
- package/build/src/objects/ecatt_test_data_container.js +0 -4
- package/build/src/objects/ecatt_test_script.js +0 -4
- package/build/src/objects/email_template.js +0 -4
- package/build/src/objects/enhancement_spot.js +0 -4
- package/build/src/objects/entity_type.js +0 -4
- package/build/src/objects/event_binding.js +0 -4
- package/build/src/objects/event_consumer.js +0 -4
- package/build/src/objects/field_catalog.js +0 -4
- package/build/src/objects/form_object_form.js +0 -4
- package/build/src/objects/form_object_interface.js +0 -4
- package/build/src/objects/format_type.js +0 -4
- package/build/src/objects/gateway_model.js +0 -4
- package/build/src/objects/gateway_model_metadata.js +0 -4
- package/build/src/objects/gateway_odata_group_and_assignment.js +0 -4
- package/build/src/objects/gateway_project.js +0 -4
- package/build/src/objects/gateway_service.js +0 -4
- package/build/src/objects/gateway_service_groups_metadata.js +0 -4
- package/build/src/objects/gateway_vocabulary_annotation.js +0 -4
- package/build/src/objects/general_hierarchy_storage_extrension_name.js +0 -4
- package/build/src/objects/general_storage_structure.js +0 -4
- package/build/src/objects/general_text.js +0 -4
- package/build/src/objects/http_service.js +0 -4
- package/build/src/objects/iac_binary_data.js +0 -4
- package/build/src/objects/iac_language_resource.js +0 -4
- package/build/src/objects/iac_service.js +0 -4
- package/build/src/objects/iac_template.js +0 -4
- package/build/src/objects/iam_app.js +0 -4
- package/build/src/objects/icf_service.js +0 -4
- package/build/src/objects/idoc.js +0 -4
- package/build/src/objects/idoc_extension.js +0 -4
- package/build/src/objects/inbound_service.js +0 -4
- package/build/src/objects/info_area.js +0 -4
- package/build/src/objects/info_object.js +0 -4
- package/build/src/objects/knowledge_transfer_document.js +0 -4
- package/build/src/objects/maintenance_and_transport_object.js +0 -4
- package/build/src/objects/messaging_channel.js +0 -4
- package/build/src/objects/mime_object.js +1 -4
- package/build/src/objects/namespace.js +0 -4
- package/build/src/objects/neptune_api.js +0 -4
- package/build/src/objects/neptune_app.js +0 -4
- package/build/src/objects/neptune_custom_color.js +0 -4
- package/build/src/objects/neptune_custom_js_helper.js +0 -4
- package/build/src/objects/neptune_documentation.js +0 -4
- package/build/src/objects/neptune_enhancement.js +0 -4
- package/build/src/objects/neptune_launchpad.js +0 -4
- package/build/src/objects/neptune_launchpad_layout.js +0 -4
- package/build/src/objects/neptune_login_page.js +0 -4
- package/build/src/objects/neptune_media_library.js +0 -4
- package/build/src/objects/neptune_media_pack.js +0 -4
- package/build/src/objects/neptune_metadata.js +0 -4
- package/build/src/objects/neptune_mobile_client.js +0 -4
- package/build/src/objects/neptune_odata.js +0 -4
- package/build/src/objects/neptune_policy.js +0 -4
- package/build/src/objects/neptune_rfc_mapping.js +0 -4
- package/build/src/objects/neptune_rich_text_template.js +0 -4
- package/build/src/objects/neptune_splash_screen.js +0 -4
- package/build/src/objects/neptune_sticky_banner.js +0 -4
- package/build/src/objects/neptune_tile.js +0 -4
- package/build/src/objects/neptune_tile_group.js +0 -4
- package/build/src/objects/neptune_tile_layout.js +0 -4
- package/build/src/objects/neptune_url_alias.js +0 -4
- package/build/src/objects/oauth2_profile.js +0 -4
- package/build/src/objects/object_characteristic.js +0 -4
- package/build/src/objects/outbound_service.js +0 -4
- package/build/src/objects/package.js +0 -4
- package/build/src/objects/package_interface.js +0 -4
- package/build/src/objects/page_format.js +0 -4
- package/build/src/objects/parameter.js +0 -4
- package/build/src/objects/personalization_object.js +0 -4
- package/build/src/objects/push_channel.js +0 -4
- package/build/src/objects/query_user_group.js +0 -4
- package/build/src/objects/restriction_field.js +0 -4
- package/build/src/objects/restriction_type.js +0 -4
- package/build/src/objects/rfc_service.js +0 -4
- package/build/src/objects/sapscript.js +0 -4
- package/build/src/objects/sapscript_style.js +0 -4
- package/build/src/objects/screen_variant.js +0 -4
- package/build/src/objects/search_help.js +0 -4
- package/build/src/objects/service_binding.js +0 -4
- package/build/src/objects/service_definition.js +0 -4
- package/build/src/objects/shared_memory.js +0 -4
- package/build/src/objects/smart_form.js +0 -4
- package/build/src/objects/smart_style.js +0 -4
- package/build/src/objects/standard_task.js +0 -4
- package/build/src/objects/switch_assignment_hierarchy.js +0 -4
- package/build/src/objects/switch_assignments.js +0 -4
- package/build/src/objects/table.js +9 -3
- package/build/src/objects/technical_job_definition.js +0 -4
- package/build/src/objects/transaction_variant.js +0 -4
- package/build/src/objects/transformation.js +0 -4
- package/build/src/objects/view_cluster.js +0 -4
- package/build/src/objects/virtual_end_point.js +0 -4
- package/build/src/objects/web_dynpro_application.js +0 -4
- package/build/src/objects/web_dynpro_application_configuration.js +0 -4
- package/build/src/objects/web_dynpro_component.js +0 -4
- package/build/src/objects/web_dynpro_component_configuration.js +0 -4
- package/build/src/objects/web_reporting_template.js +0 -4
- package/build/src/registry.js +1 -1
- package/build/src/rules/else_after_all_returns.js +162 -0
- package/build/src/rules/implement_methods.js +36 -13
- package/build/src/rules/index.js +2 -0
- package/build/src/rules/preferred_parameter_ignored.js +141 -0
- package/package.json +1 -1
|
@@ -12,10 +12,6 @@ class SAPScriptStyle extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.SAPScriptStyle = SAPScriptStyle;
|
|
21
17
|
//# sourceMappingURL=sapscript_style.js.map
|
|
@@ -12,10 +12,6 @@ class ServiceBinding extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.ServiceBinding = ServiceBinding;
|
|
21
17
|
//# sourceMappingURL=service_binding.js.map
|
|
@@ -12,10 +12,6 @@ class ServiceDefinition extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.ServiceDefinition = ServiceDefinition;
|
|
21
17
|
//# sourceMappingURL=service_definition.js.map
|
|
@@ -12,10 +12,6 @@ class SwitchAssignmentHierarchy extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.SwitchAssignmentHierarchy = SwitchAssignmentHierarchy;
|
|
21
17
|
//# sourceMappingURL=switch_assignment_hierarchy.js.map
|
|
@@ -12,10 +12,6 @@ class SwitchAssignments extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.SwitchAssignments = SwitchAssignments;
|
|
21
17
|
//# sourceMappingURL=switch_assignments.js.map
|
|
@@ -113,11 +113,17 @@ class Table extends _abstract_object_1.AbstractObject {
|
|
|
113
113
|
}
|
|
114
114
|
const ret = [];
|
|
115
115
|
for (const p of this.parsedData.fields) {
|
|
116
|
-
if (p.KEYFLAG === "X" && p.FIELDNAME === ".INCLUDE") {
|
|
117
|
-
|
|
116
|
+
if (p.KEYFLAG === "X" && (p.FIELDNAME === ".INCLUDE" || p.FIELDNAME.startsWith(".INCLU-"))) {
|
|
117
|
+
let lookup = new ddic_1.DDIC(reg).lookupTableOrView(p.PRECFIELD).type;
|
|
118
|
+
if (lookup instanceof _typed_identifier_1.TypedIdentifier) {
|
|
119
|
+
lookup = lookup.getType();
|
|
120
|
+
}
|
|
121
|
+
// same naming as in parseType(), "--AP" are .APPENDS and get no suffix
|
|
122
|
+
const postfix = p.FIELDNAME.startsWith(".INCLU-") && p.FIELDNAME !== ".INCLU--AP"
|
|
123
|
+
? p.FIELDNAME.substring(".INCLU-".length) : "";
|
|
118
124
|
if (lookup instanceof Types.StructureType) {
|
|
119
125
|
for (const c of lookup.getComponents()) {
|
|
120
|
-
ret.push(c.name);
|
|
126
|
+
ret.push(c.name + postfix);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
@@ -12,10 +12,6 @@ class TechnicalJobDefinition extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.TechnicalJobDefinition = TechnicalJobDefinition;
|
|
21
17
|
//# sourceMappingURL=technical_job_definition.js.map
|
|
@@ -12,10 +12,6 @@ class TransactionVariant extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.TransactionVariant = TransactionVariant;
|
|
21
17
|
//# sourceMappingURL=transaction_variant.js.map
|
|
@@ -12,10 +12,6 @@ class VirtualEndPoint extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.VirtualEndPoint = VirtualEndPoint;
|
|
21
17
|
//# sourceMappingURL=virtual_end_point.js.map
|
|
@@ -12,10 +12,6 @@ class WebDynproApplication extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.WebDynproApplication = WebDynproApplication;
|
|
21
17
|
//# sourceMappingURL=web_dynpro_application.js.map
|
|
@@ -12,10 +12,6 @@ class WebDynproApplicationConfiguration extends _abstract_object_1.AbstractObjec
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.WebDynproApplicationConfiguration = WebDynproApplicationConfiguration;
|
|
21
17
|
//# sourceMappingURL=web_dynpro_application_configuration.js.map
|
|
@@ -12,10 +12,6 @@ class WebDynproComponent extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.WebDynproComponent = WebDynproComponent;
|
|
21
17
|
//# sourceMappingURL=web_dynpro_component.js.map
|
|
@@ -12,10 +12,6 @@ class WebDynproComponentConfiguration extends _abstract_object_1.AbstractObject
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.WebDynproComponentConfiguration = WebDynproComponentConfiguration;
|
|
21
17
|
//# sourceMappingURL=web_dynpro_component_configuration.js.map
|
|
@@ -12,10 +12,6 @@ class WebReportingTemplate extends _abstract_object_1.AbstractObject {
|
|
|
12
12
|
allowNamespace: true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
getDescription() {
|
|
16
|
-
// todo
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
15
|
}
|
|
20
16
|
exports.WebReportingTemplate = WebReportingTemplate;
|
|
21
17
|
//# sourceMappingURL=web_reporting_template.js.map
|
package/build/src/registry.js
CHANGED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ElseAfterAllReturns = exports.ElseAfterAllReturnsConf = void 0;
|
|
37
|
+
const issue_1 = require("../issue");
|
|
38
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
39
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
40
|
+
const _irule_1 = require("./_irule");
|
|
41
|
+
const Statements = __importStar(require("../abap/2_statements/statements"));
|
|
42
|
+
const Structures = __importStar(require("../abap/3_structures/structures"));
|
|
43
|
+
const Expressions = __importStar(require("../abap/2_statements/expressions"));
|
|
44
|
+
const nodes_1 = require("../abap/nodes");
|
|
45
|
+
const edit_helper_1 = require("../edit_helper");
|
|
46
|
+
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
47
|
+
class ElseAfterAllReturnsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
48
|
+
}
|
|
49
|
+
exports.ElseAfterAllReturnsConf = ElseAfterAllReturnsConf;
|
|
50
|
+
class ElseAfterAllReturns extends _abap_rule_1.ABAPRule {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
this.conf = new ElseAfterAllReturnsConf();
|
|
54
|
+
}
|
|
55
|
+
getMetadata() {
|
|
56
|
+
return {
|
|
57
|
+
key: "else_after_all_returns",
|
|
58
|
+
title: "Else after all returns",
|
|
59
|
+
shortDescription: `Finds ELSE branches that are redundant because all prior branches exit unconditionally.`,
|
|
60
|
+
extendedInformation: `When every branch preceding ELSE ends with RETURN, EXIT, or CONTINUE (or a non-resumable RAISE / LEAVE), ` +
|
|
61
|
+
`the ELSE keyword adds no logical value and can be removed by de-indenting its body.`,
|
|
62
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
|
|
63
|
+
badExample: `IF x = 1.\n RETURN.\nELSE.\n WRITE 'hello'.\nENDIF.`,
|
|
64
|
+
goodExample: `IF x = 1.\n RETURN.\nENDIF.\nWRITE 'hello'.`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getConfig() {
|
|
68
|
+
return this.conf;
|
|
69
|
+
}
|
|
70
|
+
setConfig(conf) {
|
|
71
|
+
this.conf = conf;
|
|
72
|
+
}
|
|
73
|
+
runParsed(file, _obj) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
const structure = file.getStructure();
|
|
76
|
+
if (structure === undefined) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
for (const ifNode of structure.findAllStructures(Structures.If)) {
|
|
80
|
+
const elseNode = ifNode.findDirectStructure(Structures.Else);
|
|
81
|
+
if (elseNode === undefined) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (this.allBranchesExit(ifNode)) {
|
|
85
|
+
const elseStatement = elseNode.findFirstStatement(Statements.Else);
|
|
86
|
+
const endifStatement = ifNode.findDirectStatement(Statements.EndIf);
|
|
87
|
+
if (elseStatement === undefined || endifStatement === undefined) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const fix = edit_helper_1.EditHelper.merge(edit_helper_1.EditHelper.replaceRange(file, elseStatement.getFirstToken().getStart(), elseStatement.getLastToken().getEnd(), "ENDIF."), edit_helper_1.EditHelper.deleteStatement(file, endifStatement));
|
|
91
|
+
const message = "Redundant ELSE: all prior branches exit unconditionally";
|
|
92
|
+
issues.push(issue_1.Issue.atStatement(file, elseStatement, message, this.getMetadata().key, this.conf.severity, fix));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return issues;
|
|
96
|
+
}
|
|
97
|
+
// Returns true if every branch before the ELSE ends with an unconditional exit.
|
|
98
|
+
allBranchesExit(ifNode) {
|
|
99
|
+
// Main IF body
|
|
100
|
+
const mainBody = ifNode.findDirectStructure(Structures.Body);
|
|
101
|
+
if (!this.bodyEndsWithExit(mainBody)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
// Each ELSEIF body
|
|
105
|
+
for (const elseifNode of ifNode.findDirectStructures(Structures.ElseIf)) {
|
|
106
|
+
const elseifBody = elseifNode.findDirectStructure(Structures.Body);
|
|
107
|
+
if (!this.bodyEndsWithExit(elseifBody)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
bodyEndsWithExit(body) {
|
|
114
|
+
if (body === undefined) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const last = this.lastNonCommentStatement(body);
|
|
118
|
+
if (last === undefined) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return this.isExit(last);
|
|
122
|
+
}
|
|
123
|
+
collectStatements(node) {
|
|
124
|
+
const result = [];
|
|
125
|
+
for (const child of node.getChildren()) {
|
|
126
|
+
if (child instanceof nodes_1.StatementNode) {
|
|
127
|
+
result.push(child);
|
|
128
|
+
}
|
|
129
|
+
else if (child instanceof nodes_1.StructureNode) {
|
|
130
|
+
result.push(...this.collectStatements(child));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
lastNonCommentStatement(node) {
|
|
136
|
+
const all = this.collectStatements(node);
|
|
137
|
+
for (let i = all.length - 1; i >= 0; i--) {
|
|
138
|
+
if (!(all[i].get() instanceof _statement_1.Comment)) {
|
|
139
|
+
return all[i];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
isExit(node) {
|
|
145
|
+
const s = node.get();
|
|
146
|
+
if (s instanceof Statements.Return
|
|
147
|
+
|| s instanceof Statements.Exit
|
|
148
|
+
|| s instanceof Statements.Continue) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (s instanceof Statements.Raise) {
|
|
152
|
+
return !node.concatTokens().toUpperCase().includes("RESUMABLE");
|
|
153
|
+
}
|
|
154
|
+
if (s instanceof Statements.Leave) {
|
|
155
|
+
const tokens = node.concatTokens().toUpperCase();
|
|
156
|
+
return !tokens.includes("LIST-PROCESSING") && node.findFirstExpression(Expressions.AndReturn) === undefined;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.ElseAfterAllReturns = ElseAfterAllReturns;
|
|
162
|
+
//# sourceMappingURL=else_after_all_returns.js.map
|
|
@@ -42,6 +42,8 @@ const Statements = __importStar(require("../abap/2_statements/statements"));
|
|
|
42
42
|
const Expressions = __importStar(require("../abap/2_statements/expressions"));
|
|
43
43
|
const _irule_1 = require("./_irule");
|
|
44
44
|
const edit_helper_1 = require("../edit_helper");
|
|
45
|
+
const syntax_1 = require("../abap/5_syntax/syntax");
|
|
46
|
+
const _reference_1 = require("../abap/5_syntax/_reference");
|
|
45
47
|
// todo: abstract methods from superclass parents(might be multiple), if class is not abstract
|
|
46
48
|
class ImplementMethodsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
47
49
|
}
|
|
@@ -152,7 +154,7 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
|
|
|
152
154
|
return undefined;
|
|
153
155
|
}
|
|
154
156
|
findInterface(identifier, name) {
|
|
155
|
-
const idef = this.findInterfaceByName(name);
|
|
157
|
+
const idef = this.findInterfaceByName(name, identifier);
|
|
156
158
|
if (idef === undefined) {
|
|
157
159
|
const message = "Implemented interface \"" + name + "\" not found";
|
|
158
160
|
const issue = issue_1.Issue.atIdentifier(identifier, message, this.getMetadata().key, this.conf.severity);
|
|
@@ -160,24 +162,45 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
|
|
|
160
162
|
}
|
|
161
163
|
return idef;
|
|
162
164
|
}
|
|
163
|
-
findInterfaceByName(name) {
|
|
165
|
+
findInterfaceByName(name, usedAt) {
|
|
164
166
|
var _a;
|
|
165
|
-
let idef = undefined;
|
|
166
167
|
const intf = this.reg.getObject("INTF", name);
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
const global = (_a = intf === null || intf === void 0 ? void 0 : intf.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getInfo().listInterfaceDefinitions()[0];
|
|
169
|
+
let local = undefined;
|
|
170
|
+
for (const file of this.obj.getABAPFiles()) {
|
|
171
|
+
local = file.getInfo().getInterfaceDefinitionByName(name);
|
|
172
|
+
if (local) {
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (local === undefined || global === undefined) {
|
|
177
|
+
return global || local;
|
|
178
|
+
}
|
|
179
|
+
// both a local and a global interface exist with the same name, use what the syntax check resolved
|
|
180
|
+
const resolved = this.findResolvedInterface(name, usedAt);
|
|
181
|
+
if (resolved !== undefined) {
|
|
169
182
|
for (const file of this.obj.getABAPFiles()) {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
for (const idef of file.getInfo().listInterfaceDefinitions()) {
|
|
184
|
+
if (idef.identifier.equals(resolved)) {
|
|
185
|
+
return idef;
|
|
186
|
+
}
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
189
|
}
|
|
177
|
-
|
|
178
|
-
|
|
190
|
+
return global;
|
|
191
|
+
}
|
|
192
|
+
findResolvedInterface(name, usedAt) {
|
|
193
|
+
var _a, _b, _c;
|
|
194
|
+
const scope = new syntax_1.SyntaxLogic(this.reg, this.obj).run().spaghetti.lookupPosition(usedAt.getStart(), usedAt.getFilename());
|
|
195
|
+
const upper = name.toUpperCase();
|
|
196
|
+
for (const ref of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
|
|
197
|
+
if (ref.referenceType === _reference_1.ReferenceType.ObjectOrientedReference
|
|
198
|
+
&& ((_a = ref.extra) === null || _a === void 0 ? void 0 : _a.ooType) === "INTF"
|
|
199
|
+
&& ((_c = (_b = ref.extra) === null || _b === void 0 ? void 0 : _b.ooName) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === upper) {
|
|
200
|
+
return ref.resolved;
|
|
201
|
+
}
|
|
179
202
|
}
|
|
180
|
-
return
|
|
203
|
+
return undefined;
|
|
181
204
|
}
|
|
182
205
|
/** including implemented super interfaces */
|
|
183
206
|
findInterfaceMethods(idef) {
|
|
@@ -296,7 +319,7 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
|
|
|
296
319
|
}
|
|
297
320
|
if (found === undefined) {
|
|
298
321
|
for (const i of def.interfaces) {
|
|
299
|
-
const idef = this.findInterfaceByName(i.name);
|
|
322
|
+
const idef = this.findInterfaceByName(i.name, def.identifier);
|
|
300
323
|
if (idef === undefined) {
|
|
301
324
|
continue;
|
|
302
325
|
}
|
package/build/src/rules/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __exportStar(require("./empty_event"), exports);
|
|
|
69
69
|
__exportStar(require("./empty_line_in_statement"), exports);
|
|
70
70
|
__exportStar(require("./empty_statement"), exports);
|
|
71
71
|
__exportStar(require("./empty_structure"), exports);
|
|
72
|
+
__exportStar(require("./else_after_all_returns"), exports);
|
|
72
73
|
__exportStar(require("./exit_or_check"), exports);
|
|
73
74
|
__exportStar(require("./expand_macros"), exports);
|
|
74
75
|
__exportStar(require("./exporting"), exports);
|
|
@@ -155,6 +156,7 @@ __exportStar(require("./prefer_string_template"), exports);
|
|
|
155
156
|
__exportStar(require("./prefer_returning_to_exporting"), exports);
|
|
156
157
|
__exportStar(require("./prefer_xsdbool"), exports);
|
|
157
158
|
__exportStar(require("./preferred_compare_operator"), exports);
|
|
159
|
+
__exportStar(require("./preferred_parameter_ignored"), exports);
|
|
158
160
|
__exportStar(require("./prefix_is_current_class"), exports);
|
|
159
161
|
__exportStar(require("./reduce_procedural_code"), exports);
|
|
160
162
|
__exportStar(require("./reduce_string_templates"), exports);
|