-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1981. Wrong number of reported lines in Coverage API
This ended up being much simpler than I think any of us thought. Base problem was any lines after last *newline* marked node would not update the primitive 'coverage' array which coverage sets up. So we just call one method at end up parse to update that array to include final lines of the file.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
Showing
4 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
class Object | ||
# include the class specified by +include_class+ into the current namespace, | ||
# using either its base name or by using a name returned from an optional block, | ||
# passing all specified classes in turn and providing the block package name | ||
# and base class name. | ||
def include_class(include_class, &block) | ||
warn "#{__method__} is deprecated. Use java_import." | ||
java_import(include_class, &block) | ||
end | ||
|
||
# TODO: this can go away now, but people may be using it | ||
def java_kind_of?(other) | ||
return true if self.kind_of?(other) | ||
return false unless self.respond_to?(:java_class) && other.respond_to?(:java_class) && | ||
other.kind_of?(Module) && !self.kind_of?(Module) | ||
return other.java_class.assignable_from?(self.java_class) | ||
end | ||
|
||
# Import one or many Java classes as follows: | ||
# | ||
# java_import java.lang.System | ||
# java_import java.lang.System, java.lang.Thread | ||
# java_import [java.lang.System, java.lang.Thread] | ||
# | ||
# Optionally java_import can also include a block to be used for custom | ||
# | ||
# | ||
def java_import(*import_classes) | ||
import_classes = import_classes.each_with_object([]) do |classes, flattened| | ||
if classes.is_a?(Array) | ||
flattened.push(*classes) | ||
else | ||
flattened.push(classes) | ||
end | ||
end | ||
|
||
import_classes.map do |import_class| | ||
case import_class | ||
when String | ||
cc = java.lang.Character | ||
valid_name = import_class.split(".").all? do |frag| | ||
cc.java_identifier_start? frag[0].ord and | ||
frag.each_char.all? {|c| cc.java_identifier_part? c.ord } | ||
end | ||
unless valid_name | ||
raise ArgumentError.new "not a valid Java identifier: #{import_class}" | ||
end | ||
# pull in the class | ||
raise ArgumentError.new "must use jvm-style name: #{import_class}" if import_class.include? "::" | ||
import_class = JavaUtilities.get_proxy_class(import_class) | ||
when Module | ||
if import_class.respond_to? "java_class" | ||
# ok, it's a proxy | ||
else | ||
raise ArgumentError.new "not a Java class or interface: #{import_class}" | ||
end | ||
else | ||
raise ArgumentError.new "invalid Java class or interface: #{import_class}" | ||
end | ||
|
||
java_class = import_class.java_class | ||
class_name = java_class.simple_name | ||
|
||
if block_given? | ||
package = java_class.package | ||
|
||
# package can be nil if it's default or no package was defined by the classloader | ||
if package | ||
package_name = package.name | ||
elsif java_class.canonical_name =~ /(.*)\.[^.]$/ | ||
package_name = $1 | ||
else | ||
package_name = "" | ||
end | ||
|
||
constant = yield(package_name, class_name) | ||
else | ||
constant = class_name | ||
|
||
# Inner classes are separated with $, get last element | ||
if constant =~ /\$([^$])$/ | ||
constant = $1 | ||
end | ||
end | ||
|
||
unless constant =~ /^[A-Z].*/ | ||
raise ArgumentError.new "cannot import class `" + java_class.name + "' as `" + constant + "'" | ||
end | ||
|
||
# JRUBY-3453: Make import not complain if Java already has already imported the specific Java class | ||
# If no constant is defined, or the constant is not already set to the java_import, assign it | ||
eval_str = "if !defined?(#{constant}) || #{constant} != import_class; #{constant} = import_class; end" | ||
if Module === self | ||
class_eval(eval_str, __FILE__, __LINE__) | ||
else | ||
eval(eval_str, binding, __FILE__, __LINE__) | ||
end | ||
|
||
import_class | ||
end | ||
end | ||
|
||
private :java_import | ||
|
||
def handle_different_imports(*args, &block) | ||
if args.first.respond_to?(:java_class) | ||
java_import(*args, &block) | ||
else | ||
other_import(*args, &block) | ||
end | ||
end | ||
|
||
unless respond_to?(:import) | ||
alias :import :java_import | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enebo@Thomass-MacBook-Pro-2.local.742 |