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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1146573003: Quick Fix for missing 'part of' directive. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/analysis_server/lib/src/services/correction/fix_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 1c7e134d39a819dcd4f7981d18613f45e54b4989..a56658448294567d53efc910f6dd1963e3561665 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -143,6 +143,9 @@ class FixProcessor {
CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT) {
_addFix_createConstructorSuperImplicit();
}
+ if (errorCode == CompileTimeErrorCode.PART_OF_NON_PART) {
+ _addFix_addPartOfDirective();
+ }
if (errorCode ==
CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT) {
_addFix_createConstructorSuperExplicit();
@@ -344,6 +347,25 @@ class FixProcessor {
return false;
}
+ void _addFix_addPartOfDirective() {
+ // TODO(scheglov)
Brian Wilkerson 2015/05/18 22:22:58 Left over?
+ if (node is SimpleStringLiteral && node.parent is PartDirective) {
+ PartDirective directive = node.parent;
+ Source partSource = directive.source;
+ CompilationUnit partUnit =
+ context.getResolvedCompilationUnit2(partSource, unitSource);
+ if (partUnit != null) {
+ CorrectionUtils partUtils = new CorrectionUtils(partUnit);
+ CorrectionUtils_InsertDesc desc = partUtils.getInsertDescTop();
+ String libraryName = unitLibraryElement.name;
+ _addInsertEdit(desc.offset,
+ '${desc.prefix}part of $libraryName;$eol${desc.suffix}',
+ partUnit.element);
+ _addFix(DartFixKind.ADD_PART_OF, []);
+ }
+ }
+ }
+
void _addFix_boolInsteadOfBoolean() {
SourceRange range = rf.rangeError(error);
_addReplaceEdit(range, 'bool');
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix.dart ('k') | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698