Skip to content

Commit c3e4ec7

Browse files
Barnabás Domozibarnabasdomozi
authored andcommitted
[PythonService] Cleanup
1 parent e1d1e73 commit c3e4ec7

File tree

2 files changed

+58
-170
lines changed

2 files changed

+58
-170
lines changed

plugins/python/service/include/service/pythonservice.h

Lines changed: 16 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class PythonServiceHandler : virtual public LanguageServiceIf
4949

5050
void getDocumentation(
5151
std::string& return_,
52-
const core::AstNodeId& astNodeId_) override;
52+
const core::AstNodeId& astNodeId_) override {};
5353

5454
void getProperties(
5555
std::map<std::string, std::string>& return_,
@@ -100,121 +100,46 @@ class PythonServiceHandler : virtual public LanguageServiceIf
100100
const core::AstNodeId& astNodeId_,
101101
const std::int32_t referenceId_,
102102
const core::FileId& fileId_,
103-
const std::vector<std::string>& tags_) override;
103+
const std::vector<std::string>& tags_) override {};
104104

105105
void getReferencesPage(
106106
std::vector<AstNodeInfo>& return_,
107107
const core::AstNodeId& astNodeId_,
108108
const std::int32_t referenceId_,
109109
const std::int32_t pageSize_,
110-
const std::int32_t pageNo_) override;
110+
const std::int32_t pageNo_) override {};
111111

112112
void getFileReferenceTypes(
113113
std::map<std::string, std::int32_t>& return_,
114-
const core::FileId& fileId_) override;
114+
const core::FileId& fileId_) override {};
115115

116116
void getFileReferences(
117117
std::vector<AstNodeInfo>& return_,
118118
const core::FileId& fileId_,
119-
const std::int32_t referenceId_) override;
119+
const std::int32_t referenceId_) override {};
120120

121121
std::int32_t getFileReferenceCount(
122122
const core::FileId& fileId_,
123-
const std::int32_t referenceId_) override;
123+
const std::int32_t referenceId_) override {};
124124

125125
void getSyntaxHighlight(
126126
std::vector<SyntaxHighlight>& return_,
127-
const core::FileRange& range_) override;
127+
const core::FileRange& range_) override {};
128128

129129
enum ReferenceType
130130
{
131-
DEFINITION, /*!< By this option the definition(s) of the AST node can be
132-
queried. However according to the "one definition rule" a named entity
133-
can have only one definition, in a parsing several definitions might be
134-
available. This is the case when the project is built for several targets
135-
and in the different builds different definitions are defined for an
136-
entity (e.g. because of an #ifdef section). */
137-
138-
DECLARATION, /*!< By this options the declaration(s) of the AST node can be
139-
queried. */
140-
141-
USAGE, /*!< By this option the usages of the AST node can be queried, i.e.
142-
the nodes of which the entity hash is identical to the queried one. */
143-
144-
THIS_CALLS, /*!< Get function calls in a function. WARNING: If the
145-
definition of the AST node is not unique then it returns the callees of
146-
one of them. */
147-
148-
CALLS_OF_THIS, /*!< Get calls of a function. */
149-
150-
CALLEE, /*!< Get called functions definitions. WARNING: If the definition of
151-
the AST node is not unique then it returns the callees of one of them. */
152-
153-
CALLER, /*!< Get caller functions. */
154-
155-
VIRTUAL_CALL, /*!< A function may be used virtually on a base type object.
156-
The exact type of the object is based on dynamic information, which can't
157-
be determined statically. Weak usage returns these possible calls. */
158-
159-
FUNC_PTR_CALL, /*!< Functions can be assigned to function pointers which
160-
can be invoked later. This option returns these invocations. */
161-
162-
PARAMETER, /*!< This option returns the parameters of a function. */
163-
164-
LOCAL_VAR, /*!< This option returns the local variables of a function. */
165-
166-
RETURN_TYPE, /*!< This option returns the return type of a function. */
167-
168-
OVERRIDE, /*!< This option returns the functions which the given function
169-
overrides. */
170-
171-
OVERRIDDEN_BY, /*!< This option returns the overrides of a function. */
172-
173-
READ, /*!< This option returns the places where a variable is read. */
174-
175-
WRITE, /*!< This option returns the places where a variable is written. */
176-
177-
TYPE, /*!< This option returns the type of a variable. */
178-
179-
ALIAS, /*!< Types may have aliases, e.g. by typedefs. */
180-
181-
INHERIT_FROM, /*!< Types from which the queried type inherits. */
182-
183-
INHERIT_BY, /*!< Types by which the queried type is inherited. */
184-
185-
DATA_MEMBER, /*!< Data members of a class. */
186-
187-
METHOD, /*!< Members of a class. */
188-
189-
FRIEND, /*!< The friends of a class. */
190-
191-
UNDERLYING_TYPE, /*!< Underlying type of a typedef. */
192-
193-
ENUM_CONSTANTS, /*!< Enum constants. */
194-
195-
EXPANSION, /*!< Macro expansion. */
196-
197-
UNDEFINITION, /*!< Macro undefinition. */
198-
131+
DEFINITION,
132+
USAGE,
133+
THIS_CALLS,
134+
CALLER,
135+
PARAMETER,
136+
LOCAL_VAR,
137+
DATA_MEMBER,
138+
METHOD,
199139
PARENT,
200-
201140
PARENT_FUNCTION,
202-
203141
ANNOTATION,
204-
205-
BASE_CLASS,
206-
};
207-
208-
enum FileReferenceType
209-
{
210-
INCLUDES, /*!< Included source files in the current source file after the
211-
inclusion directive. */
212-
213-
TYPES, /*!< User defined data types such as classes, structs etc. */
214-
215-
FUNCTIONS, /*!< Functions in the current source file. */
216-
217-
MACROS, /*!< Macros in the current source file. */
142+
BASE_CLASS
218143
};
219144

220145
enum DiagramType

plugins/python/service/src/pythonservice.cpp

Lines changed: 42 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PythonServiceHandler::PythonServiceHandler(
2121
void PythonServiceHandler::getFileTypes(
2222
std::vector<std::string>& return_)
2323
{
24+
#ifndef NDEBUG
25+
LOG(info) << "[PYTHONSERVICE]" << __func__;
26+
#endif
2427
return_.push_back("PY");
2528
return_.push_back("Dir");
2629
return;
@@ -30,7 +33,9 @@ void PythonServiceHandler::getAstNodeInfo(
3033
AstNodeInfo& return_,
3134
const core::AstNodeId& astNodeId_)
3235
{
33-
LOG(info) << "[PYSERVICE] " << __func__;
36+
#ifndef NDEBUG
37+
LOG(info) << "[PYTHONSERVICE]" << __func__;
38+
#endif
3439
model::PYName pyname = PythonServiceHandler::queryNodeByID(astNodeId_);
3540

3641
PythonServiceHandler::setInfoProperties(return_, pyname);
@@ -41,7 +46,9 @@ void PythonServiceHandler::getAstNodeInfoByPosition(
4146
AstNodeInfo& return_,
4247
const core::FilePosition& fpos_)
4348
{
44-
LOG(info) << "[PYSERVICE] " << __func__;
49+
#ifndef NDEBUG
50+
LOG(info) << "[PYTHONSERVICE]" << __func__;
51+
#endif
4552
model::PYName node = PythonServiceHandler::queryNodeByPosition(fpos_);
4653
PythonServiceHandler::setInfoProperties(return_, node);
4754
return;
@@ -51,7 +58,9 @@ void PythonServiceHandler::getSourceText(
5158
std::string& return_,
5259
const core::AstNodeId& astNodeId_)
5360
{
54-
LOG(info) << "[PYSERVICE] " << __func__;
61+
#ifndef NDEBUG
62+
LOG(info) << "[PYTHONSERVICE]" << __func__;
63+
#endif
5564
model::PYName pyname = PythonServiceHandler::queryNodeByID(astNodeId_);
5665

5766
core::ProjectServiceHandler projectService(_db, _datadir, _context);
@@ -70,19 +79,11 @@ void PythonServiceHandler::getSourceText(
7079
return;
7180
}
7281

73-
void PythonServiceHandler::getDocumentation(
74-
std::string& return_,
75-
const core::AstNodeId& astNodeId_)
76-
{
77-
LOG(info) << "[PYSERVICE] " << __func__;
78-
return;
79-
}
80-
8182
void PythonServiceHandler::getProperties(
8283
std::map<std::string, std::string>& return_,
8384
const core::AstNodeId& astNodeId_)
8485
{
85-
LOG(info) << "[PYSERVICE] " << __func__;
86+
LOG(info) << "[PYTHONSERVICE]" << __func__;
8687
model::PYName pyname = PythonServiceHandler::queryNodeByID(astNodeId_);
8788

8889
if(!pyname.full_name.empty())
@@ -112,7 +113,9 @@ void PythonServiceHandler::getDiagramTypes(
112113
std::map<std::string, std::int32_t>& return_,
113114
const core::AstNodeId& astNodeId_)
114115
{
115-
LOG(info) << "[PYSERVICE] " << __func__;
116+
#ifndef NDEBUG
117+
LOG(info) << "[PYTHONSERVICE]" << __func__;
118+
#endif
116119
const model::PYName pyname = PythonServiceHandler::queryNodeByID(astNodeId_);
117120

118121
if (pyname.is_import == true) return;
@@ -144,7 +147,9 @@ void PythonServiceHandler::getDiagram(
144147
const core::AstNodeId& astNodeId_,
145148
const std::int32_t diagramId_)
146149
{
147-
LOG(info) << "[PYSERVICE] " << __func__;
150+
#ifndef NDEBUG
151+
LOG(info) << "[PYTHONSERVICE]" << __func__;
152+
#endif
148153
python::Diagram diagram(_db, _datadir, _context);
149154

150155
model::PYName pyname = PythonServiceHandler::queryNodeByID(astNodeId_);
@@ -179,7 +184,9 @@ void PythonServiceHandler::getDiagramLegend(
179184
std::string& return_,
180185
const std::int32_t diagramId_)
181186
{
182-
LOG(info) << "[PYSERVICE] " << __func__;
187+
#ifndef NDEBUG
188+
LOG(info) << "[PYTHONSERVICE]" << __func__;
189+
#endif
183190
python::Diagram diagram(_db, _datadir, _context);
184191

185192
util::Graph graph = [&]()
@@ -206,7 +213,9 @@ void PythonServiceHandler::getFileDiagramTypes(
206213
std::map<std::string, std::int32_t>& return_,
207214
const core::FileId& fileId_)
208215
{
209-
LOG(info) << "[PYSERVICE] " << __func__;
216+
#ifndef NDEBUG
217+
LOG(info) << "[PYTHONSERVICE]" << __func__;
218+
#endif
210219
return_.emplace("Module dependency", MODULE_DEPENDENCY);
211220
return;
212221
}
@@ -216,7 +225,9 @@ void PythonServiceHandler::getFileDiagram(
216225
const core::FileId& fileId_,
217226
const int32_t diagramId_)
218227
{
219-
LOG(info) << "[PYSERVICE] " << __func__;
228+
#ifndef NDEBUG
229+
LOG(info) << "[PYTHONSERVICE]" << __func__;
230+
#endif
220231
python::Diagram diagram(_db, _datadir, _context);
221232

222233
util::Graph graph = [&]()
@@ -240,7 +251,9 @@ void PythonServiceHandler::getFileDiagramLegend(
240251
std::string& return_,
241252
const std::int32_t diagramId_)
242253
{
243-
LOG(info) << "[PYSERVICE] " << __func__;
254+
#ifndef NDEBUG
255+
LOG(info) << "[PYTHONSERVICE]" << __func__;
256+
#endif
244257
python::Diagram diagram(_db, _datadir, _context);
245258

246259
util::Graph graph = [&]()
@@ -264,7 +277,9 @@ void PythonServiceHandler::getReferenceTypes(
264277
std::map<std::string, std::int32_t>& return_,
265278
const core::AstNodeId& astNodeId)
266279
{
267-
LOG(info) << "[PYSERVICE] " << __func__;
280+
#ifndef NDEBUG
281+
LOG(info) << "[PYTHONSERVICE]" << __func__;
282+
#endif
268283
return_.emplace("Definition", DEFINITION);
269284
return_.emplace("Usage", USAGE);
270285
return_.emplace("Parent", PARENT);
@@ -302,9 +317,10 @@ void PythonServiceHandler::getReferences(
302317
const std::int32_t referenceId_,
303318
const std::vector<std::string>& tags_)
304319
{
305-
LOG(info) << "[PYSERVICE] " << __func__;
320+
#ifndef NDEBUG
321+
LOG(info) << "[PYTHONSERVICE]" << __func__;
306322
LOG(info) << "astNodeID: " << astNodeId_;
307-
323+
#endif
308324
std::vector<model::PYName> nodes = PythonServiceHandler::queryReferences(astNodeId_, referenceId_);
309325

310326
for(const model::PYName& pyname : nodes)
@@ -321,67 +337,14 @@ std::int32_t PythonServiceHandler::getReferenceCount(
321337
const core::AstNodeId& astNodeId_,
322338
const std::int32_t referenceId_)
323339
{
324-
LOG(info) << "[PYSERVICE] " << __func__;
340+
#ifndef NDEBUG
341+
LOG(info) << "[PYTHONSERVICE]" << __func__;
325342
LOG(info) << "astNodeID: " << astNodeId_;
343+
#endif
326344

327345
return PythonServiceHandler::queryReferences(astNodeId_, referenceId_).size();
328346
}
329347

330-
void PythonServiceHandler::getReferencesInFile(
331-
std::vector<AstNodeInfo>& return_,
332-
const core::AstNodeId& astNodeId_,
333-
const std::int32_t referenceId_,
334-
const core::FileId& fileId_,
335-
const std::vector<std::string>& tags_)
336-
{
337-
LOG(info) << "[PYSERVICE] " << __func__;
338-
return;
339-
}
340-
341-
void PythonServiceHandler::getReferencesPage(
342-
std::vector<AstNodeInfo>& return_,
343-
const core::AstNodeId& astNodeId_,
344-
const std::int32_t referenceId_,
345-
const std::int32_t pageSize_,
346-
const std::int32_t pageNo_)
347-
{
348-
LOG(info) << "[PYSERVICE] " << __func__;
349-
return;
350-
}
351-
352-
void PythonServiceHandler::getFileReferenceTypes(
353-
std::map<std::string, std::int32_t>& return_,
354-
const core::FileId& fileId_)
355-
{
356-
LOG(info) << "[PYSERVICE] " << __func__;
357-
return;
358-
}
359-
360-
void PythonServiceHandler::getFileReferences(
361-
std::vector<AstNodeInfo>& return_,
362-
const core::FileId& fileId_,
363-
const std::int32_t referenceId_)
364-
{
365-
LOG(info) << "[PYSERVICE] " << __func__;
366-
return;
367-
}
368-
369-
std::int32_t PythonServiceHandler::getFileReferenceCount(
370-
const core::FileId& fileId_,
371-
const std::int32_t referenceId_)
372-
{
373-
LOG(info) << "[PYSERVICE] " << __func__;
374-
return 0;
375-
}
376-
377-
void PythonServiceHandler::getSyntaxHighlight(
378-
std::vector<SyntaxHighlight>& return_,
379-
const core::FileRange& range_)
380-
{
381-
LOG(info) << "[PYSERVICE] " << __func__;
382-
return;
383-
}
384-
385348
model::PYName PythonServiceHandler::queryNodeByID(const std::string& id)
386349
{
387350
return _transaction([&]()
@@ -393,7 +356,7 @@ model::PYName PythonServiceHandler::queryNodeByID(const std::string& id)
393356
{
394357
pyname = *nodes.begin();
395358
}else{
396-
LOG(info) << "[PYSERVICE] Node not found! (id = " << id << ")";
359+
LOG(info) << "[PYTHONSERVICE] Node not found! (id = " << id << ")";
397360
core::InvalidId ex;
398361
ex.__set_msg("Node not found!");
399362
throw ex;
@@ -427,7 +390,7 @@ model::PYName PythonServiceHandler::queryNodeByPosition(const core::FilePosition
427390
}
428391
}
429392
}else{
430-
LOG(info) << "[PYSERVICE] Node not found! (line = " << fpos.pos.line << " column = " << fpos.pos.column << ")";
393+
LOG(info) << "[PYTHONSERVICE] Node not found! (line = " << fpos.pos.line << " column = " << fpos.pos.column << ")";
431394
core::InvalidInput ex;
432395
ex.__set_msg("Node not found!");
433396
throw ex;

0 commit comments

Comments
 (0)