[umbrello] [Bug 397666] C++ importer does not recognize 'final' keyword

"Oliver Kellogg" <[email protected]>
Newsgroups gmane.linux.umbrello.devel
Message-ID <[email protected]/>
https://bugs.kde.org/show_bug.cgi?id=397666

Oliver Kellogg <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Latest Commit|                            |https://invent.kde.org/sdk/
                   |                            |umbrello/commit/6c8c82400ae
                   |                            |92fbb307a298e4231b607dfa8b3
                   |                            |69
         Resolution|---                         |FIXED
   Version Fixed In|                            |2.33.80 (KDE releases
                   |                            |22.03.80)

--- Comment #1 from Oliver Kellogg <[email protected]> ---
Git commit 6c8c82400ae92fbb307a298e4231b607dfa8b369 by Oliver Kellogg.
Committed on 15/02/2022 at 21:38.
Pushed by okellogg into branch 'master'.

Fix "C++ importer does not recognize 'final' keyword"

Apply final-keyword.patch by Thomas Jansen with modifications:

lib/cppparser/lexer.h
- In enum Type add Token_final.

lib/cppparser/keywords.h
- Add INSERT("final", Token_final).

lib/cppparser/ast.{h,cpp}
- In class ClassSpecifierAST,
  - add getter final_() returning m_final.get();
  - add function setFinal(AST::Node& final_);
  - add private member m_final of type AST::Node.
- In class DeclaratorAST,
  - rename getter override() to override_() for avoiding incorrect
    colorization in syntax highlighting editors;
  - add getter final_() returning m_final.get();
  - add function setFinal(AST::Node& final_);
  - add private member m_final of type AST::Node.

lib/cppparser/ast_utils.cpp
- In function declaratorToString,
  - adjust call of declarator->override() to function renaming;
  - add handling of (declarator->final_() != 0).

lib/cppparser/parser.cpp
- Remove #include "optionstate.h" and testing of
  Settings::optionState().codeImportState.supportCPP11.
  Reason: In the year 2022 there is little use for switching off C++11,
  in particular in our usecase within a UML tool not compiler frontend.
- In functions parseDeclarator and parseAbstractDeclarator, after
  skipping ')' of parameter declaration clause add loop for handling
  Token_const, Token_override, Token_final.  These are handled in a
  loop because they may appear in arbitrary order.
- In function parseClassSpecifier,
  - after parsing name set AST::Node final_ if Token_final is present;
  - call ast->setFinal(final_).

umbrello/umlmodel/operation.{h,cpp}
- Add public functions setFinal(bool) and bool getFinal().
- Rename private member m_Override to m_bOverride, m_virtual to
  m_bVirtual, m_inline to m_bInline for symmetry with m_bConst.
- Add private member m_bFinal of type bool.

umbrello/umlmodel/operation.cpp
- In UMLOperation constructor initialize m_bFinal.
- In function saveToXMI :
  - Only write XML attibutes "isQuery", "isOverride", "isVirtual",
    "isInline" if the corresponding data member is true.
    This saves space and avoids the non standard attributes when
    possible.
  - Write XML attribute "isFinal" if m_bFinal is true.
- In function load1 add retrieving of m_bFinal from XML attribute
  "isFinal".

umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
- In functions parseFunctionDefinition and parseFunctionDeclaration
  call m->setFinal(true) if d->final_() returns true.

umbrello/version.h
- Increase XMI1_FILE_VERSION to "1.7.5" and increase XMI2_FILE_VERSION
  to "2.0.2" to reflect the added UML Operation attribute "isFinal".

These changes were tested by importing the file
test/import/cxx/cxx11-explicit-overrides-and-final.h
FIXED-IN:2.33.80 (KDE releases 22.03.80)

M  +15   -2    lib/cppparser/ast.cpp
M  +18   -2    lib/cppparser/ast.h
M  +4    -1    lib/cppparser/ast_utils.cpp
M  +1    -0    lib/cppparser/keywords.h
M  +1    -0    lib/cppparser/lexer.h
M  +33   -33   lib/cppparser/parser.cpp
M  +6    -2    umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
M  +45   -19   umbrello/umlmodel/operation.cpp
M  +7    -4    umbrello/umlmodel/operation.h
M  +2    -2    umbrello/version.h

https://invent.kde.org/sdk/umbrello/commit/6c8c82400ae92fbb307a298e4231b607dfa8b369

-- 
You are receiving this mail because:
You are the assignee for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.