Merge branch 'master' into add-mql4-mql5-current

This commit is contained in:
Andrew Case
2016-10-10 17:41:29 +03:00
66 changed files with 1477 additions and 123 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
/Gemfile.lock
.bundle/
.idea
benchmark/
lib/linguist/samples.json
/grammars

9
.gitmodules vendored
View File

@@ -22,9 +22,9 @@
[submodule "vendor/grammars/Sublime-REBOL"]
path = vendor/grammars/Sublime-REBOL
url = https://github.com/Oldes/Sublime-REBOL
[submodule "vendor/grammars/Sublime-VimL"]
path = vendor/grammars/Sublime-VimL
url = https://github.com/SalGnt/Sublime-VimL
[submodule "vendor/grammars/language-viml"]
path = vendor/grammars/language-viml
url = https://github.com/Alhadis/language-viml
[submodule "vendor/grammars/ColdFusion"]
path = vendor/grammars/ColdFusion
url = https://github.com/SublimeText/ColdFusion
@@ -791,6 +791,9 @@
[submodule "vendor/grammars/language-babel"]
path = vendor/grammars/language-babel
url = https://github.com/github-linguist/language-babel
[submodule "vendor/CodeMirror"]
path = vendor/CodeMirror
url = https://github.com/codemirror/CodeMirror
[submodule "vendor/grammars/MQL5-sublime"]
path = vendor/grammars/MQL5-sublime
url = https://github.com/mqsoft/MQL5-sublime

View File

@@ -27,13 +27,13 @@ We try only to add languages once they have some usage on GitHub. In most cases
To add support for a new language:
0. Add an entry for your language to [`languages.yml`][languages].
0. Add an entry for your language to [`languages.yml`][languages]. Omit the `language_id` field for now.
0. Add a grammar for your language. Please only add grammars that have [one of these licenses](https://github.com/github/linguist/blob/257425141d4e2a5232786bf0b13c901ada075f93/vendor/licenses/config.yml#L2-L11).
0. Add your grammar as a submodule: `git submodule add https://github.com/JaneSmith/MyGrammar vendor/grammars/MyGrammar`.
0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`.
0. Download the license for the grammar: `script/licensed`. Be careful to only commit the file for the new grammar, as this script may update licenses for other grammars as well.
0. Add samples for your language to the [samples directory][samples] in the correct subdirectory.
0. Add a `language_id` for your language. See `script/set-language-ids` for more information. **You should only ever need to run `script/set-language-ids --update`. Anything other than this risks breaking GitHub search :cry:**
0. Add a `language_id` for your language using `script/set-language-ids`. **You should only ever need to run `script/set-language-ids --update`. Anything other than this risks breaking GitHub search :cry:**
0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage.
In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken:

View File

@@ -26,6 +26,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'yajl-ruby'
s.add_development_dependency 'color-proximity', '~> 0.2.1'
s.add_development_dependency 'licensed'
s.add_development_dependency 'licensee', '>= 8.3.0'
s.add_development_dependency 'licensee', '>= 8.6.0'
end

View File

@@ -105,8 +105,6 @@ vendor/grammars/Sublime-SQF-Language:
vendor/grammars/Sublime-Text-2-OpenEdge-ABL:
- source.abl
- text.html.abl
vendor/grammars/Sublime-VimL:
- source.viml
vendor/grammars/SublimeBrainfuck:
- source.bf
vendor/grammars/SublimeClarion:
@@ -416,6 +414,8 @@ vendor/grammars/language-toc-wow:
- source.toc
vendor/grammars/language-turing:
- source.turing
vendor/grammars/language-viml:
- source.viml
vendor/grammars/language-wavefront:
- source.wavefront.mtl
- source.wavefront.obj

View File

@@ -202,6 +202,8 @@ module Linguist
disambiguate ".inc" do |data|
if /^<\?(?:php)?/.match(data)
Language["PHP"]
elsif /^\s*#(declare|local|macro|while)\s/.match(data)
Language["POV-Ray SDL"]
end
end
@@ -242,7 +244,7 @@ module Linguist
Language["MUF"]
elsif /^\s*;/.match(data)
Language["M"]
elsif /^\s*\(\*/.match(data)
elsif /\*\)$/.match(data)
Language["Mathematica"]
elsif /^\s*%/.match(data)
Language["Matlab"]
@@ -252,7 +254,7 @@ module Linguist
end
disambiguate ".md" do |data|
if /^[-a-z0-9=#!\*\[|]/i.match(data)
if /(^[-a-z0-9=#!\*\[|])|<\//i.match(data) || data.empty?
Language["Markdown"]
elsif /^(;;|\(define_)/.match(data)
Language["GCC machine description"]

View File

@@ -267,6 +267,7 @@ module Linguist
# Returns an Array of Languages.
def self.ace_modes
warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set."
warn caller
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
end
@@ -300,12 +301,14 @@ module Linguist
end
@ace_mode = attributes[:ace_mode]
@codemirror_mode = attributes[:codemirror_mode]
@codemirror_mime_type = attributes[:codemirror_mime_type]
@wrap = attributes[:wrap] || false
# Set legacy search term
@search_term = attributes[:search_term] || default_alias_name
# Set the language_id
# Set the language_id
@language_id = attributes[:language_id]
# Set extensions or default to [].
@@ -397,6 +400,31 @@ module Linguist
# Returns a String name or nil
attr_reader :ace_mode
# Public: Get CodeMirror mode
#
# Maps to a directory in the `mode/` source code.
# https://github.com/codemirror/CodeMirror/tree/master/mode
#
# Examples
#
# # => "nil"
# # => "javascript"
# # => "clike"
#
# Returns a String name or nil
attr_reader :codemirror_mode
# Public: Get CodeMirror MIME type mode
#
# Examples
#
# # => "nil"
# # => "text/x-javascript"
# # => "text/x-csrc"
#
# Returns a String name or nil
attr_reader :codemirror_mime_type
# Public: Should language lines be wrapped
#
# Returns true or false
@@ -573,6 +601,8 @@ module Linguist
:aliases => options['aliases'],
:tm_scope => options['tm_scope'],
:ace_mode => options['ace_mode'],
:codemirror_mode => options['codemirror_mode'],
:codemirror_mime_type => options['codemirror_mime_type'],
:wrap => options['wrap'],
:group_name => options['group'],
:searchable => options.fetch('searchable', true),

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,98 @@
module Linguist
module Strategy
class Modeline
EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i
EMACS_MODELINE = /
-\*-
(?:
# Short form: `-*- ruby -*-`
\s* (?= [^:;\s]+ \s* -\*-)
|
# Longer form: `-*- foo:bar; mode: ruby; -*-`
(?:
.*? # Preceding variables: `-*- foo:bar bar:baz;`
[;\s] # Which are delimited by spaces or semicolons
|
(?<=-\*-) # Not preceded by anything: `-*-mode:ruby-*-`
)
mode # Major mode indicator
\s*:\s* # Allow whitespace around colon: `mode : ruby`
)
([^:;\s]+) # Name of mode
# First form vim modeline
# [text]{white}{vi:|vim:|ex:}[white]{options}
# ex: 'vim: syntax=ruby'
VIM_MODELINE_1 = /(?:vim|vi|ex):\s*(?:ft|filetype|syntax)=(\w+)\s?/i
# Ensure the mode is terminated correctly
(?=
# Followed by semicolon or whitespace
[\s;]
|
# Touching the ending sequence: `ruby-*-`
(?<![-*]) # Don't allow stuff like `ruby--*-` to match; it'll invalidate the mode
-\*- # Emacs has no problems reading `ruby --*-`, however.
)
.*? # Anything between a cleanly-terminated mode and the ending -*-
-\*-
/xi
# Second form vim modeline (compatible with some versions of Vi)
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
# ex: 'vim set syntax=ruby:'
VIM_MODELINE_2 = /(?:vim|vi|Vim|ex):\s*se(?:t)?.*\s(?:ft|filetype|syntax)=(\w+)\s?.*:/i
VIM_MODELINE = /
MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2]
# Start modeline. Could be `vim:`, `vi:` or `ex:`
(?:
(?:\s|^)
vi
(?:m[<=>]?\d+|m)? # Version-specific modeline
|
[\t\x20] # `ex:` requires whitespace, because "ex:" might be short for "example:"
ex
)
# If the option-list begins with `set ` or `se `, it indicates an alternative
# modeline syntax partly-compatible with older versions of Vi. Here, the colon
# serves as a terminator for an option sequence, delimited by whitespace.
(?=
# So we have to ensure the modeline ends with a colon
: (?=\s* set? \s [^\n:]+ :) |
# Otherwise, it isn't valid syntax and should be ignored
: (?!\s* set? \s)
)
# Possible (unrelated) `option=value` pairs to skip past
(?:
# Option separator. Vim uses whitespace or colons to separate options (except if
# the alternate "vim: set " form is used, where only whitespace is used)
(?:
\s
|
\s* : \s* # Note that whitespace around colons is accepted too:
) # vim: noai : ft=ruby:noexpandtab
# Option's name. All recognised Vim options have an alphanumeric form.
\w*
# Possible value. Not every option takes an argument.
(?:
# Whitespace between name and value is allowed: `vim: ft =ruby`
\s*=
# Option's value. Might be blank; `vim: ft= ` says "use no filetype".
(?:
[^\\\s] # Beware of escaped characters: titlestring=\ ft=ruby
| # will be read by Vim as { titlestring: " ft=ruby" }.
\\.
)*
)?
)*
# The actual filetype declaration
[\s:] (?:filetype|ft|syntax) \s*=
# Language's name
(\w+)
# Ensure it's followed by a legal separator
(?=\s|:|$)
/xi
MODELINES = [EMACS_MODELINE, VIM_MODELINE]
# Scope of the search for modelines
# Number of lines to check at the beginning and at the end of the file

View File

@@ -165,7 +165,7 @@
# Chart.js
- (^|/)Chart\.js$
# Codemirror
# CodeMirror
- (^|/)[Cc]ode[Mm]irror/(\d+\.\d+/)?(lib|mode|theme|addon|keymap|demo)
# SyntaxHighlighter - http://alexgorbatchev.com/
@@ -229,6 +229,9 @@
# Fabric
- Fabric.framework/
# BuddyBuild
- BuddyBuildSDK.framework/
# git config files
- gitattributes$
- gitignore$

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "4.8.12"
VERSION = "4.8.15"
end

View File

@@ -1,7 +1,7 @@
{
"repository": "https://github.com/github/linguist",
"dependencies": {
"season": "~>5.0"
"season": "~>5.4"
},
"license": "MIT"
}

View File

@@ -0,0 +1,6 @@
(define-abbrev-table 'c-mode-abbrev-table '(
))
(define-abbrev-table 'fundamental-mode-abbrev-table '(
("TM" "™" nil 0)
("(R)" "®" nil 0)
("C=" "€" nil 0)))

View File

@@ -0,0 +1,20 @@
(setq user-full-name "Alhadis")
(setq user-mail-address "fake.account@gmail.com")
(auto-image-file-mode)
(setq mm-inline-large-images t)
(add-to-list 'mm-attachment-override-types "image/*")
(setq gnus-select-method
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 777)
(nnimap-stream ssl)))
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials '(("smtp.gmail.com" 600 nil nil))
smtpmail-auth-credentials '(("smtp.gmail.com" 700 "me@lisp.com" nil))
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 800
setq gnus-ignored-from-addresses "^from\\.Telstra[ \t\r\n]+Thanks")

View File

@@ -0,0 +1,10 @@
(setq viper-inhibit-startup-message 't)
(setq viper-expert-level '5)
; Key bindings
(define-key viper-vi-global-user-map "\C-d" 'end-of-line)
; Return to top of window
(defun my-viper-return-to-top ()
(interactive)
(beginning-of-buffer))

View File

@@ -0,0 +1,34 @@
;; Object EDE
(ede-proj-project "Linguist"
:name "Linguist"
:version "4.9"
:file "Project.ede"
:targets (list
(ede-proj-target-elisp-autoloads "autoloads"
:name "autoloads"
:path "test/samples/Emacs Lisp"
:autoload-file "dude.el"
)
(ede-proj-target-elisp "init"
:name "init"
:path ""
:source '("ede-load.el" "wait-what.el")
:compiler 'ede-emacs-preload-compiler
:pre-load-packages '("sample-names")
)
(ede-proj-target-elisp "what"
:name "the"
:path ""
:source '("h.el" "am-i-writing.el")
:versionsource '("hell.el")
:compiler 'ede-emacs-preload-compiler
:aux-packages '("what" "the" "hell-files" "am-i-writing")
)
)
:web-site-url "https://github.com/github/linguist"
:web-site-directory "../"
:web-site-file "CONTRIBUTING.md"
:ftp-upload-site "/ftp@git.hub.com:/madeup"
:configuration-variables 'nil
:metasubproject 't
)

View File

@@ -0,0 +1,70 @@
;; UTF-8 support
;; (set-language-environment "UTF-8")
(setenv "LANG" "en_AU.UTF-8")
(setenv "LC_ALL" "en_AU.UTF-8")
(setq default-tab-width 4)
;;; Function to load all ".el" files in ~/.emacs.d/config
(defun load-directory (directory)
"Recursively load all Emacs Lisp files in a directory."
(dolist (element (directory-files-and-attributes directory nil nil nil))
(let* ((path (car element))
(fullpath (concat directory "/" path))
(isdir (car (cdr element)))
(ignore-dir (or (string= path ".") (string= path ".."))))
(cond
((and (eq isdir t) (not ignore-dir))
(load-directory fullpath))
((and (eq isdir nil) (string= (substring path -3) ".el"))
(load (file-name-sans-extension fullpath)))))))
;; Tell Emacs we'd like to use Hunspell for spell-checking
(setq ispell-program-name (executable-find "hunspell"))
;; Load Homebrew-installed packages
(let ((default-directory "/usr/local/share/emacs/site-lisp/"))
(normal-top-level-add-subdirs-to-load-path))
(load "aggressive-indent")
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
(autoload 'rust-mode "rust-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; Load Git-related syntax highlighting
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "git-modes")
(load "git-commit")
;; Keybindings
(global-set-key (kbd "C-u") (lambda ()
(interactive)
(kill-line 0)))
;; Show cursor's current column number
(setq column-number-mode t)
;; Disable autosave
(setq auto-save-default nil)
;; Use a single directory for storing backup files
(setq backup-directory-alist `(("." . "~/.emacs.d/auto-save-list")))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(column-number-mode t)
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View File

@@ -0,0 +1,8 @@
(define-abbrev-table 'fundamental-mode-abbrev-table '(
("cat" "Concatenate" nil 0)
("WTF" "World Trade Federation " nil 0)
("rtbtm" "Read that back to me" nil 0)))
(define-abbrev-table 'shell-script-mode-abbrev-table '(
("brake", "bundle rake exec" nil 0)
("pls", "warning: setting Encoding.default_external")))

View File

@@ -0,0 +1,134 @@
charmap := charmap.md
font-name := file-icons
font-folder := dist
font-config := icomoon.json
icon-size := 34
icon-folder := svg
repo-name := Alhadis/FileIcons
svg := $(wildcard $(icon-folder)/*.svg)
last-commit = $(shell git log -1 --oneline --no-abbrev | cut -d' ' -f1)
all: unpack $(font-folder)/$(font-name).woff2 charmap
# Aliases
unpack: $(font-folder)/$(font-name).ttf
charmap: $(charmap)
# Extract a downloaded IcoMoon folder
$(font-folder)/%.ttf: %.zip
@rm -rf $(font-folder) tmp $(font-config)
@unzip -qd tmp $^
@mv tmp/fonts $(font-folder)
@mv tmp/selection.json $(font-config)
@rm -rf tmp $^
@perl -pi -e 's|^( {2})+|"\t" x (length($$&)/2)|ge' $(font-config)
@echo "" >> $(font-config) # Ensure trailing newline
@echo "Files extracted."
# Generate a WOFF2 file from a TTF
%.woff2: %.ttf
@[ ! -f $@ ] && { \
hash woff2_compress 2>/dev/null || { \
echo >&2 "WOFF2 conversion tools not found. Consult the readme file."; \
exit 2; \
}; \
woff2_compress $^ >/dev/null; \
echo "WOFF2 file generated."; \
};
# Clean up SVG source
lint: $(svg)
@perl -0777 -pi -e '\
s/\r\n/\n/g; \
s/<g id="icomoon-ignore">\s*<\/g>//gmi; \
s/<g\s*>\s*<\/g>//gmi; \
s/\s+(id|viewBox|xml:space)="[^"]*"/ /gmi; \
s/<!DOCTYPE[^>]*>//gi; \
s/<\?xml.*?\?>//gi; \
s/<!--.*?-->//gm; \
s/ style="enable-background:.*?;"//gmi; \
s/"\s+>/">/g; \
s/\x20{2,}/ /g; \
s/[\t\n]+//gm;' $^
# Generate/update character map
$(charmap):
@./create-map.pl -r=$(repo-name) -i=$(icon-folder) --size=$(icon-size) $(font-folder)/$(font-name).svg $@
# POSIX systems only: reattach hard links to File-Icons package
relink:
@$(call need-var,ATOM_FILE_ICONS,ERROR_NO_PKG)
@ln -f $(font-folder)/$(font-name).woff2 $(wildcard $(ATOM_FILE_ICONS)/fonts/file-icons-*.woff2)
# Force an icon's preview to be refreshed on GitHub
cachebust:
@$(call need-var,icon,ERROR_NO_ICON)
@base="https://cdn.rawgit.com/Alhadis/FileIcons/"; \
perl -pi -e 's{$$base\K\w+(?=/svg/$(icon:%.svg=%)\.svg")}{$(last-commit)}ig;' $(charmap)
# Dummy task to improve feedback if `cachebust` is mistyped
icon:
$(call need-var,,ERROR_UNDEF_ICON)
# Reset unstaged changes/additions in object directories
clean:
@git clean -fd $(font-folder)
@git checkout -- $(font-folder) 2>/dev/null || true
# Delete extracted and generated files
distclean:
@rm -rf $(font-folder)
.PHONY: clean distclean $(charmap) cachebust icon
.ONESHELL:
# Error message shown to users attempting to run `make relink` without a link
ERROR_NO_PKG := Environment variable ATOM_FILE_ICONS not found. \
| \
| Try this instead:\
| \
| \ make relink ATOM_FILE_ICONS=/path/to/your/file-icons/installation |
# Error message shown when running `make cachebust` without an icon
ERROR_NO_ICON := No icon specified. Task aborted.| \
| Usage: \
| \ make icon=file[.svg] cachebust \
| \
| Examples: \
| \ make icon=Manpage cachebust \
| \ make icon=APL.svg cachebust |
# Shown if user tries running `make icon NAME cachebust` by mistake
ERROR_UNDEF_ICON := No task named \"icon\". \
| \
| Did you mean this? \
| \ make icon=NAME cachebust |
# If the given value is empty, die with an error message
need = @$(if $(1),,echo $(subst | ,$$'\n',$(2)); exit 2)
# Like `need`, but uses variable names instead of string values
need-var = @$(call need,$($(1)),$($(2)))

View File

@@ -0,0 +1,413 @@
//========================================================================
// GLFW 3.3 OS X - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <limits.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <CoreVideo/CVBase.h>
#include <CoreVideo/CVDisplayLink.h>
#include <ApplicationServices/ApplicationServices.h>
// Get the name of the specified display
//
static char* getDisplayName(CGDirectDisplayID displayID)
{
char* name;
CFDictionaryRef info, names;
CFStringRef value;
CFIndex size;
// NOTE: This uses a deprecated function because Apple has
// (as of January 2015) not provided any alternative
info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
kIODisplayOnlyPreferredName);
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
(const void**) &value))
{
// This may happen if a desktop Mac is running headless
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve display name");
CFRelease(info);
return strdup("Unknown");
}
size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value),
kCFStringEncodingUTF8);
name = calloc(size + 1, 1);
CFStringGetCString(value, name, size, kCFStringEncodingUTF8);
CFRelease(info);
return name;
}
// Check whether the display mode should be included in enumeration
//
static GLFWbool modeIsGood(CGDisplayModeRef mode)
{
uint32_t flags = CGDisplayModeGetIOFlags(mode);
if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
return GLFW_FALSE;
if (flags & kDisplayModeInterlacedFlag)
return GLFW_FALSE;
if (flags & kDisplayModeStretchedFlag)
return GLFW_FALSE;
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
{
CFRelease(format);
return GLFW_FALSE;
}
CFRelease(format);
return GLFW_TRUE;
}
// Convert Core Graphics display mode to GLFW video mode
//
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
CVDisplayLinkRef link)
{
GLFWvidmode result;
result.width = (int) CGDisplayModeGetWidth(mode);
result.height = (int) CGDisplayModeGetHeight(mode);
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
if (result.refreshRate == 0)
{
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
if (!(time.flags & kCVTimeIsIndefinite))
result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
}
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
{
result.redBits = 5;
result.greenBits = 5;
result.blueBits = 5;
}
else
{
result.redBits = 8;
result.greenBits = 8;
result.blueBits = 8;
}
CFRelease(format);
return result;
}
// Starts reservation for display fading
//
static CGDisplayFadeReservationToken beginFadeReservation(void)
{
CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);
return token;
}
// Ends reservation for display fading
//
static void endFadeReservation(CGDisplayFadeReservationToken token)
{
if (token != kCGDisplayFadeReservationInvalidToken)
{
CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
CGReleaseDisplayFadeReservation(token);
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Change the current video mode
//
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
CFArrayRef modes;
CFIndex count, i;
CVDisplayLinkRef link;
CGDisplayModeRef native = NULL;
GLFWvidmode current;
const GLFWvidmode* best;
best = _glfwChooseVideoMode(monitor, desired);
_glfwPlatformGetVideoMode(monitor, &current);
if (_glfwCompareVideoModes(&current, best) == 0)
return GLFW_TRUE;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
count = CFArrayGetCount(modes);
for (i = 0; i < count; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
if (_glfwCompareVideoModes(best, &mode) == 0)
{
native = dm;
break;
}
}
if (native)
{
if (monitor->ns.previousMode == NULL)
monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
CGDisplayFadeReservationToken token = beginFadeReservation();
CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
endFadeReservation(token);
}
CFRelease(modes);
CVDisplayLinkRelease(link);
if (!native)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Monitor mode list changed");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
// Restore the previously saved (original) video mode
//
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
{
if (monitor->ns.previousMode)
{
CGDisplayFadeReservationToken token = beginFadeReservation();
CGDisplaySetDisplayMode(monitor->ns.displayID,
monitor->ns.previousMode, NULL);
endFadeReservation(token);
CGDisplayModeRelease(monitor->ns.previousMode);
monitor->ns.previousMode = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
{
uint32_t i, found = 0, displayCount;
_GLFWmonitor** monitors;
CGDirectDisplayID* displays;
*count = 0;
CGGetOnlineDisplayList(0, NULL, &displayCount);
displays = calloc(displayCount, sizeof(CGDirectDisplayID));
monitors = calloc(displayCount, sizeof(_GLFWmonitor*));
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
for (i = 0; i < displayCount; i++)
{
_GLFWmonitor* monitor;
if (CGDisplayIsAsleep(displays[i]))
continue;
const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]);
monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = CGDisplayUnitNumber(displays[i]);
free(name);
found++;
monitors[found - 1] = monitor;
}
free(displays);
*count = found;
return monitors;
}
GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
// HACK: Compare unit numbers instead of display IDs to work around display
// replacement on machines with automatic graphics switching
return first->ns.unitNumber == second->ns.unitNumber;
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
if (xpos)
*xpos = (int) bounds.origin.x;
if (ypos)
*ypos = (int) bounds.origin.y;
}
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
{
CFArrayRef modes;
CFIndex found, i, j;
GLFWvidmode* result;
CVDisplayLinkRef link;
*count = 0;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
found = CFArrayGetCount(modes);
result = calloc(found, sizeof(GLFWvidmode));
for (i = 0; i < found; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
for (j = 0; j < *count; j++)
{
if (_glfwCompareVideoModes(result + j, &mode) == 0)
break;
}
// Skip duplicate modes
if (i < *count)
continue;
(*count)++;
result[*count - 1] = mode;
}
CFRelease(modes);
CVDisplayLinkRelease(link);
return result;
}
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
CGDisplayModeRef displayMode;
CVDisplayLinkRef link;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(displayMode, link);
CGDisplayModeRelease(displayMode);
CVDisplayLinkRelease(link);
}
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
CGGetDisplayTransferByTable(monitor->ns.displayID,
size,
values,
values + size,
values + size * 2,
&size);
_glfwAllocGammaArrays(ramp, size);
for (i = 0; i < size; i++)
{
ramp->red[i] = (unsigned short) (values[i] * 65535);
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
}
free(values);
}
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
int i;
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
for (i = 0; i < ramp->size; i++)
{
values[i] = ramp->red[i] / 65535.f;
values[i + ramp->size] = ramp->green[i] / 65535.f;
values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
}
CGSetDisplayTransferByTable(monitor->ns.displayID,
ramp->size,
values,
values + ramp->size,
values + ramp->size * 2);
free(values);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
return monitor->ns.displayID;
}

3
test/fixtures/Data/Modelines/iamjs.pl vendored Normal file
View File

@@ -0,0 +1,3 @@
# vim: noexpandtab: ft=javascript
"It's JavaScript, baby";

View File

@@ -0,0 +1,4 @@
# vim:noexpandtab titlestring=hi\|there\\\ ft=perl ts=4
# vim:noexpandtab titlestring=hi|there\\ ft=javascript ts=4
"Still JavaScript, bruh";

3
test/fixtures/Data/Modelines/ruby10 vendored Normal file
View File

@@ -0,0 +1,3 @@
ex: noexpandtab: ft=ruby
# Still Ruby

3
test/fixtures/Data/Modelines/ruby11 vendored Normal file
View File

@@ -0,0 +1,3 @@
# vim600: ft=ruby
# Targets Vim 6.0 or later

3
test/fixtures/Data/Modelines/ruby12 vendored Normal file
View File

@@ -0,0 +1,3 @@
vim<520: ft=ruby
# Targets Vim 5.20 and earlier

View File

@@ -0,0 +1,3 @@
// -*- foo-bar mode: c++ -*-
"Malformed modeline, but still understood by Emacs to be C++."

View File

@@ -0,0 +1 @@
/* -*- mode: c++ -------*- */

View File

@@ -0,0 +1 @@
-*--------- foo:bar mode: c++ -*-

View File

@@ -35,3 +35,11 @@ def sample_blob_memory(name)
content = File.read(filepath)
Linguist::Blob.new(name, content)
end
def silence_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = original_verbosity
end

View File

@@ -4,14 +4,18 @@ class TestBlob < Minitest::Test
include Linguist
def setup
# git blobs are normally loaded as ASCII-8BIT since they may contain data
# with arbitrary encoding not known ahead of time
@original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
silence_warnings do
# git blobs are normally loaded as ASCII-8BIT since they may contain data
# with arbitrary encoding not known ahead of time
@original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
end
end
def teardown
Encoding.default_external = @original_external
silence_warnings do
Encoding.default_external = @original_external
end
end
def script_blob(name)

View File

@@ -3,15 +3,27 @@ require_relative "./helper"
class TestFileBlob < Minitest::Test
include Linguist
def silence_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = original_verbosity
end
def setup
# git blobs are normally loaded as ASCII-8BIT since they may contain data
# with arbitrary encoding not known ahead of time
@original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
silence_warnings do
# git blobs are normally loaded as ASCII-8BIT since they may contain data
# with arbitrary encoding not known ahead of time
@original_external = Encoding.default_external
Encoding.default_external = Encoding.find("ASCII-8BIT")
end
end
def teardown
Encoding.default_external = @original_external
silence_warnings do
Encoding.default_external = @original_external
end
end
def script_blob(name)
@@ -305,7 +317,7 @@ class TestFileBlob < Minitest::Test
assert sample_blob("some/vendored/path/Chart.js").vendored?
assert !sample_blob("some/vendored/path/chart.js").vendored?
# Codemirror deps
# CodeMirror deps
assert sample_blob("codemirror/mode/blah.js").vendored?
assert sample_blob("codemirror/5.0/mode/blah.js").vendored?

View File

@@ -5,9 +5,44 @@ class TestGrammars < Minitest::Test
# List of projects that are allowed without licenses
PROJECT_WHITELIST = [
# Dual MIT and GPL license
"vendor/grammars/language-csharp",
"vendor/grammars/sublimeassembly"
"vendor/grammars/Sublime-Lasso",
"vendor/grammars/ant.tmbundle",
"vendor/grammars/sublime-spintools",
"vendor/grammars/blitzmax"
].freeze
HASH_WHITELIST = [
"bc12b3b4917eab9aedb87ec1305c2a4376e34fd1", # TextMate bundles
"16c4748566b3dd996594af0410a1875b22d3a2b3", # language-yaml and atom-salt
"ebae2d87e06d3acef075d049fcfc8958c0364863", # go-tmbundle
"ff21db2554d69d78b2220db5615b16bbba0788d3", # factor
"b9a7428fd036eed8503995e06e989180c276b17d", # jflex.tmbundle
"da39a3ee5e6b4b0d3255bfef95601890afd80709", # SCSS.tmbundle
"5f772ff20ddf3dbac1ec9b6a98c5aa50ace555b2", # gradle.tmbundle
"b5432a1e1055de7eeede2dddf91e009480651fd6", # jasmin-sublime
"74143c4d2a5649eb179105afcb37f466558c22ce", # language-clojure
"760471435f5ab0b9dc99a628203cd8f9156d28ce", # language-coffee-script
"330e6d465e26bdd232aafcd3f5dba6a1d098a20e", # language-csharp
"70fb557a431891c2d634c33fa7367feab5066fd6", # language-javascript
"e0528c23cd967f999e058f1408ccb5b7237daaba", # language-python
"8653305b358375d0fced85dc24793b99919b11ef", # language-shellscript
"9f0c0b0926a18f5038e455e8df60221125fc3111", # elixir-tmbundle
"90af581219debd4e90ef041b46c294e8b4ae6d14", # mako-tmbundle
"b9b24778619dce325b651f0d77cbc72e7ae0b0a3", # Julia.tmbundle
"2d4f8807be850efd925751a8e1839cfc539985b0", # actionscript3-tmbundle
"e06722add999e7428048abcc067cd85f1f7ca71c", # r.tmbundle
"50b14a0e3f03d7ca754dac42ffb33302b5882b78", # smalltalk-tmbundle
"eafbc4a2f283752858e6908907f3c0c90188785b", # gap-tmbundle
"1faa3a44cac6070f22384332434af37dfaaf2f70", # Stylus
"c87e7e574fca543941650e5b0a144b44c02c55d8", # language-crystal
"c78ec142ac3126cf639cfd67bd646ed8226d8b74", # atom-language-purescript
"341d7f66806fc41d081133d6e51ade856352e056", # FreeMarker.tmbundle
"15a394f6bc43400946570b299aee8ae264a1e3ff", # language-renpy
"c9118c370411f2f049c746c0fd096554e877aea2", # perl6fe
"8ccf886749c32fb7e65d4d1316a7ed0479c93dc9", # language-less
"2f03492b52d7dd83b4e7472f01b87c6121e5b1a4", # monkey
"9d8b5626cfe00f3c8a076173913c3b0312b5b122", # ejs-tmbundle
"bdab9fdc21e6790b479ccb5945b78bc0f6ce2493" # language-blade
].freeze
# List of allowed SPDX license names
@@ -87,12 +122,30 @@ class TestGrammars < Minitest::Test
end
def test_submodules_have_approved_licenses
unapproved = submodule_licenses.reject { |k,v| LICENSE_WHITELIST.include?(v) || PROJECT_WHITELIST.include?(k) }.map { |k,v| "#{k}: #{v}"}
unapproved = submodule_licenses.reject { |k,v| LICENSE_WHITELIST.include?(v) ||
PROJECT_WHITELIST.include?(k) ||
HASH_WHITELIST.include?(v) }
.map { |k,v| "#{k}: #{v}"}
message = "The following submodules have unapproved licenses:\n* #{unapproved.join("\n* ")}\n"
message << "The license must be added to the LICENSE_WHITELIST in /test/test_grammars.rb once approved."
assert_equal [], unapproved, message
end
def test_whitelisted_submodules_dont_have_licenses
licensed = submodule_licenses.reject { |k,v| v.nil? }.select { |k,v| PROJECT_WHITELIST.include?(k) }
message = "The following whitelisted submodules have a license:\n* #{licensed.keys.join("\n* ")}\n"
message << "Please remove them from the project whitelist."
assert_equal Hash.new, licensed, message
end
def test_whitelisted_hashes_dont_have_licenses
used_hashes = submodule_licenses.values.reject { |v| v.nil? || LICENSE_WHITELIST.include?(v) }
unused_hashes = HASH_WHITELIST - used_hashes
message = "The following whitelisted license hashes are unused:\n* #{unused_hashes.join("\n* ")}\n"
message << "Please remove them from the hash whitelist."
assert_equal Array.new, unused_hashes, message
end
def test_submodules_whitelist_has_no_extra_entries
skip("Need to work out how to handle dual-licensed entities")
extra_whitelist_entries = PROJECT_WHITELIST - submodule_licenses.select { |k,v| v.nil? }.keys
@@ -123,7 +176,7 @@ class TestGrammars < Minitest::Test
private
def submodule_paths
@submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last }
@submodule_paths ||= `git config --list --file "#{File.join(ROOT, ".gitmodules")}"`.lines.grep(/\.path=/).map { |line| line.chomp.split("=", 2).last }.reject { |path| path =~ /CodeMirror/ }
end
# Returns a hash of submodules in the form of submodule_path => license
@@ -136,51 +189,18 @@ class TestGrammars < Minitest::Test
end
# Given the path to a submodule, return its SPDX-compliant license key
# If the license is unrecognized, return its hash
def submodule_license(submodule)
# Prefer Licensee to detect a submodule's license
project = Licensee::FSProject.new(submodule)
project = Licensee::FSProject.new(submodule, detect_readme: true)
return project.license.key if project.license
# We know a license file exists, but Licensee wasn't able to detect the license,
# Let's try our own more permissive regex method
# We know a license exists, but no method was able to recognize it.
# We return the license hash in this case, to uniquely identify it.
if project.license_file
path = File.expand_path project.license_file.path, submodule
license = classify_license(path)
return license if license
end
# Neither Licensee nor our own regex was able to detect the license, let's check the readme
files = Dir[File.join(ROOT, submodule, "*")]
if readme = files.find { |path| File.basename(path) =~ /\Areadme\b/i }
classify_license(readme)
end
end
def classify_license(path)
content = File.read(path)
return unless content =~ /\blicen[cs]e\b/i
if content.include?("Apache License") && content.include?("2.0")
"apache-2.0"
elsif content.include?("GNU") && content =~ /general/i && content =~ /public/i
if content =~ /version 2/i
"gpl-2.0"
elsif content =~ /version 3/i
"gpl-3.0"
end
elsif content.include?("GPL") && content.include?("http://www.gnu.org/licenses/gpl.html")
"gpl-3.0"
elsif content.include?("Creative Commons Attribution-Share Alike 3.0")
"cc-by-sa-3.0"
elsif content.include?("tidy-license.txt") || content.include?("If not otherwise specified (see below)") || content.include?("Permission to copy, use, modify, sell and distribute this")
"textmate"
elsif content.include?("Permission is hereby granted") || content =~ /\bMIT\b/
"mit"
elsif content.include?("This package is provided as-is and is placed in the Public Domain")
"public"
elsif content.include?("http://www.wtfpl.net/txt/copying/")
"wtfpl"
elsif content.include?("zlib") && content.include?("license") && content.include?("2. Altered source versions must be plainly marked as such")
"zlib"
return project.license_file.hash
elsif project.readme
return project.readme.hash
end
end
end

View File

@@ -29,7 +29,11 @@ class TestHeuristcs < Minitest::Test
hash.each do |language, blobs|
Array(blobs).each do |blob|
result = Heuristics.call(file_blob(blob), candidates)
assert_equal [Language[language]], result, "Failed for #{blob}"
if language.nil?
assert_equal [], result, "Failed for #{blob}"
else
assert_equal [Language[language]], result, "Failed for #{blob}"
end
end
end
end
@@ -122,9 +126,12 @@ class TestHeuristcs < Minitest::Test
})
end
# Candidate languages = ["Assembly", "C++", "HTML", "PAWN", "PHP",
# "POV-Ray SDL", "Pascal", "SQL", "SourcePawn"]
def test_inc_by_heuristics
assert_heuristics({
"PHP" => all_fixtures("PHP", "*.inc")
"PHP" => all_fixtures("PHP", "*.inc"),
"POV-Ray SDL" => all_fixtures("POV-Ray SDL", "*.inc")
})
end
@@ -142,6 +149,26 @@ class TestHeuristcs < Minitest::Test
})
end
def test_m_by_heuristics
assert_heuristics({
"Objective-C" => all_fixtures("Objective-C", "*.m") - all_fixtures("Objective-C", "cocoa_monitor.m"),
"Mercury" => all_fixtures("Mercury", "*.m"),
"MUF" => all_fixtures("MUF", "*.m"),
"M" => all_fixtures("M", "MDB.m"),
"Mathematica" => all_fixtures("Mathematica", "*.m") - all_fixtures("Mathematica", "Problem12.m"),
"Matlab" => all_fixtures("Matlab", "create_ieee_paper_plots.m"),
"Limbo" => all_fixtures("Limbo", "*.m"),
nil => ["Objective-C/cocoa_monitor.m"]
})
end
def test_md_by_heuristics
assert_heuristics({
"Markdown" => all_fixtures("Markdown", "*.md"),
"GCC machine description" => all_fixtures("GCC machine description", "*.md")
})
end
# Candidate languages = ["C++", "Objective-C"]
def test_obj_c_by_heuristics
# Only calling out '.h' filenames as these are the ones causing issues

View File

@@ -345,8 +345,24 @@ class TestLanguage < Minitest::Test
end
def test_ace_modes
assert Language.ace_modes.include?(Language['Ruby'])
assert Language.ace_modes.include?(Language['FORTRAN'])
silence_warnings do
assert Language.ace_modes.include?(Language['Ruby'])
assert Language.ace_modes.include?(Language['FORTRAN'])
end
end
def test_codemirror_mode
assert_equal 'ruby', Language['Ruby'].codemirror_mode
assert_equal 'javascript', Language['JavaScript'].codemirror_mode
assert_equal 'clike', Language['C'].codemirror_mode
assert_equal 'clike', Language['C++'].codemirror_mode
end
def test_codemirror_mime_type
assert_equal 'text/x-ruby', Language['Ruby'].codemirror_mime_type
assert_equal 'text/javascript', Language['JavaScript'].codemirror_mime_type
assert_equal 'text/x-csrc', Language['C'].codemirror_mime_type
assert_equal 'text/x-c++src', Language['C++'].codemirror_mime_type
end
def test_wrap
@@ -436,6 +452,40 @@ class TestLanguage < Minitest::Test
assert missing.empty?, message
end
def test_codemirror_modes_present
Language.all.each do |language|
if language.codemirror_mode || language.codemirror_mime_type
assert language.codemirror_mode, "#{language.inspect} missing CodeMirror mode"
assert language.codemirror_mime_type, "#{language.inspect} missing CodeMirror MIME mode"
end
end
end
def test_valid_codemirror_mode
Language.all.each do |language|
if mode = language.codemirror_mode
assert File.exist?(File.expand_path("../../vendor/CodeMirror/mode/#{mode}", __FILE__)), "#{mode} isn't a valid CodeMirror mode"
end
end
end
def test_codemirror_mode_and_mime_defined_by_meta_mapping
meta = File.read(File.expand_path("../../vendor/CodeMirror/mode/meta.js", __FILE__))
Language.all.each do |language|
next unless language.codemirror_mode && language.codemirror_mime_type
assert meta.match(/^.+#{Regexp.escape(language.codemirror_mime_type)}.+#{Regexp.escape(language.codemirror_mode)}.+$/), "#{language.inspect}: #{language.codemirror_mime_type} not defined under #{language.codemirror_mode}"
end
end
def test_codemirror_mime_declared_in_mode_file
Language.all.each do |language|
next unless language.codemirror_mode && language.codemirror_mime_type
filename = File.expand_path("../../vendor/CodeMirror/mode/#{language.codemirror_mode}/#{language.codemirror_mode}.js", __FILE__)
assert File.exist?(filename), "#{filename} does not exist"
assert File.read(filename).match(language.codemirror_mime_type), "#{language.inspect}: #{language.codemirror_mime_type} not defined in #{filename}"
end
end
def test_all_popular_languages_exist
popular = YAML.load(File.read(File.expand_path("../../lib/linguist/popular.yml", __FILE__)))
@@ -444,4 +494,11 @@ class TestLanguage < Minitest::Test
message << missing.sort.join("\n")
assert missing.empty?, message
end
def test_no_unused_colours
Language.all.each do |language|
next unless language.type == :data || language.type == :prose
assert !language.color, "Unused colour assigned to #{language.name}"
end
end
end

View File

@@ -17,6 +17,9 @@ class TestModelines < Minitest::Test
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby7")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby8")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby9")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby10")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby11")
assert_modeline Language["Ruby"], fixture_blob("Data/Modelines/ruby12")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplus")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs1")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs2")
@@ -27,9 +30,14 @@ class TestModelines < Minitest::Test
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs10")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs11")
assert_modeline Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs12")
assert_modeline Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c")
assert_modeline Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl")
assert_modeline Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md")
assert_modeline Language["JavaScript"], fixture_blob("Data/Modelines/iamjs.pl")
assert_modeline Language["JavaScript"], fixture_blob("Data/Modelines/iamjs2.pl")
assert_modeline Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc")
assert_modeline nil, sample_blob("C/main.c")
end
@@ -48,9 +56,14 @@ class TestModelines < Minitest::Test
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs7").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs8").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs9").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs10").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs11").language
assert_equal Language["C++"], fixture_blob("Data/Modelines/seeplusplusEmacs12").language
assert_equal Language["Text"], fixture_blob("Data/Modelines/fundamentalEmacs.c").language
assert_equal Language["Prolog"], fixture_blob("Data/Modelines/not_perl.pl").language
assert_equal Language["Smalltalk"], fixture_blob("Data/Modelines/example_smalltalk.md").language
assert_equal Language["JavaScript"], fixture_blob("Data/Modelines/iamjs.pl").language
assert_equal Language["JavaScript"], fixture_blob("Data/Modelines/iamjs2.pl").language
assert_equal Language["PHP"], fixture_blob("Data/Modelines/iamphp.inc").language
end
end

1
vendor/CodeMirror vendored Submodule

Submodule vendor/CodeMirror added at 39ffcd8701

View File

@@ -1,11 +1,12 @@
---
type: grammar
name: Sublime-VimL
name: language-viml
license: mit
---
The MIT License (MIT)
Copyright (c) 2014 Max Vasiliev, Salvatore Gentile
Copyright (c) 2014-2016 Evan Hahn
Copyright (c) 2016 John Gardner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -14,13 +15,13 @@ 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 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.