diff --git a/.gitmodules b/.gitmodules index 63f36951..b94f6e6c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -325,9 +325,6 @@ [submodule "vendor/grammars/nemerle.tmbundle"] path = vendor/grammars/nemerle.tmbundle url = https://github.com/textmate/nemerle.tmbundle -[submodule "vendor/grammars/ninja.tmbundle"] - path = vendor/grammars/ninja.tmbundle - url = https://github.com/textmate/ninja.tmbundle [submodule "vendor/grammars/objective-c.tmbundle"] path = vendor/grammars/objective-c.tmbundle url = https://github.com/textmate/objective-c.tmbundle @@ -355,9 +352,6 @@ [submodule "vendor/grammars/r.tmbundle"] path = vendor/grammars/r.tmbundle url = https://github.com/textmate/r.tmbundle -[submodule "vendor/grammars/ruby-haml.tmbundle"] - path = vendor/grammars/ruby-haml.tmbundle - url = https://github.com/textmate/ruby-haml.tmbundle [submodule "vendor/grammars/scheme.tmbundle"] path = vendor/grammars/scheme.tmbundle url = https://github.com/textmate/scheme.tmbundle @@ -776,9 +770,6 @@ [submodule "vendor/grammars/vhdl"] path = vendor/grammars/vhdl url = https://github.com/textmate/vhdl.tmbundle -[submodule "vendor/grammars/xquery"] - path = vendor/grammars/xquery - url = https://github.com/textmate/xquery.tmbundle [submodule "vendor/grammars/language-rpm-spec"] path = vendor/grammars/language-rpm-spec url = https://github.com/waveclaw/language-rpm-spec @@ -803,6 +794,15 @@ [submodule "vendor/grammars/EBNF.tmbundle"] path = vendor/grammars/EBNF.tmbundle url = https://github.com/sanssecours/EBNF.tmbundle +[submodule "vendor/grammars/language-haml"] + path = vendor/grammars/language-haml + url = https://github.com/ezekg/language-haml +[submodule "vendor/grammars/language-ninja"] + path = vendor/grammars/language-ninja + url = https://github.com/khyo/language-ninja +[submodule "vendor/grammars/language-fontforge"] + path = vendor/grammars/language-fontforge + url = https://github.com/Alhadis/language-fontforge [submodule "vendor/grammars/rascal-syntax-highlighting"] path = vendor/grammars/rascal-syntax-highlighting - url = https://github.com/usethesource/rascal-syntax-highlighting + url = https://github.com/usethesource/rascal-syntax-highlighting \ No newline at end of file diff --git a/grammars.yml b/grammars.yml index 5a93eca2..bb8cc65b 100755 --- a/grammars.yml +++ b/grammars.yml @@ -362,10 +362,17 @@ vendor/grammars/language-csound: - source.csound-score vendor/grammars/language-emacs-lisp: - source.emacs.lisp +vendor/grammars/language-fontforge: +- source.fontforge +- source.opentype +- text.sfd vendor/grammars/language-gfm: - source.gfm vendor/grammars/language-graphql: - source.graphql +vendor/grammars/language-haml: +- text.haml +- text.hamlc vendor/grammars/language-haskell: - hint.haskell - hint.message.haskell @@ -393,6 +400,8 @@ vendor/grammars/language-maxscript: - source.maxscript vendor/grammars/language-ncl: - source.ncl +vendor/grammars/language-ninja: +- source.ninja vendor/grammars/language-povray: - source.pov-ray sdl vendor/grammars/language-python: @@ -474,8 +483,6 @@ vendor/grammars/nemerle.tmbundle: - source.nemerle vendor/grammars/nesC: - source.nesc -vendor/grammars/ninja.tmbundle: -- source.ninja vendor/grammars/nix: - source.nix vendor/grammars/nu.tmbundle: @@ -533,8 +540,6 @@ vendor/grammars/r.tmbundle: - text.tex.latex.rd vendor/grammars/rascal-syntax-highlighting: - source.rascal -vendor/grammars/ruby-haml.tmbundle: -- text.haml vendor/grammars/ruby-slim.tmbundle: - text.slim vendor/grammars/ruby.tmbundle: @@ -655,7 +660,5 @@ vendor/grammars/xc.tmbundle: vendor/grammars/xml.tmbundle: - text.xml - text.xml.xsl -vendor/grammars/xquery: -- source.xquery vendor/grammars/zephir-sublime: - source.php.zephir diff --git a/lib/linguist/blob.rb b/lib/linguist/blob.rb index dc0cf2ac..4e77bc58 100644 --- a/lib/linguist/blob.rb +++ b/lib/linguist/blob.rb @@ -63,7 +63,7 @@ module Linguist # # Returns an Array def extensions - _, *segments = name.downcase.split(".") + _, *segments = name.downcase.split(".", -1) segments.map.with_index do |segment, index| "." + segments[index..-1].join(".") diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index a9ca4914..de16e683 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -275,16 +275,14 @@ module Linguist return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!") end - APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp'] + APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp', '.php'] # Internal: Is the blob generated by Apache Thrift compiler? # # Returns true or false def generated_apache_thrift? return false unless APACHE_THRIFT_EXTENSIONS.include?(extname) - return false unless lines.count > 1 - - return lines[0].include?("Autogenerated by Thrift Compiler") || lines[1].include?("Autogenerated by Thrift Compiler") + return lines.first(6).any? { |l| l.include?("Autogenerated by Thrift Compiler") } end # Internal: Is the blob a C/C++ header generated by the Java JNI tool javah? diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 7216003f..b98465dd 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -110,6 +110,12 @@ module Linguist end end + disambiguate ".cls" do |data| + if /\\\w+{/.match(data) + Language["TeX"] + end + end + disambiguate ".cs" do |data| if /![\w\s]+methodsFor: /.match(data) Language["Smalltalk"] diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 65a98330..bbe6b372 100755 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1141,9 +1141,9 @@ Emacs Lisp: - ".gnus" - ".spacemacs" - ".viper" - - "Project.ede" - - "_emacs" - - "abbrev_defs" + - Project.ede + - _emacs + - abbrev_defs extensions: - ".el" - ".emacs" @@ -1473,6 +1473,8 @@ Gnuplot: Go: type: programming color: "#375eab" + aliases: + - golang extensions: - ".go" ace_mode: golang @@ -1659,13 +1661,16 @@ HTML+Django: tm_scope: text.html.django group: HTML extensions: - - ".mustache" - ".jinja" + - ".mustache" + - ".njk" aliases: - django - html+django/jinja - html+jinja - htmldjango + - njk + - nunjucks ace_mode: django codemirror_mode: django codemirror_mime_type: text/x-django @@ -1959,6 +1964,8 @@ JSON5: type: data extensions: - ".json5" + filenames: + - ".babelrc" tm_scope: source.js ace_mode: javascript codemirror_mode: javascript @@ -2953,6 +2960,15 @@ OpenSCAD: - ".scad" tm_scope: none ace_mode: scad + language_id: 431 +OpenType Feature File: + type: data + aliases: + - AFDKO + extensions: + - ".fea" + tm_scope: source.opentype + ace_mode: text language_id: 266 Org: type: prose @@ -3172,7 +3188,7 @@ Perl6: Pic: type: markup group: Groff - tm_scope: "source.pic" + tm_scope: source.pic extensions: - ".pic" - ".chem" @@ -3694,6 +3710,7 @@ Ruby: - Berksfile - Brewfile - Buildfile + - Dangerfile - Deliverfile - Fastfile - Gemfile @@ -4034,6 +4051,13 @@ SourcePawn: - ".sma" tm_scope: source.sp ace_mode: text + language_id: 432 +Spline Font Database: + type: data + extensions: + - ".sfd" + tm_scope: text.sfd + ace_mode: yaml language_id: 354 Squirrel: type: programming @@ -4265,6 +4289,7 @@ Text: - ".no" filenames: - COPYING + - FONTLOG - INSTALL - LICENSE - NEWS diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 5e83cd50..16515c98 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -50,6 +50,9 @@ # Go dependencies - Godeps/_workspace/ +# GNU indent profiles +- .indent.pro + # Minified JavaScript and CSS - (\.|-)min\.(js|css)$ diff --git a/samples/HTML+Django/nunjucks.njk b/samples/HTML+Django/nunjucks.njk new file mode 100644 index 00000000..3370de57 --- /dev/null +++ b/samples/HTML+Django/nunjucks.njk @@ -0,0 +1,48 @@ +{% from "forms.html" import label as description %} + + +{% macro field(name, value='', type='text') %} +
+ +
+{% endmacro %} + + + + {% extends "head.html" %} + + +{% if horse %} + Chuck Norris once kicked a horse in the chin. Its descendants are known today as Giraffes. +{% elif optimus %} + Chuck Norris once urinated in a semi truck's gas tank as a joke....that truck is now known as Optimus Prime. +{% else %} + Chuck Norris threw a grenade and killed 50 people, then the grenade exploded. +{% endif %} + +{% block left %} + This is the left side! +{% endblock %} + +{% block right %} + This is the right side! +{% endblock %} + +{{ description('Username') }} +{{ field('user') }} +{{ field('pass', type='password') }} + +

Posts

+ + +{# Don't escape foo #} +{{ foo | safe }} + + diff --git a/samples/JSON5/filenames/.babelrc b/samples/JSON5/filenames/.babelrc new file mode 100644 index 00000000..432c7684 --- /dev/null +++ b/samples/JSON5/filenames/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "es2015", + "es2016" + ] +} diff --git a/samples/PHP/ThriftGenerated.php b/samples/PHP/ThriftGenerated.php new file mode 100644 index 00000000..0f031ffd --- /dev/null +++ b/samples/PHP/ThriftGenerated.php @@ -0,0 +1,93 @@ + array( + 'var' => 'title', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['title'])) { + $this->title = $vals['title']; + } + } + } + + public function getName() { + return 'PullRequest'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->title); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('PullRequest'); + if ($this->title !== null) { + $xfer += $output->writeFieldBegin('title', TType::STRING, 1); + $xfer += $output->writeString($this->title); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} diff --git a/samples/Ruby/filenames/Dangerfile b/samples/Ruby/filenames/Dangerfile new file mode 100644 index 00000000..f8ddfee9 --- /dev/null +++ b/samples/Ruby/filenames/Dangerfile @@ -0,0 +1,75 @@ +# Sometimes its a README fix, or something like that - which isn't relevant for +# including in a CHANGELOG for example +# From https://github.com/danger/danger/blob/master/Dangerfile + +has_app_changes = !git.modified_files.grep(/lib/).empty? +has_test_changes = !git.modified_files.grep(/spec/).empty? +is_version_bump = git.modified_files.sort == ["CHANGELOG.md", "lib/danger/version.rb"].sort + +if has_app_changes && !has_test_changes && !is_version_bump + warn("Tests were not updated", sticky: false) +end + +# Thanks other people! +message(":tada:") if is_version_bump && github.pr_author != "orta" + +# Make a note about contributors not in the organization +unless github.api.organization_member?('danger', github.pr_author) + message "@#{github.pr_author} is not a contributor yet, would you like to join the Danger org?" + + # Pay extra attention if they modify the gemspec + if git.modified_files.include?("*.gemspec") + warn "External contributor has edited the Gemspec" + end +end + +# Mainly to encourage writing up some reasoning about the PR, rather than +# just leaving a title +if github.pr_body.length < 5 + fail "Please provide a summary in the Pull Request description" +end + +# Let people say that this isn't worth a CHANGELOG entry in the PR if they choose +declared_trivial = (github.pr_title + github.pr_body).include?("#trivial") || !has_app_changes + +if !git.modified_files.include?("CHANGELOG.md") && !declared_trivial + fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/danger/danger/blob/master/CHANGELOG.md).", sticky: false) +end + +# Docs are critical, so let's re-run the docs part of the specs and show any issues: +core_plugins_docs = `bundle exec danger plugins lint lib/danger/danger_core/plugins/*.rb --warnings-as-errors` + +# If it failed, fail the build, and include markdown with the output error. +unless $?.success? + # We want to strip ANSI colors for our markdown, and make paths relative + colourless_error = core_plugins_docs.gsub(/\e\[(\d+)(;\d+)*m/, "") + markdown("### Core Docs Errors \n\n#{colourless_error}") + fail("Failing due to documentation issues, see below.", sticky: false) +end + +# Oddly enough, it's quite possible to do some testing of Danger, inside Danger +# So, you can ignore these, if you're looking at the Dangerfile to get ideas. +# +# If these are all empty something has gone wrong, better to raise it in a comment +if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty? + fail "This PR has no changes at all, this is likely an issue during development." +end + +# This comes from `./danger_plugins/protect_files.rb` which is automatically parsed by Danger +files.protect_files(path: "danger.gemspec", message: ".gemspec modified", fail_build: false) + +# Ensure that our core plugins all have 100% documentation +core_plugins = Dir.glob("lib/danger/danger_core/plugins/*.rb") +core_lint_output = `bundle exec yard stats #{core_plugins.join ' '} --list-undoc --tag tags` + +if !core_lint_output.include?("100.00%") + fail "The core plugins are not at 100% doc'd - see below:", sticky: false + markdown "```\n#{core_lint_output}```" +elsif core_lint_output.include? "warning" + warn "The core plugins are have yard warnings - see below", sticky: false + markdown "```\n#{core_lint_output}```" +end + +junit.parse "junit-results.xml" +junit.headers = [:file, :name] +junit.report diff --git a/script/add-grammar b/script/add-grammar index d97d8202..f5a8bf11 100755 --- a/script/add-grammar +++ b/script/add-grammar @@ -78,6 +78,8 @@ https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}" repo_new = "vendor/grammars/#{parts[:repo]}" repo_old = parse_submodule($replace) if $replace +Dir.chdir(ROOT) + if repo_old log "Deregistering: #{repo_old}" `git submodule deinit #{repo_old}` @@ -93,4 +95,5 @@ log "Confirming license" `script/licensed --module "#{repo_new}"` log "Updating grammar documentation in vendor/REAEDME.md" -`script list-grammars` +`bundle exec rake samples` +`script/list-grammars` diff --git a/script/convert-grammars b/script/convert-grammars index 2155827f..64c75d14 100755 --- a/script/convert-grammars +++ b/script/convert-grammars @@ -1,5 +1,6 @@ #!/usr/bin/env ruby +require 'bundler/setup' require 'json' require 'net/http' require 'optparse' diff --git a/script/list-grammars b/script/list-grammars index 96e3a35d..09aaa09c 100755 --- a/script/list-grammars +++ b/script/list-grammars @@ -1,19 +1,20 @@ #!/usr/bin/env ruby +require "bundler/setup" require "linguist" require "json" require "yaml" class GrammarList - + ROOT = File.expand_path "../../", __FILE__ - + def initialize @submodules = load_submodules() @sources = load_sources() @language_names = load_languages() end - + # Load .gitmodules def load_submodules submodules = {} @@ -29,14 +30,14 @@ class GrammarList end submodules end - + # Grab the name of each language, sorted case-insensitively def load_languages Linguist::Language.all.map(&:name).sort do |a, b| a.downcase() <=> b.downcase() end end - + # Load grammars.yml def load_sources sources = {} @@ -46,7 +47,7 @@ class GrammarList end sources end - + # Shorten a repository URL def shorten(url) if url =~ /^https?:\/\/(?:www\.)?github\.com\/([^\/]+\/[^\/]+)/i @@ -57,7 +58,7 @@ class GrammarList url.replace(/^https?:\/\/(?:www\.)?/i, "") end end - + # Markdown: Generate grammar list def to_markdown markdown = "" @@ -87,7 +88,7 @@ class GrammarList markdown end - + # Update the file displaying the reader-friendly list of grammar repos def update_readme readme = "#{ROOT}/vendor/README.md" diff --git a/script/prune-grammars b/script/prune-grammars index 0fab9e6a..6fb81236 100755 --- a/script/prune-grammars +++ b/script/prune-grammars @@ -1,10 +1,13 @@ #!/usr/bin/env ruby +require "bundler/setup" require "json" require "linguist" require "set" require "yaml" +ROOT = File.expand_path("../../", __FILE__) + def find_includes(json) case json when Hash @@ -32,7 +35,7 @@ def transitive_includes(scope, includes) end includes = {} -Dir["grammars/*.json"].each do |path| +Dir[File.join(ROOT, "grammars/*.json")].each do |path| scope = File.basename(path).sub(/\.json/, '') json = JSON.load(File.read(path)) incs = find_includes(json) @@ -41,7 +44,7 @@ Dir["grammars/*.json"].each do |path| includes[scope] += incs end -yaml = YAML.load(File.read("grammars.yml")) +yaml = YAML.load(File.read(File.join(ROOT, "grammars.yml"))) language_scopes = Linguist::Language.all.map(&:tm_scope).to_set # The set of used scopes is the scopes for each language, plus all the scopes @@ -54,4 +57,4 @@ puts "Unused grammar repos" puts unused.map { |repo, scopes| sprintf("%-100s %s", repo, scopes.join(", ")) }.sort.join("\n") yaml.delete_if { |k| unused.key?(k) } -File.write("grammars.yml", YAML.dump(yaml)) +File.write(File.join(ROOT, "grammars.yml"), YAML.dump(yaml)) diff --git a/script/set-language-ids b/script/set-language-ids index ecbe1e76..769b850c 100755 --- a/script/set-language-ids +++ b/script/set-language-ids @@ -1,4 +1,6 @@ #!/usr/bin/env ruby + +require 'bundler/setup' require 'yaml' require 'pry' @@ -11,6 +13,8 @@ header = <<-EOF # ace_mode - A String name of the Ace Mode used for highlighting whenever # a file is edited. This must match one of the filenames in http://git.io/3XO_Cg. # Use "text" if a mode does not exist. +# codemirror_mode - A String name of the CodeMirror Mode used for highlighting whenever a file is edited. +# This must match a mode from https://git.io/vi9Fx # wrap - Boolean wrap to enable line wrapping (default: false) # extensions - An Array of associated extensions (the first one is # considered the primary extension, the others should be @@ -20,9 +24,9 @@ header = <<-EOF # search_term - Deprecated: Some languages may be indexed under a # different alias. Avoid defining new exceptions. # language_id - Integer used as a language-name-independent indexed field so that we can rename -# languages in Linguist without reindexing all the code on GitHub. Must not be +# languages in Linguist without reindexing all the code on GitHub. Must not be # changed for existing languages without the explicit permission of GitHub staff. -# color - CSS hex color to represent the language. +# color - CSS hex color to represent the language. Only used if type is "programming" or "prose". # tm_scope - The TextMate scope that represents this programming # language. This should match one of the scopes listed in # the grammars.yml file. Use "none" if there is no grammar @@ -36,21 +40,23 @@ header = <<-EOF # Please keep this list alphabetized. Capitalization comes before lowercase. EOF +require 'digest' generated = true if ARGV[0] == "--force" update = true if ARGV[0] == "--update" +def generate_language_id(language) + Digest::SHA256.hexdigest(language).to_i(16) % (2**30 - 1) +end + if generated puts "You're regenerating all of the language_id attributes for all Linguist " puts "languages defined in languages.yml. This is almost certainly NOT what" puts "you meant to do!" - language_index = 0 - languages = YAML.load(File.read("lib/linguist/languages.yml")) languages.each do |name, vals| - vals.merge!('language_id' => language_index) - language_index += 1 + vals.merge!('language_id' => generate_language_id(name)) end File.write("lib/linguist/languages.yml", header + YAML.dump(languages)) @@ -58,20 +64,12 @@ elsif update puts "Adding new language_id attributes to languages.yml that don't have one set" languages = YAML.load(File.read("lib/linguist/languages.yml")) - # First grab the maximum language_id - language_ids = [] - languages.each { |name, vals| language_ids << vals['language_id'] if vals.has_key?('language_id')} - max_language_id = language_ids.max - puts "Current maximum language_id is #{max_language_id}" - missing_count = 0 - language_index = max_language_id languages.each do |name, vals| unless vals.has_key?('language_id') - language_index += 1 missing_count += 1 - vals.merge!('language_id' => language_index) + vals.merge!('language_id' => generate_language_id(name)) end end diff --git a/test/test_blob.rb b/test/test_blob.rb index 588360ff..42945941 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -202,6 +202,7 @@ class TestBlob < Minitest::Test assert sample_blob_memory("JavaScript/gen-js-linguist-thrift.js").generated? assert sample_blob_memory("Ruby/gen-rb-linguist-thrift.rb").generated? assert sample_blob_memory("Objective-C/gen-cocoa-linguist-thrift.m").generated? + assert sample_blob_memory("PHP/ThriftGenerated.php").generated? # Generated JNI assert sample_blob_memory("C/jni_layer.h").generated? diff --git a/test/test_file_blob.rb b/test/test_file_blob.rb index 84cee723..2c52b0a7 100644 --- a/test/test_file_blob.rb +++ b/test/test_file_blob.rb @@ -294,6 +294,8 @@ class TestFileBlob < Minitest::Test assert !sample_blob("Godeps/Godeps.json").vendored? assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored? + assert sample_blob(".indent.pro").vendored? + # Rails vendor/ assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored? diff --git a/test/test_grammars.rb b/test/test_grammars.rb index 418fca8a..7344be30 100644 --- a/test/test_grammars.rb +++ b/test/test_grammars.rb @@ -6,7 +6,6 @@ class TestGrammars < Minitest::Test # List of projects that are allowed without licenses PROJECT_WHITELIST = [ "vendor/grammars/Sublime-Lasso", - "vendor/grammars/ant.tmbundle", "vendor/grammars/sublime-spintools", "vendor/grammars/blitzmax" ].freeze @@ -40,6 +39,7 @@ class TestGrammars < Minitest::Test "c9118c370411f2f049c746c0fd096554e877aea2", # perl6fe "8ccf886749c32fb7e65d4d1316a7ed0479c93dc9", # language-less "2f03492b52d7dd83b4e7472f01b87c6121e5b1a4", # monkey + "241e5ddbb4423d792216783e9f668bd670b026e4", # ant.tmbundle "bdab9fdc21e6790b479ccb5945b78bc0f6ce2493" # language-blade ].freeze diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 921cc021..4fe3d38a 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -73,6 +73,15 @@ class TestHeuristcs < Minitest::Test }) end + def test_cls_by_heuristics + assert_heuristics({ + "TeX" => all_fixtures("TeX", "*.cls"), + nil => all_fixtures("Apex", "*.cls"), + nil => all_fixtures("OpenEdge ABL", "*.cls"), + nil => all_fixtures("Visual Basic", "*.cls"), + }) + end + def test_cs_by_heuristics assert_heuristics({ "C#" => all_fixtures("C#", "*.cs"), diff --git a/test/test_language.rb b/test/test_language.rb index 67066cc3..a82040e2 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -235,6 +235,7 @@ class TestLanguage < Minitest::Test assert_equal [Language['Clojure']], Language.find_by_filename('riemann.config') assert_equal [Language['HTML+Django']], Language.find_by_filename('index.jinja') assert_equal [Language['Chapel']], Language.find_by_filename('examples/hello.chpl') + assert_equal [], Language.find_by_filename('F.I.L.E.') end def test_find_by_interpreter @@ -426,6 +427,14 @@ class TestLanguage < Minitest::Test assert missing.empty?, message end + def test_all_languages_have_a_valid_id + invalid = Language.all.select { |language| language.language_id < 0 || language.language_id >= (2**31 - 1) } + + message = "The following languages do not have a valid language_id. Please use script/set-language-ids --update as per the contribution guidelines.\n" + invalid.each { |language| message << "#{language.name}\n" } + assert invalid.empty?, message + end + def test_all_language_id_are_unique duplicates = Language.all.group_by{ |language| language.language_id }.select { |k, v| v.size > 1 }.map(&:first) diff --git a/vendor/README.md b/vendor/README.md index 7900b209..fdee48b3 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -6,6 +6,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **1C Enterprise:** [xDrivenDevelopment/atom-language-1c-bsl](https://github.com/xDrivenDevelopment/atom-language-1c-bsl) - **ABAP:** [pvl/abap.tmbundle](https://github.com/pvl/abap.tmbundle) +- **ABNF:** [sanssecours/ABNF.tmbundle](https://github.com/sanssecours/ABNF.tmbundle) - **ActionScript:** [simongregory/actionscript3-tmbundle](https://github.com/simongregory/actionscript3-tmbundle) - **Ada:** [textmate/ada.tmbundle](https://github.com/textmate/ada.tmbundle) - **Agda:** [mokus0/Agda.tmbundle](https://github.com/mokus0/Agda.tmbundle) @@ -91,6 +92,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **DTrace:** [textmate/c.tmbundle](https://github.com/textmate/c.tmbundle) - **Dylan:** [textmate/dylan.tmbundle](https://github.com/textmate/dylan.tmbundle) - **Eagle:** [textmate/xml.tmbundle](https://github.com/textmate/xml.tmbundle) +- **EBNF:** [sanssecours/EBNF.tmbundle](https://github.com/sanssecours/EBNF.tmbundle) - **eC:** [ecere/ec.tmbundle](https://github.com/ecere/ec.tmbundle) - **Ecere Projects:** [textmate/json.tmbundle](https://github.com/textmate/json.tmbundle) - **ECLiPSe:** [alnkpa/sublimeprolog](https://github.com/alnkpa/sublimeprolog) @@ -136,7 +138,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Groovy:** [textmate/groovy.tmbundle](https://github.com/textmate/groovy.tmbundle) - **Groovy Server Pages:** [textmate/java.tmbundle](https://github.com/textmate/java.tmbundle) - **Hack:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle) -- **Haml:** [textmate/ruby-haml.tmbundle](https://github.com/textmate/ruby-haml.tmbundle) +- **Haml:** [ezekg/language-haml](https://github.com/ezekg/language-haml) - **Handlebars:** [daaain/Handlebars](https://github.com/daaain/Handlebars) - **Harbour:** [hernad/atom-language-harbour](https://github.com/hernad/atom-language-harbour) - **Haskell:** [atom-haskell/language-haskell](https://github.com/atom-haskell/language-haskell) @@ -222,7 +224,6 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **NewLisp:** [textmate/lisp.tmbundle](https://github.com/textmate/lisp.tmbundle) - **Nginx:** [brandonwamboldt/sublime-nginx](https://github.com/brandonwamboldt/sublime-nginx) - **Nimrod:** [Varriount/NimLime](https://github.com/Varriount/NimLime) -- **Ninja:** [textmate/ninja.tmbundle](https://github.com/textmate/ninja.tmbundle) - **Nit:** [R4PaSs/Sublime-Nit](https://github.com/R4PaSs/Sublime-Nit) - **Nix:** [wmertens/sublime-nix](https://github.com/wmertens/sublime-nix) - **NSIS:** [github-linguist/NSIS](https://github.com/github-linguist/NSIS) @@ -264,6 +265,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Puppet:** [russCloak/SublimePuppet](https://github.com/russCloak/SublimePuppet) - **PureScript:** [purescript-contrib/atom-language-purescript](https://github.com/purescript-contrib/atom-language-purescript) - **Python:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython) +- **Python console:** [atom/language-python](https://github.com/atom/language-python) - **Python traceback:** [atom/language-python](https://github.com/atom/language-python) - **QMake:** [textmate/cpp-qt.tmbundle](https://github.com/textmate/cpp-qt.tmbundle) - **QML:** [skozlovf/Sublime-QML](https://github.com/skozlovf/Sublime-QML) diff --git a/vendor/grammars/language-fontforge b/vendor/grammars/language-fontforge new file mode 160000 index 00000000..b8233304 --- /dev/null +++ b/vendor/grammars/language-fontforge @@ -0,0 +1 @@ +Subproject commit b8233304fdc9575a08a62f9280587050b10518f6 diff --git a/vendor/grammars/language-haml b/vendor/grammars/language-haml new file mode 160000 index 00000000..301625df --- /dev/null +++ b/vendor/grammars/language-haml @@ -0,0 +1 @@ +Subproject commit 301625dff414653eb88320c624434429ef8e244c diff --git a/vendor/grammars/language-ninja b/vendor/grammars/language-ninja new file mode 160000 index 00000000..207a6037 --- /dev/null +++ b/vendor/grammars/language-ninja @@ -0,0 +1 @@ +Subproject commit 207a60371f4c86d094dcad17e12ea57d4ca0eb7f diff --git a/vendor/licenses/grammar/language-fontforge.txt b/vendor/licenses/grammar/language-fontforge.txt new file mode 100644 index 00000000..3c0b29a8 --- /dev/null +++ b/vendor/licenses/grammar/language-fontforge.txt @@ -0,0 +1,18 @@ +--- +type: grammar +name: language-fontforge +license: isc +--- +Copyright (c) 2016, John Gardner + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/licenses/grammar/language-haml.txt b/vendor/licenses/grammar/language-haml.txt new file mode 100644 index 00000000..04eadbe3 --- /dev/null +++ b/vendor/licenses/grammar/language-haml.txt @@ -0,0 +1,25 @@ +--- +type: grammar +name: language-haml +license: mit +--- +The MIT License (MIT) + +Copyright (c) 2014 Rob Cameron + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/licenses/grammar/language-ninja.txt b/vendor/licenses/grammar/language-ninja.txt new file mode 100644 index 00000000..85caa518 --- /dev/null +++ b/vendor/licenses/grammar/language-ninja.txt @@ -0,0 +1,25 @@ +--- +type: grammar +name: language-ninja +license: mit +--- +Copyright (c) 2015 Kyle Howen + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/licenses/grammar/ninja.tmbundle.txt b/vendor/licenses/grammar/ninja.tmbundle.txt deleted file mode 100644 index 41f94c59..00000000 --- a/vendor/licenses/grammar/ninja.tmbundle.txt +++ /dev/null @@ -1,15 +0,0 @@ ---- -type: grammar -name: ninja.tmbundle -license: permissive -curated: true ---- - -If not otherwise specified (see below), files in this repository fall under the following license: - - Permission to copy, use, modify, sell and distribute this - software is granted. This software is provided "as is" without - express or implied warranty, and with no claim as to its - suitability for any purpose. - -An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. diff --git a/vendor/licenses/grammar/ruby-haml.tmbundle.txt b/vendor/licenses/grammar/ruby-haml.tmbundle.txt deleted file mode 100644 index 78fd05a6..00000000 --- a/vendor/licenses/grammar/ruby-haml.tmbundle.txt +++ /dev/null @@ -1,15 +0,0 @@ ---- -type: grammar -name: ruby-haml.tmbundle -license: permissive -curated: true ---- - -If not otherwise specified (see below), files in this repository fall under the following license: - - Permission to copy, use, modify, sell and distribute this - software is granted. This software is provided "as is" without - express or implied warranty, and with no claim as to its - suitability for any purpose. - -An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”.