Commit Graph

9197 Commits

Author SHA1 Message Date
Andrew Dupont
11ebeeab61 Prefer a more graceful solution 2024-01-29 22:00:58 -08:00
Andrew Dupont
14e3562330 Fix failing spec 2024-01-29 21:55:04 -08:00
DeeDeeG
4f3bc686e1
Merge branch 'master' into tree-sitter-january 2024-01-29 22:44:18 -05:00
Andrew Dupont
5855241698 Fix issue with looking up objects in atom.config
…when a project-specific config is present.

Most people don't use a project-specific config, which is why this bug has been present for ages. Read the new spec for an explanation.
2024-01-28 00:47:32 -08:00
Andrew Dupont
f691cfce28 Allow for any number of @_IGNORE_ capture names in a query…
…by namespacing them as `@_IGNORE_.foo`, `@_IGNORE_.bar`, etc.

It's sometimes necessary to define a capture in a query not because you want to apply a scope name, but because you need to use it as the argument to a predicate. `@_IGNORE_` was intended for that purpose, but it was the _only_ capture name with that special effect.

Now, you can specify any number of captures that don't apply scope names. As long as it equals `@_IGNORE_` or _starts with_ `@_IGNORE_.`, it'll have the same effect. This lets you target two or more nodes and use them all in predicates in the same query without any of them applying a scope name.
2024-01-27 23:11:41 -08:00
Andrew Dupont
46877b05ff [language-php] Add meta.embedded.block/meta.embedded.line
…to each PHP section in order to match the functionality of the TextMate grammar.

This was a gigantic endeavor and involved doing several things that were on my “ugh, I’ll get around to it” list:

* To make some of this stuff work, we were using two different PHP parser layers. The root one did the syntax highlighting and separated the HTML from the rest, and the deeper injection was there just so we could scope some ranges as `source.php`.

  That doesn’t work because of rules we have about shallower layers acting before deeper layers when iterating through syntax highlighting boundaries. I was trying to be too clever. Now the _root_ layer is the one that does no highlighting, and the _deeper_ layer is the one that exists to apply `source.php` _and then_ perform highlighting and indentation hinting and folding and whatnot.

  If we need to, we can move some of the queries to the root layer for whatever reason; maybe we come across a bug six months from now that could be fixed if we made the root layer in charge of folding. We have options.

* All boundaries for `HighlightIterator`s now _either_ open one or more scopes _or_ close one or more scopes. If one boundary can close some scopes and open others, then boundaries on different layers that share a buffer position cannot possibly close/open in the correct order because they can't intermingle. This needed to happen and this was as good of an excuse as any to do it.
* We needed to present sane PHP opening/closing ranges to the injection. Ironically, `tree-sitter-php` itself makes this nearly impossible because of how the tree is structured; it tries to hide the `<?php` and `?>` tags from the PHP layer and treat them as text, despite the fact that PHP is the thing that knows how to parse that.

  The best way to do this — at least until I encounter a reason why it can’t work — is to find all the `<?php`s and `?>`s, sort them, group them, and build fake node ranges. This is fine! I mean, it’s ridiculous, but it’s fine! The ranges that we hand off to another parser are allowed to be completely arbitrary!

  This lets us do what we were only approximating before: have _one_ PHP injection layer with _any number of_ content ranges, each of which begins with `<?php` and ends with `?>` without trying to claim any surrounding whitespace. This would be worth it even if we didn’t have to do any of this other stuff.

* Each content range of the injection needs _either_ `meta.embedded.line.php` _or_ `meta.embedded.block.php` depending on whether the range begins and ends on the same line. This is not something I was willing to regress on because it's _hard_ to distinguish between PHP and non-PHP unless your editor helps you out, and because I wasn't going to go into a bunch of themes and tell them to treat `source.php` like `meta.embedded`.

  This also meant that we needed to be able to add _multiple_ “root” scope names per content range. But we already had a mode in which the `languageScope` injection option could be a callback, so it wasn't hard to make it a callback that could take extra parameters for the buffer and range.

  This isn't a feature that I'm eager for other grammars to use, or even necessarily know about, but it was what we needed to deliver feature parity here. And none of it would have been necessary if `tree-sitter-php` made more sensible choices. (Whatever. Maybe what I want isn't possible for some strange reason.)

All existing tests pass. Tests have been written for the new `languageScope` features. Tests need to be written for PHP just like for all other language grammars, but that was on the to-do list anyway. If any of this turns out to be catastrophic, it’s easy to roll back, but tests are passing on my machine and I expect them to pass in CI.
2024-01-20 20:49:17 -08:00
Andrew Dupont
2a0ebacf62 An injection with no highlights query should still apply its root scope 2024-01-20 13:50:31 -08:00
Andrew Dupont
c01099323f (forgot to change this spec) 2024-01-19 20:45:48 -08:00
Andrew Dupont
1ed84b8180 Adjust fold in response to tree-sitter-javascript change 2024-01-18 13:53:23 -08:00
Andrew Dupont
4a8df88ca5 Fix other grammar paths 2024-01-18 13:53:23 -08:00
Andrew Dupont
13c5c07412 Change references to JS grammar path in specs 2024-01-18 13:53:23 -08:00
Clayton Carter
ae03e1e9ba fix(tree-sitter): pass node text to grammar
This fixes a subtle breaking change in the WASM tree-sitter modes that
affected the semanticolor package. (And probably only that package.)

Although the node text is unused in `idForScope` in the core editor, the
legacy tree-sitter mode was specifically modified to pass the node text
into `idForScope` so that the semanticolor package could make use of it
to give custom scopes (and thus colors) to different symbols. (On
activation, semanticolor monkey patches that method in relevant
grammars.)

This alone is not enough to get sematicolor working with Pulsar's new
WASM tree-sitter modes, but it's one piece of the puzzle.

Ref: 97b905a2b0
Ref: https://github.com/atom/atom/pull/20212
Ref: 1bf7fc4025/src/tree-sitter-language-mode.js (L1321-L1324)
Ref: d219ef9a1f/lib/semanticolor-grammar.js (L44-L65)
2024-01-16 07:42:16 -05:00
Andrew Dupont
254440e6bc Oops 2024-01-11 15:07:11 -08:00
Andrew Dupont
4c6b0ba7d0 Ensure indentation decisions consult the correct layers…
…when straddling injection boundaries.
2024-01-11 15:07:11 -08:00
Andrew Dupont
a40bae4b88 Allow (#set! capture.final) as shorthand…
…instead of making grammars specify `(#set! capture.final true)`.
2024-01-11 15:07:08 -08:00
Andrew Dupont
58f76a8378 Address feedback 2024-01-10 20:47:51 -08:00
Andrew Dupont
413eeeaa5b Fix memory access error on autocomplete-html specs 2024-01-07 15:35:08 -08:00
Andrew Dupont
206a15a7b1 Get more TextEditor specs passing 2024-01-07 15:35:08 -08:00
Andrew Dupont
c7cde85856 Get Workspace specs passing 2024-01-07 15:35:08 -08:00
Andrew Dupont
11e5a6176f Get TextEditorRegistry specs passing 2024-01-07 15:35:07 -08:00
Andrew Dupont
3c4493b895 Get PackageManager specs passing 2024-01-07 15:35:07 -08:00
Andrew Dupont
98c80eb245 Get GrammarRegistry specs passing 2024-01-07 15:35:07 -08:00
Andrew Dupont
9884445241 Get WASMTreeSitterLanguageMode specs passing 2024-01-07 15:35:07 -08:00
Andrew Dupont
1bf7fc4025 Get TextEditor specs passing 2024-01-07 15:35:07 -08:00
Andrew Dupont
76ac2cf81c Make useExperimentalModernTreeSitter the default…
…and create `useLegacyTreeSitter` for those who want to opt into the previous default behavior.

(Legacy Tree-sitter grammars will soon be removed, but this is a step toward that future!)
2024-01-07 15:35:07 -08:00
Andrew Dupont
09db9e060b Fix behavior of new ScopeResolver config caching in specs 2023-12-15 21:20:04 -08:00
Andrew Dupont
7bc3ff7280 [tree-sitter] Share config caches between ScopeResolvers 2023-12-15 17:08:52 -08:00
confused-Techie
d7f7fede7a Add missing path delimiter 2023-11-08 19:55:11 -08:00
confused-Techie
339f228dd8 Match path translations 2023-11-06 22:23:10 -08:00
confused-Techie
46c0b3a6c0 Add newlines to expected specs 2023-11-06 21:50:19 -08:00
confused-Techie
3378746454 Move Atom link transformations out, fix tests 2023-11-06 21:28:48 -08:00
confused_techie
fb006f65c1 Add some minor specs 2023-11-06 10:50:28 -08:00
confused-Techie
4c590f07e7 Remove accidentally included test file 2023-10-18 12:01:40 -07:00
confused-Techie
e7c14be227 Migrate notifications to new API 2023-10-18 12:00:23 -07:00
Andrew Dupont
69038a1c4c
Merge pull request #677 from savetheclocktower/tree-sitter-more-fixes
Tree-sitter running fixes (August edition)
2023-09-13 15:14:27 -07:00
Andrew Dupont
e9903ad9d6 Change behavior of “adjustment exceeds bounds” error
Previously, we threw an error when a scope adjustment violated its bounds constraints, but that's a bit disruptive for everyday use. Instead, we throw an error in dev mode (so that the grammar's author doesn't fail to notice the problem), but downgrade it to a warning outside of dev mode so that it's recoverable.

There's a chance that the warning will be _too_ subtle, but we'll give it a shot.

We also include more diagnostic information so that it's clearer exactly _where_ the violation is happening.
2023-09-11 15:14:19 -07:00
confused_techie
24ab36323c
Merge pull request #668 from pulsar-edit/mothball-current-auto-update-logic
Remove AutoUpdate functionality from Core
2023-08-24 16:45:20 -07:00
confused-Techie
dec390abf5 Fix bad spec 2023-08-13 18:53:22 -07:00
confused-Techie
a40207ddd0 Add spec to ensure behavior 2023-08-13 17:59:17 -07:00
confused-Techie
6fc2b65ff5 Remove auto update functionality from core 2023-08-10 19:22:44 -07:00
confused_techie
f90d9bfdf8
Merge pull request #653 from pulsar-edit/fix-style-manager-regex
[core]: Transforming Deprecated Math Usage - Support for Variables
2023-08-01 17:14:38 -07:00
confused-Techie
010a02f89e Incorrect spec added 2023-07-25 16:54:17 -07:00
Andrew Dupont
6dc39587e4 Un-focus config specs 2023-07-22 22:05:41 -07:00
Andrew Dupont
ea6b42d759 [settings-view] Don't let project settings…
…pollute the UI.

Anything that is present in a project-specific settings override should not
appear in the settings panel. The settings panel should only be able to read
from the global config file, because that's the only place it writes to.

But if we notice that a setting in the UI is affected by a project-specific
setting, we'll include a warning so that the user doesn't wonder why changes
in the settings UI don't seem to have an effect.
2023-07-22 20:24:39 -07:00
confused-Techie
2ecaf27596 Fixed incorrect test expectations 2023-07-20 22:39:23 -07:00
confused_techie
068775b880
Update spec/style-manager-spec.js
Co-authored-by: Andrew Dupont <github@andrewdupont.net>
2023-07-20 22:38:17 -07:00
confused-Techie
ed83c9c1fa Upgrade Regex to support Less variables, add tests 2023-07-20 21:47:43 -07:00
Andrew Dupont
ce1980496a Fix typo 2023-07-20 18:34:04 -07:00
Andrew Dupont
c8cbd82518 Overhaul Tree-sitter scope tests
I realized a few days ago that the `#is?` and `#is-not?` predicates — which
puzzled me upon first investigation back in February, and which I'd ignored ever
since — are exactly what I should've been using all along for scope tests.

They are counterparts to `#set!` in that they are two additional buckets in
which to store arbitrary data. And they remove the need to have both
`test.onlyIfFoo` and `test.onlyIfNotFoo`, since the presence of `test.onlyIfFoo`
in the `refutedProperties` bucket can behave opposite to the its presence in the
`assertedProperties` bucket.

This further means that a test called `test.onlyIfFoo` can be renamed
`test.foo`. The `onlyIf` was my way of making it clear through context that this
`#set!` predicate actually enforced a criterion — but that's implicit now that
it'll be using an `#is?` or `#is-not?` predicate.

I also took the opportunity to move `test.final` and `test.shy` to their own
namespace. `final` is an oddball in the sense that it sets criteria for _other_
captures as well as its own, and they're both oddballs in the sense that they
consider the effects of other captures on the same range. And I don't want to
introduce the idea that a predicate like `#is?` can have side effects.

So they stay on `#set!` and live at `capture.final` and `capture.shy`,
respectively.

To summarize, here's a before and after:

  ((string "\"" @punctuation.start)
    (#set! test.onlyIfFirst true)
    (#set! test.final true)

  ((bar) @baz
    (#set! test.onlyIfNotDescendantOfType thud))

becomes

  ((string "\"" @punctuation.start)
    (#is? test.first true)
    (#set! capture.final true)

  ((bar) @baz
    (#is-not? test.descendantOfType thud))

This PR changes all the built-in grammars. I don't know if there are any
third-party modern-Tree-sitter grammars out there except for mine, but I've
added a simple compatibility layer so that all of the old predicates should
still work for now. But I'm going to remove that code before we ship this stuff
for real.
2023-07-20 15:17:01 -07:00
Andrew Dupont
b38be58719 Add forgotten specs 2023-07-18 14:22:21 -07:00