Skip to content

Commit 112d696

Browse files
committed
update docs
1 parent a7826e6 commit 112d696

File tree

2 files changed

+1096
-85
lines changed

2 files changed

+1096
-85
lines changed

CHANGELOG.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
* Add constructor generics support (ConstructorGenericsContext)
2-
* Inlying contexts: generics context building for type "inside" known hierarchy:
3-
"Drill down" case, when new generics context must be build for some type, using generics of current context.
4-
For example, we have some generics context and analyzing class fields. Some field is MyType<T\> - generified with
5-
current class's generic. Inlying context is building new hierarchy with extra known generics (for example for class MyType<String\>).
1+
### 3.0.0 (2018-06-19)
2+
* Add constructor generics support
3+
* Add inlying contexts support: generics context building for type "inside" of known hierarchy (field, method parameter etc):
4+
"Drill down" case, when target type could contain generics known in current hierarchy (e.g. field type MyType<T>)
65
Context methods:
7-
- inlyingType(Type) = GenericsContext - universal inlying context builder (the same as GenericsResolver.resolve(class) if class does not have generics)
6+
- context.inlyingType(Type) = GenericsContext - universal inlying context builder (the same as GenericsResolver.resolve(class) if class does not have generics)
87
- context.fieldType(Field) - shortcut for fields (guarantee correct base type or error if type not in hierarchy)
98
- method(Method).returnType() - shortcut for method return type (guarantee correct base type)
109
- method(Method).parameterType(pos) - shortcut for method parameter type (guarantee correct base type)
10+
- constructor(Constructor).parameterType(pos) - shortcut fot constructor parameter
1111
- returned context have reference to root context: GenericsContext.rootContext()
12-
* Inlying context building for sub type: it's like inlying context (knowing type's root generics), but target type is
13-
a subtype for current. Very special case, required for instance analysis: useful when not just type declarations, but
14-
also actual instance is used for analysis:
12+
* Inlying context building for higher type then declared (e.g. in field or method). Very special case, required for
13+
instance analysis when not just type declarations, but also actual instance is used for analysis:
1514
Suppose we have field MyType<String\> inside class. But we know that actual instance is MySpecificType<T, K\> extends MyType<T\>.
1615
We need to build generics context for actual class (MySpecificType), but as we know base class type, we can track class generics
1716
as MySpecificType<String, Object\> (partially tracked)
18-
- inlyingTypeAs(Type, Class) = GenericsContext - universal inlying context building for target class
17+
- context.inlyingTypeAs(Type, Class) = GenericsContext - universal inlying context building for higher target class
1918
- Shortcuts, by analogy with simple inlying contexts: fieldTypeAs(Field, Class), returnTypeAs(Class), parameterTypeAs(pos, Class)
20-
- Tracks root type generics from known middle generics (e.g. Root<T\> extends Base<T\> when known Base<String\> will resolve to Root<String\>).
19+
- Target type generics tracking from known declared type generics (e.g. Root<T\> extends Base<T\> when known Base<String\> will resolve to Root<String\>).
2120
Support composite generic declarations (and any hierarchy depth).
2221
* Internal analysis logic opened as utilities (for low level usage without GenericsResolver)
2322
- GenericsResolutionUtils - generics analysis logic (with access to analyzed type)
24-
- GenericsTrackingUtils - root generics tracking from middle class's known generics (with access to analyzed types)
25-
- TypeUtils - generic utilities on types (ignoring unknown generics)
23+
- GenericsTrackingUtils - root generics tracking from middle class's known generics
24+
- TypeUtils - generic utilities for types (ignoring unknown generics)
2625
* Types deep comparison api: TypesWalker.walk(Type, Type, Visitor) could walk on two types side by side to check or compare actual classes on each level
2726
Usages:
2827
- TypeUtils.isCompatible(Type, Type) - deep types compatibility check
@@ -35,12 +34,12 @@
3534
- Now all exceptions extend base type GenericsException (runtime) to simplify generic analysis errors interception (catch(GenericException ex))
3635
- General tracking exception: GenericsTrackingException - thrown on generics tracking problems
3736
- General resolution exception: GenericsResolutionException - thrown on type hierarchy generics analysis problems
38-
- WrongGenericsContextException thrown when supplied type contains generics incompatible with current class
37+
- WrongGenericsContextException thrown when supplied type contains generics incompatible with current hierarchy
3938
(not reachable from current context)
4039
- More informative error messages
4140
- (breaking) UnknownGenericException moved to different package
4241
- (breaking) NoGenericException removed. Was thrown for resolveGenericsOf(Type) methods when class does not declare generics.
43-
Now empty list or null will be returned.
42+
Now empty list or null is returned.
4443
* Context api improvements:
4544
* Check all supplied types for compatibility with current class: throw exception when type contains generics
4645
belonging to other class (avoid usage errors)
@@ -50,39 +49,40 @@
5049
- ownerGenericsMap() - visible generics of outer class (if current is inner)
5150
- methodGenericsMap() - method generics
5251
- constructorGenericsMap() - constructor generics
53-
- visibleGenericsMap() - all visible generics (type +owner +method)
52+
- visibleGenericsMap() - all visible generics (type +owner +method/constructor)
5453
* Type resolution methods (return type with all generic variables replaced with known values):
5554
- resolveType(Type) = Type
5655
- Shortcuts:
5756
- resolveFieldType(Field) - field type without generic variables
5857
- resolveParameterType(pos) - (method context) parameter type without generic variables
5958
- resolveReturnType() - (method context) return type without generic variables
6059
- resolveTypeGenerics(Type) = Type[]
61-
* Shortcuts for Field's type resolution (with automatic context tracking to avoid silly mistakes):
60+
* Shortcuts for common Field's resolutions:
6261
- resolveFieldClass(Field) - field class
6362
- resolveFieldGenerics(Field) - field's class generics (List<Class\>)
6463
- resolveFieldGeneric(Field) - field's class generic (Class)
65-
* More to string utilities:
66-
- GenericsContext to string methods for context type:
64+
* More toString utilities:
65+
- GenericsContext toString methods for context type:
6766
- toStringCurrentClassDeclaration() - current with resolved generics ("MyClass<Integer>")
6867
- toStringCurrentClass() - current class with named generics ("MyClass<T>")
6968
- toStringMethod() - method string with resolved generics ("void do(MyType)")
7069
- toStringConstructor() - constructor string with resolved generics ("Some(Long)")
71-
* (breaking) resolveGenericsOf() called on class will return upper bounds from generic declaration (previously returns empty map)
70+
* (breaking) resolveGenericsOf() called on Class will return upper bounds from generic declaration (previously returns empty map)
7271
* Improved debugging support:
7372
- Core context could be printed as string (class hierarchy with resolved generics): context.getGenericsInfo().toString()
7473
- For customized context string rendering: context.getGenericsInfo().toStringHierarchy(TypeWriter)
75-
- Direct toString() on context (GenericsContext) prints entire hierarchy with current position marker "<-- current" marker.
76-
In intellij idea you can use "view" value link inside debugger to quickly overview current context (with resolved generics) and position
77-
* Inner classes support (Outer<T\>.Inner, not static): outer class generics are resolved to avoid UnknownGenericException
78-
- Used owner class (context.ownerClass()) generics: context.ownerGenericsMap() (empty map for not inner class)
79-
- For inlying context building, root class may be used as generics source for inner class (if root class hierachy contains owner class).
74+
- Direct toString() on context (GenericsContext) prints entire hierarchy with current position marker ("<-- current").
75+
In intellij idea, current context (with resolved generics) and position could be seen by using "view value" link inside debugger
76+
* Add inner classes support (Outer<T\>.Inner, not static) - outer class generics are resolved during hierarchy building:
77+
- GenericsInfo contains maps with both type generics and owner generics
78+
- context.ownerClass() returns owner class, visible owner generics are accessible with context.ownerGenericsMap() (empty map for not inner class)
79+
- For inlying context building, root class may be used as generics source for inner class (if root class hierarchy contains owner class).
8080
This is not always true, but, for most cases, inner class is used inside owner and so generics resolution will be correct
8181
* Improved bounds support:
8282
- Support multiple upper bounds declaration: My<T extends A & B\> now stored as wildcard (? extends A & B) and used
83-
for more precise checks (compatibility, assignability). As before, resolveClass("T") will use first upper bound (A).
83+
for more precise checks (e.g. compatibility, assignability checks). As before, resolveClass("T") will use first upper bound (A).
8484
- (breaking) avoid upper bound wildcards (transform <? extends Something\> -> Something) as only type matter at runtime
85-
affects GenericsUtils.resolveTypeVariables()
85+
Affects hierarchy resolution: root generics will not contain Wildcards as before, but just type
8686

8787
Compatibility notes:
8888
* API did not changed, only new methods were added.

0 commit comments

Comments
 (0)