Add assistant to generate header guards
ClosedPublic

Authored by amhndu on Dec 5 2018, 6:28 PM.

Details

Summary

Assistant with two actions allowing you to either add a conventional macro-
based header guard or pragma-once.

Test Plan

Run test_assistants testHeaderGuardAssistant

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
amhndu created this revision.Dec 5 2018, 6:28 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptDec 5 2018, 6:28 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
amhndu requested review of this revision.Dec 5 2018, 6:28 PM
amhndu updated this revision to Diff 46950.Dec 6 2018, 11:17 AM
  • QStringLiteral -> i18n
amhndu updated this revision to Diff 46988.Dec 6 2018, 6:24 PM
  • Add tests for HeaderGuardAssistant
amhndu edited the test plan for this revision. (Show Details)Dec 6 2018, 6:25 PM
arrowd added a subscriber: arrowd.Jan 3 2019, 12:03 PM
arrowd added inline comments.
plugins/clang/util/clangutils.cpp
465

This method uses stuff from libclang 7, so it should be #ifdefed.

amhndu updated this revision to Diff 48624.Jan 3 2019, 7:22 PM
  • Remove dependency on clang 7.0.0 functions
arrowd added a comment.Jan 3 2019, 8:15 PM

It now compiles and unit test passes, however my own quick test revealed following problem.

I created an empty file called test.h and typed

int a;

there. Now, trying (2) solution results in

#endif // TEST_H_INCLUDED#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED

int a;

The (1) solution works fine, though.

amhndu updated this revision to Diff 48694.Jan 4 2019, 7:55 PM
  • Fix some edge cases, cleanup and add more test cases
arrowd accepted this revision as: arrowd.EditedJan 5 2019, 8:56 AM

Works great, good job!

This revision is now accepted and ready to land.Jan 5 2019, 8:56 AM
amhndu added a comment.Jan 7 2019, 5:47 AM

Any objections for pushing this to 5.3 ?

apol added a subscriber: apol.Jan 7 2019, 3:42 PM

As a new feature I'd say it's just easier to get this in master.

This revision was automatically updated to reflect the committed changes.