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
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?
|
||||
|
||||
31
samples/JavaScript/proto.js
Normal file
31
samples/JavaScript/proto.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @fileoverview
|
||||
* @enhanceable
|
||||
* @public
|
||||
*/
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
goog.provide('proto.google.protobuf.Timestamp');
|
||||
|
||||
goog.require('jspb.Message');
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.google.protobuf.Timestamp = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.google.protobuf.Timestamp, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.google.protobuf.Timestamp.displayName = 'proto.google.protobuf.Timestamp';
|
||||
}
|
||||
|
||||
|
||||
// Remainder elided
|
||||
@@ -197,6 +197,7 @@ class TestBlob < Minitest::Test
|
||||
assert sample_blob_memory("Python/protocol_buffer_pb2.py").generated?
|
||||
assert sample_blob_memory("Go/api.pb.go").generated?
|
||||
assert sample_blob_memory("Go/embedded.go").generated?
|
||||
assert sample_blob_memory("JavaScript/proto.js").generated?
|
||||
|
||||
# Apache Thrift generated code
|
||||
assert sample_blob_memory("Python/gen-py-linguist-thrift.py").generated?
|
||||
|
||||
Reference in New Issue
Block a user