File tree 1 file changed +15
-6
lines changed
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,7 @@ def constant_name_from_node(node, ancestors:)
17
17
return nil if parent && Node . constant? ( parent )
18
18
19
19
if constant_in_module_or_class_definition? ( node , parent : parent )
20
- # We're defining a class with this name, in which case the constant is implicitly fully qualified by its
21
- # enclosing namespace
22
- name = Node . parent_module_name ( ancestors : ancestors )
23
- name ||= Node . enclosing_namespace_path ( node , ancestors : ancestors ) . push ( Node . constant_name ( node ) ) . join ( "::" )
24
-
25
- "::" + name
20
+ fully_qualify_constant ( node , ancestors : ancestors )
26
21
else
27
22
begin
28
23
Node . constant_name ( node )
@@ -40,5 +35,19 @@ def constant_in_module_or_class_definition?(node, parent:)
40
35
parent_name && parent_name == Node . constant_name ( node )
41
36
end
42
37
end
38
+
39
+ def fully_qualify_constant ( node , ancestors :)
40
+ # We're defining a class with this name, in which case the constant is implicitly fully qualified by its
41
+ # enclosing namespace
42
+ name = Node . parent_module_name ( ancestors : ancestors )
43
+ name ||= generate_qualified_constant ( node , ancestors )
44
+ "::" + name
45
+ end
46
+
47
+ def generate_qualified_constant ( node , ancestors :)
48
+ namespace_path = Node . enclosing_namespace_path ( node , ancestors : ancestors )
49
+ constant_name = Node . constant_name ( node )
50
+ namespace_path . push ( constant_name ) . join ( "::" )
51
+ end
43
52
end
44
53
end
You can’t perform that action at this time.
0 commit comments