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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 11464025: dart2js: complain about missing part-of tags. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/diagnostic_listener.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 reportDiagnostic(span, 'Error: $message', api.Diagnostic.ERROR); 759 reportDiagnostic(span, 'Error: $message', api.Diagnostic.ERROR);
760 throw new CompilerCancelledException(message.toString()); 760 throw new CompilerCancelledException(message.toString());
761 } 761 }
762 762
763 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { 763 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) {
764 // TODO(ahe): The names Diagnostic and api.Diagnostic are in 764 // TODO(ahe): The names Diagnostic and api.Diagnostic are in
765 // conflict. Fix it. 765 // conflict. Fix it.
766 reportDiagnostic(span, "$message", kind); 766 reportDiagnostic(span, "$message", kind);
767 } 767 }
768 768
769 void onDeprecatedFeature(Spannable span, String feature) { 769 /// Returns true if a diagnostic was emitted.
770 bool onDeprecatedFeature(Spannable span, String feature) {
770 if (currentElement == null) 771 if (currentElement == null)
771 throw new SpannableAssertionFailure(span, feature); 772 throw new SpannableAssertionFailure(span, feature);
772 if (!checkDeprecationInSdk && 773 if (!checkDeprecationInSdk &&
773 currentElement.getLibrary().isPlatformLibrary) { 774 currentElement.getLibrary().isPlatformLibrary) {
774 return; 775 return false;
775 } 776 }
776 var kind = rejectDeprecatedFeatures 777 var kind = rejectDeprecatedFeatures
777 ? api.Diagnostic.ERROR : api.Diagnostic.WARNING; 778 ? api.Diagnostic.ERROR : api.Diagnostic.WARNING;
778 var message = rejectDeprecatedFeatures 779 var message = rejectDeprecatedFeatures
779 ? MessageKind.DEPRECATED_FEATURE_ERROR.error([feature]) 780 ? MessageKind.DEPRECATED_FEATURE_ERROR.error([feature])
780 : MessageKind.DEPRECATED_FEATURE_WARNING.error([feature]); 781 : MessageKind.DEPRECATED_FEATURE_WARNING.error([feature]);
781 reportMessage(spanFromSpannable(span), message, kind); 782 reportMessage(spanFromSpannable(span), message, kind);
783 return true;
782 } 784 }
783 785
784 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); 786 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind);
785 787
786 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { 788 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) {
787 if (begin == null || end == null) { 789 if (begin == null || end == null) {
788 // TODO(ahe): We can almost always do better. Often it is only 790 // TODO(ahe): We can almost always do better. Often it is only
789 // end that is null. Otherwise, we probably know the current 791 // end that is null. Otherwise, we probably know the current
790 // URI. 792 // URI.
791 throw 'Cannot find tokens to produce error message.'; 793 throw 'Cannot find tokens to produce error message.';
792 } 794 }
793 if (uri == null && currentElement != null) { 795 if (uri == null && currentElement != null) {
794 uri = currentElement.getCompilationUnit().script.uri; 796 uri = currentElement.getCompilationUnit().script.uri;
795 } 797 }
796 return SourceSpan.withCharacterOffsets(begin, end, 798 return SourceSpan.withCharacterOffsets(begin, end,
797 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); 799 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset));
798 } 800 }
799 801
800 SourceSpan spanFromNode(Node node, [Uri uri]) { 802 SourceSpan spanFromNode(Node node, [Uri uri]) {
801 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); 803 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri);
802 } 804 }
803 805
804 SourceSpan spanFromElement(Element element) { 806 SourceSpan spanFromElement(Element element) {
805 if (Elements.isErroneousElement(element)) { 807 if (Elements.isErroneousElement(element)) {
806 element = element.enclosingElement; 808 element = element.enclosingElement;
807 } 809 }
808 if (element.position() == null) { 810 if (element.position() == null && !element.isCompilationUnit()) {
809 // Sometimes, the backend fakes up elements that have no 811 // Sometimes, the backend fakes up elements that have no
810 // position. So we use the enclosing element instead. It is 812 // position. So we use the enclosing element instead. It is
811 // not a good error location, but cancel really is "internal 813 // not a good error location, but cancel really is "internal
812 // error" or "not implemented yet", so the vicinity is good 814 // error" or "not implemented yet", so the vicinity is good
813 // enough for now. 815 // enough for now.
814 element = element.enclosingElement; 816 element = element.enclosingElement;
815 // TODO(ahe): I plan to overhaul this infrastructure anyways. 817 // TODO(ahe): I plan to overhaul this infrastructure anyways.
816 } 818 }
817 if (element == null) { 819 if (element == null) {
818 element = currentElement; 820 element = currentElement;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // TODO(johnniwinther): Use [spannable] and [message] to provide better 942 // TODO(johnniwinther): Use [spannable] and [message] to provide better
941 // information on assertion errors. 943 // information on assertion errors.
942 if (condition is Function){ 944 if (condition is Function){
943 condition = condition(); 945 condition = condition();
944 } 946 }
945 if (spannable == null || !condition) { 947 if (spannable == null || !condition) {
946 throw new SpannableAssertionFailure(spannable, message); 948 throw new SpannableAssertionFailure(spannable, message);
947 } 949 }
948 return true; 950 return true;
949 } 951 }
OLDNEW
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/diagnostic_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698