Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1762193002: Resynthesize codeOffset/codeLength properties. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index df23151bff8c755ddd6b2946a0793a126f1c36a5..005f86184217f7c2515f570889264a2e02198793 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1020,6 +1020,7 @@ class _LibraryResynthesizer {
classElement.type = correspondingType;
buildDocumentation(classElement, serializedClass.documentationComment);
buildAnnotations(classElement, serializedClass.annotations);
+ buildCodeRange(classElement, serializedClass);
resolveConstructorInitializers(classElement);
unitHolder.addType(classElement);
currentTypeParameters.removeLast();
@@ -1028,6 +1029,55 @@ class _LibraryResynthesizer {
constructors = null;
}
+ void buildCodeRange(ElementImpl element, Object summary) {
+ int offset;
+ int length;
+ if (summary is UnlinkedClass) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedEnum) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedExecutable) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedParam) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedTypedef) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedTypeParam) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedUnit) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ } else if (summary is UnlinkedVariable) {
+ if (summary.hasCodeRange) {
+ offset = summary.codeOffset;
+ length = summary.codeLength;
+ }
+ }
+ if (offset != null) {
+ element.setCodeRange(offset, length);
+ }
+ }
+
/**
* Resynthesize a [NamespaceCombinator].
*/
@@ -1151,6 +1201,7 @@ class _LibraryResynthesizer {
classElement.supertype = summaryResynthesizer.typeProvider.objectType;
buildDocumentation(classElement, serializedEnum.documentationComment);
buildAnnotations(classElement, serializedEnum.annotations);
+ buildCodeRange(classElement, serializedEnum);
ElementHolder memberHolder = new ElementHolder();
// Build the 'index' field.
FieldElementImpl indexField = new FieldElementImpl('index', -1);
@@ -1306,6 +1357,7 @@ class _LibraryResynthesizer {
buildDocumentation(
executableElement, serializedExecutable.documentationComment);
buildAnnotations(executableElement, serializedExecutable.annotations);
+ buildCodeRange(executableElement, serializedExecutable);
executableElement.functions =
serializedExecutable.localFunctions.map(buildLocalFunction).toList();
executableElement.labels =
@@ -1707,6 +1759,7 @@ class _LibraryResynthesizer {
}
parameterElement.synthetic = synthetic;
buildAnnotations(parameterElement, serializedParameter.annotations);
+ buildCodeRange(parameterElement, serializedParameter);
if (serializedParameter.isFunctionTyped) {
FunctionElementImpl parameterTypeElement =
new FunctionElementImpl('', -1);
@@ -1840,6 +1893,7 @@ class _LibraryResynthesizer {
buildDocumentation(
functionTypeAliasElement, serializedTypedef.documentationComment);
buildAnnotations(functionTypeAliasElement, serializedTypedef.annotations);
+ buildCodeRange(functionTypeAliasElement, serializedTypedef);
unitHolder.addTypeAlias(functionTypeAliasElement);
currentTypeParameters.removeLast();
assert(currentTypeParameters.isEmpty);
@@ -1860,6 +1914,7 @@ class _LibraryResynthesizer {
serializedTypeParameter.name, serializedTypeParameter.nameOffset);
typeParameterElement.type = new TypeParameterTypeImpl(typeParameterElement);
buildAnnotations(typeParameterElement, serializedTypeParameter.annotations);
+ buildCodeRange(typeParameterElement, serializedTypeParameter);
return typeParameterElement;
}
@@ -1933,6 +1988,7 @@ class _LibraryResynthesizer {
buildVariableInitializer(element, serializedVariable.initializer);
buildDocumentation(element, serializedVariable.documentationComment);
buildAnnotations(element, serializedVariable.annotations);
+ buildCodeRange(element, serializedVariable);
}
/**
@@ -1947,6 +2003,7 @@ class _LibraryResynthesizer {
FunctionElementImpl initializerElement =
buildLocalFunction(serializedInitializer);
initializerElement.synthetic = true;
+ initializerElement.setCodeRange(null, null);
variable.initializer = initializerElement;
}
@@ -2204,6 +2261,7 @@ class _LibraryResynthesizer {
for (PropertyAccessorElementImpl accessor in unit.accessors) {
elementMap[accessor.identifier] = accessor;
}
+ buildCodeRange(unit, unlinkedUnit);
resynthesizedUnits[absoluteUri] = unit;
resynthesizedElements[absoluteUri] = elementMap;
assert(currentTypeParameters.isEmpty);

Powered by Google App Engine
This is Rietveld 408576698