Format current sourcode: operable program or batch file

Post here any ideas/problems/suggestions you have regarding CodeLite's CodeFormatter (AStyle) plugin
hptphuong
CodeLite Curious
Posts: 8
Joined: Mon May 29, 2017 1:18 pm
Genuine User: Yes
IDE Question: PHP
Contact:

Format current sourcode: operable program or batch file

Post by hptphuong »

Hi all,

I tried to use "Format current sourcode".

But when I select my code and choose this function, it delete all my code and appear this line"operable program or batch file."

Anyone know what is my issue, May be i miss some setup or wrong in operate.

Please help me fix this issue.(I'm using windown 10 with newest version of codelite 10.0.4)

Thanks & Best Regards,

Phuong Hoang
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by eranif »

Please enable CodeLite log and post the log output here.
To enable the log: settings->preferences->misc->log->codelite log level->Debug

The log file can be seen under: %appdata%\CodeLite\codelite.log
Make sure you have read the HOW TO POST thread
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by AJenbo »

It would also be nice to know if this is for php or c++ and what formatter you have selected under options.

The error you are getting means that windows was not able to locate the formatting tool, so my best guess is that you didn't set the "clang-format path" for c++ or PHP Executable if you are trying to format php.
hptphuong
CodeLite Curious
Posts: 8
Joined: Mon May 29, 2017 1:18 pm
Genuine User: Yes
IDE Question: PHP
Contact:

Re: Format current sourcode: operable program or batch file

Post by hptphuong »

@eranif: There is my log:

Code: Select all

[00:06:50:698 DBG] Formatting file: ' C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp '
[00:06:50:698 DBG] Using C++/Clang formatter
[00:06:50:714 DBG] CodeForamtter: C:\Windows\system32\cmd.exe /C "C:\Program Files\CodeLite\codelite-clang-format.exe" -assume-filename=main_app.cpp  -style="{ BasedOnStyle: WebKit, IndentWidth: 4, UseTab: ForIndentation, Language : Cpp , AlignEscapedNewlinesLeft: true, AlignTrailingComments : true, AllowAllParametersOfDeclarationOnNextLine : false, AllowShortFunctionsOnASingleLine : false, AllowShortBlocksOnASingleLine : false, AllowShortLoopsOnASingleLine : false, AllowShortIfStatementsOnASingleLine : false, AlwaysBreakBeforeMultilineStrings : false, AlwaysBreakTemplateDeclarations : false, BinPackParameters : false, BreakBeforeBinaryOperators : false, BreakBeforeTernaryOperators : false, BreakConstructorInitializersBeforeComma : true, IndentCaseLabels : true, IndentFunctionDeclarationAfterType : true, SpaceBeforeAssignmentOperators : true, SpaceBeforeParens : Never, SpacesInParentheses : false, BreakBeforeBraces : Linux, ColumnLimit : 120, PointerAlignment : Left }"  -cursor=0 -offset=0 -length=508 "C:\Users\hptphuong\Documents\Self C++\learning\first\.code-formatter-tmp.cpp"
[00:06:50:808 DBG] Done
[00:06:50:823 DBG] Formatting file: ' C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp '...is done
[00:06:51:886 DBG] No EditorConfig file found for file: C:\Users\hptphuong\AppData\Roaming\codelite\codelite.log
[00:06:54:911 DBG] No EditorConfig file found for file: C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp
Please help me find what is the issue?
@Ajenbo: I'm working on C++. Please help me to set "clang-format path" for c+
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by eranif »

can you try and execute the command from the command line?
Make sure you have read the HOW TO POST thread
hptphuong
CodeLite Curious
Posts: 8
Joined: Mon May 29, 2017 1:18 pm
Genuine User: Yes
IDE Question: PHP
Contact:

Re: Format current sourcode: operable program or batch file

Post by hptphuong »

@eranif: Please let me know how to do it? one more, it's ridiculous to reindent by code. It's inconvenient. In sublime, i can make it easy with hot key.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by eranif »

it is also done by hot key in codelite (ctrl-i). it works everywhere, except for you :(

i wanted you to try and run it from the command line just to see if we get some additional information of why it fails to run from within codelite
Make sure you have read the HOW TO POST thread
hptphuong
CodeLite Curious
Posts: 8
Joined: Mon May 29, 2017 1:18 pm
Genuine User: Yes
IDE Question: PHP
Contact:

Re: Format current sourcode: operable program or batch file

Post by hptphuong »

Please help me run it by command line. I don't know how do it
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by AJenbo »

hptphuong:

Open a command prompt (cmd) and paste the following in it:

Code: Select all

C:\Windows\system32\cmd.exe /C "C:\Program Files\CodeLite\codelite-clang-format.exe" -assume-filename=main_app.cpp  -style="{ BasedOnStyle: WebKit, IndentWidth: 4, UseTab: ForIndentation, Language : Cpp , AlignEscapedNewlinesLeft: true, AlignTrailingComments : true, AllowAllParametersOfDeclarationOnNextLine : false, AllowShortFunctionsOnASingleLine : false, AllowShortBlocksOnASingleLine : false, AllowShortLoopsOnASingleLine : false, AllowShortIfStatementsOnASingleLine : false, AlwaysBreakBeforeMultilineStrings : false, AlwaysBreakTemplateDeclarations : false, BinPackParameters : false, BreakBeforeBinaryOperators : false, BreakBeforeTernaryOperators : false, BreakConstructorInitializersBeforeComma : true, IndentCaseLabels : true, IndentFunctionDeclarationAfterType : true, SpaceBeforeAssignmentOperators : true, SpaceBeforeParens : Never, SpacesInParentheses : false, BreakBeforeBraces : Linux, ColumnLimit : 120, PointerAlignment : Left }"  -cursor=0 -offset=0 -length=508 "C:\Users\hptphuong\Documents\Self C++\learning\first\.code-formatter-tmp.cpp"
Hit enter and copy-pate the result to the forum so we can see it.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Format current sourcode: operable program or batch file

Post by eranif »

One thing to note here:
change the filename from: .code-formatter-tmp.cpp to the actual filename you want to format
Make sure you have read the HOW TO POST thread
Post Reply