| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.dart.compiler.DartCompilerListener; | 7 import com.google.dart.compiler.DartCompilerListener; |
| 8 import com.google.dart.compiler.DartSource; | 8 import com.google.dart.compiler.DartSource; |
| 9 import com.google.dart.compiler.Source; | 9 import com.google.dart.compiler.Source; |
| 10 import com.google.dart.compiler.ast.DartComment; | 10 import com.google.dart.compiler.ast.DartComment; |
| 11 import com.google.dart.compiler.ast.DartDeclaration; | 11 import com.google.dart.compiler.ast.DartDeclaration; |
| 12 import com.google.dart.compiler.ast.DartNode; | 12 import com.google.dart.compiler.ast.DartNode; |
| 13 import com.google.dart.compiler.ast.DartNodeTraverser; | 13 import com.google.dart.compiler.ast.ASTVisitor; |
| 14 import com.google.dart.compiler.ast.DartUnit; | 14 import com.google.dart.compiler.ast.DartUnit; |
| 15 import com.google.dart.compiler.metrics.CompilerMetrics; | 15 import com.google.dart.compiler.metrics.CompilerMetrics; |
| 16 import com.google.dart.compiler.util.DartSourceString; | 16 import com.google.dart.compiler.util.DartSourceString; |
| 17 | 17 |
| 18 import java.util.ArrayList; | 18 import java.util.ArrayList; |
| 19 import java.util.Collections; | 19 import java.util.Collections; |
| 20 import java.util.Comparator; | 20 import java.util.Comparator; |
| 21 import java.util.List; | 21 import java.util.List; |
| 22 | 22 |
| 23 /** | 23 /** |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (comments != null) { | 142 if (comments != null) { |
| 143 assignDartComments(unit, comments); | 143 assignDartComments(unit, comments); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return unit; | 146 return unit; |
| 147 } | 147 } |
| 148 | 148 |
| 149 private void assignDartComments(DartUnit unit, List<DartComment> comments) { | 149 private void assignDartComments(DartUnit unit, List<DartComment> comments) { |
| 150 // Collect the AST nodes in a list. | 150 // Collect the AST nodes in a list. |
| 151 final List<DartNode> astNodes = new ArrayList<DartNode>(); | 151 final List<DartNode> astNodes = new ArrayList<DartNode>(); |
| 152 unit.accept(new DartNodeTraverser<DartNode>() { | 152 unit.accept(new ASTVisitor<DartNode>() { |
| 153 @Override | 153 @Override |
| 154 public DartNode visitDeclaration(DartDeclaration<?> node) { | 154 public DartNode visitDeclaration(DartDeclaration<?> node) { |
| 155 astNodes.add(node); | 155 astNodes.add(node); |
| 156 return super.visitNode(node); | 156 return super.visitNode(node); |
| 157 } | 157 } |
| 158 }); | 158 }); |
| 159 | 159 |
| 160 // Collect all the nodes in one list. | 160 // Collect all the nodes in one list. |
| 161 List<DartNode> nodes = new ArrayList<DartNode>(); | 161 List<DartNode> nodes = new ArrayList<DartNode>(); |
| 162 | 162 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 return false; | 205 return false; |
| 206 } | 206 } |
| 207 | 207 |
| 208 private List<DartNode> getChildren(DartNode parent) { | 208 private List<DartNode> getChildren(DartNode parent) { |
| 209 final List<DartNode> children = new ArrayList<DartNode>(); | 209 final List<DartNode> children = new ArrayList<DartNode>(); |
| 210 | 210 |
| 211 parent.visitChildren(new DartNodeTraverser<DartNode>() { | 211 parent.visitChildren(new ASTVisitor<DartNode>() { |
| 212 @Override | 212 @Override |
| 213 public DartNode visitNode(DartNode node) { | 213 public DartNode visitNode(DartNode node) { |
| 214 children.add(node); | 214 children.add(node); |
| 215 return null; | 215 return null; |
| 216 } | 216 } |
| 217 }); | 217 }); |
| 218 | 218 |
| 219 return children; | 219 return children; |
| 220 } | 220 } |
| 221 | 221 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 236 */ | 236 */ |
| 237 private DartComment.Style getCommentStyle(String sourceString, int commentStar
t) { | 237 private DartComment.Style getCommentStyle(String sourceString, int commentStar
t) { |
| 238 if (sourceString.charAt(commentStart + 1) == '/') { | 238 if (sourceString.charAt(commentStart + 1) == '/') { |
| 239 return DartComment.Style.END_OF_LINE; | 239 return DartComment.Style.END_OF_LINE; |
| 240 } else if (sourceString.charAt(commentStart + 2) == '*') { | 240 } else if (sourceString.charAt(commentStart + 2) == '*') { |
| 241 return DartComment.Style.DART_DOC; | 241 return DartComment.Style.DART_DOC; |
| 242 } | 242 } |
| 243 return DartComment.Style.BLOCK; | 243 return DartComment.Style.BLOCK; |
| 244 } | 244 } |
| 245 } | 245 } |
| OLD | NEW |