style: Convert leading spaces to tabs in Generals#2562
style: Convert leading spaces to tabs in Generals#2562bobtista wants to merge 8 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/convert_leading_spaces_to_tabs.py | New reference script using tree-sitter for accurate C++ indentation analysis; contains a minor edge-case bug where a // comment containing /* without a closing */ can incorrectly set in_block_comment = True for subsequent lines |
| Generals/Code/GameEngine/Include/Common/BitFlags.h | Whitespace-only conversion: leading spaces replaced with tabs; verified no non-whitespace changes by git diff -w |
| Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp | Whitespace-only conversion: stray leading spaces and mixed space/tab indentation normalized to tabs; no logic changes |
| Generals/Code/GameEngine/Source/GameLogic/AI/AI.cpp | Whitespace-only conversion; passes git diff -w check |
| Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h | Whitespace-only conversion; access specifiers placed at class-brace level per codebase convention |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/cpp/convert_leading_spaces_to_tabs.py
Line: 409-414
Comment:
**`//` comment containing `/*` can incorrectly open block-comment state**
If a processed line contains `/*` inside a `//` comment with no matching `*/` on the same line (e.g. `foo(); // uses /* notation`), `in_block_comment` is set to `True`. The next line(s) will be treated as inside a block comment and skipped, until a `*/` is seen. This causes those lines to be silently left unconverted on future runs of the script.
Adding a guard for `//` comments before checking for `/*` would fix this:
```python
# Track mid-line block comment opens (e.g. /**< trailing doc comments)
line_comment_pos = stripped.find('//')
last_open = stripped.rfind('/*')
if last_open >= 0 and (line_comment_pos < 0 or last_open < line_comment_pos):
after_open = stripped[last_open + 2:]
if '*/' not in after_open:
in_block_comment = True
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (4): Last reviewed commit: "style: Preserve indentation inside prepr..." | Re-trigger Greptile
Skyaero42
left a comment
There was a problem hiding this comment.
Ive only reviewed the first 100 files or so.
|
|
||
| virtual void execute(); /**< The "main loop" of the game engine. | ||
| It will not return until the game exits. */ | ||
| It will not return until the game exits. */ |
There was a problem hiding this comment.
The indentation here is an issue imho and should be resolved before this PR (or optionally in this PR) rather then after.
I think a multi-line comment needs to be above the parameter/function, i.e.
/** The "main loop" of the game engine.
It will not return until the game exits. */
virtual void execute();Or as java would do:
/**
* The "main loop" of the game engine.
* It will not return until the game exits.
*/
virtual void execute();This is a much nicer way to do it and more in the style of a proper documentation comment.
| Bool m_selectionFlashHouseColor ; /// skip the house color and just use white. | ||
|
|
||
| Real m_cameraAudibleRadius; ///< If the camera is being used as the position of audio, then how far can we hear? | ||
| Real m_groupMoveClickToGatherFactor; /** if you take all the selected units and calculate the smallest possible rectangle |
There was a problem hiding this comment.
Place documentation comment before field parameter
| Bool m_isPrerequisite; ///< Is this thing considered in a prerequisite for any other thing? | ||
| Bool m_isBridge; ///< True if this model is a bridge. | ||
| Bool m_isBuildFacility; ///< is this the build facility for something? (calculated based on other template's prereqs) | ||
| Bool m_isBuildFacility; ///< is this the build facility for something? (calculated based on other template's prereqs) |
| Object* m_obj; | ||
| Object* m_otherObj; | ||
| const Team* m_team; | ||
| CommandSourceType m_cmdSource; |
| const PolygonTrigger* m_polygon; | ||
| Int m_intValue; /// misc usage | ||
| DamageInfo m_damage; | ||
| const Waypoint* m_waypoint; |
| { | ||
| for( PlayerTeamList::const_iterator it = m_playerTeamPrototypes.begin(); | ||
| it != m_playerTeamPrototypes.end(); ++it ) | ||
| it != m_playerTeamPrototypes.end(); ++it ) |
There was a problem hiding this comment.
INcorrect indentation, a few more times in this file
| for( DLINK_ITERATOR< Object > objIt = iterate_TeamMemberList(); | ||
| objIt.done() == FALSE; | ||
| objIt.advance() ) | ||
| objIt.done() == FALSE; |
| y < halfFootprintHeight + sampleResolution; | ||
| y += sampleResolution ) | ||
| y < halfFootprintHeight + sampleResolution; | ||
| y += sampleResolution ) |
| { | ||
| MYEIP1: | ||
| mov eax, MYEIP1 | ||
| mov eax, MYEIP1 |
| { | ||
| MYEIP2: | ||
| mov eax, MYEIP2 | ||
| mov eax, MYEIP2 |
Summary
git diff -wis empty)Access specifiers (
public:/private:/protected:) are placed at the classbrace level, matching the existing codebase convention.
Script
The formatting script is included in the PR for reference but is not intended
to be merged — it shows how the changes were generated.
See
scripts/cpp/convert_leading_spaces_to_tabs.pyfor details.Part 2 of 4 — Generals/ (425 files).
See also: #2561, #2563, #2564.