Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KDevelop
KDevelop Python Support
Commits
3b6f270a
Commit
3b6f270a
authored
Oct 25, 2022
by
frmdstryr
Committed by
Sven Brauch
Nov 05, 2022
Browse files
Cleanup unecessary code
parent
0af21e64
Changes
1
Hide whitespace changes
Inline
Side-by-side
parser/astbuilder.cpp
View file @
3b6f270a
...
...
@@ -20,7 +20,6 @@
#include
"cythonsyntaxremover.h"
#include
"rangefixvisitor.h"
#include
<QStandardPaths>
#include
<QDebug>
#include
"parserdebug.h"
...
...
@@ -61,31 +60,12 @@ struct PythonParser : private QMutexLocker
{
Py_InitializeEx
(
0
);
Q_ASSERT
(
Py_IsInitialized
());
//addSupportDirToSysPath();
// Import the parse function. This intentially a separate module
// to allow other parsers to be hooked in without needing to re-compile.
m_parser_mod
=
PyImport_ImportModule
(
"ast"
);
Q_ASSERT
(
m_parser_mod
);
// parser import error
m_parse_func
=
PyObject_GetAttrString
(
m_parser_mod
,
"parse"
);
Q_ASSERT
(
m_parse_func
);
// parser function renamed?
}
void
addSupportDirToSysPath
()
const
{
QFileInfo
parserFile
=
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
"kdevpythonsupport/kdevparser.py"
);
QString
supportDir
=
parserFile
.
absoluteDir
().
path
();
Q_ASSERT
(
supportDir
.
size
());
PyObjectRef
sys
=
PyImport_ImportModule
(
"sys"
);
if
(
!
sys
)
return
;
PyObjectRef
path
=
PyObject_GetAttrString
(
sys
,
"path"
);
if
(
!
path
)
return
;
PyObjectRef
append
=
PyObject_GetAttrString
(
path
,
"append"
);
if
(
!
append
)
return
;
PyObjectRef
arg
=
PyUnicode_FromString
(
supportDir
.
toUtf8
().
data
());
if
(
!
arg
)
return
;
PyObjectRef
r
=
PyObject_CallOneArg
(
append
,
arg
);
}
// Call parser function and return the python ast.Module.
// NOTE: The caller must DECREF the result
PyObject
*
parse
(
QString
const
&
source
,
QString
const
&
filename
)
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment