Merge pull request #2822 from AbigailBuccaneer/master

Add detection of GrammarKit-generated files
This commit is contained in:
Arfon Smith
2016-02-04 20:28:12 -07:00
4 changed files with 1143 additions and 1 deletions

View File

@@ -72,7 +72,9 @@ module Linguist
vcr_cassette? ||
generated_module? ||
generated_unity3d_meta? ||
generated_racc?
generated_racc? ||
generated_jflex? ||
generated_grammarkit?
end
# Internal: Is the blob an Xcode file?
@@ -373,5 +375,32 @@ module Linguist
return false unless lines.count > 2
return lines[2].start_with?("# This file is automatically generated by Racc")
end
# Internal: Is this a JFlex-generated file?
#
# A JFlex-generated file contains:
# /* The following code was generated by JFlex x.y.z on d/at/e ti:me */
# on the first line.
#
# Return true or false
def generated_jflex?
return false unless extname == '.java'
return false unless lines.count > 1
return lines[0].start_with?("/* The following code was generated by JFlex ")
end
# Internal: Is this a GrammarKit-generated file?
#
# A GrammarKit-generated file typically contain:
# // This is a generated file. Not intended for manual editing.
# on the first line. This is not always the case, as it's possible to
# customize the class header.
#
# Return true or false
def generated_grammarkit?
return false unless extname == '.java'
return false unless lines.count > 1
return lines[0].start_with?("// This is a generated file. Not intended for manual editing.")
end
end
end