Skip to content

Commit 8b88ec9

Browse files
committed
Свой ModuleType
1 parent 336a31b commit 8b88ec9

File tree

71 files changed

+194
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+194
-78
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
2626
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
2727
import com.github._1c_syntax.bsl.languageserver.context.FileType;
28+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
2829
import com.github._1c_syntax.bsl.languageserver.context.symbol.RegionSymbol;
2930
import com.github._1c_syntax.bsl.languageserver.utils.Regions;
3031
import com.github._1c_syntax.mdclasses.Configuration;
3132
import com.github._1c_syntax.mdclasses.common.ConfigurationSource;
32-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
3333
import com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant;
3434
import org.eclipse.lsp4j.CodeAction;
3535
import org.eclipse.lsp4j.CodeActionKind;

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.github._1c_syntax.bsl.languageserver.context.computer.CyclomaticComplexityComputer;
2929
import com.github._1c_syntax.bsl.languageserver.context.computer.DiagnosticComputer;
3030
import com.github._1c_syntax.bsl.languageserver.context.computer.DiagnosticIgnoranceComputer;
31+
import com.github._1c_syntax.bsl.languageserver.context.computer.ModuleTypeComputer;
3132
import com.github._1c_syntax.bsl.languageserver.context.computer.QueryComputer;
3233
import com.github._1c_syntax.bsl.languageserver.context.computer.SymbolTreeComputer;
3334
import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol;
@@ -39,7 +40,6 @@
3940
import com.github._1c_syntax.bsl.parser.SDBLTokenizer;
4041
import com.github._1c_syntax.mdclasses.common.ConfigurationSource;
4142
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase;
42-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
4343
import com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant;
4444
import com.github._1c_syntax.mdclasses.supportconf.SupportConfiguration;
4545
import com.github._1c_syntax.mdclasses.supportconf.SupportVariant;
@@ -344,7 +344,8 @@ private SymbolTree computeSymbolTree() {
344344

345345

346346
private ModuleType computeModuleType() {
347-
return context.getConfiguration().getModuleType(uri);
347+
348+
return new ModuleTypeComputer(this).computeModuleType();
348349
}
349350

350351
private Map<SupportConfiguration, SupportVariant> computeSupportVariants() {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2022
5+
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
package com.github._1c_syntax.bsl.languageserver.context;
23+
24+
public enum ModuleType {
25+
BotModule(),
26+
IntegrationServiceModule(),
27+
CommandModule(),
28+
CommonModule(),
29+
ObjectModule(),
30+
ManagerModule(),
31+
FormModule(),
32+
RecordSetModule(),
33+
ValueManagerModule(),
34+
ApplicationModule(),
35+
ManagedApplicationModule(),
36+
SessionModule(),
37+
ExternalConnectionModule(),
38+
OrdinaryApplicationModule(),
39+
HTTPServiceModule(),
40+
WEBServiceModule(),
41+
Class(),
42+
Module(),
43+
UNKNOWN(); // для неизвестных типов модулей
44+
45+
public static ModuleType valueOf(com.github._1c_syntax.mdclasses.mdo.support.ModuleType mdoModuleType){
46+
47+
return valueOf(mdoModuleType.name());
48+
}
49+
}

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder;
2525
import com.github._1c_syntax.mdclasses.Configuration;
26-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
2726
import com.github._1c_syntax.utils.Absolute;
2827
import com.github._1c_syntax.utils.Lazy;
2928
import lombok.RequiredArgsConstructor;

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
package com.github._1c_syntax.bsl.languageserver.context.computer;
2323

2424
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
25+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
2526
import com.github._1c_syntax.bsl.languageserver.context.symbol.ModuleSymbol;
2627
import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder;
2728
import com.github._1c_syntax.bsl.languageserver.utils.Ranges;
2829
import com.github._1c_syntax.bsl.parser.BSLLexer;
29-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
3030
import org.antlr.v4.runtime.Token;
3131
import org.eclipse.lsp4j.SymbolKind;
3232

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2022
5+
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
package com.github._1c_syntax.bsl.languageserver.context.computer;
23+
24+
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
25+
import com.github._1c_syntax.bsl.languageserver.context.FileType;
26+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
27+
28+
public class ModuleTypeComputer {
29+
30+
private final DocumentContext documentContext;
31+
32+
public ModuleTypeComputer(DocumentContext documentContext) {
33+
this.documentContext = documentContext;
34+
}
35+
36+
public ModuleType computeModuleType() {
37+
38+
ModuleType moduleType;
39+
if (documentContext.getFileType() == FileType.BSL) {
40+
moduleType = computeBSL();
41+
} else if (documentContext.getFileType() == FileType.OS) {
42+
moduleType = computeOS();
43+
} else {
44+
moduleType = ModuleType.UNKNOWN;
45+
}
46+
47+
return moduleType;
48+
}
49+
50+
private ModuleType computeBSL() {
51+
com.github._1c_syntax.mdclasses.mdo.support.ModuleType type = documentContext.getServerContext()
52+
.getConfiguration().getModuleType(documentContext.getUri());
53+
return ModuleType.valueOf(type.name());
54+
}
55+
56+
private ModuleType computeOS() {
57+
if (documentContext.getUri().toString().contains("Модули")) {
58+
return ModuleType.Module;
59+
} else if (documentContext.getUri().toString().contains("Классы")) {
60+
return ModuleType.Class;
61+
} else {
62+
return ModuleType.UNKNOWN;
63+
}
64+
}
65+
}
66+

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.diagnostics;
2323

24+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
2425
import com.github._1c_syntax.bsl.languageserver.utils.Ranges;
2526
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBSL;
2627
import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase;
2728
import com.github._1c_syntax.mdclasses.mdo.support.MDOType;
28-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
2929
import org.checkerframework.checker.nullness.qual.NonNull;
3030
import org.eclipse.lsp4j.Range;
3131

@@ -111,7 +111,7 @@ private void checkMetadataWithModules() {
111111
documentContext.getMdObject().ifPresent((AbstractMDObjectBase mdo) -> {
112112
if (mdo instanceof AbstractMDObjectBSL) {
113113
var modules = ((AbstractMDObjectBSL) mdo).getModules().stream()
114-
.filter(mdoModule -> OBJECT_MODULES.contains(mdoModule.getModuleType()))
114+
.filter(mdoModule -> OBJECT_MODULES.contains(ModuleType.valueOf(mdoModule.getModuleType())))
115115
.collect(Collectors.toList());
116116

117117
// чтобы не анализировать несколько раз, выберем только один модуль, например модуль менеджера
@@ -134,7 +134,7 @@ private void checkMetadataWithoutModules() {
134134
.filter(mdo -> filterMdoTypes.contains(mdo.getType()))
135135
.filter(mdo -> !(mdo instanceof AbstractMDObjectBSL)
136136
|| (((AbstractMDObjectBSL) mdo).getModules().stream()
137-
.noneMatch(module -> OBJECT_MODULES.contains(module.getModuleType()))))
137+
.noneMatch(module -> OBJECT_MODULES.contains(ModuleType.valueOf(module.getModuleType())))))
138138
.forEach(this::checkMetadata);
139139
}
140140
}

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType;
3030
import com.github._1c_syntax.bsl.languageserver.utils.Keywords;
3131
import com.github._1c_syntax.mdclasses.mdo.MDCommonModule;
32-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
32+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
3333
import com.github._1c_syntax.mdclasses.mdo.support.ReturnValueReuse;
3434
import com.github._1c_syntax.utils.CaseInsensitivePattern;
3535

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType;
2929
import com.github._1c_syntax.bsl.languageserver.utils.Trees;
3030
import com.github._1c_syntax.bsl.parser.BSLParser;
31-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
31+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
3232
import com.github._1c_syntax.utils.CaseInsensitivePattern;
3333
import org.antlr.v4.runtime.tree.ParseTree;
3434

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.diagnostics;
2323

24+
import com.github._1c_syntax.bsl.languageserver.context.ModuleType;
2425
import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol;
2526
import com.github._1c_syntax.bsl.languageserver.context.symbol.RegionSymbol;
2627
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticCompatibilityMode;
@@ -35,7 +36,6 @@
3536
import com.github._1c_syntax.bsl.languageserver.utils.Trees;
3637
import com.github._1c_syntax.bsl.parser.BSLParser;
3738
import com.github._1c_syntax.bsl.parser.BSLParserRuleContext;
38-
import com.github._1c_syntax.mdclasses.mdo.support.ModuleType;
3939
import org.antlr.v4.runtime.tree.ParseTree;
4040
import org.antlr.v4.runtime.tree.TerminalNode;
4141
import org.antlr.v4.runtime.tree.Tree;
@@ -72,6 +72,7 @@ public class CodeOutOfRegionDiagnostic extends AbstractVisitorDiagnostic {
7272
public ParseTree visitFile(BSLParser.FileContext ctx) {
7373

7474
// Для неизвестных модулей не будем требовать нахождения кода в области
75+
// fix me bsl only
7576
if (documentContext.getModuleType() == ModuleType.UNKNOWN && !checkUnknownModuleType) {
7677
return ctx;
7778
}

0 commit comments

Comments
 (0)