Skip to content

Commit

Permalink
Add Haxe generated source detection (#4808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gama11 authored Mar 10, 2020
1 parent 506e013 commit 7b805b6
Show file tree
Hide file tree
Showing 10 changed files with 1,126 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def generated?
generated_perl_ppport_header? ||
generated_gamemakerstudio? ||
generated_gimp? ||
generated_visualstudio6?
generated_visualstudio6? ||
generated_haxe?
end

# Internal: Is the blob an Xcode file?
Expand Down Expand Up @@ -627,6 +628,16 @@ def generated_visualstudio6?
lines.first(3).any? { |l| l.include? '# Microsoft Developer Studio Generated Build File' }
end

HAXE_EXTENSIONS = ['.js', '.py', '.lua', '.cpp', '.h', '.java', '.cs', '.php']

# Internal: Is this a generated Haxe-generated source file?
#
# Return true or false
def generated_haxe?
return false unless HAXE_EXTENSIONS.include?(extname)
return lines.first(3).any? { |l| l.include?("Generated by Haxe") }
end

# Internal: Is this a generated HTML file?
#
# HTML documents generated by authoring tools often include a
Expand Down
86 changes: 86 additions & 0 deletions test/fixtures/Generated/Haxe/Main.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions test/fixtures/Generated/Haxe/Main.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions test/fixtures/Generated/Haxe/Main.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions test/fixtures/Generated/Haxe/Main.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions test/fixtures/Generated/Haxe/Main.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/fixtures/Generated/Haxe/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7b805b6

Please sign in to comment.