Search in sources :

Example 6 with ModuleType

use of com.github._1c_syntax.mdclasses.mdo.support.ModuleType in project bsl-language-server by 1c-syntax.

the class ReferenceIndex method getSourceDefinedSymbol.

private Optional<SourceDefinedSymbol> getSourceDefinedSymbol(MultiKey<String> multikey) {
    String mdoRef = multikey.getKey(0);
    ModuleType moduleType = ModuleType.valueOf(multikey.getKey(1));
    String symbolName = multikey.getKey(2);
    return serverContext.getDocument(mdoRef, moduleType).map(DocumentContext::getSymbolTree).flatMap(symbolTree -> symbolTree.getMethodSymbol(symbolName));
}
Also used : ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType)

Example 7 with ModuleType

use of com.github._1c_syntax.mdclasses.mdo.support.ModuleType in project bsl-language-server by 1c-syntax.

the class ReferenceIndex method addMethodCall.

/**
 * Добавить вызов метода в индекс.
 *
 * @param uri        URI документа, откуда произошел вызов.
 * @param mdoRef     Ссылка на объект-метаданных, к которому происходит обращение (например, CommonModule.ОбщийМодуль1).
 * @param moduleType Тип модуля, к которому происходит обращение (например, {@link ModuleType#CommonModule}).
 * @param symbolName Имя символа, к которому происходит обращение.
 * @param range      Диапазон, в котором происходит обращение к символу.
 */
@Synchronized
public void addMethodCall(URI uri, String mdoRef, ModuleType moduleType, String symbolName, Range range) {
    String symbolNameCanonical = symbolName.toLowerCase(Locale.ENGLISH);
    Location location = new Location(uri.toString(), range);
    MultiKey<String> key = getKey(mdoRef, moduleType);
    MultiKey<String> rangesKey = getRangesKey(mdoRef, moduleType, symbolNameCanonical);
    referencesTo.computeIfAbsent(key, k -> new ArrayListValuedHashMap<>()).put(symbolNameCanonical, location);
    referencesFrom.computeIfAbsent(uri, k -> new ArrayListValuedHashMap<>()).put(rangesKey, range);
    referencesRanges.computeIfAbsent(uri, k -> new HashMap<>()).put(range, rangesKey);
}
Also used : MultiMapUtils(org.apache.commons.collections4.MultiMapUtils) SymbolKind(org.eclipse.lsp4j.SymbolKind) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Range(org.eclipse.lsp4j.Range) HashMap(java.util.HashMap) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) SourceDefinedSymbol(com.github._1c_syntax.bsl.languageserver.context.symbol.SourceDefinedSymbol) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Ranges(com.github._1c_syntax.bsl.languageserver.utils.Ranges) Locale(java.util.Locale) Map(java.util.Map) Location(org.eclipse.lsp4j.Location) Position(org.eclipse.lsp4j.Position) URI(java.net.URI) Exportable(com.github._1c_syntax.bsl.languageserver.context.symbol.Exportable) MultiKey(org.apache.commons.collections4.keyvalue.MultiKey) ServerContext(com.github._1c_syntax.bsl.languageserver.context.ServerContext) Synchronized(lombok.Synchronized) MultiValuedMap(org.apache.commons.collections4.MultiValuedMap) Collection(java.util.Collection) MdoRefBuilder(com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder) ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) List(java.util.List) SymbolTree(com.github._1c_syntax.bsl.languageserver.context.symbol.SymbolTree) Optional(java.util.Optional) Collections(java.util.Collections) HashMap(java.util.HashMap) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Location(org.eclipse.lsp4j.Location) Synchronized(lombok.Synchronized)

Example 8 with ModuleType

use of com.github._1c_syntax.mdclasses.mdo.support.ModuleType in project mdclasses by 1c-syntax.

the class MDOUtils method moduleTypesForMDOTypes.

private Map<MDOType, Set<ModuleType>> moduleTypesForMDOTypes() {
    Map<MDOType, Set<ModuleType>> result = new EnumMap<>(MDOType.class);
    for (MDOType mdoType : MDOType.values()) {
        Set<ModuleType> types = new HashSet<>();
        switch(mdoType) {
            case INTEGRATION_SERVICE:
                types.add(ModuleType.IntegrationServiceModule);
                break;
            case BOT:
                types.add(ModuleType.BotModule);
                break;
            case ACCOUNTING_REGISTER:
            case ACCUMULATION_REGISTER:
            case CALCULATION_REGISTER:
            case INFORMATION_REGISTER:
                types.add(ModuleType.ManagerModule);
                types.add(ModuleType.RecordSetModule);
                break;
            case BUSINESS_PROCESS:
            case CATALOG:
            case CHART_OF_ACCOUNTS:
            case CHART_OF_CALCULATION_TYPES:
            case CHART_OF_CHARACTERISTIC_TYPES:
            case DATA_PROCESSOR:
            case DOCUMENT:
            case EXCHANGE_PLAN:
            case REPORT:
            case TASK:
                types.add(ModuleType.ManagerModule);
                types.add(ModuleType.ObjectModule);
                break;
            case COMMAND_GROUP:
            case COMMON_ATTRIBUTE:
            case COMMON_PICTURE:
            case COMMON_TEMPLATE:
            case DEFINED_TYPE:
            case DOCUMENT_NUMERATOR:
            case EVENT_SUBSCRIPTION:
            case FUNCTIONAL_OPTION:
            case ROLE:
            case SCHEDULED_JOB:
            case SESSION_PARAMETER:
            case STYLE_ITEM:
            case STYLE:
            case SUBSYSTEM:
            case WS_REFERENCE:
            case XDTO_PACKAGE:
                break;
            case COMMON_COMMAND:
            case COMMAND:
                types.add(ModuleType.CommandModule);
                break;
            case COMMON_FORM:
            case FORM:
                types.add(ModuleType.FormModule);
                break;
            case COMMON_MODULE:
                types.add(ModuleType.CommonModule);
                break;
            case CONFIGURATION:
                types.add(ModuleType.ApplicationModule);
                types.add(ModuleType.SessionModule);
                types.add(ModuleType.ExternalConnectionModule);
                types.add(ModuleType.ManagedApplicationModule);
                types.add(ModuleType.OrdinaryApplicationModule);
                break;
            case CONSTANT:
                types.add(ModuleType.ValueManagerModule);
                break;
            case DOCUMENT_JOURNAL:
            case ENUM:
            case FILTER_CRITERION:
            case SETTINGS_STORAGE:
                types.add(ModuleType.ManagerModule);
                break;
            case HTTP_SERVICE:
                types.add(ModuleType.HTTPServiceModule);
                break;
            case SEQUENCE:
                types.add(ModuleType.RecordSetModule);
                break;
            case WEB_SERVICE:
                types.add(ModuleType.WEBServiceModule);
                break;
            default:
        }
        result.put(mdoType, types);
    }
    return result;
}
Also used : ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) HashSet(java.util.HashSet) Set(java.util.Set) MDOType(com.github._1c_syntax.mdclasses.mdo.support.MDOType) EnumMap(java.util.EnumMap) HashSet(java.util.HashSet)

Aggregations

ModuleType (com.github._1c_syntax.mdclasses.mdo.support.ModuleType)8 DocumentContext (com.github._1c_syntax.bsl.languageserver.context.DocumentContext)3 Collections (java.util.Collections)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 LanguageServerConfiguration (com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration)2 FileType (com.github._1c_syntax.bsl.languageserver.context.FileType)2 Configuration (com.github._1c_syntax.mdclasses.Configuration)2 Collection (java.util.Collection)2 Set (java.util.Set)2 RequiredArgsConstructor (lombok.RequiredArgsConstructor)2 Position (org.eclipse.lsp4j.Position)2 Range (org.eclipse.lsp4j.Range)2 Component (org.springframework.stereotype.Component)2 Language (com.github._1c_syntax.bsl.languageserver.configuration.Language)1 DiagnosticsOptions (com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions)1 Mode (com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.Mode)1 SkipSupport (com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.SkipSupport)1 ServerContext (com.github._1c_syntax.bsl.languageserver.context.ServerContext)1