Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Apr 17, 2024
1 parent f270359 commit 10f9657
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/src/embedded/importer/file.dart
Expand Up @@ -21,8 +21,8 @@ final class FileImporter extends ImporterBase {
..importerId = _importerId
..url = url.toString()
..fromImport = fromImport;
var containingUrl = canonicalizeContext.containingUrlWithoutMarking;
if (containingUrl case var containingUrl?) {
if (canonicalizeContext.containingUrlWithoutMarking
case var containingUrl?) {
request.containingUrl = containingUrl.toString();
}
var response = dispatcher.sendFileImportRequest(request);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/embedded/importer/host.dart
Expand Up @@ -35,8 +35,8 @@ final class HostImporter extends ImporterBase {
..importerId = _importerId
..url = url.toString()
..fromImport = fromImport;
var containingUrl = canonicalizeContext.containingUrlWithoutMarking;
if (containingUrl case var containingUrl?) {
if (canonicalizeContext.containingUrlWithoutMarking
case var containingUrl?) {
request.containingUrl = containingUrl.toString();
}
var response = dispatcher.sendCanonicalizeRequest(request);
Expand Down
12 changes: 5 additions & 7 deletions lib/src/importer/canonicalize_context.dart
@@ -1,7 +1,9 @@
// Copyright 2014 Google Inc. Use of this source code is governed by an
// Copyright 2024 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

import 'dart:async';

import 'package:meta/meta.dart';

/// Contextual information used by importers' `canonicalize` method.
Expand All @@ -25,17 +27,13 @@ final class CanonicalizeContext {
/// Whether [containingUrl] has been accessed.
///
/// This is used to determine whether canonicalize result is cacheable.
///
/// @nodoc
@internal
bool get wasContainingUrlAccessed => _wasContainingUrlAccessed;
var _wasContainingUrlAccessed = false;

/// Runs [callback] in a context with specificed [fromImport].
///
/// @nodoc
@internal
T withFromImport<T>(bool fromImport, T callback()) {
assert(Zone.current[#_canonicalizeContext] == this);

var oldFromImport = _fromImport;
_fromImport = fromImport;
try {
Expand Down

0 comments on commit 10f9657

Please sign in to comment.