Skip to content

Commit

Permalink
Merge pull request #200 from dart-lang/class-mixins
Browse files Browse the repository at this point in the history
list the mixins for a class
  • Loading branch information
sethladd committed Feb 16, 2015
2 parents f7eef60 + b0dc35d commit 056d47e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class Class extends ModelElement {
_mixins = _cls.mixins.map((f) {
var lib = new Library(f.element.library, p);
return new ElementType(f, new ModelElement.from(f.element, lib));
}).toList();
}).toList(growable: false);
if (hasSupertype) {
var lib = new Library(_cls.supertype.element.library, p);
_supertype = new ElementType(
Expand All @@ -509,7 +509,7 @@ class Class extends ModelElement {
_interfaces = _cls.interfaces.map((f) {
var lib = new Library(f.element.library, p);
return new ElementType(f, new ModelElement.from(f.element, lib));
}).toList();
}).toList(growable: false);
}

bool get isAbstract => _cls.isAbstract;
Expand All @@ -521,9 +521,11 @@ class Class extends ModelElement {

List<ElementType> get mixins => _mixins;

bool get hasMixins => mixins.isNotEmpty;

List<ElementType> get interfaces => _interfaces;

bool get hasInterfaces => _interfaces.isNotEmpty;
bool get hasInterfaces => interfaces.isNotEmpty;

List<Field> _getAllfields() {
List<FieldElement> elements = _cls.fields.toList()
Expand Down Expand Up @@ -555,8 +557,6 @@ class Class extends ModelElement {
List<Method> get methods {
if (_methods != null) return _methods;

// Do not sort. We want source order.
// Also, check if this is lexically ordered
_methods = _cls.methods
.where(isPublic)
.map((e) {
Expand Down
10 changes: 7 additions & 3 deletions lib/src/new_html_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class NewHtmlGenerator extends Generator {
void _writeFile(String filename, String template, Map data) {
File f = _createOutputFile(filename);
String content = render(template, data, partial: _partials,
assumeNullNonExistingProperty: false);
assumeNullNonExistingProperty: false,
errorOnMissingProperty: true);
f.writeAsStringSync(content);
}

Expand All @@ -144,7 +145,8 @@ class NewHtmlGenerator extends Generator {
/// and removes any script tags. Returns the HTML as a string.
String renderMarkdown(String markdown, {nestedContext}) {
String mustached = render(markdown.trim(), nestedContext,
assumeNullNonExistingProperty: false);
assumeNullNonExistingProperty: false,
errorOnMissingProperty: true);
String html = md.markdownToHtml(mustached);
Document doc = parse(html);
doc.querySelectorAll('script').forEach((s) => s.remove());
Expand All @@ -153,7 +155,9 @@ String renderMarkdown(String markdown, {nestedContext}) {

String oneLiner(String text, {nestedContext}) {
String mustached = render(text.trim(), nestedContext,
assumeNullNonExistingProperty: false).trim();
assumeNullNonExistingProperty: false,
errorOnMissingProperty: true)
.trim();
if (mustached == null || mustached.trim().isEmpty) return '';

// Parse with Markdown, but only care about the first block or paragraph.
Expand Down
13 changes: 12 additions & 1 deletion templates/new/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="title">
<section class="desc markdown">

{{#markdown}}
{{{ class.description }}}
{{{ class.documentation }}}
{{/markdown}}

</section>
Expand All @@ -42,6 +42,17 @@ <h4>Implements</h4>
</section>
{{/class.hasInterfaces}}

{{#class.hasMixins}}
<section id="mixes-in">
<h4>Mixes-in</h4>
<ul class="interfaces-implemented">
{{#class.mixins}}
<li>{{{linkedName}}}</li>
{{/class.mixins}}
</ul>
</section>
{{/class.hasMixins}}

<section class="summary" id="constructors">
<h2>Constructors</h2>

Expand Down
7 changes: 6 additions & 1 deletion test/fake_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class Cool {

}

/// Perfect for mix-ins.
abstract class MixMeIn {

}

/// An interface that can be implemented.
abstract class Interface {

Expand All @@ -61,7 +66,7 @@ abstract class AnotherInterface {
/// across... wait for it... two physical lines.
///
/// The rest of this is not in the first paragraph.
class LongFirstLine implements Interface, AnotherInterface {
class LongFirstLine extends Object with MixMeIn implements Interface, AnotherInterface {

/// The default constructor.
LongFirstLine();
Expand Down

0 comments on commit 056d47e

Please sign in to comment.