Commit Graph

9172 Commits

Author SHA1 Message Date
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
Andrew Dupont
5c00a36c30 [styleguide] Fix error when styleguide is shown…
…before certain grammars are loaded.
2023-07-18 12:21:42 -07:00
Andrew Dupont
30e63884f5
Merge pull request #555 from savetheclocktower/tree-sitter-heaven
Running PR for Tree-sitter fixes
2023-07-13 22:06:48 -07:00
Andrew Dupont
59fe4a8af3 [tree-sitter] Add multiple argument support…
…to each of `onlyIfDescendantOfType` and `onlyIfAncestorOfType`.

Each of these can now accept a space-separated list of node types. If any of the
node's ancestors or descendants matches any of the given types, the test passes.
2023-07-08 18:01:03 -07:00
confused_techie
c6783a00dc
Merge pull request #588 from pulsar-edit/easy-version-comparison
[core]: Implement API on `atom.` to compare Pulsar Versions
2023-07-04 12:34:52 -07:00
confused-Techie
a2a2a063b7 More safety checks, allowing us to bail quickly, more tests 2023-07-02 12:22:45 -07:00
confused-Techie
9e4f754ef6 New tests, multi parameter fixes 2023-07-02 03:38:03 -07:00
confused-Techie
9353b113ed Better tests 2023-07-01 21:02:06 -07:00
confused-Techie
76f1210c68 Starting some tests 2023-07-01 18:36:26 -07:00
confused-Techie
95ae9e8b6a Rewrite, and simplify 2023-06-14 17:17:20 -07:00
confused-Techie
d00729fe24 Implement proper version checking functions 2023-06-13 19:30:34 -07:00
Andrew Dupont
2006f9ccd0 (oops) 2023-05-22 18:10:29 -07:00
Andrew Dupont
83c76da0d8 Fix issue with scopeDescriptorForPosition
…when more than one layer wants to apply a scope at the given point.
2023-05-22 17:47:21 -07:00
Andrew Dupont
ef2f8abed2 Update TreeSitterLanguageMode spec…
…not to expect empty tokens.

I made a change in 29cfcad that neglected to apply any scopes for a range that
was zero characters long. My instincts tell me that this is a safe change to
make, but it does affect any tests that used `tokensForScreenRow` and expected
it to report information about zero-length tokens. So the expected results
needed to be updated.
2023-05-19 14:32:27 -07:00
Andrew Dupont
8afe2f6fc4 Ensure suggestedIndentForBufferRows works right…
…when straddling an injection boundary.

When we do this one row at a time, the controlling layer for an indent query is
the comparison (previous) row, because that's where the query starts. The batch
version should be no different.

The new spec describes the exact scenario that revealed this bug.
2023-05-19 14:18:04 -07:00
Andrew Dupont
a20cd066be Merge from master 2023-05-19 11:00:56 -07:00
confused-Techie
8385f0dc80 Fix text that test checks for 2023-05-10 19:40:09 -07:00
confused-Techie
e7607d2ee9 Add new package activation hook, and spec 2023-05-10 17:59:53 -07:00
Maurício Szabo
d4b5bc3090 Removed tests related to caching incompatible things 2023-05-09 21:07:44 -03:00
Andrew Dupont
31f67b9fd6 Give onlyIf(Not)Type ability…
…to accept multiple node types.
2023-05-04 21:28:39 -07:00
Andrew Dupont
1c90032276 Add namespaces to custom #set! predicates
Predicates were getting pretty chaotic. With the namespace, it's now clearer
where a predicate may be defined and what its purpose is. It also helps resolve
ambiguity — e.g., both folds and highlights can have an `endAt` predicate, so
now they're disambiguated as `fold.endAt` and `adjust.endAt`, respectively.

Namespaces:

* `highlight` for highlight-specific settings (of which there is presently only
   one)
* `test` for scope tests (currently used by highlights and indents)
* `adjust` for scope adjustments (highlights)
* `indent` for indent settings
* `fold` for fold settings

Right now, only the `test` namespace will be used by more than one kind of query
file, but I could imagine that changing in the future.

For now, tests and adjustments still work without the prepended namespace, but
I imagine I'll take that out even before we ship this feature experimentally.
Much easier to make big changes like this before anyone depends on them.

This also draws a much clearer line between `#set!` predicates with special
meaning in Pulsar… and those which are being used to set arbitrary data for
later use. For instance, if you see `(#set! isOnLeftSideOfAssignment true)`, you
know it must just be arbitrary data.
2023-04-29 14:58:42 -07:00
Andrew Dupont
92dfb5aab3 Add scope test onlyIfFirstTextOnRow
…and its negation.
2023-04-26 18:17:41 -07:00
Andrew Dupont
71d4ad1d07 Restore core.useTreeSitterParsers setting…
…along with a temporary `core.useExperimentalModernTreeSitter` setting.

If we truly planned to keep three different language modes around indefinitely,
changing `core.useTreeSitterParsers` to an enum would make sense. But we don't,
so it'd actually just be a gigantic pain in the ass to migrate one setting to
another of a different type.

When we ship modern-tree-sitter experimentally, we'll make it opt-in via the
temporary setting. When we make it the official tree-sitter implementation and
remove the legacy node-tree-sitter version, we'll remove the temporary setting
and just change the semantics around `core.useTreeSitterParsers`.

Reverting the addition of the `core.languageParser` setting is a chore, but it
prevents a _gigantic_ future headache.
2023-04-26 17:46:02 -07:00
Andrew Dupont
4ca19440dc Add invalidateOnChange scope setting
It's possible to assign a node different scopes based on its contents, but we
need a way to detect these sorts of nodes so that we know how much of the buffer
to invalidate when that node's contents change.

Previously, we were simply finding the range of the deepest node in the tree for
a given edit and invalidating its entire region, in the hopes that this
heuristic would let us hide this complexity from users. Sadly, we can't get away
with that in terms of performance; the most specific node could end up being a
_very large_ node, and it's just not worth slowing everything else down just to
handle these silly edge cases.

Instead, a grammar author can mark certain queries in `highlights.scm` with
an `invalidateOnChange` property:

```scm
((comment) @comment.block.documentation.javadoc.java
  (#match? @comment.block.documentation.javadoc.java "^/\\*\\*")
  (#set! final true)
  (#set! invalidateOnChange true))

((comment) @comment.block.java
  (#match? @comment.block.java "^/\\*")
  (#set! invalidateOnChange true))

```
Here we've got one scope for a JavaDoc (`/**`) block comment and one for a
regular (`/*`) block comment. Since a change in either kind can flip the scope
of the entire comment, both should be marked with `invalidateOnChange`.

If the world were perfect — if the web-tree-sitter bindings allowed it, or if
we could pre-process query files — we could set this property automatically
whenever a node both (a) defined a `#match?` predicate and (b) began and ended
on different rows. We'd be able to use that information to keep track of these
nodes on our own, as well as detect whether an arbitrary edit will actually
trigger a scope change. In the meantime, this is an unusual enough need that
we'll put the onus on the grammar author for now.
2023-04-26 17:30:50 -07:00
Andrew Dupont
70b8bad11b Style tweaks 2023-04-25 17:47:33 -07:00
Andrew Dupont
2cd20067b5 Rename syntaxQuery to highlightsQuery
The `syntaxQuery` key in a grammar definition file is the only query whose name
differs from its canonical filename, and there's no reason why that should be
the case. Might as well change it now before we ship instead of going through
the pain of changing it later.
2023-04-25 11:38:53 -07:00