Changes between Initial Version and Version 1 of SemanticQuery/TypeEntity


Ignore:
Timestamp:
Feb 27, 2015, 2:01:38 PM (9 years ago)
Author:
manualwiki
Comment:

mostly sq-type related changes

Legend:

Unmodified
Added
Removed
Modified
  • SemanticQuery/TypeEntity

    v1 v1  
     1= Type entity = 
     2 
     3Type entities can represent ''-type'', ''-opaque'' attributes(user-defined types), built-in types or any type expression in an erlang file. Please note that type expressions consisting of only a single atom(e.g.: ok, 'error') are filtered from the results of any selector that returns type entities. 
     4 
     5== Initial selector == 
     6When a type expression is indicated by the given position, the {{{@type}}} initial-selector can be used to return the corresponding type entity. 
     7 
     8== Selectors == 
     9 
     10''The type of the result elements are indicated in parenthesis.'' 
     11 
     12* {{{file}}} (''file''): The defining file of the type. 
     13* {{{arguments}}} (''type''): The arguments of the type. 
     14* {{{subtypes}}} (''type''): Subtypes of the given type. 
     15* {{{specref}}} (''spec''): Specs using this type. 
     16* {{{references}}} (''type''): The references of the type. 
     17* {{{paramsref}}} (''type''): The references of the types arguments. 
     18 
     19== Properties == 
     20 
     21The following properties are defined for spec entities: 
     22 
     23* {{{name}}} (''atom''): The name of the type 
     24* {{{arity}}} (''int''): The arity of the type. 
     25* {{{exported}}} (''bool''): Returns whether the type is exported. 
     26* {{{opaque}}} (''bool''): Returns whether the type is opaque. 
     27* {{{builtin}}} (''bool''): Returns whether the type is built-in. 
     28 
     29== Textual output format == 
     30 
     31When using any of our interfaces, other than ris?, this entity will be represented in the output as a string with the following possible formats: 
     32 
     33* When the entity represents a user-defined or built-in type: 
     34{{{ 
     35Type -> string (Module:Name/Arity) 
     36Module -> atom (defining module of the type) 
     37Name -> atom (name of the type = Type.name) 
     38Arity -> int (number of parameters of the type = Type.arity) 
     39}}} 
     40 
     41* When the entity represents a type expression: 
     42{{{ 
     43Type -> string (textual representation of the type expression, as it was formatted in the source) 
     44}}} 
     45 
     46== Review of non-trivial selectors == 
     47Due to the multiple structures represented by this entity, some of the selectors have a complex specification. These are described below: 
     48 
     49=== Type.arguments: === 
     50Returns the type or type expression of the given type's parameters. 
     51{{{ 
     52%%-type myt(Key, Val) :: myt(Key, ok). 
     53ri:q("mods.types.params").            
     54a:myt/2 
     55    Key 
     56     Val 
     57ok 
     58ri:q("mods.types.subtypes.params"). 
     59 myt(Key, ok) 
     60    Key 
     61}}} 
     62 
     63=== Type.subtypes: === 
     64If the given type is a user-defined type it returns the type's body as a type expression. When the given type is a type expression it returns the expression's subexpressions(1-level deep). 
     65{{{ 
     66ri:q("mods.types.subtypes"). 
     67a:prp_user/2 
     68     [{atom(), Key, Val}] 
     69a:myt/2 
     70     myt(Key, ok) 
     71ok 
     72ri:q("mods.types.subtypes.subtypes"). 
     73 [{atom(), Key, Val}] 
     74    {atom(), Key, Val} 
     75 myt(Key, ok) 
     76    Key 
     77}}} 
     78 
     79=== Type.specrefs: === 
     80For user-defined and built-in types, returns the specs referencing this type. 
     81{{{ 
     82ri:q("mods.types.specrefs"). 
     83b:prp_user/2 
     84    -spec g(prp_user(X,Y))->'ok'. 
     85}}} 
     86 
     87=== Type.references: === 
     88Returns the type expressions using this user-defined or built-in type. If the given type is a type expression it tries to find the user-defined or built-in type referenced in the type expression and continues from there. Otherwise the result is empty. 
     89{{{ 
     90ri:q("mods.types.refs").                   
     91b:prp_user/2 
     92    prp_user(X,Y) 
     93a:myt/2 
     94     myt(list(), ok) 
     95     myt(Key, ok) 
     96}}}