Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
Support v2 dev sdks, fix deprecated usages
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jul 27, 2017
1 parent 3d4be9e commit 4eca2de
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
7 changes: 1 addition & 6 deletions lib/src/dart_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

library code_transformers.src.dart_sdk;

import 'dart:io' show Directory;

import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
Expand All @@ -20,10 +18,7 @@ import 'package:cli_util/cli_util.dart' as cli_util;
/// This will return null if the SDK cannot be found
///
/// Note that this may not be correct when executing outside of `pub`.
String get dartSdkDirectory {
Directory sdkDir = cli_util.getSdkDir();
return sdkDir != null ? sdkDir.path : null;
}
String get dartSdkDirectory => cli_util.getSdkPath();

/// Sources that are annotated with a source uri, so it is easy to resolve how
/// to support `Resolver.getImportUri`.
Expand Down
9 changes: 3 additions & 6 deletions lib/src/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'package:code_transformers/messages/messages.dart';
const NO_ABSOLUTE_PATHS = const MessageTemplate(
const MessageId('code_transformers', 1),
'absolute paths not allowed: "%-url-%"',
'Absolute paths not allowed',
'''
'Absolute paths not allowed', '''
The transformers processing your code were trying to resolve a URL and identify
a file that they correspond to. Currently only relative paths can be resolved.
''');
Expand Down Expand Up @@ -55,8 +54,7 @@ See [issue 15797](http://dartbug.com/15797) and
const UNSPECIFIED_FROM_IN_NON_LIB_ASSET = const MessageTemplate(
const MessageId('code_transformers', 4),
'Cannot create URI for %-id-% without specifying where to import it from.',
'Missing `from` argument.',
'''
'Missing `from` argument.', '''
Assets outside of the lib folder can only be imported via relative URIs. Use
the `from` argument in `assetIdToUri` to specify the location in the same
package where you intend to import this asset from.
Expand All @@ -65,8 +63,7 @@ package where you intend to import this asset from.
const IMPORT_FROM_DIFFERENT_PACKAGE = const MessageTemplate(
const MessageId('code_transformers', 5),
'Not possible to import %-toId-% from %-fromId-%',
'Cannot import asset.',
'''
'Cannot import asset.', '''
Assets outside of the lib folder can only be imported via relative URIs from
assets in the same package. To import an asset from another package, you need to
move it into the lib folder of your package.
Expand Down
6 changes: 4 additions & 2 deletions lib/src/resolver_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ class ResolverImpl implements Resolver {

var importUri = _getSourceUri(element);
var spanPath = importUri != null ? importUri.toString() : assetId.path;
return new SourceFile(sources[assetId].rawContents, url: spanPath);
return new SourceFile.fromString(sources[assetId].rawContents,
url: spanPath);
}
}

Expand Down Expand Up @@ -435,7 +436,8 @@ class AssetBasedSource extends Source {
SourceFile _getSourceFile([String contents]) {
var uri = assetIdToUri(assetId);
var path = uri != null ? uri : assetId.path;
return new SourceFile(contents != null ? contents : rawContents, url: path);
return new SourceFile.fromString(contents != null ? contents : rawContents,
url: path);
}
}

Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: code_transformers
version: 0.5.1+3
version: 0.5.2-dev
author: Dart Team <misc@dartlang.org>
description: Collection of utilities related to creating barback transformers.
homepage: https://github.com/dart-lang/code-transformers
environment:
sdk: '>=1.0.0 <2.0.0'
sdk: '>=1.0.0 <2.0.0-dev.infinity'
dependencies:
analyzer: '>=0.28.0 <0.31.0'
barback: '>=0.14.2 <0.16.0'
cli_util: '>=0.0.1 <0.2.0'
cli_util: '>=0.1.0 <0.2.0'
path: '>=0.9.0 <2.0.0'
source_maps: '>=0.9.4 <0.11.0'
source_span: '>=1.0.0 <2.0.0'
source_span: '>=1.4.0 <2.0.0'
dev_dependencies:
test: '>=0.12.1 <0.13.0'
transformer_test: '>=0.1.0 <0.3.0'

0 comments on commit 4eca2de

Please sign in to comment.