Using clang-format with IAR embedded workbench - embedded

I have a project in IAR embedded workbench. Is there a way using the tools menu to add in a code formatter such as clang-format? I've managed to call it, but have not set the command line options correctly in order to feed the current file into the formatter.
Simon

Yes it is possible:
Here are the settings I used.
Menu Text: Clang Format
Command: C:\Program Files\LLVM\bin\clang-format.exe
Argument: --style=file $FILE_PATH$ -i
Initial Directory: $FILE_DIR$
These settings require a file .clang-format to be saved in the project directory, no bad thing in my view as if checked in with the project it sets a standard for the project code format.
I think simply using clang-format for the command would work if the directory is added to the PATH environment variable. Or you'll need to browse to the location of clang-format on your system if it's different you mine.
Screenshot of dialog window

Related

javadoc: error cannot read Input length = 1 (IntelliJ - no maven) [duplicate]

I know there are plenty of questions about this problem, but no one of the solved it for me! I'm using the Community Edition of IntelliJ and I tried to run JavaDoc through the IDE. Everytime and it doesn't matter fo which file, I run JavaDoc I got the following output:
javadoc: error - cannot read Input length = 1
I already figured out, that it might be an encoding problem... I'm working on a Windows 10 maschine. I already tried the following:
JavaDoc argfile encoding error
Start the terminal from IntelliJ with cmd.exe /K chcp 65001 instead of the default one cmd.exe to set the charset to UTF-8
I also set the project's default charset through the IntelliJ settings to UTF-8 (See: This Guide)
The problem seems to be the javadoc_args file respectively the path to that file... The path is C:\Users\Somebody Müller\AppData\Local\Temp\javadoc_args. Also if I view the file from IntelliJ, all ü characters are replaced by an unknown symbol.
I know that I could generate the documentation through a maven plugin, but I would prefer to do it via the IntelliJ IDE...
Could somebody identify the problem in detail and/or provide a solution or maybe parts of it?
EDIT
skomisa described the situation/behaviour in easy words:
For me the javadoc_args file does not exist! I see it is named in the Javadoc window as an argument to javadoc.exe, and if I click the link its content is shown in a pop up window within Intellij IDEA, but if I check in File Explorer there is no such file. Is this the case for you as well? I have no idea how it gets generated. Also, I created a project in a folder named Müller and the ü was rendered as � within the popup window that showed the content of javadoc_args.
UPDATE 04/12/2018
As skomisa already commented, JetBrains plans to fix this bug in a future version, likely in version 2019.1 (Build 191.2458).
UPDATE 22/02/2019
I know this question is quite old but it seems to be still relevant. I didn't check up to now if JetBrains fixed the bug but a similar one occurred for me when I try to open an JavaFX fxml externally inside of the SceneBuilder. In another post about renaming a Windows 10 user directory I found a possible workaround at least for Windows users! Just create an additional user directory without ü in the path and link to the existing one:
C:
CD\Users
MKLINK /J Müller Mueller
If you now uses the link as directory for project paths it should work fine.
I am unable to generate the Javadoc for a project in Intellij IDEA if the name of the path contains the character ü (u with umlaut). The workaround is to rename the project so that the project directory file path does not contain an umlaut.
To reproduce:
Use the project wizard to create a trivial Java Hello World project where the root directory name contains ü. I used Müller for testing purposes.
Ensure that the class for main() contains valid Javadoc documentation.
Build and run the project to verify that there are no unexpected issues.
Select Tools > Generate Javadoc, specify an empty Output Directory and click OK.
Javadoc creation fails with the error - cannot read Input length = 1 (shown below), and clicking the link to C:\Users\johndoe\AppData\Local\Temp\javadoc_args shows that the ü in the file path is (mis)represented as �, which presumably is the cause of the Javadoc error.
However, once the root directory is renamed from Müller to Muller (to remove the umlaut) the Javadoc creation works:
As a sanity check, rename the project from Muller back to Müller to reintroduce the error:
Notes:
As noted in the comments, the javadoc_args file does not exist, and I see no way to prevent its use during the Javadoc creation process.
Having the project name as Müller is not an issue; it's having ü within the project's file path that causes the problem.
Environment: Windows 10 + Intellij IDEA 2018 3.1 EAP (Ultimate Edition) + Open JDK 10.
I raised a bug report with JetBrains for this: https://youtrack.jetbrains.com/issue/IDEA-202849
Update 11/25/18
There is a workaround for this issue without needing to rename the project's path:
Run Generate Javadoc and let it fail.
Click the link to the file .../javadoc_args shown in the Javadoc window.
Copy and paste the content of the file javadoc_args into a text editor.
Correct any characters that are misrepresented (e.g. change M�ller to Müller).
Save the file using UTF-8 encoding, and the same absolute filename.
Open a Command Prompt window.
Copy the entire javadoc.exe command from the Javadoc window in Intellij IDEA and paste it to the Command Prompt window.
Submit the line that was pasted. It will now work because the project's path is correctly specified in the file javadoc_args.
Today (21-aug-2021) I tried to generate a javadoc but it failed. The error message was:
javadoc: error - cannot read Input length = 1
In my case it referred to the length of the path to the file, which is shown below.
D:\Tecnologia(ytrabajo)ysistemas26sep2020\misiontic2022\U El Bosque\UEB académico\Ciclo 2\Programación Básica\NetBProjects\R5DTO_DAOMVC_GUI
So I shortened the path to the following:
D:\Tecnologia(ytrabajo)ysistemas26sep2020\misiontic2022\NBProjects(m)\R5DTO_DAOMVC_GUI
As one can see, this route is shorter than the first so NetBeans could access it and generate the javadoc.
Note: It is not possible that NetBeans could not read the location because of the following characters: é and á in the words académico and Básica that I used in the first file location. Because, in that location, I tried to generate a JavaDoc in another project located there and NetBeans generated the Doc. So the error is more about the length of the path and the names of the files in the project.

Run code formatter from the command line with PhpStorm open

If I go to my PhpStorm\bin folder I can run the format.bat command to format files from the command line e.g.
phpstorm format -r C:\path\to\my\code -r -s c:\path\to\my\settings.xml
and that works great. However I cannot run the command if PhpStorm is open, I get an error:
Only one instance of PhpStorm can be run at a time
Not ideal to have to close my IDE or have to use a 3rd party code formatter. Is there any workaround? Without installing another copy of PhpStorm.
It's a known issue, please see: https://youtrack.jetbrains.com/issue/IDEA-160462
The link from y.bedrov led me to here https://confluence.jetbrains.com/display/IDEADEV/Command-Line+Source+Code+Formatter with a potential solution.
Unfortunately I don't seem to be able to get it to work, I had to resort to copying my PhpStorm directory and using the copy instead. But I add it here in hopes that it helps others
Running Command-Line Formatter when the IDE is Running
On Linux/MacOS
Go to /bin directory where is a directory where Intellij IDEA or Intellij IDEA-based product is installed.
Copy idea.properties to some other file, for example, format.properties
Modify format.properties as follows:
Uncomment the lines:
# idea.config.path=${user.home}/.IntelliJIdea/config
# idea.system.path=${user.home}/.IntelliJIdea/system
Change them to point to some directories which differ from defaults, for example:
idea.config.path=${user.home}/.IntelliJIdea/format/config
idea.system.path=${user.home}/.IntelliJIdea/format/system
Modify format.sh by adding the line with IDEA_PROPERTIES variable:
\#!/bin/sh
\# ------------------------------------------------------
\# IntelliJ IDEA formatting script.
\# ------------------------------------------------------
IDE_BIN_HOME="${0%/*}"
export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
exec "$IDE_BIN_HOME/idea.sh" format "$#"
Run format.sh without closing the IDE, it should give the following output:
IntelliJ IDEA ..., build ... Formatter
Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
-h|-help Show a help message and exit.
-s|-settings A path to Intellij IDEA code style settings .xml file.
-r|-R Scan directories recursively.
-m|-mask A comma-separated list of file masks.
path.. A path to a file or a directory.
On Windows
You have to create a separate format.properties file as described above for Linux/MacOS.
Change format.bat file by adding a line with IDEA_PROPERTIES variable as follows:
#ECHO OFF
::----------------------------------------------------------------------
:: IntelliJ IDEA formatting script.
::----------------------------------------------------------------------
SET IDE_BIN_DIR=%~dp0
SET IDEA_PROPERTIES=%IDE_BIN_DIR%\format.properties
CALL "%IDE_BIN_DIR%\idea.bat" format %*
Run format.bat, it will list the command-line formatter options.
This guide works for me. But ensure use PHPSTORM_PROPERTIES instead of IDEA_PROPERTIES when export environment variable as described in the article:
export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
And what's more, from version 2022.1, IntelliJ IDEA supports dry run which is very useful for format validation based pre-commit git hook.

Setup golang environment using jetbrains

I have setup an golang developing envionemnt using idea (13.1 community edition).
It seems the SDK is recognized.
However, I could not create a GO file by right click the "New" under the source folder. (The item of "go" is grayed)
Currently I have to manually set the file extension to ".go" and edit the file, but autocomplete is OK.
This only exist on my Mac(with version 10.9.4)
I have set the GOPATH directory access mode to 777 but still not work.
This works fine on windows7.
So what should I do ?
This is what it looks like in windows
Thanks VonC, I already tried the /Users/Tom/go setting, this doesn't work and I switch to this root path.
here's my previous setting
macbook:home root# go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mac/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
And this is what is look like in the /Users/Tom/Go
Thanks VonC, however, this doesn't work. I am not sure what's the reason.
This is the envionment setting using GOCODE
This is several steps!
step1
By the way, I noticed that there are a difference from mac and windows when creating a new Go Project
at this step, the windows platform will show a "project sdk" while mac won't.
Make sure your IntelliJ project reference the right path within GOPATH.
From the plugin page:
If you have only one directory in the GOPATH and you are creating a project inside that path when you are working with packages that are part of the project you must still specify the whole import path for them, not the relative one. Example:
GOPATH is: /home/florin/go
the correct way to setup a project called demogo is: /home/florin/go/src/github.com/dlsniper/demogo/
new package is: /home/florin/go/src/github.com/dlsniper/demogo/newpack
the correct import statement is: github.com/dlsniper/demogo/newpack not newpack
Also make sure you have the latest version of the plugin, as issue 756 illustrates that IntelliJ IDEA 13 doesn't create the project directory structure on Mac OS X.
Finally, check if IDEA has correctly detected GOROOT and GOPATH:
See the page "Fix missing environment paths (Mac)".
The OP python adds in the comments:
If I have create a new Go project, this new feature is disabled.
If I create a new Java Command line App, then I could right click and add new Go file.
Right-click on either the top-level project or on the src directory and then go to Mark Directory As > Sources Root. After this you will be able to access the enabled Go context menus.

Running an Mac OS command line application, how to

Suppose you create a new Mac OS Command Line Application using Xcode, which prints something. How do you actually find and run it using your command line or Finder?
Application was "built", but project directory structure does not seem to contain an executable file. For what matter in what format will this file be?
Please advise
This should help out:
Choose to build your project for archiving (Product->Build
For->Archiving).
The executable will be created and placed in the project build
folder. This will typically be something like
/Users//Library/Developer/XCode/DerivedData//Build/Products/Release.
If you wish, copy the executable to a more convenient location.
To run it, open up a shell window, browse to the executable
directory, and type in your command name.
EDIT
I see you mentioned iOS in your question and tagged it as such. This answer is NOT relevant to iOS, infact I see no option to build a command line application for that system and it doesn't really make much sense to have one.

How to add new programming language to jEdit?

I've recently been learning the Processing programming language. Processing includes an IDE called the Processing Development Environment (PDE), but the editor is quite basic.
The IDE has an option to use an external editor. One of my preferred editors is jEdit due to it's cross-platform support. Jedit has built-in support for over 170 languages, but not processing which I guess is still a little bit too niche at the moment.
How do I add Processing with all the color highlights to jEdit?
The whole process for adding processing has been detailed here: http://wiki.processing.org/w/JEdit_as_External_IDE.
Basically, jEdit is using XML files to define syntax coloring rules (incl. simple checking) for its various editing modes. Each syntax definition file has a file extension mapping to tell jEdit which language mode to use for individual files. For Processing files we will use the standard .pde extension.
There are two things you need to do: (Before installing any of the files below, please make sure jEdit is not running.)
Syntax Highlighting
Download File:Processing.xml into the "modes" folder inside your jEdit installation.
On Linux/MAC this is usually /usr/share/jedit/modes
On Windows this is C:\Program Files\jEdit\modes
Then copy and paste the following XML node into the file "catalog" inside the same folder and syntax coloring/checking for PDE files should be ready: <MODE NAME="processing" FILE="Processing.xml" FILE_NAME_GLOB="*.pde" />
Abbreviations
Download Media:abbrevs_v0.1.zip and extract it into the right folder for your system:
Windows
C:\Documents and Settings\{USERNAME}\.jedit
Mac
/Users/{USERNAME}/.jedit
Note: This folder is not visible in the Finder. Unzip the file in your home folder, open a terminal window and type: mv ~/abbrevs ~/.jedit/abbrevs</source>
Linux
Find the location of the jEdit settings directory via the menu: Utilities > Troubleshooting > Activity log, then extract/copy the file in that folder.
For all systems, you'll need to restart jEdit in order for the abbreviations to come in effect.