File: idecodecompletiontypes.hxx

package info (click to toggle)
libreoffice 4%3A26.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,833,120 kB
  • sloc: cpp: 4,395,780; xml: 499,109; java: 254,438; python: 81,820; ansic: 33,823; perl: 30,297; javascript: 19,722; sh: 12,050; makefile: 10,854; cs: 8,865; yacc: 8,549; objc: 2,131; lex: 1,385; asm: 1,231; awk: 996; pascal: 914; csh: 20; sed: 5
file content (176 lines) | stat: -rw-r--r-- 4,752 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <vector>
#include <map>
#include <optional>
#include <memory>
#include <string_view>

#include <rtl/ustring.hxx>
#include <basic/sbxdef.hxx>

namespace basctl
{
enum class IdeSymbolKind
{
    UNKNOWN,
    VARIABLE,
    CONSTANT,
    PARAMETER,
    FUNCTION,
    SUB,
    PROPERTY_GET,
    PROPERTY_LET,
    PROPERTY_SET,
    UDT, // User Defined Type (Struct)
    UDT_MEMBER,
    ENUM,
    ENUM_MEMBER,
    MODULE,
    NAMESPACE,
    LIBRARY,
    CLASS_MODULE, // BASIC Class Module
    // UNO specific kinds
    UNO_SERVICE,
    UNO_INTERFACE,
    UNO_STRUCT,
    UNO_ENUM,
    UNO_CONSTANTS, // A constants group
    UNO_EXCEPTION,
    UNO_TYPE, // Generic UNO type
    UNO_TYPEDEF,
    UNO_METHOD,
    UNO_PROPERTY,
    UNO_FIELD, // For struct/exception members
    // Built-in specific kinds
    BUILTIN_FUNCTION,
    BUILTIN_PROPERTY,
    GLOBAL_CONSTANT_UNO, // e.g. StarDesktop
    // Logical groupings for the browser UI
    ROOT_APPLICATION_LIBS,
    ROOT_DOCUMENT_LIBS,
    ROOT_UNO_APIS,
    ROOT_BASIC_BUILTINS,
    UNO_NAMESPACE,
    PLACEHOLDER // For temporary UI nodes like "[Loading...]"
};

enum class IdeScopeKind
{
    UNKNOWN,
    GLOBAL_APPLICATION,
    GLOBAL_DOCUMENT,
    LIBRARY_PUBLIC,
    MODULE_PUBLIC,
    MODULE_PRIVATE,
    CLASS_MEMBER_PUBLIC,
    CLASS_MEMBER_PRIVATE,
    PROCEDURE_LOCAL,
    BLOCK_LOCAL,
    WITH_BLOCK_MEMBER
};

enum class IdeAccessModifier
{
    NOT_APPLICABLE,
    PUBLIC,
    PRIVATE
};

struct IdeParamInfo
{
    OUString sName;
    OUString sTypeName;
    OUString sQualifiedTypeName;
    SbxDataType eBasicType = SbxDataType::SbxEMPTY;
    bool bIsByVal = true;
    bool bIsOptional = false;
    bool bIsUnoTypeOrigin = false;
    std::optional<OUString> osDefaultValueExpression;
    bool bIsParamArray = false;
    // For UNO parameters
    bool bIsOut = false;
    bool bIsIn = true;

    IdeParamInfo() = default;
    IdeParamInfo(OUString sName_, OUString sTypeName_, bool bOut, bool bIn);
};

/**
 * @struct IdeDimensionInfo
 * @brief Represents array dimension bounds.
 */
struct IdeDimensionInfo
{
    sal_Int32 nLowerBound = 0;
    sal_Int32 nUpperBound = 0;
    bool bIsDynamic = true;

    IdeDimensionInfo() = default;
    IdeDimensionInfo(sal_Int32 lower, sal_Int32 upper, bool dynamic = false);
};

/**
 * @struct IdeSymbolInfo
 * @brief Comprehensive structure for storing metadata about any program symbol.
 * @comment For mapMembers, the IdeSymbolInfo objects pointed to are owned.
 *          Direct cycles through mapMembers are not expected from BASIC language constructs.
 *          UNO type cycles are handled by name resolution against a global UNO type cache.
 */
struct IdeSymbolInfo
{
    bool bSelectable = true;
    OUString sIdentifier;
    OUString sName;
    OUString sQualifiedName;
    IdeSymbolKind eKind = IdeSymbolKind::UNKNOWN;
    OUString sTypeName;
    OUString sQualifiedTypeName;
    SbxDataType eBasicType = SbxDataType::SbxEMPTY;
    bool bIsUnoTypeOrigin = false;
    IdeScopeKind eScope = IdeScopeKind::UNKNOWN;
    OUString sOriginLibrary;
    OUString sOriginLocation;
    OUString sOriginModule;
    OUString sOriginUnoContainer;
    OUString sParentName;
    sal_Int32 nSourceLine = -1;
    sal_Int32 nSourceColumn = -1;
    std::vector<IdeParamInfo> aParameters;
    OUString sReturnTypeName;
    OUString sQualifiedReturnTypeName;
    bool bIsArray = false;
    std::vector<IdeDimensionInfo> aArrayDimensions;
    IdeAccessModifier eAccessModifier = IdeAccessModifier::NOT_APPLICABLE;
    bool bIsResolved = true;
    bool bHasParseErrors = false;
    std::optional<OUString> osConstantValue;
    std::optional<OUString> osBriefDescription;
    std::optional<OUString> osFullSignatureForDisplay;
    std::optional<OUString> osHelpURL;
    std::map<OUString, std::shared_ptr<IdeSymbolInfo>> mapMembers;

    IdeSymbolInfo() = default;
    IdeSymbolInfo(std::u16string_view rName, IdeSymbolKind eTheKind,
                  std::u16string_view rParentIdentifier);

    void AddMember(std::shared_ptr<IdeSymbolInfo> pMember);
};

using SymbolInfoList = std::vector<std::shared_ptr<IdeSymbolInfo>>;
using ParamInfoList = std::vector<IdeParamInfo>;

OUString CreateRootIdentifier(IdeSymbolKind eKind, std::u16string_view sOptionalPayload = u"");

} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */