big refactoring for StandardClasses class

This commit is contained in:
Pavel Talanov
2012-01-26 14:15:02 +04:00
parent a17697702a
commit 940824db34
5 changed files with 286 additions and 281 deletions
+169 -153
View File
@@ -14,9 +14,11 @@
<bookmark url="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/DescriptorUtils.java" line="155" mnemonic="2" />
</component>
<component name="ChangeListManager">
<list default="true" id="f02ef53d-47a4-4f5e-a1aa-3df68aae9b20" name="Default" comment="">
<list default="true" id="f02ef53d-47a4-4f5e-a1aa-3df68aae9b20" name="Default" comment="big refactoring for StandardClasses class">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js" afterPath="$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java" afterPath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java" afterPath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java" afterPath="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt" afterPath="$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt" />
</list>
<ignored path="k2js.iws" />
@@ -278,55 +280,76 @@
<splitter split-orientation="horizontal" split-proportion="0.63900137">
<split-first>
<leaf>
<file leaf-file-name="whenType.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/cases/whenType.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="whenType.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenType.js">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="whenNotValue.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotValue.js">
<provider selected="true" editor-type-id="text-editor">
<state line="10" column="41" selection-start="203" selection-end="203" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="JsBreak.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/src/com/google/dart/compiler/backend/js/ast/JsBreak.java">
<provider selected="true" editor-type-id="text-editor">
<state line="9" column="19" selection-start="340" selection-end="340" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="kotlin_lib.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/kotlin_lib.js">
<provider selected="true" editor-type-id="text-editor">
<state line="791" column="60" selection-start="22661" selection-end="22661" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="whenNotType.js" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="whenNotType.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="25" selection-start="369" selection-end="369" vertical-scroll-proportion="0.25705644">
<state line="10" column="5" selection-start="201" selection-end="201" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="whenNotType.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/cases/whenNotType.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="11" column="44" selection-start="122" selection-end="122" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="StdlibTest.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/StdlibTest.java">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="16" selection-start="305" selection-end="305" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Filter.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="35" column="4" selection-start="843" selection-end="843" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ReferenceTranslator.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="97" selection-start="2341" selection-end="2341" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="StandardClasses.java" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java">
<provider selected="true" editor-type-id="text-editor">
<state line="73" column="11" selection-start="2488" selection-end="2488" vertical-scroll-proportion="0.028846154">
<folding>
<element signature="e#5837#5853#0" expanded="true" />
<element signature="e#5932#5949#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TranslationContext.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="33" selection-start="1773" selection-end="1773" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="JsDeclarations.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/stdlib/ktSrc/jssupport/JsDeclarations.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -344,25 +367,7 @@
<file leaf-file-name="WhenTranslator.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/expression/WhenTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="22" selection-start="1790" selection-end="1790" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="CallTranslator.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="85" column="13" selection-start="4057" selection-end="4057" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="PsiUtils.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java">
<provider selected="true" editor-type-id="text-editor">
<state line="77" column="11" selection-start="2945" selection-end="2945" vertical-scroll-proportion="0.0">
<state line="49" column="0" selection-start="1743" selection-end="1743" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -420,7 +425,7 @@
<file leaf-file-name="Iterators.jet" pinned="false" current="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/src/jet/Iterators.jet">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.14447592">
<folding />
</state>
</provider>
@@ -487,22 +492,22 @@
<component name="IdeDocumentHistory">
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/TupleTest.java" />
<option value="$PROJECT_DIR$/translator/testFiles/tuple/cases/multipleMembers.kt" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/K2JSTranslator.java" />
<option value="$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/StdlibTest.java" />
<option value="$PROJECT_DIR$/../../Kotlin/jet/stdlib/ktSrc/jssupport/JsSupport.jet" />
<option value="$PROJECT_DIR$/translator/testFiles/examples/cases/inheritedMethod.jet" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/ClassSorter.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/declaration/ClassTranslator.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java" />
<option value="$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt" />
<option value="$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotValue.js" />
<option value="$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js" />
<option value="$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java" />
<option value="$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java" />
</list>
</option>
</component>
@@ -1015,7 +1020,7 @@
<recent name="org.jetbrains.k2js.test.examples" />
</key>
</component>
<component name="RunManager" selected="JUnit.StdlibTest">
<component name="RunManager" selected="JUnit.All in jetTests">
<configuration default="false" name="ExtensionPropertyTest.propertyWithGetterAndSetter" type="JUnit" factoryName="JUnit" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
@@ -1179,6 +1184,14 @@
<option name="Maven.BeforeRunTask" enabled="false" />
</method>
</configuration>
<configuration default="true" type="FlexUnitRunConfigurationType" factoryName="FlexUnit" adl_options="" air_descriptor_path="" air_program_params="" air_publisher_id="" air_root_dir_path="" air_run_mode="AppDescriptor" browser_family="FIREFOX" class_name="" debugger_sdk="Module SDK" html_or_swf_file_path="" launcher_type="OSDefault" main_class_name="" method_name="" module_name="" output_log_level="" package_name="" player_path="FlashPlayer.exe" run_mode="HtmlOrSwfFile" run_trusted="true" scope="Class" url_to_launch="http://">
<method>
<option name="AntTarget" enabled="false" />
<option name="BuildArtifacts" enabled="false" />
<option name="Make" enabled="true" />
<option name="Maven.BeforeRunTask" enabled="false" />
</method>
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
@@ -1327,12 +1340,12 @@
<list size="8">
<item index="0" class="java.lang.String" itemvalue="JUnit.ExtensionPropertyTest.propertyWithGetterAndSetter" />
<item index="1" class="java.lang.String" itemvalue="JUnit.ArrayListTest.isEmpty" />
<item index="2" class="java.lang.String" itemvalue="JUnit.TupleTest" />
<item index="3" class="java.lang.String" itemvalue="JUnit.StdlibTest" />
<item index="4" class="java.lang.String" itemvalue="JUnit.StdlibTest.filter" />
<item index="5" class="java.lang.String" itemvalue="Applet.Applet" />
<item index="6" class="java.lang.String" itemvalue="JUnit.tests" />
<item index="7" class="java.lang.String" itemvalue="JUnit.All in jetTests" />
<item index="2" class="java.lang.String" itemvalue="Applet.Applet" />
<item index="3" class="java.lang.String" itemvalue="JUnit.tests" />
<item index="4" class="java.lang.String" itemvalue="JUnit.All in jetTests" />
<item index="5" class="java.lang.String" itemvalue="JUnit.TupleTest" />
<item index="6" class="java.lang.String" itemvalue="JUnit.StdlibTest" />
<item index="7" class="java.lang.String" itemvalue="JUnit.StdlibTest.filter" />
</list>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
@@ -1401,11 +1414,12 @@
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1176" extended-state="6" />
<editor active="false" />
<editor active="true" />
<layout>
<window_info id="Data Sources" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32853025" sideWeight="0.49812934" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756963" sideWeight="0.4216996" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24973261" sideWeight="0.7183908" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.34774256" sideWeight="0.7733832" order="3" side_tool="false" content_ui="tabs" />
<window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32949087" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
@@ -1413,20 +1427,19 @@
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32977018" sideWeight="0.6705091" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32853025" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.22382325" sideWeight="0.41956174" order="9" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32949087" sideWeight="0.49599144" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Metrics" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756963" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.20363443" sideWeight="0.7588857" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32977018" sideWeight="0.6570605" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3997862" sideWeight="0.6705998" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.20791021" sideWeight="0.7463977" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.2536023" sideWeight="0.8530198" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.20791021" sideWeight="0.7463977" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2536023" sideWeight="0.8530198" order="2" side_tool="false" content_ui="tabs" />
<window_info id="CodeWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.0908605" sideWeight="0.7146974" order="2" side_tool="false" content_ui="combo" />
<window_info id="ResolveWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756963" sideWeight="0.4216996" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.22382325" sideWeight="0.41956174" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39865515" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="JsTestDriver Server" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32907662" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" />
@@ -1468,7 +1481,7 @@
<option name="CREATE_PATCH_EXPAND_DETAILS_DEFAULT" value="true" />
<option name="SHOW_FILE_HISTORY_DETAILS" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
<option name="LAST_COMMIT_MESSAGE" value="expression as statement bug fixed" />
<option name="LAST_COMMIT_MESSAGE" value="add filter test" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@@ -1481,7 +1494,6 @@
<option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
<MESSAGE value="migrated from JetNamespace to NamespaceDescriptor and JetFile /* Lots of tests fail due to: missing array methods and unconverted tests*/" />
<MESSAGE value="migrated tests to new syntax /*tests fail due to migrated size problem*/" />
<MESSAGE value="resolved part of the problem" />
<MESSAGE value="changed tests not to use std lib for now /*all tests pass*/" />
@@ -1506,6 +1518,7 @@
<MESSAGE value="migrated to new code" />
<MESSAGE value="tuple support and tests" />
<MESSAGE value="expression as statement bug fixed" />
<MESSAGE value="add filter test" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
@@ -1515,93 +1528,79 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java">
<provider selected="true" editor-type-id="text-editor">
<state line="77" column="11" selection-start="2945" selection-end="2945" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/tuple/cases/twoElements.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="4" column="39" selection-start="108" selection-end="108" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/tuple/cases/multipleMembers.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="81" selection-start="446" selection-end="446" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/TupleTest.java">
<provider selected="true" editor-type-id="text-editor">
<state line="23" column="41" selection-start="492" selection-end="492" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/src/jet/Numbers.jet">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="11" selection-start="10" selection-end="11" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/src/jet/Iterables.jet">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/matchNullableType.js">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/general/TranslatorVisitor.java">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/expression/WhenTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="17" column="0" selection-start="539" selection-end="539" vertical-scroll-proportion="0.0">
<state line="49" column="0" selection-start="1743" selection-end="1743" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitor.java">
<provider selected="true" editor-type-id="text-editor">
<state line="146" column="0" selection-start="4560" selection-end="4690" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/TranslationTest.java">
<provider selected="true" editor-type-id="text-editor">
<state line="2" column="0" selection-start="34" selection-end="34" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/StringTest.java">
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="13" selection-start="104" selection-end="104" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/src/jet/Iterators.jet">
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenType.js">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/cases/whenNotType.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="11" column="44" selection-start="122" selection-end="122" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotValue.js">
<provider selected="true" editor-type-id="text-editor">
<state line="10" column="41" selection-start="203" selection-end="203" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js">
<provider selected="true" editor-type-id="text-editor">
<state line="10" column="5" selection-start="201" selection-end="201" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/test/org/jetbrains/k2js/test/StdlibTest.java">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="16" selection-start="305" selection-end="305" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/src/com/google/dart/compiler/backend/js/ast/JsBreak.java">
<provider selected="true" editor-type-id="text-editor">
<state line="9" column="19" selection-start="340" selection-end="340" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/stdlib/cases/Filter.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="54" column="33" selection-start="1513" selection-end="1513" vertical-scroll-proportion="0.0">
<state line="35" column="4" selection-start="843" selection-end="843" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/matchNullableType.js">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<state line="85" column="13" selection-start="4057" selection-end="4057" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java">
<provider selected="true" editor-type-id="text-editor">
<state line="77" column="11" selection-start="2945" selection-end="2945" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -1613,20 +1612,37 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/cases/multipleCases.kt">
<entry file="file://$PROJECT_DIR$/../../Kotlin/jet/stdlib/ktSrc/jssupport/JsDeclarations.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/testFiles/patternMatching/out/whenNotType.js">
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/TranslationContext.java">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="25" selection-start="369" selection-end="369" vertical-scroll-proportion="0.25705644">
<state line="45" column="33" selection-start="1773" selection-end="1773" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/reference/ReferenceTranslator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="97" selection-start="2341" selection-end="2341" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java">
<provider selected="true" editor-type-id="text-editor">
<state line="73" column="11" selection-start="2488" selection-end="2488" vertical-scroll-proportion="0.028846154">
<folding>
<element signature="e#5837#5853#0" expanded="true" />
<element signature="e#5932#5949#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
@@ -3,10 +3,9 @@ package org.jetbrains.k2js.translate.context;
import com.google.dart.compiler.backend.js.ast.JsName;
import com.google.dart.compiler.backend.js.ast.JsScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.types.JetStandardLibrary;
@@ -14,7 +13,8 @@ import java.util.HashMap;
import java.util.Map;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFQName;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getContainingDeclaration;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getFunctionByName;
/**
* @author Pavel Talanov
@@ -22,65 +22,93 @@ import static org.jetbrains.k2js.translate.utils.DescriptorUtils.*;
//TODO: REFACTOR FFS
public final class StandardClasses {
private final class Builder {
@Nullable
private /*var*/ String currentFQName = null;
@Nullable
private /*var*/ String currentKotlinName = null;
@NotNull
public Builder forFQ(@NotNull String classFQName) {
currentFQName = classFQName;
return this;
}
@NotNull
public Builder kotlinName(@NotNull String kotlinName) {
assert currentFQName != null;
currentKotlinName = kotlinName;
declareStandardTopLevelObject(currentFQName, kotlinName);
constructor();
return this;
}
@NotNull
private Builder constructor() {
assert currentFQName != null;
assert currentKotlinName != null;
declareStandardInnerDeclaration(currentFQName, "<init>", currentKotlinName);
return this;
}
@NotNull
public Builder methods(String... methodNames) {
assert currentFQName != null;
declareMethods(currentFQName, methodNames);
return this;
}
@NotNull
public Builder properties(String... propertyNames) {
assert currentFQName != null;
declareReadonlyProperties(currentFQName, propertyNames);
return this;
}
}
//TODO: move declaration code to some kind of builder
@NotNull
public static StandardClasses bindImplementations(@NotNull JetStandardLibrary standardLibrary,
@NotNull JsScope kotlinObjectScope) {
StandardClasses standardClasses = new StandardClasses(kotlinObjectScope);
declareArray(standardClasses, standardLibrary);
declareIterator(standardClasses, standardLibrary);
declareRange(standardClasses);
declareString(standardClasses);
declareJavaArrayList(standardClasses);
declareJavaHasMap(standardClasses);
declareJavaStringBuilder(standardClasses);
declareJetObjects(standardLibrary, standardClasses);
declareJavaUtilObjects(standardClasses);
declareTopLevelFunctions(standardClasses);
declareJavaCollection(standardClasses);
declareMap(standardClasses);
declareInteger(standardClasses);
// declareTuples(standardClasses);
return standardClasses;
}
// private static void declareTuples(@NotNull StandardClasses standardClasses) {
// for (int tupleId = 0; tupleId <= JetStandardClasses.TUPLE_COUNT) {
// declareTuple(standardClasses, tupleId);
// }
// }
//
// private static void declareTuple(@NotNull StandardClasses standardClasses,
// int tupleId) {
// String tupleFQName = "jet.Tuple" + tupleId;
//
// }
//TODO: test all the methods
private static void declareJavaUtilObjects(@NotNull StandardClasses standardClasses) {
standardClasses.declare().forFQ("java.util.ArrayList").kotlinName("ArrayList")
.methods("size", "add", "get", "isEmpty", "set", "remove", "addAll", "contains", "clear", "iterator");
private static void declareMap(@NotNull StandardClasses standardClasses) {
String hashMapFQName = "java.util.Map";
standardClasses.declareStandardTopLevelObject(hashMapFQName, "Map");
standardClasses.declareStandardInnerDeclaration(hashMapFQName, "<init>", "HashMap");
declareMethods(standardClasses, hashMapFQName, "size", "put", "get",
"isEmpty", "remove", "addAll", "clear", "keySet");
standardClasses.declare().forFQ("java.util.Collection").kotlinName("Collection")
.methods("iterator");
standardClasses.declare().forFQ("java.util.HashMap").kotlinName("HashMap")
.methods("size", "put", "get", "isEmpty", "remove", "addAll", "clear", "keySet");
standardClasses.declare().forFQ("java.util.StringBuilder").kotlinName("StringBuilder")
.methods("append", "toString");
standardClasses.declare().forFQ("java.util.Map").kotlinName("Map")
.methods("size", "put", "get", "isEmpty", "remove", "addAll", "clear", "keySet");
}
private static void declareJavaCollection(@NotNull StandardClasses standardClasses) {
String collection = "java.util.Collection";
standardClasses.declareStandardTopLevelObject(collection, "Collection");
declareMethods(standardClasses, collection, "iterator");
}
private static void declareJetObjects(@NotNull JetStandardLibrary standardLibrary,
@NotNull StandardClasses standardClasses) {
declareArray(standardClasses, standardLibrary);
private static void declareJavaStringBuilder(@NotNull StandardClasses standardClasses) {
String stringBuilderFQName = "java.util.StringBuilder";
standardClasses.declareStandardTopLevelObject(stringBuilderFQName, "StringBuilder");
standardClasses.declareStandardInnerDeclaration(stringBuilderFQName, "<init>", "StringBuilder");
declareMethods(standardClasses, stringBuilderFQName, "append", "toString");
}
standardClasses.declare().forFQ("jet.Iterator").kotlinName("ArrayIterator")
.methods("next", "hasNext");
private static void declareJavaHasMap(@NotNull StandardClasses standardClasses) {
String hashMapFQName = "java.util.HashMap";
standardClasses.declareStandardTopLevelObject(hashMapFQName, "HashMap");
standardClasses.declareStandardInnerDeclaration(hashMapFQName, "<init>", "HashMap");
declareMethods(standardClasses, hashMapFQName, "size", "put", "get",
"isEmpty", "remove", "addAll", "clear", "keySet");
standardClasses.declare().forFQ("jet.IntRange").kotlinName("NumberRange")
.methods("iterator", "contains").properties("start", "size", "end", "reversed");
standardClasses.declare().forFQ("jet.String").kotlinName("String").
properties("length");
}
//TODO: refactor
@@ -99,73 +127,12 @@ public final class StandardClasses {
standardClasses.declareStandardInnerDeclaration(integerFQName, "parseInt", "parseInt");
}
private static void declareString(@NotNull StandardClasses standardClasses) {
String stringFQName = "jet.String";
standardClasses.declareStandardTopLevelObject(stringFQName, "String");
declareReadonlyProperties(standardClasses, stringFQName, "length");
}
//TODO: duplication
private static void declareRange(@NotNull StandardClasses standardClasses) {
String intRangeFQName = "jet.IntRange";
standardClasses.declareStandardTopLevelObject(intRangeFQName, "NumberRange");
standardClasses.declareStandardInnerDeclaration(intRangeFQName, "<init>", "NumberRange");
declareMethods(standardClasses, intRangeFQName, "iterator", "contains");
declareReadonlyProperties(standardClasses, intRangeFQName, "start", "size", "end", "reversed");
}
private static void declareJavaArrayList(@NotNull StandardClasses standardClasses) {
String arrayListFQName = "java.util.ArrayList";
standardClasses.declareStandardTopLevelObject(arrayListFQName, "ArrayList");
standardClasses.declareStandardInnerDeclaration(arrayListFQName, "<init>", "ArrayList");
declareMethods(standardClasses, arrayListFQName, "size", "add", "get",
"isEmpty", "set", "remove", "addAll", "contains", "clear", "iterator");
}
private static void declareIterator(@NotNull StandardClasses standardClasses,
@NotNull JetStandardLibrary standardLibrary) {
ClassDescriptor iteratorClass = (ClassDescriptor)
standardLibrary.getLibraryScope().getClassifier("Iterator");
assert iteratorClass != null;
standardClasses.declareTopLevel(iteratorClass, "ArrayIterator");
declareMethods(standardClasses, getFQName(iteratorClass), "next", "hasNext");
}
private static void declareArray(@NotNull StandardClasses standardClasses,
@NotNull JetStandardLibrary standardLibrary) {
ClassDescriptor arrayClass = standardLibrary.getArray();
standardClasses.declareTopLevel(arrayClass, "Array");
standardClasses.declare().forFQ("jet.Array").kotlinName("Array")
.properties("size", "indices");
FunctionDescriptor nullConstructorFunction = getFunctionByName(standardLibrary.getLibraryScope(), "Array");
standardClasses.declareTopLevel(nullConstructorFunction, "array");
PropertyDescriptor sizeProperty =
getPropertyByName(arrayClass.getDefaultType().getMemberScope(), "size");
standardClasses.declareInner(sizeProperty, "size");
PropertyDescriptor indices = getPropertyByName(arrayClass.getDefaultType().getMemberScope(), "indices");
standardClasses.declareInner(indices, "indices");
}
private static void declareMethods(@NotNull StandardClasses standardClasses,
@NotNull String classFQName,
@NotNull String... methodNames) {
for (String methodName : methodNames) {
standardClasses.declareStandardInnerDeclaration(classFQName, methodName, methodName);
}
}
private static void declareReadonlyProperties(@NotNull StandardClasses standardClasses,
@NotNull String classFQName,
@NotNull String... propertyNames) {
for (String propertyName : propertyNames) {
standardClasses.declareStandardInnerDeclaration(classFQName,
propertyName, propertyName);
//TODO: provide general and concise way to declare
// standardClasses.declareStandardInnerDeclaration(classFQName,
// "get-" + propertyName, propertyName);
}
}
@NotNull
@@ -209,6 +176,21 @@ public final class StandardClasses {
nameMap.put(fullQualifiedMethodName, declaredName);
}
private void declareMethods(@NotNull String classFQName,
@NotNull String... methodNames) {
for (String methodName : methodNames) {
declareStandardInnerDeclaration(classFQName, methodName, methodName);
}
}
private void declareReadonlyProperties(@NotNull String classFQName,
@NotNull String... propertyNames) {
for (String propertyName : propertyNames) {
declareStandardInnerDeclaration(classFQName, propertyName, propertyName);
}
}
public boolean isStandardObject(@NotNull DeclarationDescriptor descriptor) {
return nameMap.containsKey(getFQName(descriptor));
}
@@ -217,4 +199,9 @@ public final class StandardClasses {
public JsName getStandardObjectName(@NotNull DeclarationDescriptor descriptor) {
return nameMap.get(getFQName(descriptor));
}
@NotNull
private Builder declare() {
return new Builder();
}
}
@@ -43,7 +43,7 @@ public final class TranslationContext {
return new TranslationContext(staticContext, DynamicContext.contextWithScope(newScope));
}
// Note: Should be used if and only if scope has no corresponding descriptor
// Note: Should be used ONLY if scope has no corresponding descriptor
@NotNull
public TranslationContext innerJsScope(@NotNull JsScope enclosingScope) {
return new TranslationContext(staticContext, dynamicContext.innerScope(enclosingScope));
@@ -43,6 +43,7 @@ public final class ReferenceTranslator {
@NotNull TranslationContext context) {
if (referencedDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
assert context.hasQualifierForDescriptor(referencedDescriptor) : referencedDescriptor;
return translateAsFQReference(referencedDescriptor, context);
}
JsName referencedName = context.getNameForDescriptor(referencedDescriptor);
+18 -17
View File
@@ -33,23 +33,24 @@ private class FilterIterator<T>(val original: Iterator<T>, val filter: (T)-> Boo
var nextElement: T? = null
override val hasNext: Boolean
get() =
when(state) {
1 -> true // checked and next present
2 -> false // checked and next not present
else -> {{() : Boolean ->
while(original.hasNext) {
val candidate = original.next()
if((filter)(candidate)) {
nextElement = candidate
state = 1
true
}
}
state = 2
false
}()}
}
get() {
if (state == 1) {
return true;
}
if (state == 2) {
return false;
}
while(original.hasNext) {
val candidate = original.next()
if((filter)(candidate)) {
nextElement = candidate
state = 1;
return true;
}
}
state = 2;
return false;
}
override fun next(): T {
val res = nextElement as T