Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Changes to activate package only on Ruby file load #99

Merged
merged 5 commits into from
Sep 4, 2017
Merged

Changes to activate package only on Ruby file load #99

merged 5 commits into from
Sep 4, 2017

Conversation

deiga
Copy link
Contributor

@deiga deiga commented May 16, 2017

This speeds up Atom startup

@ricardograca
Copy link
Member

Any ideas why all the tests are failing? Seems to be related to this change.

@deiga
Copy link
Contributor Author

deiga commented May 16, 2017

Not right now, I'll check it out :)

@Arcanemagus
Copy link
Member

When you switch to an activationHooks model the specs need to be modified to activate the package properly.

See here for an example.

@deiga
Copy link
Contributor Author

deiga commented Jun 2, 2017

@ricardograca Now it should work :)

@ricardograca
Copy link
Member

Great! Looks good to me, but I'm not that familiar with this activation stuff yet, so I'll leave the final word to @Arcanemagus.

Copy link
Member

@Arcanemagus Arcanemagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took so long to get to! It got lost in my notifications 😞.

The original example that linter-jscs was based on used the same model it did where the activation promise was stored before activating the relevant language and opening a related file, then waiting on the package activation promise to complete, but if directly waiting on it works that's a nice simplification.

});
);

atom.packages.triggerActivationHook('language-ruby:grammar-used');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method I linked should work without this line, and as we already are reaching into the non-public API with the next line I'd rather this was removed.

(The opening of the good.erb file should have triggered this for us.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arcanemagus I tested it, but it does not activate for some reason

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this the tests time out when waiting for linter-erb since there is no language-ruby activation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case then the file you are opening isn't being recognized as Ruby.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that changing the code to be equal to linter-jscs example doesn't work, since the linter never activates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some debugging it seems like the fixture file doesn't correctly instantiate the editor, as the scope for the file is text.plain.null-grammar

Copy link
Member

@ricardograca ricardograca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the ERB linter. It should lint ERB files, so it should work with the previous files names. If it didn't the problem is something else, but not the file names.

@deiga
Copy link
Contributor Author

deiga commented Jun 25, 2017

@ricardograca Fair enough, but with the correct file type it recognizes a grammar and with just .erb it doesn't. It might of course be an issue with language-ruby grammar definition, but I still would write the tests here so that everything passes and file an issue upstream

@deiga
Copy link
Contributor Author

deiga commented Jun 25, 2017

The problem here is, that I don't know how to debug Atom from this point onward. So I have no idea where the issue with plain .erb files is.

@ricardograca
Copy link
Member

It's probably just a matter of adding the correct scope in here. Have you tried that?

There's also the matter of the Travis build failing. It was also failing a little while ago, but it was already fixed. Maybe you branched off before that change. More info in #102.

@deiga
Copy link
Contributor Author

deiga commented Jun 25, 2017

I opened an upstream issue about this problem atom/language-ruby#203

@ricardograca I can't fix this by adding a new scope as the linter-erb would work on all Plain Text files :)

The problem here is that ERB files actualyl have no grammar at all in Atom :) They used to all be HTML (ERB) files, but then somebody went and removed .erb from the grammars file extension. Now as language-ruby-on-rails has the file ext for HTML (Rails) Grammar it works in general, but tests where you have only limited packages makes it fail.

I could of course change the test to just activate language-ruby-on-rails instead of language-ruby, but it's still dancing around the issue of missing an actual grammar for ERB files

deiga added 5 commits June 25, 2017 21:41
Why:

* The correct grammar was not identified for `*.erb` files

This change addresses the need by:

* Renamed the file extensions
* Fixed test setup to work without too much black API magic

What side effects does this change have?:

* None, AFAIK
Why:

* Plain `.erb` files don't activate `language-ruby` package atm

This change addresses the need by:

* Adds new activation hook
@deiga
Copy link
Contributor Author

deiga commented Jun 25, 2017

@ricardograca I did a rebase from master, but still Travis fails with a missing glibc

@ricardograca
Copy link
Member

It seems a fix for that is on its way: atom/atom#14827 (comment)

@deiga
Copy link
Contributor Author

deiga commented Jul 7, 2017

@ricardograca Could you schedule a rebuild? I'd hate to push an empty commit just to restart travis :)

@ricardograca
Copy link
Member

@deiga Done. It passed.

@deiga
Copy link
Contributor Author

deiga commented Jul 7, 2017

@Arcanemagus Is this now up to par, or should some changes still be applied?

Copy link
Member

@Arcanemagus Arcanemagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, note that you would have had to add language-ruby-on-rails anyway, as otherwise users of that would suddenly have this stop working. That's the major downside of mixing package names and scope names like activationHooks forces you to do.

@ricardograca ricardograca merged commit 43b6b24 into AtomLinter:master Sep 4, 2017
@ricardograca
Copy link
Member

Sorry it took so long and thanks for the contribution. We'll probably release a new version with these changes soon.

@Arcanemagus
Copy link
Member

🎉 This PR is included in version 1.1.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@deiga deiga deleted the patch-1 branch May 17, 2018 13:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants