|
16 | 16 | import java.util.Collection;
|
17 | 17 | import java.util.Collections;
|
18 | 18 | import java.util.Iterator;
|
19 |
| -import java.util.List; |
20 | 19 |
|
21 | 20 | import org.eclipse.emf.common.util.EList;
|
22 | 21 | import org.eclipse.emf.common.util.WrappedException;
|
|
122 | 121 | import eu.numberfour.n4js.ts.typeRefs.TypeRef;
|
123 | 122 | import eu.numberfour.n4js.ts.types.TypeVariable;
|
124 | 123 | import eu.numberfour.n4js.utils.N4JSLanguageUtils;
|
125 |
| -import eu.numberfour.n4jsx.n4JSX.JSXAttribute; |
126 |
| -import eu.numberfour.n4jsx.n4JSX.JSXChild; |
127 |
| -import eu.numberfour.n4jsx.n4JSX.JSXElement; |
128 |
| -import eu.numberfour.n4jsx.n4JSX.JSXElementName; |
129 |
| -import eu.numberfour.n4jsx.n4JSX.JSXExpression; |
130 |
| -import eu.numberfour.n4jsx.n4JSX.JSXPropertyAttribute; |
131 |
| -import eu.numberfour.n4jsx.n4JSX.JSXSpreadAttribute; |
132 |
| -import eu.numberfour.n4jsx.n4JSX.JSXText; |
133 |
| -import eu.numberfour.n4jsx.n4JSX.N4JSXPackage; |
134 | 124 |
|
135 | 125 | /**
|
136 | 126 | * Traverses an intermediate model and serializes it to a {@link SourceMapAwareAppendable}. Client code should only use
|
@@ -180,9 +170,6 @@ protected Boolean doSwitch(int classifierID, EObject elemInIM) {
|
180 | 170 |
|
181 | 171 | @Override
|
182 | 172 | public Boolean defaultCase(EObject object) {
|
183 |
| - if (object.eClass().getEPackage() == N4JSXPackage.eINSTANCE) { // TODO IDE-2416 remove this |
184 |
| - return caseJSX(object); |
185 |
| - } |
186 | 173 | throw new IllegalStateException(
|
187 | 174 | "PrettyPrinterSwitch missing a case for objects of type " + object.eClass().getName());
|
188 | 175 | }
|
@@ -937,102 +924,6 @@ public Boolean caseSnippet(Snippet original) {
|
937 | 924 | return DONE;
|
938 | 925 | }
|
939 | 926 |
|
940 |
| - // ############################################################################################################### |
941 |
| - // JSX support |
942 |
| - // TODO IDE-2416 |
943 |
| - |
944 |
| - private Boolean caseJSX(EObject object) { |
945 |
| - if (object instanceof JSXElement) { |
946 |
| - return caseJSXElement((JSXElement) object); |
947 |
| - } else if (object instanceof JSXText) { |
948 |
| - return caseJSXText((JSXText) object); |
949 |
| - } else if (object instanceof JSXExpression) { |
950 |
| - return caseJSXExpression((JSXExpression) object); |
951 |
| - } else if (object instanceof JSXElementName) { |
952 |
| - return caseJSXElementName((JSXElementName) object); |
953 |
| - } else if (object instanceof JSXPropertyAttribute) { |
954 |
| - return caseJSXPropertyAttribute((JSXPropertyAttribute) object); |
955 |
| - } else if (object instanceof JSXSpreadAttribute) { |
956 |
| - return caseJSXSpreadAttribute((JSXSpreadAttribute) object); |
957 |
| - } else { |
958 |
| - throw new UnsupportedOperationException("unsupported type of object: " + object.eClass().getName()); |
959 |
| - } |
960 |
| - } |
961 |
| - |
962 |
| - private Boolean caseJSXElement(JSXElement object) { |
963 |
| - write("<"); |
964 |
| - if (object.getJsxElementName() == null) |
965 |
| - throw new IllegalStateException( |
966 |
| - "JSX element has no name " + object.eClass().getName()); |
967 |
| - |
968 |
| - doSwitch(object.getJsxElementName()); |
969 |
| - |
970 |
| - if (!object.getJsxAttributes().isEmpty()) { |
971 |
| - for (JSXAttribute attr : object.getJsxAttributes()) { |
972 |
| - doSwitch(attr); |
973 |
| - } |
974 |
| - } |
975 |
| - |
976 |
| - JSXElementName jsxClosingName = object.getJsxClosingName(); |
977 |
| - if (jsxClosingName == null) { |
978 |
| - write("/>"); |
979 |
| - } else { |
980 |
| - write(">"); |
981 |
| - List<JSXChild> jsxChildren = object.getJsxChildren(); |
982 |
| - if (jsxChildren.isEmpty() == false) { |
983 |
| - for (JSXChild child : jsxChildren) { |
984 |
| - doSwitch(child); |
985 |
| - } |
986 |
| - } |
987 |
| - write("</"); |
988 |
| - doSwitch(object.getJsxClosingName()); |
989 |
| - write(">"); |
990 |
| - } |
991 |
| - |
992 |
| - return DONE; |
993 |
| - } |
994 |
| - |
995 |
| - private Boolean caseJSXText(@SuppressWarnings("unused") JSXText object) { |
996 |
| - write("/* TODO JSXText not supported */"); |
997 |
| - return DONE; |
998 |
| - } |
999 |
| - |
1000 |
| - private Boolean caseJSXExpression(JSXExpression object) { |
1001 |
| - write("{"); |
1002 |
| - doSwitch(object.getExpression()); |
1003 |
| - write("}"); |
1004 |
| - return DONE; |
1005 |
| - } |
1006 |
| - |
1007 |
| - private Boolean caseJSXElementName(JSXElementName object) { |
1008 |
| - write(((IdentifierRef_IM) object.getExpression()).getIdAsText()); |
1009 |
| - return DONE; |
1010 |
| - } |
1011 |
| - |
1012 |
| - private Boolean caseJSXPropertyAttribute(JSXPropertyAttribute object) { |
1013 |
| - write(' '); |
1014 |
| - write(object.getPropertyAsText()); |
1015 |
| - write("="); |
1016 |
| - final Expression value = object.getJsxAttributeValue(); |
1017 |
| - final boolean requiresCurlyBraces = !(value instanceof StringLiteral); |
1018 |
| - if (requiresCurlyBraces) { |
1019 |
| - write('{'); |
1020 |
| - doSwitch(value); |
1021 |
| - write('}'); |
1022 |
| - } else { |
1023 |
| - doSwitch(value); |
1024 |
| - } |
1025 |
| - return DONE; |
1026 |
| - } |
1027 |
| - |
1028 |
| - private Boolean caseJSXSpreadAttribute(JSXSpreadAttribute object) { |
1029 |
| - write("{"); |
1030 |
| - write("... "); |
1031 |
| - doSwitch(object.getExpression()); |
1032 |
| - write("}"); |
1033 |
| - return DONE; |
1034 |
| - } |
1035 |
| - |
1036 | 927 | // ###############################################################################################################
|
1037 | 928 | // UTILITY AND CONVENIENCE METHODS
|
1038 | 929 |
|
|
0 commit comments