Changeset View
Changeset View
Standalone View
Standalone View
parser/astbuilder.cpp
Show First 20 Lines • Show All 557 Lines • ▼ Show 20 Line(s) | 557 | if (Py_IsInitialized()) | |||
---|---|---|---|---|---|
558 | Py_Finalize(); | 558 | Py_Finalize(); | ||
559 | } | 559 | } | ||
560 | PyArena* arena; | 560 | PyArena* arena; | ||
561 | }; | 561 | }; | ||
562 | } | 562 | } | ||
563 | 563 | | |||
564 | CodeAst::Ptr AstBuilder::parse(const QUrl& filename, QString &contents) | 564 | CodeAst::Ptr AstBuilder::parse(const QUrl& filename, QString &contents) | ||
565 | { | 565 | { | ||
566 | qDebug() << " ====> AST ====> building abstract syntax tree for " << filename.path(); | 566 | qCDebug(KDEV_PYTHON_PARSER) << " ====> AST ====> building abstract syntax tree for " << filename.path(); | ||
567 | 567 | | |||
568 | Py_NoSiteFlag = 1; | 568 | Py_NoSiteFlag = 1; | ||
569 | 569 | | |||
570 | contents.append('\n'); | 570 | contents.append('\n'); | ||
571 | 571 | | |||
572 | QPair<QString, int> hacked = fileHeaderHack(contents, filename); | 572 | QPair<QString, int> hacked = fileHeaderHack(contents, filename); | ||
573 | contents = hacked.first; | 573 | contents = hacked.first; | ||
574 | int lineOffset = hacked.second; | 574 | int lineOffset = hacked.second; | ||
Show All 11 Lines | |||||
586 | if (filename.fileName().endsWith(".pyx", Qt::CaseInsensitive)) { | 586 | if (filename.fileName().endsWith(".pyx", Qt::CaseInsensitive)) { | ||
587 | qCDebug(KDEV_PYTHON_PARSER) << filename.fileName() << "is probably Cython file."; | 587 | qCDebug(KDEV_PYTHON_PARSER) << filename.fileName() << "is probably Cython file."; | ||
588 | contents = cythonSyntaxRemover.stripCythonSyntax(contents); | 588 | contents = cythonSyntaxRemover.stripCythonSyntax(contents); | ||
589 | } | 589 | } | ||
590 | 590 | | |||
591 | mod_ty syntaxtree = PyParser_ASTFromString(contents.toUtf8().data(), "<kdev-editor-contents>", file_input, &flags, arena); | 591 | mod_ty syntaxtree = PyParser_ASTFromString(contents.toUtf8().data(), "<kdev-editor-contents>", file_input, &flags, arena); | ||
592 | 592 | | |||
593 | if ( ! syntaxtree ) { | 593 | if ( ! syntaxtree ) { | ||
594 | qDebug() << " ====< parse error, trying to fix"; | 594 | qCDebug(KDEV_PYTHON_PARSER) << " ====< parse error, trying to fix"; | ||
595 | 595 | | |||
596 | PyErr_Fetch(&exception, &value, &backtrace); | 596 | PyErr_Fetch(&exception, &value, &backtrace); | ||
597 | qCDebug(KDEV_PYTHON_PARSER) << "Error objects: " << exception << value << backtrace; | 597 | qCDebug(KDEV_PYTHON_PARSER) << "Error objects: " << exception << value << backtrace; | ||
598 | 598 | | |||
599 | if ( ! value ) { | 599 | if ( ! value ) { | ||
600 | qCWarning(KDEV_PYTHON_PARSER) << "Internal parser error: exception value is null, aborting"; | 600 | qCWarning(KDEV_PYTHON_PARSER) << "Internal parser error: exception value is null, aborting"; | ||
601 | return CodeAst::Ptr(); | 601 | return CodeAst::Ptr(); | ||
602 | } | 602 | } | ||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |