Author Topic: any component for autocomplete c++ headers?  (Read 11748 times)

derek.john.evans

  • Guest
Re: any component for autocomplete c++ headers?
« Reply #15 on: November 24, 2016, 01:37:59 am »
Mmmm. Very true..

What about cppcheck?
http://cppcheck.sourceforge.net/

I just installed that, wrote a simple C program and ran:
cppcheck.exe --dump test.c

The output is an XML file with vars, functions, structures etc.

That might be the one.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: any component for autocomplete c++ headers?
« Reply #16 on: November 24, 2016, 01:44:35 am »
I just installed that, wrote a simple C program and ran:
cppcheck.exe --dump test.c

Can it handle header files? I believe that's what he needs to parse. I just pasted a simple header into their online demo app and it blew up.

derek.john.evans

  • Guest
Re: any component for autocomplete c++ headers?
« Reply #17 on: November 24, 2016, 01:54:55 am »
Yep. I just ran it on mshtmlc.h (2.32 MB)
It outputs more than enough information in the XML file.

When dumping, it doesn't seem to do the error check anymore, which is what you would want.

I guess its then a matter of extracting the information required to create a script for whatever TSynEdit code completer you use.


Michael Collier

  • Sr. Member
  • ****
  • Posts: 329
Re: any component for autocomplete c++ headers?
« Reply #18 on: November 24, 2016, 01:57:40 am »
@Phil, can you post sample to make it crash please?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: any component for autocomplete c++ headers?
« Reply #19 on: November 24, 2016, 02:20:48 am »
@Phil, can you post sample to make it crash please?

It's probably not the parser that's crashing. I suspect they have a bug in their CGI script, per the error message:

1. Server: cppcheck.sourceforge.net
2. URL path: /cgi-bin/democlient.cgi
3. Error notes: Premature end of script headers: democlient.cgi
4. Error type: 500
5. Request method: POST
6. Request query string:
7. Time: 2016-11-24 01:12:59 UTC (1479949979)

Here's a stripped down (<1024 chars) version of the header file for the NDFD library from this project:

https://macpgmr.github.io/MacXPlatform/PascalDynLibs_3.html

Code: [Select]
#include <stdint.h>

#ifdef _MSC_VER
  #define CDECL __cdecl
  #define STDCALL __stdcall
#else
  #define CDECL  /* */
  #define STDCALL __attribute__((stdcall))
#endif

#ifdef USE_STDCALL
  #define NDFD_CALL STDCALL
#else
  #define NDFD_CALL CDECL
#endif

typedef char NDFD_CHAR;
typedef const NDFD_CHAR* NDFD_PCHAR;
typedef uint32_t NDFD_UINT;
typedef const void* NDFD_POBJ;
typedef int32_t NDFD_BOOL;

void NDFD_CALL NdfdGetLibVersion(NDFD_PCHAR VerBuf,
                                 NDFD_UINT VerBufLen);

NDFD_POBJ NDFD_CALL NdfdInit();

NDFD_BOOL NDFD_CALL NdfdUninit(NDFD_POBJ NdfdObj);

void NDFD_CALL NdfdGetLastError(NDFD_POBJ NdfdObj,
                                NDFD_PCHAR ErrBuf,
                                NDFD_UINT ErrBufLen);

NDFD_BOOL NDFD_CALL NdfdLoadForecast(NDFD_POBJ NdfdObj,
                                     NDFD_PCHAR Latitude,
                                     NDFD_PCHAR Longitude,
                                     NDFD_BOOL GetMetric);


Michael Collier

  • Sr. Member
  • ****
  • Posts: 329
Re: any component for autocomplete c++ headers?
« Reply #20 on: November 24, 2016, 02:56:49 am »
Yep, it looks like the CGI part failed, I parsed the text OK on command line.

Looking through the dump xml I see it has isStatic property, but I can't seem to get it to set "true".

I can get isPointer, isArray, isReference to set "true". Maybe I'm doing something wrong, but it looks hopeful..

Code: C  [Select][+][-]
  1. namespace ns1
  2. {
  3.   class t_class
  4.   {
  5.     public:
  6.              int   member1   ( const volatile int & param1     ) ;
  7.       static int   member2   ( int                  param2_1[] ) ;
  8.              int * member3                                       ;
  9.              int   member4[5]                                    ;
  10.   } ;
  11.  
  12.   t_class my_class ;
  13. } ;
  14.  
  15.  

AlexTP

  • Hero Member
  • *****
  • Posts: 2732
    • UVviewsoft
Re: any component for autocomplete c++ headers?
« Reply #21 on: November 24, 2016, 03:34:43 am »
Do finding for "Subime Text C++ auto-complete",
you find https://github.com/pl-ca/ClangAutoComplete
it is based on CLang, see details on GH

2) See https://packagecontrol.io/packages/EasyClangComplete
« Last Edit: November 24, 2016, 03:36:39 am by Alextp »

Edson

  • Hero Member
  • *****
  • Posts: 1330
Re: any component for autocomplete c++ headers?
« Reply #22 on: November 24, 2016, 05:00:54 pm »
@Edson Thanks for the link, I tried both SynFacilSyn & SynFacilCompletion example projects. It looks like it is possible to do drop down of keywords ( int, double, float, do ) but what I'd like to be able to do is get the component to give drop downs for user defined classes and their members.

SynFacilCompletion has been designed to work statically and dinamically  :D (not tested dinamically  :( yet). In fact, has been created to be used in a IDE (like https://github.com/t-edson/PicPas). But it has not a specific language. If you want to work with C++, you have to define de syntax, the parser and the completion-tool.
There is some other libraries based on SynFacilSyn, that can help:

* SynFacilutils (https://github.com/t-edson/SynFacilUtils) utilities to create editors with completion and highlighting:
* t-Xpres (https://github.com/t-edson/t-Xpres) lexer and parser, to implement interpreters or compilers.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Michael Collier

  • Sr. Member
  • ****
  • Posts: 329
Re: any component for autocomplete c++ headers?
« Reply #23 on: November 24, 2016, 06:37:43 pm »
Do finding for "Subime Text C++ auto-complete",
you find https://github.com/pl-ca/ClangAutoComplete
it is based on CLang, see details on GH

OK, looked at the source (python), seems it executes a command prompt to the clang system (I'm not a python expert..). So I did similar at a linux command prompt.

clang -w -fsyntax-only -Xclang -code-completion-at=clang_test.cpp:20:17 clang_test.cpp -std=c++11

Here is the file I used as source for clang, requesting completion at  "if ( my_class."

Code: C  [Select][+][-]
  1. namespace ns1
  2. {
  3.   class t_class
  4.   {
  5.     public:
  6.       int member1 ;
  7.       static int member2 ;
  8.   } ;
  9. }
  10. ;
  11.  
  12. int ns1::t_class::member2 {1};
  13.  
  14. template<typename T>
  15. int myfunction()
  16. {
  17.   T my_type ;
  18.   int my_int {5} ;
  19.   ns1::t_class my_class ;
  20.   if ( my_class./*20:17 cursor*/member1 ==1 ) {} ;
  21.   return 0;
  22. };
  23.  

Here is the output, it has correctly listed member1 and member2. I'm not sure why it is listing some other items, I'm not c++ expert. It looks interesting though..

Code: Text  [Select][+][-]
  1. COMPLETION: member1 : [#int#]member1
  2. COMPLETION: member2 : [#int#]member2
  3. COMPLETION: operator= : [#ns1::t_class &#]operator=(<#const ns1::t_class &#>)
  4. COMPLETION: operator= : [#ns1::t_class &#]operator=(<#ns1::t_class &&#>)
  5. COMPLETION: t_class : t_class::
  6. COMPLETION: template
  7. COMPLETION: ~t_class : [#void#]~t_class()

Michael Collier

  • Sr. Member
  • ****
  • Posts: 329
Re: any component for autocomplete c++ headers?
« Reply #24 on: November 24, 2016, 06:40:14 pm »
If you want to work with C++, you have to define de syntax, the parser and the completion-tool.

It's the parsing part I'd like to avoid (it's hard work but also seems the standard(s) keep changing too).

Michael Collier

  • Sr. Member
  • ****
  • Posts: 329
Re: any component for autocomplete c++ headers?
« Reply #25 on: November 24, 2016, 06:43:08 pm »
The output is an XML file with vars, functions, structures etc.

It looks promising, it is an alternative to requiring clang being installed on the users system.

Edson

  • Hero Member
  • *****
  • Posts: 1330
Re: any component for autocomplete c++ headers?
« Reply #26 on: December 13, 2016, 08:27:31 pm »
If you want to work with C++, you have to define de syntax, the parser and the completion-tool.

It's the parsing part I'd like to avoid (it's hard work but also seems the standard(s) keep changing too).

There is a basic C parser with completion code in: https://github.com/t-edson/t-Xpres
Look at the: Demo5 - C Parser


Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018