mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:57:35 +00:00
Remove CompilationUnitElementImpl.sourceContent
I hoped to get hints on why we get out of sync with the number of classes, getters, etc in the AST and the element model. Unfortunately it don't not help, we might have a unit without any variables, the corresponding code, but AST has variables. So, this code does not help, and I want to remove it. It was also used for Move File refactoring, we would need some different solution later. For now I revert to the state it was not long ago. Change-Id: If7468aac33ce000f85e94f96bfa2d2966892e560 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214341 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
6459e73570
commit
ec29dce8e0
|
@ -8,10 +8,8 @@ import 'package:analysis_server/src/services/refactoring/refactoring.dart';
|
|||
import 'package:analysis_server/src/services/refactoring/refactoring_internal.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
|
@ -179,11 +177,8 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
}
|
||||
|
||||
bool _isPackageReference(SourceReference reference) {
|
||||
var unitSourceContent = reference.element.unitSourceContent;
|
||||
if (unitSourceContent == null) {
|
||||
return false;
|
||||
}
|
||||
var quotedImportUri = unitSourceContent.substring(reference.range.offset,
|
||||
var source = reference.element.source!;
|
||||
var quotedImportUri = source.contents.data.substring(reference.range.offset,
|
||||
reference.range.offset + reference.range.length);
|
||||
return packagePrefixedStringPattern.hasMatch(quotedImportUri);
|
||||
}
|
||||
|
@ -220,10 +215,3 @@ class MoveFileRefactoringImpl extends RefactoringImpl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension on Element {
|
||||
String? get unitSourceContent {
|
||||
var unitElement = thisOrAncestorOfType<CompilationUnitElementImpl>();
|
||||
return unitElement?.sourceContent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ import 'package:meta/meta.dart';
|
|||
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
|
||||
class AnalysisDriver implements AnalysisDriverGeneric {
|
||||
/// The version of data format, should be incremented on every format change.
|
||||
static const int DATA_VERSION = 179;
|
||||
static const int DATA_VERSION = 180;
|
||||
|
||||
/// The number of exception contexts allowed to write. Once this field is
|
||||
/// zero, we stop writing any new exception contexts in this process.
|
||||
|
|
|
@ -974,10 +974,6 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
|||
@override
|
||||
late Source source;
|
||||
|
||||
/// The content of the [source] for which this element model was built.
|
||||
/// Might be `null` if we don't have it (for example in google3 summaries).
|
||||
String? sourceContent;
|
||||
|
||||
@override
|
||||
LineInfo? lineInfo;
|
||||
|
||||
|
|
|
@ -107,16 +107,6 @@ class ElementWalker {
|
|||
(element.aliasedElement as GenericFunctionTypeElement).parameters,
|
||||
_typeParameters = element.typeParameters;
|
||||
|
||||
String? get _unitSourceContent {
|
||||
Element? element = this.element;
|
||||
while (element != null) {
|
||||
if (element is CompilationUnitElementImpl) {
|
||||
return element.sourceContent;
|
||||
}
|
||||
element = element.enclosingElement;
|
||||
}
|
||||
}
|
||||
|
||||
void consumeLocalElements() {
|
||||
_functionIndex = _functions!.length;
|
||||
}
|
||||
|
@ -138,8 +128,7 @@ class ElementWalker {
|
|||
'[accessors: $accessors]'
|
||||
'[element.source: ${element.source?.fullName}]'
|
||||
'[libraryFilePath: $libraryFilePath]'
|
||||
'[unitFilePath: $unitFilePath]'
|
||||
'[unitSourceContent: $_unitSourceContent]',
|
||||
'[unitFilePath: $unitFilePath]',
|
||||
);
|
||||
}
|
||||
return _accessors![_accessorIndex++] as PropertyAccessorElementImpl;
|
||||
|
@ -158,8 +147,7 @@ class ElementWalker {
|
|||
'[classes: $classes]'
|
||||
'[element.source: ${element.source?.fullName}]'
|
||||
'[libraryFilePath: $libraryFilePath]'
|
||||
'[unitFilePath: $unitFilePath]'
|
||||
'[unitSourceContent: $_unitSourceContent]',
|
||||
'[unitFilePath: $unitFilePath]',
|
||||
);
|
||||
}
|
||||
return _classes![_classIndex++] as ClassElementImpl;
|
||||
|
@ -215,8 +203,7 @@ class ElementWalker {
|
|||
'[variables: $variables]'
|
||||
'[element.source: ${element.source?.fullName}]'
|
||||
'[libraryFilePath: $libraryFilePath]'
|
||||
'[unitFilePath: $unitFilePath]'
|
||||
'[unitSourceContent: $_unitSourceContent]',
|
||||
'[unitFilePath: $unitFilePath]',
|
||||
);
|
||||
}
|
||||
return _variables![_variableIndex++] as VariableElementImpl;
|
||||
|
|
|
@ -1266,7 +1266,6 @@ class LibraryReader {
|
|||
|
||||
unitElement.uri = _reader.readOptionalStringReference();
|
||||
unitElement.isSynthetic = _reader.readBool();
|
||||
unitElement.sourceContent = _reader.readOptionalStringUtf8();
|
||||
|
||||
_readUnitMacroGenerationDataList(unitElement);
|
||||
_readClasses(unitElement, unitReference);
|
||||
|
|
|
@ -449,7 +449,6 @@ class BundleWriter {
|
|||
_sink._writeStringReference('${unitElement.source.uri}');
|
||||
_sink._writeOptionalStringReference(unitElement.uri);
|
||||
_sink.writeBool(unitElement.isSynthetic);
|
||||
_sink.writeOptionalStringUtf8(unitElement.sourceContent);
|
||||
_resolutionSink._writeAnnotationList(unitElement.metadata);
|
||||
_writeUnitElementMacroGenerationDataList(unitElement);
|
||||
_writeList(unitElement.classes, _writeClassElement);
|
||||
|
|
|
@ -415,7 +415,6 @@ class LibraryBuilder {
|
|||
unitElement.librarySource = inputLibrary.source;
|
||||
unitElement.lineInfo = unitNode.lineInfo;
|
||||
unitElement.source = inputUnit.source;
|
||||
unitElement.sourceContent = inputUnit.sourceContent;
|
||||
unitElement.uri = inputUnit.partUriStr;
|
||||
unitElement.setCodeRange(0, unitNode.length);
|
||||
|
||||
|
|
Loading…
Reference in a new issue