From b229d6cf55027ca8ee1887d4017c833d93893ff0 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sun, 5 Feb 2012 22:51:24 -0800 Subject: [PATCH] Ignore empty multi-line comments: /**/ A corner case that wasn't taken care of. --- lib/jsduck/lexer.rb | 2 +- spec/lexer_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jsduck/lexer.rb b/lib/jsduck/lexer.rb index e6c54480..8ec3d985 100644 --- a/lib/jsduck/lexer.rb +++ b/lib/jsduck/lexer.rb @@ -140,7 +140,7 @@ module JsDuck elsif @input.check(/\//) # Several things begin with dash: # - comments, regexes, division-operators - if @input.check(/\/\*\*/) + if @input.check(/\/\*\*[^\/]/) return { :type => :doc_comment, # Calculate current line number, starting with 1 diff --git a/spec/lexer_spec.rb b/spec/lexer_spec.rb index fd1fe667..43304ac2 100644 --- a/spec/lexer_spec.rb +++ b/spec/lexer_spec.rb @@ -127,6 +127,10 @@ describe JsDuck::Lexer do lex("a /* foo */ b").should == [[:ident, "a"], [:ident, "b"]] end + it "ignores empty multi-line comments" do + lex("a /**/ b").should == [[:ident, "a"], [:ident, "b"]] + end + it "identifies doc-comments together with line numbers" do lex("/** foo */").should == [[:doc_comment, "/** foo */", 1]] end -- GitLab