Bug 454545

Summary: Python classes with metaclass are not detected by the Symbols Viewer
Product: [Applications] kate Reporter: Alain Laporte <alain>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 21.12.3   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Alain Laporte 2022-05-28 22:27:05 UTC
SUMMARY

A Python class declaration like:

class AustralianPhilosopher(Philosopher, default_name="Bruce"):

Is not detected by the Symbols Viewer and methods of this class are associated to the previously detected class.

STEPS TO REPRODUCE
1. Create a file like:

class Philosopher:
    def __init_subclass__(cls, default_name):
        cls.default_name = default_name

class AustralianPhilosopher(Philosopher, default_name="Bruce"):
    def toto():
        pass

2. Open the Symbols Viewer

OBSERVED RESULT

Class AustralianPhilosopher is not detected and method foo is associated to the class Philosopher.

EXPECTED RESULT

Class AustralianPhilosopher is detected and method foo is associated to the class AustralianPhilosopher.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION

An issue with a patch was created on Gitlab => https://invent.kde.org/utilities/kate/-/issues/75
Comment 1 Christoph Cullmann 2022-06-06 18:23:39 UTC
Git commit cfcc864550448b277909e6340424e575852d88d9 by Christoph Cullmann, on behalf of Alain Laporte.
Committed on 06/06/2022 at 18:23.
Pushed by cullmann into branch 'master'.

More simpler regexp to match different class declarations

Tested class declarations:

class Philosopher:
class AustralianPhilosopher(Philosopher, default_name="Bruce"):
class Meta():
class MyClass(metaclass=Meta):
class MySubclass(MyClass):

Fix case where AustralianPhilosopher is not detected

ISSUE: https://invent.kde.org/utilities/kate/-/issues/75

M  +1    -1    addons/symbolviewer/python_parser.cpp

https://invent.kde.org/utilities/kate/commit/cfcc864550448b277909e6340424e575852d88d9