CQ. Add LibraryFragment.isOriginNotExistingFile, to replace isSynthetic
`isSynthetic` was already deprecated, but now we have a replacement. Change-Id: I187207557e9ee2de5d819500f2b377886044fb9f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479180 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
75006d89ca
commit
42e6dbd9d4
@@ -6,6 +6,7 @@
|
||||
* Stabilize `FieldElement.declaringFormalParameter`.
|
||||
* Stabilize `FieldFormalParameterElement.isDeclaring` and `privateName`.
|
||||
* Stabilize `FieldFormalParameterFragment.privateName`.
|
||||
* Deprecate `LibraryFragment.isSynthetic`, use `isOriginNotExistingFile` instead.
|
||||
|
||||
## 10.0.2
|
||||
|
||||
|
||||
@@ -3913,6 +3913,7 @@ package:analyzer/dart/element/element.dart:
|
||||
functions (getter: List<TopLevelFunctionFragment>)
|
||||
getters (getter: List<GetterFragment>)
|
||||
importedLibraries (getter: List<LibraryElement>)
|
||||
isOriginNotExistingFile (getter: bool)
|
||||
libraryExports (getter: List<LibraryExport>)
|
||||
libraryImports (getter: List<LibraryImport>)
|
||||
lineInfo (getter: LineInfo)
|
||||
|
||||
@@ -2385,6 +2385,9 @@ abstract class LibraryFragment implements Fragment {
|
||||
/// those that are imported without a prefix.
|
||||
List<LibraryElement> get importedLibraries;
|
||||
|
||||
/// Whether the library fragment is created from a file that does not exist.
|
||||
bool get isOriginNotExistingFile;
|
||||
|
||||
/// The libraries exported by this unit.
|
||||
List<LibraryExport> get libraryExports;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ testFineAfterLibraryAnalyzerHook;
|
||||
// TODO(scheglov): Clean up the list of implicitly analyzed files.
|
||||
class AnalysisDriver {
|
||||
/// The version of data format, should be incremented on every format change.
|
||||
static const int DATA_VERSION = 610;
|
||||
static const int DATA_VERSION = 611;
|
||||
|
||||
/// The number of exception contexts allowed to write. Once this field is
|
||||
/// zero, we stop writing any new exception contexts in this process.
|
||||
|
||||
@@ -6044,11 +6044,7 @@ class LibraryElementImpl extends ElementImpl
|
||||
globalResultRequirements?.record_library_isOriginNotExistingFile(
|
||||
element: this,
|
||||
);
|
||||
return hasModifier(Modifier.ORIGIN_NOT_EXISTING_FILE);
|
||||
}
|
||||
|
||||
set isOriginNotExistingFile(bool value) {
|
||||
setModifier(Modifier.ORIGIN_NOT_EXISTING_FILE, value);
|
||||
return _firstFragment.isOriginNotExistingFile;
|
||||
}
|
||||
|
||||
@Deprecated('Use isOriginNotExistingFile instead')
|
||||
@@ -6638,8 +6634,9 @@ class LibraryExportImpl extends ElementDirectiveImpl implements LibraryExport {
|
||||
}
|
||||
|
||||
/// A concrete implementation of [LibraryFragment].
|
||||
@GenerateFragmentImpl(modifiers: _LibraryFragmentImplModifiers.values)
|
||||
class LibraryFragmentImpl extends FragmentImpl
|
||||
with DeferredResolutionReadingMixin
|
||||
with DeferredResolutionReadingMixin, _LibraryFragmentImplMixin
|
||||
implements LibraryFragment {
|
||||
@override
|
||||
final Source source;
|
||||
@@ -10709,6 +10706,8 @@ enum _FragmentImplModifiers {
|
||||
isSynthetic,
|
||||
}
|
||||
|
||||
enum _LibraryFragmentImplModifiers { isOriginNotExistingFile }
|
||||
|
||||
enum _MethodFragmentImplModifiers { isOriginDeclaration, isOriginInterface }
|
||||
|
||||
enum _MixinFragmentImplModifiers { isBase }
|
||||
|
||||
@@ -322,6 +322,20 @@ mixin _FragmentImplMixin {
|
||||
void setModifier(Modifier modifier, bool value);
|
||||
}
|
||||
|
||||
mixin _LibraryFragmentImplMixin {
|
||||
bool get isOriginNotExistingFile {
|
||||
return hasModifier(Modifier.ORIGIN_NOT_EXISTING_FILE);
|
||||
}
|
||||
|
||||
set isOriginNotExistingFile(bool value) {
|
||||
setModifier(Modifier.ORIGIN_NOT_EXISTING_FILE, value);
|
||||
}
|
||||
|
||||
bool hasModifier(Modifier modifier);
|
||||
|
||||
void setModifier(Modifier modifier, bool value);
|
||||
}
|
||||
|
||||
mixin _MethodFragmentImplMixin {
|
||||
bool get isOriginDeclaration {
|
||||
return hasModifier(Modifier.ORIGIN_DECLARATION);
|
||||
|
||||
@@ -1404,7 +1404,7 @@ class LibraryReader {
|
||||
}
|
||||
});
|
||||
|
||||
libraryFragment.isSynthetic = _reader.readBool();
|
||||
libraryFragment.readModifiers(_reader);
|
||||
|
||||
libraryFragment.libraryImports = _reader.readTypedList(() {
|
||||
return _readLibraryImport(containerUnit: libraryFragment);
|
||||
|
||||
@@ -821,9 +821,7 @@ class BundleWriter {
|
||||
|
||||
void _writeUnitElement(LibraryFragmentImpl libraryFragment) {
|
||||
_writeResolutionOffset();
|
||||
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
_sink.writeBool(libraryFragment.isSynthetic);
|
||||
libraryFragment.writeModifiers(_sink);
|
||||
|
||||
_sink.writeList(libraryFragment.libraryImports, _writeLibraryImport);
|
||||
_sink.writeList(libraryFragment.libraryExports, _writeLibraryExport);
|
||||
|
||||
@@ -659,6 +659,7 @@ class LibraryBuilder {
|
||||
);
|
||||
partUnitNode.declaredFragment = libraryFragment;
|
||||
libraryFragment.isSynthetic = !partFile.exists;
|
||||
libraryFragment.isOriginNotExistingFile = !partFile.exists;
|
||||
libraryFragment.setCodeRange(0, partUnitNode.length);
|
||||
|
||||
units.add(LinkingUnit(node: partUnitNode, fragment: libraryFragment));
|
||||
@@ -774,7 +775,6 @@ class LibraryBuilder {
|
||||
libraryUnitNode.featureSet,
|
||||
);
|
||||
if (!libraryFile.exists) {
|
||||
libraryElement.isOriginNotExistingFile = true;
|
||||
libraryElement.isSynthetic = true;
|
||||
}
|
||||
libraryElement.languageVersion = libraryUnitNode.languageVersion;
|
||||
@@ -790,6 +790,7 @@ class LibraryBuilder {
|
||||
);
|
||||
libraryUnitNode.declaredFragment = libraryFragment;
|
||||
libraryFragment.isSynthetic = !libraryFile.exists;
|
||||
libraryFragment.isOriginNotExistingFile = !libraryFile.exists;
|
||||
libraryFragment.setCodeRange(0, libraryUnitNode.length);
|
||||
|
||||
linkingUnits.add(
|
||||
|
||||
@@ -1265,6 +1265,7 @@ class _Element2Writer extends _AbstractElementWriter {
|
||||
void _writeLibraryFragment(LibraryFragmentImpl f) {
|
||||
_sink.writeIndentedLine(() {
|
||||
_writeObjectId(f);
|
||||
_sink.writeIf(f.isOriginNotExistingFile, 'isOriginNotExistingFile ');
|
||||
|
||||
var uriStr = f.source.uri.toString();
|
||||
if (uriStr == 'package:test/test.dart') {
|
||||
|
||||
@@ -47,6 +47,17 @@ library
|
||||
''');
|
||||
}
|
||||
|
||||
test_isOriginNotExistingFile() async {
|
||||
var library = await testContextLibrary('package:test/test.dart');
|
||||
checkElementText(library, r'''
|
||||
library
|
||||
reference: <testLibrary>
|
||||
fragments
|
||||
#F0 isOriginNotExistingFile <testLibraryFragment>
|
||||
element: <testLibrary>
|
||||
''');
|
||||
}
|
||||
|
||||
test_library() async {
|
||||
var library = await buildLibrary('');
|
||||
checkElementText(library, r'''
|
||||
|
||||
Reference in New Issue
Block a user