OLD | NEW |
---|---|
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 package com.google.dart.compiler.type; | 4 package com.google.dart.compiler.type; |
5 | 5 |
6 import com.google.common.base.Joiner; | 6 import com.google.common.base.Joiner; |
7 import com.google.common.collect.Iterables; | 7 import com.google.common.collect.Iterables; |
8 import com.google.common.collect.Lists; | 8 import com.google.common.collect.Lists; |
9 import com.google.common.collect.Maps; | 9 import com.google.common.collect.Maps; |
10 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; | 10 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; |
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2916 | 2916 |
2917 public void test_variableUsedAsType() throws Exception { | 2917 public void test_variableUsedAsType() throws Exception { |
2918 AnalyzeLibraryResult libraryResult = analyzeLibrary( | 2918 AnalyzeLibraryResult libraryResult = analyzeLibrary( |
2919 "// filler filler filler filler filler filler filler filler filler fille r", | 2919 "// filler filler filler filler filler filler filler filler filler fille r", |
2920 "var func;", | 2920 "var func;", |
2921 "func i;"); | 2921 "func i;"); |
2922 assertErrors( | 2922 assertErrors( |
2923 libraryResult.getErrors(), | 2923 libraryResult.getErrors(), |
2924 errEx(TypeErrorCode.NOT_A_TYPE, 3, 1, 4)); | 2924 errEx(TypeErrorCode.NOT_A_TYPE, 3, 1, 4)); |
2925 } | 2925 } |
2926 | |
2927 public void test_metadata_deprecated() throws Exception { | |
2928 AnalyzeLibraryResult libraryResult = analyzeLibrary( | |
2929 "// filler filler filler filler filler filler filler filler filler fille r", | |
2930 "// @deprecated", | |
2931 "ttt() {}", | |
2932 "// @deprecated", | |
Brian Wilkerson
2012/06/29 16:17:49
Does deprecating a class implicitly deprecate ever
scheglov
2012/06/29 20:11:57
Constructor invocation has form: Type[.nameOfConst
Brian Wilkerson
2012/06/29 20:20:28
OK. I understand the reasoning behind the behavior
| |
2933 "class A {", | |
2934 " // @deprecated", | |
2935 " var fff;", | |
2936 " // @deprecated", | |
2937 " mmm() {}", | |
2938 "}", | |
2939 "main() {", | |
2940 " ttt();", | |
2941 " A a = new A();", | |
2942 " a.fff = 0;", | |
2943 " a.mmm();", | |
2944 "}", | |
2945 ""); | |
2946 assertErrors( | |
2947 libraryResult.getErrors(), | |
2948 errEx(TypeErrorCode.DEPRECATED_ELEMENT, 13, 3, 1), | |
2949 errEx(TypeErrorCode.DEPRECATED_ELEMENT, 13, 13, 1), | |
2950 errEx(TypeErrorCode.DEPRECATED_ELEMENT, 12, 3, 3), | |
2951 errEx(TypeErrorCode.DEPRECATED_ELEMENT, 14, 5, 3), | |
2952 errEx(TypeErrorCode.DEPRECATED_ELEMENT, 15, 5, 3)); | |
2953 } | |
2926 | 2954 |
2927 private static <T extends DartNode> T findNode( | 2955 private static <T extends DartNode> T findNode( |
2928 AnalyzeLibraryResult libraryResult, | 2956 AnalyzeLibraryResult libraryResult, |
2929 final Class<T> clazz, | 2957 final Class<T> clazz, |
2930 String pattern) { | 2958 String pattern) { |
2931 final int index = libraryResult.source.indexOf(pattern); | 2959 final int index = libraryResult.source.indexOf(pattern); |
2932 assertTrue(index != -1); | 2960 assertTrue(index != -1); |
2933 final AtomicReference<T> result = new AtomicReference<T>(); | 2961 final AtomicReference<T> result = new AtomicReference<T>(); |
2934 Iterator<DartUnit> unitsIterator = libraryResult.getLibraryUnitResult().getU nits().iterator(); | 2962 Iterator<DartUnit> unitsIterator = libraryResult.getLibraryUnitResult().getU nits().iterator(); |
2935 unitsIterator.next(); | 2963 unitsIterator.next(); |
2936 DartUnit unit = unitsIterator.next(); | 2964 DartUnit unit = unitsIterator.next(); |
2937 unit.accept(new ASTVisitor<Void>() { | 2965 unit.accept(new ASTVisitor<Void>() { |
2938 @Override | 2966 @Override |
2939 @SuppressWarnings("unchecked") | 2967 @SuppressWarnings("unchecked") |
2940 public Void visitNode(DartNode node) { | 2968 public Void visitNode(DartNode node) { |
2941 SourceInfo sourceInfo = node.getSourceInfo(); | 2969 SourceInfo sourceInfo = node.getSourceInfo(); |
2942 if (sourceInfo.getOffset() <= index | 2970 if (sourceInfo.getOffset() <= index |
2943 && index < sourceInfo.getEnd() | 2971 && index < sourceInfo.getEnd() |
2944 && clazz.isInstance(node)) { | 2972 && clazz.isInstance(node)) { |
2945 result.set((T) node); | 2973 result.set((T) node); |
2946 } | 2974 } |
2947 return super.visitNode(node); | 2975 return super.visitNode(node); |
2948 } | 2976 } |
2949 }); | 2977 }); |
2950 return result.get(); | 2978 return result.get(); |
2951 } | 2979 } |
2952 } | 2980 } |
OLD | NEW |