mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Detect Javascript files generated by Protocol Buffers.
This commit is contained in:
		
				
					committed by
					
						 Brandon Black
						Brandon Black
					
				
			
			
				
	
			
			
			
						parent
						
							f951ec07de
						
					
				
				
					commit
					f98ab593fb
				
			| @@ -70,6 +70,7 @@ module Linguist | ||||
|       compiled_cython_file? || | ||||
|       generated_go? || | ||||
|       generated_protocol_buffer? || | ||||
|       generated_javascript_protocol_buffer? || | ||||
|       generated_apache_thrift? || | ||||
|       generated_jni_header? || | ||||
|       vcr_cassette? || | ||||
| @@ -277,6 +278,17 @@ module Linguist | ||||
|       return lines[0].include?("Generated by the protocol buffer compiler.  DO NOT EDIT!") | ||||
|     end | ||||
|  | ||||
|     # Internal: Is the blob a Javascript source file generated by the | ||||
|     # Protocol Buffer compiler? | ||||
|     # | ||||
|     # Returns true of false. | ||||
|     def generated_javascript_protocol_buffer? | ||||
|       return false unless extname == ".js" | ||||
|       return false unless lines.count > 6 | ||||
|  | ||||
|       return lines[5].include?("GENERATED CODE -- DO NOT EDIT!") | ||||
|     end | ||||
|  | ||||
|     APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp', '.php'] | ||||
|  | ||||
|     # Internal: Is the blob generated by Apache Thrift compiler? | ||||
| @@ -435,7 +447,7 @@ module Linguist | ||||
|       return false unless lines.count > 1 | ||||
|       return lines[0].start_with?("// This is a generated file. Not intended for manual editing.") | ||||
|     end | ||||
|          | ||||
|  | ||||
|     # Internal: Is this a roxygen2-generated file? | ||||
|     # | ||||
|     # A roxygen2-generated file typically contain: | ||||
| @@ -449,7 +461,7 @@ module Linguist | ||||
|  | ||||
|       return lines[0].include?("% Generated by roxygen2: do not edit by hand") | ||||
|     end | ||||
|          | ||||
|  | ||||
|     # Internal: Is this a Jison-generated file? | ||||
|     # | ||||
|     # Jison-generated parsers typically contain: | ||||
| @@ -465,7 +477,7 @@ module Linguist | ||||
|       return false unless extname == '.js' | ||||
|       return false unless lines.count > 1 | ||||
|       return lines[0].start_with?("/* parser generated by jison ") || | ||||
|               lines[0].start_with?("/* generated by jison-lex ") | ||||
|              lines[0].start_with?("/* generated by jison-lex ") | ||||
|     end | ||||
|   end | ||||
| end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user