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

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

Issue 462403005: Move Location factories and RefactoringProblemSeverity.max into the generated classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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/status.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/status.dart b/pkg/analysis_server/lib/src/services/correction/status.dart
index 58ceaf1b9ec9a8f6299cc9670445eec218964664..11d9460ed14bec7ca89c84dd8675de8c8cc978ad 100644
--- a/pkg/analysis_server/lib/src/services/correction/status.dart
+++ b/pkg/analysis_server/lib/src/services/correction/status.dart
@@ -4,109 +4,10 @@
library services.status;
-import 'package:analysis_server/src/protocol2.dart' hide Element;
-import 'package:analysis_server/src/services/correction/source_range.dart';
-import 'package:analysis_server/src/services/search/search_engine.dart';
-import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/element.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/source.dart';
+import 'package:analysis_server/src/protocol2.dart';
/**
- * Creates a new [Location].
- */
-Location createLocation(AnalysisContext context, Source source,
- SourceRange range) {
- int startLine = 0;
- int startColumn = 0;
- {
- LineInfo lineInfo = context.getLineInfo(source);
- if (lineInfo != null) {
- LineInfo_Location offsetLocation = lineInfo.getLocation(range.offset);
- startLine = offsetLocation.lineNumber;
- startColumn = offsetLocation.columnNumber;
- }
- }
- return new Location(
- source.fullName,
- range.offset,
- range.length,
- startLine,
- startColumn);
-}
-
-
-/**
- * Creates a new [Location] for the given [Element].
- */
-Location createLocation_forElement(Element element) {
- AnalysisContext context = element.context;
- Source source = element.source;
- SourceRange range = rangeElementName(element);
- return createLocation(context, source, range);
-}
-
-
-/**
- * Creates a new [Location] for the given [SearchMatch].
- */
-Location createLocation_forMatch(SearchMatch match) {
- Element enclosingElement = match.element;
- return createLocation(
- enclosingElement.context,
- enclosingElement.source,
- match.sourceRange);
-}
-
-
-/**
- * Creates a new [Location] for the given [AstNode].
- */
-Location createLocation_forNode(AstNode node) {
- CompilationUnit unit = node.getAncestor((node) => node is CompilationUnit);
- CompilationUnitElement unitElement = unit.element;
- AnalysisContext context = unitElement.context;
- Source source = unitElement.source;
- SourceRange range = rangeNode(node);
- return createLocation(context, source, range);
-}
-
-
-/**
- * Creates a new [Location] for the given [CompilationUnit].
- */
-Location createLocation_forUnit(CompilationUnit unit, SourceRange range) {
- CompilationUnitElement unitElement = unit.element;
- AnalysisContext context = unitElement.context;
- Source source = unitElement.source;
- return createLocation(context, source, range);
-}
-
-
-RefactoringProblemSeverity _maxSeverity(RefactoringProblemSeverity a,
- RefactoringProblemSeverity b) {
- if (b == null) {
- return a;
- }
- if (a == null) {
- return b;
- } else if (a == RefactoringProblemSeverity.INFO) {
- return b;
- } else if (a == RefactoringProblemSeverity.WARNING) {
- if (b == RefactoringProblemSeverity.ERROR ||
- b == RefactoringProblemSeverity.FATAL) {
- return b;
- }
- } else if (a == RefactoringProblemSeverity.ERROR) {
- if (b == RefactoringProblemSeverity.FATAL) {
- return b;
- }
- }
- return a;
-}
-
-/**
* An outcome of a condition checking operation.
*/
class RefactoringStatus {
@@ -243,7 +144,7 @@ class RefactoringStatus {
return;
}
problems.addAll(other.problems);
- _severity = _maxSeverity(_severity, other.severity);
+ _severity = RefactoringProblemSeverity.max(_severity, other.severity);
}
/**
@@ -285,6 +186,6 @@ class RefactoringStatus {
problems.add(problem);
// update maximum severity
RefactoringProblemSeverity severity = problem.severity;
- _severity = _maxSeverity(_severity, severity);
+ _severity = RefactoringProblemSeverity.max(_severity, severity);
}
}

Powered by Google App Engine
This is Rietveld 408576698