Mercurial > hg > soundsoftware-site
annotate .svn/pristine/a7/a728943093f6831306c2b123cde489f05fdadba9.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration
Fix failure to interpret Javascript when autocompleting members for project
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Thu, 11 Sep 2014 10:24:38 +0100 |
parents | cbb26bc654de |
children |
rev | line source |
---|---|
Chris@909 | 1 module CodeRay |
Chris@909 | 2 module Encoders |
Chris@909 | 3 |
Chris@909 | 4 # Counts the LoC (Lines of Code). Returns an Integer >= 0. |
Chris@909 | 5 # |
Chris@909 | 6 # Alias: +loc+ |
Chris@909 | 7 # |
Chris@909 | 8 # Everything that is not comment, markup, doctype/shebang, or an empty line, |
Chris@909 | 9 # is considered to be code. |
Chris@909 | 10 # |
Chris@909 | 11 # For example, |
Chris@909 | 12 # * HTML files not containing JavaScript have 0 LoC |
Chris@909 | 13 # * in a Java class without comments, LoC is the number of non-empty lines |
Chris@909 | 14 # |
Chris@909 | 15 # A Scanner class should define the token kinds that are not code in the |
Chris@909 | 16 # KINDS_NOT_LOC constant, which defaults to [:comment, :doctype]. |
Chris@909 | 17 class LinesOfCode < TokenKindFilter |
Chris@909 | 18 |
Chris@909 | 19 register_for :lines_of_code |
Chris@909 | 20 |
Chris@909 | 21 NON_EMPTY_LINE = /^\s*\S.*$/ |
Chris@909 | 22 |
Chris@909 | 23 protected |
Chris@909 | 24 |
Chris@909 | 25 def setup options |
Chris@909 | 26 if scanner |
Chris@909 | 27 kinds_not_loc = scanner.class::KINDS_NOT_LOC |
Chris@909 | 28 else |
Chris@909 | 29 warn "Tokens have no associated scanner, counting all nonempty lines." if $VERBOSE |
Chris@909 | 30 kinds_not_loc = CodeRay::Scanners::Scanner::KINDS_NOT_LOC |
Chris@909 | 31 end |
Chris@909 | 32 |
Chris@909 | 33 options[:exclude] = kinds_not_loc |
Chris@909 | 34 |
Chris@909 | 35 super options |
Chris@909 | 36 end |
Chris@909 | 37 |
Chris@909 | 38 def finish options |
Chris@909 | 39 output @tokens.text.scan(NON_EMPTY_LINE).size |
Chris@909 | 40 end |
Chris@909 | 41 |
Chris@909 | 42 end |
Chris@909 | 43 |
Chris@909 | 44 end |
Chris@909 | 45 end |