jesperhh / qmlfmt Goto Github PK
View Code? Open in Web Editor NEWqmlfmt - command line application that formats QML files
qmlfmt - command line application that formats QML files
Please add an option to allow/disallow the alphabetical order of properties.
libQt5Concurrent.so.5: cannot open shared object file: No such file or directory
Hello,
I try to build your tool but I meet some troubles. After cloning your repo, I launched this two commands:
$ cmake .
$ make
An error appear on the second one:
[...] [ 31%] No patch step for 'QtCreator' [ 36%] Performing update step for 'QtCreator' [ 40%] Performing configure step for 'QtCreator' -- The C compiler identification is AppleClang 10.0.0.10001145 -- The CXX compiler identification is AppleClang 10.0.0.10001145 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:39 (find_package): By not providing "FindQt5Script.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Script", but CMake did not find one.Could not find a package configuration file provided by "Qt5Script" with
any of the following names:Qt5ScriptConfig.cmake qt5script-config.cmake
Add the installation prefix of "Qt5Script" to CMAKE_PREFIX_PATH or set
"Qt5Script_DIR" to a directory containing one of the above files. If
"Qt5Script" provides a separate development package or SDK, be sure it has
been installed.-- Configuring incomplete, errors occurred!
See also "/Users/nbazille/www/qmlfmt/QtCreator-prefix/src/QtCreator-build/CMakeFiles/CMakeOutput.log".
make[2]: *** [QtCreator-prefix/src/QtCreator-stamp/QtCreator-configure] Error 1
make[1]: *** [CMakeFiles/QtCreator.dir/all] Error 2
make: *** [all] Error 2
Environment:
$ sw_vers ProductName: Mac OS X ProductVersion: 10.14.1 BuildVersion: 18B75
$ cmake --version cmake version 3.10.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i386-apple-darwin11.3.0
Problem with launching cmake
Hi there, I follow the tutorial to install your git project on my computer but when i am in the build folder and I launch :
cmake ..
I got the following error :
`CMake Error at qmljs/CMakeLists.txt:35 (find_package):
By not providing "FindQt5Qml.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Qml", but
CMake did not find one.Could not find a package configuration file provided by "Qt5Qml" with any
of the following names:Qt5QmlConfig.cmake qt5qml-config.cmake
Add the installation prefix of "Qt5Qml" to CMAKE_PREFIX_PATH or set
"Qt5Qml_DIR" to a directory containing one of the above files. If "Qt5Qml"
provides a separate development package or SDK, be sure it has been
installed.-- Configuring incomplete, errors occurred!
See also "/home/etienne/qmlfmt/build/CMakeFiles/CMakeOutput.log".`Qt version : 5.15.2
Cmake version : 3.16.3
OS : Ubuntu 20.04.2 LTS
GNOME version : 3.36.8Could you help me please ?
QML enum is removed
qmlfmt is also affected by QTCREATORBUG-22196: when trying to save a document such as
import QtQuick 2.9 Item { enum MyEnum { Red, Green, Blue } }the resulting formatted document has the
enum
removed:import QtQuick 2.9 Item { }Update QtCreator to 4.0
If qmlfmt will use http://download.qt.io/official_releases/qtcreator/4.0/4.0.3/qt-creator-opensource-src-4.0.3.tar.gz this version, problems with "pragma Singleton" and removed "readonly" will dissapear.
Right now I changed URL to 4.0.3 and tryied compile, I have following problems.[ 15%] Building CXX object CMakeFiles/utils.dir/src/libs/utils/bracematcher.cpp.o [ 15%] Building CXX object CMakeFiles/utils.dir/src/libs/utils/filesystemwatcher.cpp.o [ 16%] Building CXX object CMakeFiles/utils.dir/src/libs/utils/unixutils.cpp.o /home/crupizkas/Documents/Work/AllView/qmlfmt/.build/QtCreator-prefix/src/QtCreator/src/libs/utils/consoleprocess_unix.cpp: In member function ‘bool Utils::ConsoleProcess::start(const QString&, const QString&)’: /home/crupizkas/Documents/Work/AllView/qmlfmt/.build/QtCreator-prefix/src/QtCreator/src/libs/utils/consoleprocess_unix.cpp:150:28: error: expected primary-expression before ‘(’ token + QLatin1String("/" QTC_REL_TOOLS_PATH "/qtcreator_process_stub"); ^ /home/crupizkas/Documents/Work/AllView/qmlfmt/.build/QtCreator-prefix/src/QtCreator/src/libs/utils/consoleprocess_unix.cpp:150:33: error: expected ‘)’ before ‘QTC_REL_TOOLS_PATH’ + QLatin1String("/" QTC_REL_TOOLS_PATH "/qtcreator_process_stub"); ^ make[5]: *** [CMakeFiles/utils.dir/src/libs/utils/consoleprocess_unix.cpp.o] Error 1 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [CMakeFiles/utils.dir/all] Error 2 make[3]: *** [all] Error 2 make[2]: *** [QtCreator-prefix/src/QtCreator-stamp/QtCreator-build] Error 2 make[1]: *** [CMakeFiles/QtCreator.dir/all] Error 2 make: *** [all] Error 2 FAIL: 2generating an AST
hello ,
can you help me to generate an ast in c++ using boost spirit v2 and the grammar bellow ?
I saw all documentation and examples but I stil didn't start .
#include
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_string.hpp>
#include <boost/fusion/adapted.hpp>
using namespace std;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;//Nos règles de grammaire
namespace regles_de_grammar{//Importing our using librairies
using boost::spirit::qi::char_;
using boost::spirit::qi::uint_;
using boost::spirit::qi::int_;
using boost::spirit::qi::lit;//Rules for predicats
auto pred_gt = char_('>'); // the pred_gt is defined by the character '>'
auto pred_lt = char_('<'); // defined by <auto pred_ge = char_('>')>char_('=');//defined by > followed by =
auto pred_le = char_('<')>char_('=');//defined by < followed by =
auto pred_eq = char_('=');//defined by =
auto pred_ne = char_('!')>char_('=');//defined by ! followed by =auto predicate = pred_gt | pred_lt | pred_ge |
pred_le | pred_eq | pred_ne;auto tbl_name = char_>> *(char_); // the name of the table is a string
auto col_name = char_>> *(char_) ;// the name of a column is a string
auto start= uint_;
auto t_end=uint_;
//je dois verifier col_ref
auto col_reference = col_name | (col_name > '[' > start >':' > ']') | (col_name > '[' > ':' > t_end >']') | (col_name > '['> start > ':'> t_end>']');
auto col_predicate = col_reference >> predicate >> *(char_);
auto col_projection = col_reference >> col_predicate;
auto project_list = (col_projection) % (',') | col_projection;
auto from_stmt = tbl_name;//def of a from statement
auto seq_any_log_expr = "ANY" >> col_predicate;
auto seq_all_log_expr= "ALL">> col_predicate;
auto select = lit("SELECT") > project_list >lit("FROM") >from_stmt;//defined bu select followed by project_list followed by from_stmt
/auto pos_log_expr = col_predicate | (pos_and_log_expr) | (pos_or_log_expr);//let these 2
auto pos_and_log_expr= ((pos_log_expr )> "AND" >( pos_log_expr>));
auto pos_or_log_expr = ((pos_log_expr) > "OR" >>(pos_log_expr)) | pos_log_expr >> "OR" >> pos_log_expr;/}//fin namespace regles_de_grammar
No version number output
This is rather minor... however when I run
qmlfmt -v
I get the outputqmlfmt
but I'd expect
qmlfmt 1.0.71
(since I'm testing with the pre-build binary v1.0.71 from the GitHub release page).
Difference to qmlformat
I am interested in this project, but the readme does not tell me what it does better than
qmlformat
, the command line tool that ships with Qt.Binaries
This isn't an bug with the tool, but I just wanted to ask if it's possible to publish binaries for all platforms as part of a release!
I had a bunch of trouble to get it to build on Windows due to issues on my system, but it would be great to have a binary for all platforms if possible. Thank you!
Doesn't work with JS lambdas
with this QML:
onPressed: (mouse)=> {
if (mouse.modifiers & Qt.AltModifier) {
if (mouse.button == Qt.LeftButton) {
state = 1;
} else if (mouse.button == Qt.RightButton) {
state = 2;
} else if (mouse.button == Qt.MiddleButton) {
state = 3;
}
}
it produced:
onPressed: function mouse }
if (mouse.modifiers & Qt.AltModifier) {
if (mouse.button == Qt.LeftButton) {
state = 1
} else if (mouse.button == Qt.RightButton) {
state = 2
} else if (mouse.button == Qt.MiddleButton) {
state = 3
}
}More options for format?
Seems it is using the formatter in QtCreator?
I think this formatter is not very well handling when to wrap a line and creates deep indent for nested JS functions
Can we add more configurable options aside from indent width? On QtCreator there no configs maybe it is possible though the code?
Formatting of QML comments
Running qmlfmt on this:
import QtQuick 2.7 Item { /* This is a comment * of the component */ }
returns
import QtQuick 2.7 Item { /* This is a comment * of the component */ }
It seems like the starting asterisk is interpreted as multiplication sign which causes an increased indent.
Distributing as a standalone tool
Hi,
I wonder how this tool could be built and distributed in any platform without requiring a Qt installation (a standalone version).
When I build it on my Mac and try to launch on another Mac I get this error:
dyld: Library not loaded: @rpath/QtConcurrent.framework/Versions/5/QtConcurrent Referenced from: /path/to/qmlfmt Reason: image not found
Do you have an idea on how I do that?
Regards.
"cannot execute binary file" using prebuilt on macOS
Thanks for this project!
I tried running the command (using both clang and gcc releases of v1.0.85:
/path/to/qmlfmt # and also: /path/to/qmlfmt /path/to/file.qmlError message:
-bash: /path/to/qmlfmt: cannot execute binary file
I tried
chmod +x
etc, still same issue.System specs:
$ clang -v Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin $ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin $ uname -r 17.7.0On Ubuntu 14.04 can't assemble QtCreator via simple make
Linking CXX static library RELEASE/libqmljs.a [100%] Built target qmljs [ 80%] No install step for 'QtCreator' [ 90%] Completed 'QtCreator' [ 90%] Built target QtCreator Scanning dependencies of target qmlfmt make[2]: *** No rule to make target `QtCreator-prefix/src/QtCreator-build/Release/libcplusplus.a', needed by `qmlfmt'. Stop. make[2]: *** Waiting for unfinished jobs.... [100%] Building CXX object CMakeFiles/qmlfmt.dir/qmlfmt.cpp.o make[1]: *** [CMakeFiles/qmlfmt.dir/all] Error 2 make: *** [all] Error 2 FAIL: 2Seems like problem in CMake, which not defined rule, right?
import qrc:
Hi, I got segmentation fault when I try to format qml file with import "qrc:..."
Example, in main.qml
import "qrc:/test"
To debug, I run with strace
strace qmlfmt main.qml
Output :
stat("/home/mathben/qml_test/qrc:/test", 0x7fff6fa274b0) = -1 ENOENT (No such file or directory)
Column and line information not shown
I was wonderding whether it's possible to remove that line:
Line 81 in 4d4399c
Given a simple erroneous component file like this
// MyItem.qml import QtQuick 2.7 Item {
the command
qmlfmt -e MyItem.qml
does output the error but not the location of the error (Error: Expected token }
). With the aforementioned line removed, it outputsError:3:1: Expected token }
which provides more information and can be parsed (which again helps to use qmlfmt as tool for syntax checking plugin in e.g. vim).Indent with tabs
Is it possible to configure qmlfmt so that it uses tabs for indention?
Generate an AST document
Hi!
Now that I could generate a
qmlfmt
build with success (mainly through your help on the issue #14) I can see it working on my project and formatting my.qml
files.But, according how QtCreator reformat the JavaScript part, I think it looks like particularly inelegant. Except the indentation size there isn't any more available option.
So I was wondering if using Prettier could be a solution to improve that, because it already formats the JavaScript code and does it better than QtCreator. To do that I have to create a new plugin for Prettier and I will need a QML parser. I've supposed I could take advantage of the QtCreator's parser part to generate an AST document. WYT?
Properties sorting
Properties are often ordered by meaning instead of alphabetically, so forcing them with an alphabetical order could be a problem.
Example
Rectangle { color: "red" height: 40 objectName: "foo" width: 100 }
Obviously I'd like to have width and height close and an alphabetical order make more difficult to read a complex file.
Would be reasonable to add an option to disable the alphabetical order while keeping the guidelines suggestion active?
Build against Qt Creator 10.x
Did you try to build this code against Qt Creator 10.x? We are also running into the Lambda formatting bug and this is fixed in Qt Creator 10.x. So the only challenge left is to update
qmlfmt
.Recommend Projects
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
TensorFlow
An Open Source Machine Learning Framework for Everyone
Django
The Web framework for perfectionists with deadlines.
Laravel
A PHP framework for web artisans
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
web
Some thing interesting about web. New door for the world.
server
A server is a program made to process requests and deliver data to clients.
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Visualization
Some thing interesting about visualization, use data art
Game
Some thing interesting about game, make everyone happy.
Recommend Org
We are working to build community through open source technology. NB: members must have two-factor auth.
Microsoft
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba
Alibaba Open Source for everyone
D3
Data-Driven Documents codes.
Tencent
China tencent open source team.