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

Unified Diff: pkg/analysis_server/tool/spec/codegen_java_types.dart

Issue 1431683002: Refactor analysis server code generation to re-use logic from analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/tool/spec/codegen_java_types.dart
diff --git a/pkg/analysis_server/tool/spec/codegen_java_types.dart b/pkg/analysis_server/tool/spec/codegen_java_types.dart
index 2dec54ce4d4fad18a1e1700022c33663bce86daf..0389ea4db066e88b678357f98b6d024d4d989cde 100644
--- a/pkg/analysis_server/tool/spec/codegen_java_types.dart
+++ b/pkg/analysis_server/tool/spec/codegen_java_types.dart
@@ -7,18 +7,54 @@
*/
library java.generator.types;
+import 'package:analyzer/src/codegen/tools.dart';
import 'package:html/dom.dart' as dom;
import 'api.dart';
import 'codegen_java.dart';
-import 'codegen_tools.dart';
import 'from_html.dart';
import 'implied_types.dart';
-final String pathToGenTypes = 'generated/java/types/';
+/**
+ * A map between the field names and values for the Element object such as:
+ *
+ * private static final int ABSTRACT = 0x01;
+ */
+const Map<String, String> _extraFieldsOnElement = const {
+ 'ABSTRACT': '0x01',
+ 'CONST': '0x02',
+ 'FINAL': '0x04',
+ 'TOP_LEVEL_STATIC': '0x08',
+ 'PRIVATE': '0x10',
+ 'DEPRECATED': '0x20',
+};
-final GeneratedDirectory targetDir = new GeneratedDirectory(pathToGenTypes, () {
- Api api = readApi();
+/**
+ * A map between the method names and field names to generate additional methods on the Element object:
+ *
+ * public boolean isFinal() {
+ * return (flags & FINAL) != 0;
+ * }
+ */
+const Map<String, String> _extraMethodsOnElement = const {
+ 'isAbstract': 'ABSTRACT',
+ 'isConst': 'CONST',
+ 'isDeprecated': 'DEPRECATED',
+ 'isFinal': 'FINAL',
+ 'isPrivate': 'PRIVATE',
+ 'isTopLevelOrStatic': 'TOP_LEVEL_STATIC',
+};
+
+/**
+ * Type references in the spec that are named something else in Java.
+ */
+const Map<String, String> _typeRenames = const {'Override': 'OverrideMember',};
+
+final String pathToGenTypes = 'tool/spec/generated/java/types';
+
+final GeneratedDirectory targetDir =
+ new GeneratedDirectory(pathToGenTypes, (String pkgPath) {
+ Api api = readApi(pkgPath);
Map<String, ImpliedType> impliedTypes = computeImpliedTypes(api);
Map<String, FileContentsComputer> map =
new Map<String, FileContentsComputer>();
@@ -37,7 +73,7 @@ final GeneratedDirectory targetDir = new GeneratedDirectory(pathToGenTypes, () {
if (_typeRenames.containsKey(typeNameInSpec)) {
typeNameInJava = _typeRenames[typeNameInSpec];
}
- map['${typeNameInJava}.java'] = () {
+ map['${typeNameInJava}.java'] = (String pkgPath) {
String superclassName = null;
if (isRefactoringFeedback) {
superclassName = 'RefactoringFeedback';
@@ -67,51 +103,10 @@ final GeneratedDirectory targetDir = new GeneratedDirectory(pathToGenTypes, () {
}
}
}
+ print(map.keys);
return map;
});
-/**
- * A map between the field names and values for the Element object such as:
- *
- * private static final int ABSTRACT = 0x01;
- */
-const Map<String, String> _extraFieldsOnElement = const {
- 'ABSTRACT': '0x01',
- 'CONST': '0x02',
- 'FINAL': '0x04',
- 'TOP_LEVEL_STATIC': '0x08',
- 'PRIVATE': '0x10',
- 'DEPRECATED': '0x20',
-};
-
-/**
- * A map between the method names and field names to generate additional methods on the Element object:
- *
- * public boolean isFinal() {
- * return (flags & FINAL) != 0;
- * }
- */
-const Map<String, String> _extraMethodsOnElement = const {
- 'isAbstract': 'ABSTRACT',
- 'isConst': 'CONST',
- 'isDeprecated': 'DEPRECATED',
- 'isFinal': 'FINAL',
- 'isPrivate': 'PRIVATE',
- 'isTopLevelOrStatic': 'TOP_LEVEL_STATIC',
-};
-
-/**
- * Type references in the spec that are named something else in Java.
- */
-const Map<String, String> _typeRenames = const {'Override': 'OverrideMember',};
-
-/**
- * Translate spec_input.html into AnalysisServer.java.
- */
-main() {
- targetDir.generate();
-}
-
class CodegenJavaType extends CodegenJavaVisitor {
final String className;
final String superclassName;
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_java.dart ('k') | pkg/analysis_server/tool/spec/codegen_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698