Linter Demo Errors: 0Warnings: 6File: /home/fstrocco/Dart/dart/benchmark/devcompiler/lib/src/dart_sdk.dart // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. /// Common logic needed to provide a Dart SDK to the analyzer's resolver. This /// includes logic to determine where the sdk is located in the filesystem, and /// definitions to provide mock sdks. library dev_compiler.src.dart_sdk; import 'package:analyzer/src/generated/engine.dart'; import 'package:analyzer/src/generated/sdk.dart'; import 'package:analyzer/src/generated/source.dart'; /// Dart SDK which contains a mock implementation of the SDK libraries. May be /// used to speed up execution when most of the core libraries is not needed. class MockDartSdk implements DartSdk { final Map _sources = {}; final bool reportMissing; final Map _libs = {}; final String sdkVersion = '0'; List get uris => _sources.keys.map((uri) => '$uri').toList(); final AnalysisContext context = new SdkAnalysisContext(); DartUriResolver _resolver; DartUriResolver get resolver => _resolver; MockDartSdk(Map sources, {this.reportMissing}) { sources.forEach((uriString, contents) { var uri = Uri.parse(uriString); _sources[uri] = new _MockSdkSource(uri, contents); _libs[uriString] = new SdkLibraryImpl(uri.path) ..setDart2JsLibrary() ..setVmLibrary(); }); _resolver = new DartUriResolver(this); context.sourceFactory = new SourceFactory([_resolver]); } List get sdkLibraries => _libs.values.toList(); SdkLibrary getSdkLibrary(String dartUri) => _libs[dartUri]; Source mapDartUri(String dartUri) => _getSource(Uri.parse(dartUri)); Source fromEncoding(UriKind kind, Uri uri) { if (kind != UriKind.DART_URI) { throw new UnsupportedError('expected dart: uri kind, got $kind.'); } return _getSource(uri); } Source _getSource(Uri uri) { var src = _sources[uri]; if (src == null) { if (reportMissing) print('warning: missing mock for $uri.'); _sources[uri] = src = new _MockSdkSource(uri, 'library dart.${uri.path};'); } return src; } @override Source fromFileUri(Uri uri) { throw new UnsupportedError('MockDartSdk.fromFileUri'); } } class _MockSdkSource implements Source { /// Absolute URI which this source can be imported from. final Uri uri; final String _contents; _MockSdkSource(this.uri, this._contents); bool exists() => true; int get hashCode => uri.hashCode; final int modificationStamp = 1; TimestampedData get contents => new TimestampedData(modificationStamp, _contents); String get encoding => "${uriKind.encoding}$uri"; Source get source => this; String get fullName => shortName; String get shortName => uri.path; UriKind get uriKind => UriKind.DART_URI; bool get isInSystemLibrary => true; Source resolveRelative(Uri relativeUri) => throw new UnsupportedError('not expecting relative urls in dart: mocks'); Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError('not expecting relative urls in dart: mocks'); } /// Sample mock SDK sources. final Map mockSdkSources = { // The list of types below is derived from: // * types we use via our smoke queries, including HtmlElement and // types from `_typeHandlers` (deserialize.dart) // * types that are used internally by the resolver (see // _initializeFrom in resolver.dart). 'dart:core': ''' library dart.core; void print(Object o) {} class Object { int get hashCode {} Type get runtimeType {} String toString(){} bool ==(other){} } class Function {} class StackTrace {} class Symbol {} class Type {} class String { String operator +(String other) {} } class bool {} class num { num operator +(num other) {} } class int extends num { bool operator<(num other) {} int operator-() {} } class double extends num {} class DateTime {} class Null {} class Deprecated { final String expires; const Deprecated(this.expires); } const Object deprecated = const Deprecated("next release"); class _Override { const _Override(); } const Object override = const _Override(); class _Proxy { const _Proxy(); } const Object proxy = const _Proxy(); class Iterable {} class List implements Iterable { List([int length]); List.filled(int length, E fill); } class Map { Iterable get keys {} } ''', 'dart:async': ''' class Future { Future then(callback) {} } class Stream {} ''', 'dart:html': ''' library dart.html; class HtmlElement {} ''', };