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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart

Issue 2708893002: fasta: Cache relativizeUri(fileUri) on LibraryBuilder and ClassBuilder (or rather it's base class) (Closed)
Patch Set: Reorder import Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.kernel_field_builder; 5 library fasta.kernel_field_builder;
6 6
7 import 'package:kernel/ast.dart' show 7 import 'package:kernel/ast.dart' show
8 Expression, 8 Expression,
9 Field, 9 Field,
10 Library, 10 Library,
11 Name; 11 Name;
12 12
13 import 'kernel_builder.dart' show 13 import 'kernel_builder.dart' show
14 Builder, 14 Builder,
15 FieldBuilder, 15 FieldBuilder,
16 KernelTypeBuilder, 16 KernelTypeBuilder,
17 MetadataBuilder; 17 MetadataBuilder;
18 18
19 import '../util/relativize.dart' show
20 relativizeUri;
21
22 class KernelFieldBuilder extends FieldBuilder<Expression> { 19 class KernelFieldBuilder extends FieldBuilder<Expression> {
23 final Field field; 20 final Field field;
24 final List<MetadataBuilder> metadata; 21 final List<MetadataBuilder> metadata;
25 final KernelTypeBuilder type; 22 final KernelTypeBuilder type;
26 23
27 KernelFieldBuilder(this.metadata, this.type, String name, int modifiers, 24 KernelFieldBuilder(this.metadata, this.type, String name, int modifiers,
28 Builder compilationUnit, int charOffset) 25 Builder compilationUnit, int charOffset)
29 : field = 26 : field =
30 new Field(null, fileUri: relativizeUri(compilationUnit?.fileUri)) 27 new Field(null, fileUri: compilationUnit?.relativeFileUri)
31 ..fileOffset = charOffset, 28 ..fileOffset = charOffset,
32 super(name, modifiers, compilationUnit, charOffset); 29 super(name, modifiers, compilationUnit, charOffset);
33 30
34 void set initializer(Expression value) { 31 void set initializer(Expression value) {
35 field.initializer = value 32 field.initializer = value
36 ..parent = field; 33 ..parent = field;
37 } 34 }
38 35
39 Field build(Library library) { 36 Field build(Library library) {
40 field.name ??= new Name(name, library); 37 field.name ??= new Name(name, library);
41 if (type != null) { 38 if (type != null) {
42 field.type = type.build(); 39 field.type = type.build();
43 } 40 }
44 bool isInstanceMember = !isStatic && !isTopLevel; 41 bool isInstanceMember = !isStatic && !isTopLevel;
45 return field 42 return field
46 ..isFinal = isFinal 43 ..isFinal = isFinal
47 ..isConst = isConst 44 ..isConst = isConst
48 ..hasImplicitGetter = isInstanceMember 45 ..hasImplicitGetter = isInstanceMember
49 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal 46 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal
50 ..isStatic = !isInstanceMember; 47 ..isStatic = !isInstanceMember;
51 } 48 }
52 49
53 Field get target => field; 50 Field get target => field;
54 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698