News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Fix 'Tokenizer::FixArgument' bug: support skip C++ comment

Started by Loaden, April 28, 2010, 05:33:51 AM

Previous topic - Next topic

Loaden

Index: src/plugins/codecompletion/parser/tokenizer.cpp

===================================================================

--- src/plugins/codecompletion/parser/tokenizer.cpp (revision 6205)

+++ src/plugins/codecompletion/parser/tokenizer.cpp (working copy)

@@ -708,6 +708,16 @@


    TRACE(_T("FixArgument() : src='%s'."), src.wx_str());

+    // skip C++ comments
+    for (size_t i = 0; i < src.Length() - 1; ++i)
+    {
+        if (src.GetChar(i) == _T('/') && src.GetChar(i + 1) == _T('/'))
+        {
+            do src.SetChar(i, _T(' '));
+            while (src.GetChar(++i) != _T('\n') && i < src.Length() - 1);
+        }
+    }
+
    // str.Replace is massive overkill here since it has to allocate one new block per replacement
    { // this is much faster:
        size_t i;

Test Demo:
void function ( int testInt1
//#ifdef AAA
, int testInt2)
//#else
//)
//#endif
{

};

void test(int testInt3
// test
         , int testInt4)
{
   testInt3
}

void ok(int testInt5 /*test*/, int testInt6)
{
   tes
}


Here is another test demo:
#include <iostream>

using namespace std;

int test(int testInt1, // testijfiejfijeifje
         int testInt2, // fjiejifjfisjfif
         int testInt3)
{
    tes|
}

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}