Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slice language (.ice) #4243

Merged
merged 9 commits into from
Sep 25, 2018
Merged

Add Slice language (.ice) #4243

merged 9 commits into from
Sep 25, 2018

Conversation

externl
Copy link
Contributor

@externl externl commented Aug 21, 2018

Add new language syntax for Slice

Checklist:

@externl
Copy link
Contributor Author

externl commented Aug 21, 2018

The errors seem unrelated, or maybe I'm mistaken?

Copy link
Contributor

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request!

Please include a Lightshow example for the grammar as per the template.

@externl
Copy link
Contributor Author

externl commented Aug 22, 2018

Thanks, @pchaigno. I've added that.

@pchaigno
Copy link
Contributor

pchaigno commented Aug 22, 2018

Are these files also Slice? They look like JSON.

Could you try to update your branch with the latest master to address the Travis CI issue? Actually, I can reproduce the issue locally with the master branch. @lildude Any idea of what's happening here?

@lildude
Copy link
Member

lildude commented Aug 22, 2018

@lildude Any idea of what's happening here?

Looking now. My suspicion is licensed has changed again 😞

@pchaigno
Copy link
Contributor

@lildude Actually, it's Licensee this time. I filled an issue: licensee/licensee#328.

@lildude
Copy link
Member

lildude commented Aug 22, 2018

Yeah, I was just about to confirm this.

@externl
Copy link
Contributor Author

externl commented Aug 22, 2018

Are these files also Slice? They look like JSON.

Yeah, most of those are definitely JSON. Some binary files too.

@pchaigno
Copy link
Contributor

Yeah, most of those are definitely JSON.

We'll need to find a way to distinguish JSON and Slice files then.

@externl
Copy link
Contributor Author

externl commented Aug 22, 2018

Ok, I'll add a heuristic for Slice to heuristic.rb

@externl
Copy link
Contributor Author

externl commented Aug 22, 2018

Ok, so I was going to add:

disambiguate ".ice" do |data|
    if /^\s*(#\s*(include|if[n]def|pragma)|module\s+[A-Za-z][_A-Za-z0-9]*)/i.match(data)
        Language["Slice"]
    end
end

This should be a good check for Slice. I don't really see a good check for JSON.

Is this okay?

@pchaigno
Copy link
Contributor

@externl Could you update your branch with the latest master? It includes a fix for the Travis CI tests.

I don't really see a good check for JSON.

Would checking for the root object of the JSON document ({ or [) be enough? /cc @Alhadis who, with a bit of luck, knows more about the JSON spec. than I do.

@externl
Copy link
Contributor Author

externl commented Aug 28, 2018

@pchaigno I've merged in the latest. Maybe the best is to just not check for JSON, leave it non-highlighted?

@pchaigno
Copy link
Contributor

Unfortunately, that's not an option our classifier has at the moment. With this pull request all .ice files will be classified as either JSON or Slice, so we need to do a good job distinguishing the two.

@externl
Copy link
Contributor Author

externl commented Aug 28, 2018

What happens to files that don't match the heuristic?

disambiguate ".ice" do |data|
    if /^\s*(#\s*(include|if[n]def|pragma)|module\s+[A-Za-z][_A-Za-z0-9]*)/i.match(data)
        Language["Slice"]
    end
end

vs

disambiguate ".ice" do |data|
    if /^\s*(#\s*(include|if[n]def|pragma)|module\s+[A-Za-z][_A-Za-z0-9]*)/i.match(data)
        Language["Slice"]
    elsif SOME_JSON_CHECK
        Language["JSON"]
    end
end

?

@pchaigno
Copy link
Contributor

They go to the naïve Bayesian classifier (see How Linguist Works) which assigns a score to each language based on the tokens identified in the file.

@externl
Copy link
Contributor Author

externl commented Sep 21, 2018

@pchaigno I've rebased my branch on the latest. Do you still want me to look into adding a JSON disambiguations check for these other .ice files?

@pchaigno
Copy link
Contributor

Do you still want me to look into adding a JSON disambiguations check for these other .ice files?

Yes, that would be much better.

Would checking for the root object of the JSON document ({ or [) be enough?

@lildude @Alhadis Any ideas on the above?

@Alhadis
Copy link
Collaborator

Alhadis commented Sep 21, 2018

Any ideas on the above?

Yep. Don't forget to check for leading whitespace too (either vertical or horizontal). E.g, something like this should be enough:

/\A\s*[{[]/

@pchaigno
Copy link
Contributor

@externl Could you implement the above heuristic rule with the corresponding test in test/test_heuristics.rb?

OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? In my recent commit I added the version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This line appears to have been modified, although GitHub's diff-view isn't showing what changed... Strange.

A trailing newline may have been added or removed when you edited the license, but GitHub normally indicates that with an 🚫 icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah my local diff shows that I added a trailing newline

diff --git a/vendor/licenses/grammar/vscode-slice.txt b/vendor/licenses/grammar/vscode-slice.txt
index b1e84f5c..0103ec63 100644
--- a/vendor/licenses/grammar/vscode-slice.txt
+++ b/vendor/licenses/grammar/vscode-slice.txt
@@ -1,6 +1,7 @@
 ---
 type: grammar
 name: vscode-slice
+version: 6a28c2125bb442fa6a7f31c995ce423b1c9bbfb7
 license: bsd-3-clause
 ---
 BSD 3-Clause License
@@ -31,4 +32,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@Alhadis
Copy link
Collaborator

Alhadis commented Sep 21, 2018

  1) Error:
TestFileBlob#test_include_in_language_stats:
RegexpError: empty char-class: /\A\s*[{[]/

Ah whoops, my bad. Sorry, that expression should have been:

/\A\s*[{\[]/

@externl
Copy link
Contributor Author

externl commented Sep 21, 2018

@externl Could you implement the above heuristic rule with the corresponding test in test/test_heuristics.rb?

Is this correct?

def test_ice_by_heuristics
    assert_heuristics({
      "Slice" => all_fixtures("Slice", "*.ice"),
      "JSON" => all_fixtures("JSON", "*.ice")
    })
  end

@Alhadis
Copy link
Collaborator

Alhadis commented Sep 21, 2018

Looks fine to me.

@externl
Copy link
Contributor Author

externl commented Sep 21, 2018

How do I fix:

/home/travis/build/github/linguist/vendor/licenses/grammar/vscode-slice.txt:
  - cached license data out of date0m

@lildude
Copy link
Member

lildude commented Sep 21, 2018

How do I fix:

/home/travis/build/github/linguist/vendor/licenses/grammar/vscode-slice.txt:
  - cached license data out of date0m

You need to ensure that the SHA in the version is the same as the SHA for the committed grammar submodule. script/licensed should have done this for you if your local repo was on the same SHA as that that you've committed in this PR.

Committed submodule SHA: 635d41ba3924f168ba5a54101bf71fbf8aef3d20
License version: 6a28c2125bb442fa6a7f31c995ce423b1c9bbfb7

As you can see, they're not the same.

Copy link
Contributor

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @externl for your patience!

Copy link
Collaborator

@Alhadis Alhadis left a comment

Choose a reason for hiding this comment

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

LGTM. I'm mortified that I didn't think to make an "Ice-ense" pun somewhere, though. 😓

@externl
Copy link
Contributor Author

externl commented Sep 22, 2018

@pchaigno @Alhadis Thanks for guiding me through the process.

LGTM. I'm mortified that I didn't think to make an "Ice-ense" pun somewhere, though. 😓

I'm going to start using this 😄

ace_mode: text
extensions:
- ".ice"
language_id: 894641667
Copy link
Member

Choose a reason for hiding this comment

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

Errm, don't you want a colour associated with this language? At the moment it's going to fallback to the default of #cccccc.

Looking at https://doc.zeroc.com/ice/latest/the-slice-language, it seems blue is the colour of choice so it's probably going to be a PITA to find one that doesn't conflict with one already associated with a language on GitHub.com - blue is really really popular.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, would definitely like a colour. Can we use #477ed0?

Copy link
Member

Choose a reason for hiding this comment

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

I doubt it. Various shades of blue are already highly used. Try it. Add the color: entry and then run bundle exec ruby test/test_color_proximity.rb (I'm assuming you've already run script/bootstrap). Rinse and repeat until you find a colour the test likes, then commit your colour and push.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @lildude, I found a blue! #003fa2

Copy link
Member

Choose a reason for hiding this comment

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

🎉 nice!!

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the PR and welcome to the world of Linguist.

@lildude lildude merged commit 8cd9d74 into github-linguist:master Sep 25, 2018
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants