 Chromium Code Reviews
 Chromium Code Reviews Issue 2815713003:
  Issue 29109. Resynthesize PrefixElement(s) to fix constants evaluation.  (Closed)
    
  
    Issue 2815713003:
  Issue 29109. Resynthesize PrefixElement(s) to fix constants evaluation.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:io'; | 5 import 'dart:io'; | 
| 6 | 6 | 
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; | 
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; | 
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; | 
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; | 
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 | 800 | 
| 801 String onlyName(String uri) { | 801 String onlyName(String uri) { | 
| 802 if (uri.startsWith('file:///')) { | 802 if (uri.startsWith('file:///')) { | 
| 803 return uri.substring(uri.lastIndexOf('/') + 1); | 803 return uri.substring(uri.lastIndexOf('/') + 1); | 
| 804 } | 804 } | 
| 805 return uri; | 805 return uri; | 
| 806 } | 806 } | 
| 807 | 807 | 
| 808 ElementLocation location = element.location; | 808 ElementLocation location = element.location; | 
| 809 List<String> components = location.components.toList(); | 809 List<String> components = location.components.toList(); | 
| 810 if (components.length > 1) { | |
| 
Brian Wilkerson
2017/04/11 18:16:35
Shouldn't this be ">= 1"? (and similarly on line 8
 
scheglov
2017/04/11 18:27:13
Yes, I think you're right, it's cleaner to check f
 | |
| 811 components[0] = onlyName(components[0]); | |
| 812 } | |
| 810 if (components.length > 2) { | 813 if (components.length > 2) { | 
| 811 components[0] = onlyName(components[0]); | |
| 812 components[1] = onlyName(components[1]); | 814 components[1] = onlyName(components[1]); | 
| 813 if (components[0] == components[1]) { | 815 if (components[0] == components[1]) { | 
| 814 components.removeAt(0); | 816 components.removeAt(0); | 
| 815 } | 817 } | 
| 816 } | 818 } | 
| 817 return components.join(';'); | 819 return components.join(';'); | 
| 818 } | 820 } | 
| 819 } | 821 } | 
| 820 | 822 | 
| 821 class _Replacement { | 823 class _Replacement { | 
| 822 final int offset; | 824 final int offset; | 
| 823 final int end; | 825 final int end; | 
| 824 final String text; | 826 final String text; | 
| 825 _Replacement(this.offset, this.end, this.text); | 827 _Replacement(this.offset, this.end, this.text); | 
| 826 } | 828 } | 
| OLD | NEW |