Skip to content

Commit

Permalink
feat(types): mark unused types with marker trait
Browse files Browse the repository at this point in the history
For some reason, some google APIs define types they never use. We now
mark them, just because we can, to show our superiority ;) ;) ;) :D .
  • Loading branch information
Byron committed Mar 20, 2015
1 parent 10dfeeb commit 8bb2166
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mako/lib.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use std::io;
use std::fs;
use std::old_io::timer::sleep;

pub use cmn::{MultiPartReader, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate};
pub use cmn::{MultiPartReader, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, UnusedType};


// ##############
Expand Down
3 changes: 3 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ def schema_markers(s, c, transitive=True):
if len(c.sta_map.get(s.id, dict())) == 0:
res.add(PART_MARKER_TRAIT)

if len(res) == 1 and PART_MARKER_TRAIT in res and len(s.used_by) == 0:
res.add('UnusedType')

return sorted(res)

## -- End Rust TypeSystem -- @}
Expand Down
4 changes: 4 additions & 0 deletions src/rust/cmn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub trait ResponseResult: MarkerTrait {}
/// Identifies types which are used in API requests.
pub trait RequestValue: MarkerTrait {}

/// Identifies types which are not actually used by the API
/// This might be a bug within the google API schema.
pub trait UnusedType: MarkerTrait {}

/// Identifies types which are only used as part of other types, which
/// usually are carrying the `Resource` trait.
pub trait Part: MarkerTrait {}
Expand Down

0 comments on commit 8bb2166

Please sign in to comment.