Commit graph

41 commits

Author SHA1 Message Date
James Westman
9b9fab832b
Add tests, remove unused code, fix bugs
- Added tests for more error messages
- Test the "go to reference" feature at every character index of every
test case
- Delete unused code and imports
- Fix some bugs I found along the way
2024-12-22 18:00:39 -06:00
Jordan Petridis
ac70ea7403 Port to libgirepository-2.0
pygobject 3.52 has switched [1] to using libgirepository-2.0 which
comes from glib itself now, rather than the 1.0 which came from
gobject-introspection.

This means that it fails to load the incompatible "GIRepository 2.0"
and thus must be ported to 3.0 (which is provided by
libgirepository-2.0).

Migration guide is here [2]

[1]: https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/320
[2]: https://docs.gtk.org/girepository/migrating-gi.html

This commit adds suppport for importing with
"gi.require_version("GIRepository", "3.0") and falling
back to the existing "GIRepository 2.0" if not found.
2024-12-16 13:37:40 +00:00
James Westman
c1a82a034b decompiler: Add more decompilable tags
Add more tags to the list of things the decompiler can handle. This
required some changes to track the containing object class in the
DecompileCtx, since some objects use the same tag names.

The improved support means we can test the decompiler on most of the
test suite. Any new test samples will by default be tested to ensure the
decompiler produces the original blueprint file.

Also, updated the decompiler to always use double quotes.
2024-07-26 23:05:37 -05:00
James Westman
8dfa10019b lsp: Fix online docs links for interfaces 2024-07-27 02:52:56 +00:00
James Westman
24eed1048e gir: Fix assignable_to for template types
If we don't know the template's parent type, we should be able to assign
it to an extern type, since we don't know anything about that either.
2024-07-27 02:40:27 +00:00
Sonny Piers
adc2be1454 Support template without parent 2024-07-04 22:14:16 +00:00
Sonny Piers
896dd7f824 fix linter 2024-07-04 22:07:02 +00:00
Sonny Piers
a075b26769 lsp: Extend completion documentation 2024-07-04 22:07:02 +00:00
Diego Augusto
da5b9909fc Support array type 2024-07-04 22:02:51 +00:00
Sonny Piers
ba8b492134 Add support for Adw.AlertDialog 2024-02-02 11:03:16 +01:00
Jerry James
0c02195510
Handle big endian bitfields correctly 2023-09-13 08:43:54 -06:00
James Westman
35ee058192 lsp: Add code action to add missing imports 2023-07-25 20:02:03 -05:00
James Westman
94db929f74 Emit deprecation warnings 2023-07-23 18:09:29 -05:00
James Westman
c4fc4f3de8 docs: Fix bug with colliding names
Often a vfunc has the same name as a signal, and the wrong docs would be
shown.
2023-07-16 16:52:51 -05:00
James Westman
e1b7410e51 docs: Add link to online documentation 2023-07-16 16:52:51 -05:00
James Westman
4eaf735732 gir: Fix signatures for properties and signals
Add arguments to signal signatures and fix property signatures
2023-07-16 16:52:51 -05:00
gregorni
3730e2e726 Add isort to CI and run on files 2023-07-09 14:26:37 +00:00
James Westman
4e02c34a5b
Minor performance optimizations 2023-06-13 19:01:33 -05:00
James Westman
04509e4b2e Change template syntax
Templates now use a TypeName instead of an identifier, which makes it
clearer that it's an extern symbol (or that it's a Gtk.ListItem).
2023-05-13 16:49:48 -05:00
James Westman
88f5b4f1c7
Fix template types 2023-04-08 20:10:16 -05:00
James Westman
bc605c5df8
Reduce errors when a namespace is not found
When the typelib for a namespace is not found, don't emit "namespace not
imported" errors. Just emit the one error on the import statement.
2023-03-21 11:31:02 -05:00
James Westman
8c3c43a34a
Add --typelib-path command line argument
Allows adding directories to search for typelib files.
2023-03-16 18:21:56 -05:00
James Westman
fad3b35531 types: Remove g* type names
They aren't used in GIR parsing anymore since we use typelibs, and
blueprint files should use the non-prefixed names.
2023-03-11 21:37:26 -06:00
James Westman
9fcb63a013
typelib: Fix crash when handling array types 2023-02-16 20:43:17 -06:00
James Westman
0b7dbaf90d
Add some type hints 2023-01-12 15:49:19 -06:00
James Westman
59aa054c4c
language: Add closure expressions 2022-12-25 14:04:41 -06:00
James Westman
2033bd9e16
types: Add UncheckedType
This allows us to remember information about an external type, such as
its name, while still marking it as unchecked.
2022-12-25 14:04:36 -06:00
James Westman
6c67e1fc5a
xml: Fix flags and enums
GtkBuilder XML uses enum nicknames, full names, or integer values, but
we accept GIR names, so passing those through doesn't work if the name
has an underscore (which traditionally turns into a dash in the
nickname). Avoid the problem by always writing the integer value of the
enum member.
2022-12-19 15:15:25 -06:00
James Westman
8fee46ec68
Format using black 2022-12-19 11:52:59 -06:00
James Westman
a24f16109f
Separate output into its own module 2022-10-15 19:40:47 -05:00
James Westman
c0c40b1577
language: Support boxed types and GType
- Add support for type checking boxed types
- Remove support for converting string and number literals
- Add the `typeof()` operator for GType literals
2022-10-06 13:03:33 -05:00
James Westman
0a0389b1f8
grammar: Create an AST node for type names 2022-07-09 16:05:10 -05:00
James Westman
68610a7dba
typelib: Use GIRepository to find typelib path 2022-06-28 23:58:48 -05:00
James Westman
c5f2e4ed4b
gir: Gracefully handle missing .gir files
They aren't required for compilation anymore, and not being able to show
documentation on hover is probably not worth crashing the language
server over.
2022-06-25 00:15:20 -05:00
James Westman
06f54c8ff8
Use typelib instead of XML
For normal compilation, use .typelib files rather than .gir XML files.
This is much faster.

Rather than using libgirepository, which would try to actually load the
libraries, we use a custom parser.

The language server will still read XML because it needs to access
documentation, which is not in the typelib, but that's generally fine
because it's a long lived process and only has to do that once.
2022-06-25 00:15:20 -05:00
James Westman
99e428d93c validation: Disallow instantiating abstract classes 2022-04-28 23:35:34 -05:00
James Westman
f78478bea1 validation: Writable/construct-only properties
Add two new errors, one for non-writable properties and another for
binding construct-only properties.
2022-04-28 22:52:30 -05:00
James Westman
f197e68589 Use cached_property instead of a custom decorator 2022-03-28 14:38:05 -05:00
James Westman
85150d397b
gir: Fix assignable_to for interface implementations
Part of #29
2022-01-11 22:37:24 -06:00
James Westman
8e4433a487
Create an interactive porting tool
`blueprint-compiler port` interactively ports a project to blueprint.
It will create the subproject wrap file, add it to .gitignore, decompile
your GtkBuilder XML files, emit code to copy and paste into your
meson.build file, and update POTFILES.in.

It can't quite handle all of the features the forward compiler can, so
it will skip those files.
2021-12-01 23:38:28 -06:00
James Westman
544d152fb6
Rename to blueprint-compiler
This isn't an official GTK project so better to avoid using "GTK" in the
name.
2021-12-01 15:35:58 -06:00
Renamed from gtkblueprinttool/gir.py (Browse further)