Class: CoderCompanion::ParserFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/codercompanion/parser_factory.rb

Class Method Summary collapse

Class Method Details

.get_parser(language) ⇒ CoderCompanion::LanguageParser

Parameters:

  • language (String)

Returns:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/codercompanion/parser_factory.rb', line 8

def self.get_parser(language)
    case(language)
    when Languages::RUBY[:key]
        return CoderCompanion::Ruby::RubyParser.new 
=begin #Uncomment when we add c++ and java
    when Languages::CPP[:key]
        return CoderCompanion::Cpp::CppParser.new
=end

    when Languages::JAVA[:key]
        return CoderCompanion::Java::JavaParser.new
    else
        message = CoderCompanion::error_format("The language (#{language}) specified in your config file is either" + 
                            " invalid or currently not supported. To see a list of supported languages run: codercmp --language\n") +
                            CoderCompanion::error_format("More information at: ") +
                            CoderCompanion::error_url_format("http://codercompanion.com/#/how-it-works")
        raise CoderCompanionException.new message
    end
end