[
  {
    "path": ".gitattributes",
    "content": "**/testData/** linguist-vendored\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: kotlin-eclipse\n\non:\n  push:\n    branches: [ \"master\" ]\n\n  workflow_dispatch:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout source code\n        uses: actions/checkout@v3\n\n      - name: Set up JDK 17\n        uses: actions/setup-java@v3\n        with:\n          java-version: '17'\n          distribution: 'adopt'\n\n      - name: Build with Maven\n        run: mvn --batch-mode --nsu clean && mvn --batch-mode --update-snapshots clean validate -Pwith-gradle -pl kotlin-bundled-compiler && mvn --batch-mode --update-snapshots package\n\n      - name: Publish eclipse repository\n        uses: actions/upload-artifact@v3\n        with:\n          name: kotlin-eclipse-plugin\n          path: kotlin-eclipse-p2updatesite/target/kotlin-eclipse-plugin.zip\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\n.gradle\n.idea\n.metadata\n.recommenders\n.gradletasknamecache\n\nbin\nbuild\ncommon_testData\nkotlin-eclipse-ui-test/lib\nkotlin-eclipse-gradle-model/lib\ntarget\n\n*.iml\n*.orig\n\ntarget/\n.settings\n.classpath\n.project\nlib"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2013-2019 JetBrains s.r.o. and Kotlin for Eclipse project contributors.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "Kotlin for Eclipse\r\n==============\r\n\r\n[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\r\n\r\nWelcome to Kotlin for Eclipse project! Some handy links:\r\n\r\n * [Kotlin Site](http://kotlinlang.org/)\r\n * [Getting Started Guide](http://kotlinlang.org/docs/tutorials/getting-started-eclipse.html)\r\n * [Kotlin on Eclipse Marketplace](https://marketplace.eclipse.org/content/kotlin-plugin-eclipse)\r\n * Issue Tracker: [File New Issue](https://youtrack.jetbrains.com/newIssue?project=KE&clearDraft=true), [All Open Issues](https://youtrack.jetbrains.com/issues/KE?q=%23Unresolved)\r\n * [Kotlin Blog](http://blog.jetbrains.com/kotlin/)\r\n * [Forum](https://discuss.kotlinlang.org/)\r\n * [TeamCity CI build](https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_EclipsePlugin)\r\n * [Follow Kotlin on Twitter](https://twitter.com/kotlin)\r\n\r\n### Installation\r\n\r\nTo give it a try you will need a clean installation of Eclipse Neon or newer. The Kotlin plugin is available from the Eclipse Marketplace. The easiest way to install the Kotlin plugin is to **drag-and-drop this button into a running Eclipse window**:\r\n\r\n<a href=\"http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=2257536\" class=\"drag\" title=\"Drag to your running Eclipse workspace to install Kotlin Plugin for Eclipse\"><img src=\"https://marketplace.eclipse.org/sites/all/themes/solstice/public/images/components/drag-drop/installbutton.png\" alt=\"Drag to your running Eclipse workspace to install Kotlin Plugin for Eclipse\" /></a>\r\n\r\nAlternatively, you can use *Help -> Eclipse Marketplace�* menu, or the following update site:\r\n\r\n    https://files.pkg.jetbrains.space/kotlin/p/kotlin-eclipse/main/last/\r\n\r\n### Building and Development\r\n\r\n*Eclipse IDE for Eclipse Committers* is the recommended way to build and develop the `kotlin-eclipse` project. Eclipse [Oxygen 4.7](https://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/oxygenr) is used so far.\r\n\r\nIn order to start development in Eclipse:\r\n - Install the [AspectJ Eclipse plug-in for Eclipse 4.7](http://www.eclipse.org/ajdt/downloads/index.php). To install AJDT 2.2.4 use the following update site:\r\n\r\n\t\thttp://download.eclipse.org/tools/ajdt/47/dev/update\r\n\r\n - Since Kotlin plugin contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in Eclipse. To install the Kotlin Eclipse plugin use the following update site:\r\n\r\n \t\thttps://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_EclipsePlugin/bootstrap.tcbuildtag/\r\n\r\n - Since Kotlin plugin uses weaving, you need to launch the project with weaving enabled. Installation of Equinox Weaving Launcher will add two additional launch configurations types for running plugin and for testing. To install the Equinox Weaving Launcher you can use the following update site: \r\n\r\n \t\thttp://download.scala-ide.org/plugins/equinox-weaving-launcher/releases/site/\r\n\r\n - Import plugin projects from the cloned repository into your workspace \r\n \r\n        File -> Import -> Existing Projects into Workspace\r\n\r\n - Using the command line, run gradle build to download the Kotlin compiler. It will be used as a bundled compiler in built plugin and as a library during development.\r\n \r\n       cd {repository}/kotlin-bundled-compiler\r\n       ./gradlew clean getBundled\r\n    or in Windows environment:\r\n  \r\n       cd {repository}\\kotlin-bundled-compiler\r\n       gradlew.bat clean getBundled\r\n\r\n - Run another instance of Eclipse with the Kotlin plugin inside \r\n \r\n        kotlin-eclipse-ui -> Run As -> Eclipse Weaving enabled Eclipse Application\r\n\r\nBuilding from the command line is also available (Note that Maven **3.0.5** is required):\r\n\r\n    cd {repository}\r\n    mvn install\r\n\r\n### Eclipse update sites\r\n\r\nLatest stable release:\r\n\r\n    https://files.pkg.jetbrains.space/kotlin/p/kotlin-eclipse/main/last/\r\n\r\nAny previously released version (replace *:version* with the version number):\r\n\r\n    https://files.pkg.jetbrains.space/kotlin/p/kotlin-eclipse/main/:version/\r\n\r\nNightly build:\r\n\r\n    https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_EclipsePlugin/.lastSuccessful/\r\n\r\n### Kotlin Eclipse Plugin Developer Documentation\r\n\r\nSee basic developer documentation [here](https://github.com/JetBrains/kotlin-eclipse/blob/master/docs/dev-documentation.md)\r\n"
  },
  {
    "path": "common-settings/kotlin-formatting.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<profiles version=\"12\">\n<profile kind=\"CodeFormatterProfile\" name=\"Kotlin\" version=\"12\">\n<setting id=\"org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.disabling_tag\" value=\"@formatter:off\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_field\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.use_on_off_tags\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_ellipsis\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_multiple_fields\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_conditional_expression\" value=\"80\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_binary_operator\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_array_initializer\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_after_package\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.continuation_indentation\" value=\"2\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_binary_operator\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_package\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.source\" value=\"1.7\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_line_comments\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.join_wrapped_lines\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_member_type\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.align_type_members_on_columns\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_unary_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.indent_parameter_description\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.lineSplit\" value=\"120\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indentation.size\" value=\"4\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.enabling_tag\" value=\"@formatter:on\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_assignment\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"error\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.tabulation.char\" value=\"space\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_statements_compare_to_body\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_method\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_method_declaration\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_switch\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.problem.enumIdentifier\" value=\"error\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_ellipsis\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_block\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_method_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.compact_else_if\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.indent_root_tags\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_enum_constant\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.tabulation.size\" value=\"4\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_empty_lines\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_block_in_case\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.compliance\" value=\"1.7\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer\" value=\"2\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_unary_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_binary_expression\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode\" value=\"enabled\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_label\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_javadoc_comments\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.line_length\" value=\"80\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_between_import_groups\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_semicolon\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.wrap_before_binary_operator\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_statements_compare_to_block\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.join_lines_in_comments\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_compact_if\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_before_imports\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_html\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_source_code\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.compiler.codegen.targetPlatform\" value=\"1.7\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_resources_in_try\" value=\"80\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation\" value=\"16\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_header\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.format_block_comments\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.alignment_for_enum_constants\" value=\"0\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.brace_position_for_type_declaration\" value=\"end_of_line\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.blank_lines_after_imports\" value=\"1\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header\" value=\"true\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for\" value=\"insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments\" value=\"do not insert\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column\" value=\"false\"/>\n<setting id=\"org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line\" value=\"false\"/>\n</profile>\n</profiles>\n"
  },
  {
    "path": "docs/dev-documentation.md",
    "content": "# Kotlin Eclipse Plugin Developer Documentation\n\n## Kotlin Eclipse plugins overview\n\nKotlin plugin consists of several plugins, here is a short description for each of them:\n\n- `kotlin-bundled-compiler`: This plugin is used as a dependency for all other plugins, it exports main jars to work with Kotlin (`kotlin-compiler.jar`, `kotlin-ide-common.jar`...).\nKotlin compiler will be used as the bundled compiler in the built plugin and as a library during development.\n\n    Also, `kotlin-bundled-compiler` plugin contains several helper classes for IDE-features (such as formatter) that are coming from IntelliJ IDEA.\n\n- `kotlin-eclipse-aspects`: This plugin provides several aspects to weave into Eclipse and JDT internals.\n\n- `kotlin-eclipse-core`: This plugin is used to interact with the Kotlin compiler to configure it and provide such features as analysis, compilation and interoperability with Java.\n\n- `kotlin-eclipse-maven`: This plugin depends on `m2e` plugin and provides functionality to configure maven project with Kotlin.\n\n- `kotlin-eclipse-ui`: This plugin provides IDE features through the standard Eclipse and JDT extension points.\n    \n- `kotlin-eclipse-test-framework`: This plugin contains useful utils and mock classes to write tests\n    \n- `kotlin-eclipse-ui-test`: This plugin contains functional tests for IDE features\n    \n#### Interoperability with JDT\n\nExisting Java code can be called from Kotlin in a natural way, and Kotlin code can be used from Java.\nJava code in Eclipse should understand Kotlin. Features such as navigation, refactorings, find usages, and others should work together with Kotlin and Java.\n\n##### Light classes\n\nNote that Kotlin does not have a presentation compiler, like Java or Scala. Instead of this, the\nKotlin plugin generates so called \"light class files\": Kotlin source code translated to bytecode declarations without bodies.\nEach project with Kotlin in Eclipse depends on `KOTLIN_CONTAINER` (see [`KotlinClasspathContainer`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/KotlinClasspathContainer.kt)) \nwhich contains `kotlin-stdlib.jar`, `kotlin-reflect.jar` and a folder with light classfiles (`kotlin_bin`).\nLight classes are stored only in virtual memory and are managed by a special file system (see [`KotlinFileSystem`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinFileSystem.java)\n, [`KotlinFileStore`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinFileStore.kt)), \nso they do not affect the runtime.\n  \nLet us describe what is happening on each file save.\nOn each file save Eclipse triggers Kotlin builder, then the method [`KotlinLightClassGeneration.updateLightClasses()`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/KotlinLightClassGeneration.kt) \nis called which takes affected files and computes names of class files that can be created from the affected source files. \nIf we don't find a light class in our cache, we create a new empty class file in our file system. If file exists, we touch that file. \nAfter this, Eclipse determines that some class files on the classpath were added or changed which triggers reindex for those files \nby calling method [`KotlinFileStore.openInputStream`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinFileStore.kt#L46). \nThis method generates bytecode for the light class by calling the Kotlin compiler in special mode ([`KotlinLightClassGeneration.buildLightClasses`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/KotlinLightClassGeneration.kt#L43)).\nBasically, this allows Java to see Kotlin sources as special binary dependency.\n\n##### Light classes to Kotlin source code\n\nExistence of light classes allows to call Kotlin code from Java in Eclipse, but to navigate from Java to Kotlin source code we have to map light classes to the source code.\nOtherwise we would navigate to the binary code. Unfortunately, Eclipse JDT does not provide any extension point to handle such case, and to do so, we use aspects to weave\ninto Java navigation mechanism. We provide a simple aspect ([`KotlinOpenEditorAspect.aj`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/navigation/KotlinOpenEditorAspect.aj)), \nwhich weaves into `org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor` method and checks input element. \nIf this element belongs to our special file system, then we are trying to find corresponding source element in Kotlin and navigate to it.\n\n### Editor Actions\n\nKotlin plugin provides editors for usual Kotlin files (`.kt`), Kotlin script files (`.kts`) and Kotlin binary files (`.class` files).\nEach editor implements common interface [`KotlinEditor`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinEditor.kt).\nEditors for Kotlin files and script files also implement [`KotlinCommonEditor`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCommonEditor.kt).\n[`KotlinCommonEditor`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCommonEditor.kt) \nextends Java editor (`CompilationUnitEditor`) and provides own editor actions (see [`createActions`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCommonEditor.kt#L108))\n\n#### Organize imports action example\n\nAs an example of editor action let's consider how organize imports works. Organize imports action is registered in [`createActions`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCommonEditor.kt#L145) \nmethod with the corresponding action ID. As we reuse the Java editor, we don't have to set up shortcuts, they will be the same as for Java editor.\nThe main method for this action is [`KotlinOrganizeImportsAction.run`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/organizeImports/KotlinOrganizeImportsAction.kt#L59). \n\nFirst of all, it collects missing imports, adds them to the existing imports and then runs [`KotlinOrganizeImportsAction.optimizeImports`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/organizeImports/KotlinOrganizeImportsAction.kt#L86).\nThis method removes duplicates and unused imports, reorganizes imports and replaces some explicit imports with the star import. The important part here is that we\nreuse the code to optimize imports from the Kotlin plugin for IntelliJ IDEA. The original method that is called from the Eclipse plugin is [`buildOptimizedImports`](https://github.com/JetBrains/kotlin/blob/master/idea/ide-common/src/org/jetbrains/kotlin/idea/util/OptimizedImportsBuilder.kt#L87), \nwhich is also used in the plugin for IDEA.\n\n#### Code reuse from the IDEA plugin\n\nEclipse plugin depends on `kotlin-ide-common.jar` artifact, which provides common functionality for IDEA and Eclipse plugin. \nBasically, this is a module ([`ide-common`](https://github.com/JetBrains/kotlin/tree/master/idea/ide-common)) in Kotlin project with minimum dependencies, \nso it can be used in Eclipse or Netbeans plugin. This module provides several features that are used across the Eclipse plugin. \nFor example, completion in the Eclipse plugin mostly reuses parts of completion from the IDEA plugin \n([`KotlinCompletionUtils.getReferenceVariants`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/completion/KotlinCompletionUtils.kt#L84) \nuses [`ReferenceVarianceHelper`](https://github.com/JetBrains/kotlin/blob/master/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt)).\nGenerally, it's a preferable way to implement features in the Eclipse plugin, i.e. to reuse parts from the IDEA plugin. Unfortunately, there is no\ncommon way to do this because of different models of IDEs.\n\n### Kotlin compilation and launch\n\nKotlin Eclipse plugin does not support incremental compilation or presentation compiler. Kotlin files are compiled using the \nKotlin compiler in [`KotlinCompiler.compileKotlinFiles`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/compiler/KotlinCompiler.java#L48).\n \n#### Kotlin Builder\n\nKotlin plugin uses the Eclipse builder concept to track changes and compile Kotlin files if needed. For a usual change in project, \nKotlin builder only updates light classes. Then, if project is being built to launch the application ([`KotlinBuilder.isBuildingForLaunch`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/KotlinBuilder.kt#L180)), \nKotlin builder compiles Kotlin files (in [`KotlinBuilder.build`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/KotlinBuilder.kt#L63)). \nTherefore, Kotlin builder should always precede Java builder.\n\n#### Kotlin Nature\n\nThere is a Kotlin [nature](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinNature.kt) \nto mark Kotlin projects.\n\n#### Kotlin Debugger\n\nKotlin Eclipse plugin is using the standard debugger for Java in Eclipse. \nFor example, there are [`KotlinToggleBreakpointAdapter`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/debug/KotlinToggleBreakpointAdapter.kt) \nand [`KotlinRunToLineAdapter`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/debug/KotlinRunToLineAdapter.kt) \nadapters to add breakpoint to a specific line and to support action \"run to cursor\".     \n\n### Kotlin environment and project analysis\n\nIn order to analyse files and use compiler API, [`KotlinEnvironment`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinEnvironment.kt#L207) \nhave to be configured. Basically, `KotlinEnvironment` is created for each project in Eclipse and maps external (from Eclipse) project model to the internal one. \nAlso, it registers various services and configures dependencies, see [`KotlinEnvironment.configureClasspath`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinEnvironment.kt#L231). \nImportant note: if classpath was changed, corresponding Kotlin environment should be recreated.  \n\n#### Kotlin parsing\n\nThere are PSI and Kt elements that are basically represent concrete syntax tree of Kotlin program. (The term \"PSI\" is used in IntelliJ IDEA to refer to the syntax tree, and stands for \"Program Structure Interface\".) To get the parsed version of a source file\n[`KotlinPsiManager`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/builder/KotlinPsiManager.kt) \nshould be used. Note that it caches last version of `KtFile`, so to get actual `KtFile`, source code of file can be\nexplicitly passed to the [`getKotlinFileIfExist`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/builder/KotlinPsiManager.kt#L368) \nmethod, or you can use [`commitFile`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/builder/KotlinPsiManager.kt#L389) \nto reparse and cache changed file.\n\n#### \"Remove explicit type\" quick assist example\n\nLet's consider how \"Remove explicit type\" quick assist works. This quick assist removes explicitly written type reference for property, \nfunction and loop parameter, i.e. it converts `val s: String = \"value\"` to `val s = \"value\"`.\n  \nFirst of all, when user invokes quick assist on some element (`ctrl+1`), method\n[`KotlinQuickAssist.isApplicable`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssist.kt#L32) \nis called. `isApplicable` method obtains current PSI element ([`getActiveElement`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssist.kt#L37)),\nit gets PSI file and then calls `findElementAt` to get concrete element at specific offset.\n\nOnce we get active PSI element, we pass it to our quick assists and check for theirs applicability. \n[`KotlinRemoveExplicitTypeAssistProposal.isApplicable`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinRemoveExplicitTypeAssistProposal.kt#L35)\nchecks that active PSI element is actually a property, function or loop parameter with a type reference. \nIn method [`KotlinRemoveExplicitTypeAssistProposal.apply`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinRemoveExplicitTypeAssistProposal.kt#L62) \nquick assist is executed and removes corresponding type reference.\n\nThis and other quick assists and actions rely completely on the knowledge of CST for Kotlin. In order to make it easier, there is an action\n\"View Psi Structure for Current File\" in the context menu for Kotlin file, which can be used to examine structure of the Kotlin CST.\n\n#### Kotlin analyzer\n\nMany features in IDE requires more deep knowledge of the Kotlin compiler implementation. For example, [`KotlinLineAnnotationsReconciler`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/annotations/AnnotationManager.kt#L146)\nis used  to show diagnostics from the compiler. It uses concept of `ReconcilingStrategy` and runs after each change in active file,\nwhen analysis results for the file will be ready and cached. The main line there is `KotlinAnalyzer.analyzeFile(file)...`, which returns\nanalysis results and can be used to get diagnostics from the compiler.\n\nKotlin compiler uses map called `BindingContext` to contain all types and internal representations (descriptors) for expressions in program. \nTo get binding context one can use [`KotlinAnalyzer.analyzeFile(file).bindingContext`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinAnalyzer.kt#L26). \nSee [`KotlinSemanticHighlighter`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlighting.kt) \nfor an example of the compiler analysis use. There are several methods in [`KotlinSemanticHighlightingVisitor`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlightingVisitor.kt), \nwhich uses binding context to obtain information either from a declaration ([`visitProperty`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlightingVisitor.kt#L123)), \nor from a reference ([`visitSimpleNameExpression`](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlightingVisitor.kt#L82)).     \n\n"
  },
  {
    "path": "kotlin-bundled-compiler/Get Bundled Kotlin.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.eclipse.ant.AntLaunchConfigurationType\">\n<stringAttribute key=\"bad_container_name\" value=\"\\kotlin-bundled-compiler\\get_bundled_kotlin\"/>\n<booleanAttribute key=\"org.eclipse.ant.ui.DEFAULT_VM_INSTALL\" value=\"false\"/>\n<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_PATHS\">\n<listEntry value=\"/kotlin-bundled-compiler/get_bundled.xml\"/>\n</listAttribute>\n<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_TYPES\">\n<listEntry value=\"1\"/>\n</listAttribute>\n<stringAttribute key=\"org.eclipse.jdt.launching.CLASSPATH_PROVIDER\" value=\"org.eclipse.ant.ui.AntClasspathProvider\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"kotlin-bundled-compiler\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER\" value=\"org.eclipse.ant.ui.AntClasspathProvider\"/>\n<stringAttribute key=\"org.eclipse.ui.externaltools.ATTR_LOCATION\" value=\"${workspace_loc:/kotlin-bundled-compiler/get_bundled.xml}\"/>\n<stringAttribute key=\"process_factory_id\" value=\"org.eclipse.ant.ui.remoteAntProcessFactory\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "kotlin-bundled-compiler/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Bundled Kotlin Compiler\nBundle-SymbolicName: org.jetbrains.kotlin.bundled-compiler;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Vendor: JetBrains\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ClassPath: .,\n lib/ide-common.jar,\n lib/kotlin-compiler.jar,\n lib/ide-dependencies.jar,\n lib/kotlin-stdlib.jar,\n lib/kotlin-plugin-parts.jar,\n lib/kotlin-script-runtime.jar,\n lib/kotlin-scripting-compiler.jar,\n lib/kotlin-formatter.jar,\n lib/kotlin-common.jar,\n lib/kotlin-core.jar,\n lib/kotlin-idea.jar,\n lib/kotlin-j2k-old.jar,\n lib/kotlin-j2k-new.jar,\n lib/kotlin-j2k-idea.jar,\n lib/kotlin-j2k-services.jar,\n lib/kotlin-frontend-independent.jar,\n lib/kotlin-reflect.jar,\n ../kotlin-eclipse-ui-test/lib/gson-2.3.1.jar,\n lib/annotations-13.0.jar,\n lib/kotlin-scripting-compiler-impl.jar,\n lib/kotlin-scripting-common.jar,\n lib/kotlin-scripting-jvm.jar,\n lib/kotlinx-coroutines-core.jar\nExport-Package: com.google.common.collect,\n com.intellij,\n org.jetbrains.kotlin.idea.util.application,\n org.jetbrains.kotlin.idea.caches.resolve,\n org.jetbrains.kotlin.idea.core.util,\n org.jetbrains.kotlin.nj2k,\n org.jetbrains.kotlin.idea.j2k,\n org.jetbrains.kotlin.nj2k.postProcessing,\n com.intellij.codeInsight,\n com.intellij.codeInsight.completion.scope,\n com.intellij.codeInsight.folding,\n com.intellij.codeInsight.folding.impl,\n com.intellij.codeInsight.javadoc,\n com.intellij.codeInsight.runner,\n com.intellij.core,\n com.intellij.diagnostic,\n com.intellij.extapi.psi,\n com.intellij.formatting,\n com.intellij.icons,\n com.intellij.ide,\n com.intellij.ide.highlighter,\n com.intellij.ide.plugins,\n com.intellij.ide.util,\n com.intellij.injected.editor,\n com.intellij.lang,\n com.intellij.lang.folding,\n com.intellij.lang.impl,\n com.intellij.lang.injection,\n com.intellij.lang.java,\n com.intellij.lang.java.lexer,\n com.intellij.lang.java.parser,\n com.intellij.lang.jvm,\n com.intellij.lang.jvm.facade,\n com.intellij.lexer,\n com.intellij.mock,\n com.intellij.navigation,\n com.intellij.openapi,\n com.intellij.openapi.application,\n com.intellij.openapi.application.ex,\n com.intellij.openapi.application.impl,\n com.intellij.openapi.command,\n com.intellij.openapi.command.impl,\n com.intellij.openapi.command.undo,\n com.intellij.openapi.components,\n com.intellij.openapi.diagnostic,\n com.intellij.openapi.editor,\n com.intellij.openapi.editor.actionSystem,\n com.intellij.openapi.editor.colors,\n com.intellij.openapi.editor.event,\n com.intellij.openapi.editor.ex,\n com.intellij.openapi.editor.impl,\n com.intellij.openapi.editor.impl.event,\n com.intellij.openapi.editor.markup,\n com.intellij.openapi.extensions,\n com.intellij.openapi.extensions.impl,\n com.intellij.openapi.fileEditor,\n com.intellij.openapi.fileEditor.impl,\n com.intellij.openapi.fileTypes,\n com.intellij.openapi.module,\n com.intellij.openapi.progress,\n com.intellij.openapi.project,\n com.intellij.openapi.projectRoots,\n com.intellij.openapi.roots,\n com.intellij.openapi.ui,\n com.intellij.openapi.util,\n com.intellij.openapi.util.io,\n com.intellij.openapi.util.objectTree,\n com.intellij.openapi.util.registry,\n com.intellij.openapi.util.text,\n com.intellij.openapi.vfs,\n com.intellij.openapi.vfs.encoding,\n com.intellij.openapi.vfs.ex,\n com.intellij.openapi.vfs.impl,\n com.intellij.openapi.vfs.impl.jar,\n com.intellij.openapi.vfs.local,\n com.intellij.openapi.vfs.newvfs,\n com.intellij.openapi.vfs.newvfs.events,\n com.intellij.openapi.vfs.pointers,\n com.intellij.patterns,\n com.intellij.patterns.compiler,\n com.intellij.pom,\n com.intellij.pom.event,\n com.intellij.pom.impl,\n com.intellij.pom.java,\n com.intellij.pom.tree,\n com.intellij.pom.tree.events,\n com.intellij.pom.tree.events.impl,\n com.intellij.psi,\n com.intellij.psi.augment,\n com.intellij.psi.codeStyle,\n com.intellij.psi.compiled,\n com.intellij.psi.controlFlow,\n com.intellij.psi.css,\n com.intellij.psi.filters,\n com.intellij.psi.filters.classes,\n com.intellij.psi.filters.element,\n com.intellij.psi.filters.position,\n com.intellij.psi.formatter,\n com.intellij.psi.impl,\n com.intellij.psi.impl.cache,\n com.intellij.psi.impl.compiled,\n com.intellij.psi.impl.file,\n com.intellij.psi.impl.file.impl,\n com.intellij.psi.impl.java.stubs,\n com.intellij.psi.impl.java.stubs.impl,\n com.intellij.psi.impl.java.stubs.index,\n com.intellij.psi.impl.light,\n com.intellij.psi.impl.meta,\n com.intellij.psi.impl.smartPointers,\n com.intellij.psi.impl.source,\n com.intellij.psi.impl.source.codeStyle,\n com.intellij.psi.impl.source.javadoc,\n com.intellij.psi.impl.source.resolve,\n com.intellij.psi.impl.source.resolve.graphInference,\n com.intellij.psi.impl.source.resolve.graphInference.constraints,\n com.intellij.psi.impl.source.resolve.reference,\n com.intellij.psi.impl.source.resolve.reference.impl,\n com.intellij.psi.impl.source.resolve.reference.impl.manipulators,\n com.intellij.psi.impl.source.resolve.reference.impl.providers,\n com.intellij.psi.impl.source.tree,\n com.intellij.psi.impl.source.tree.injected,\n com.intellij.psi.impl.source.tree.java,\n com.intellij.psi.infos,\n com.intellij.psi.javadoc,\n com.intellij.psi.meta,\n com.intellij.psi.presentation.java,\n com.intellij.psi.scope,\n com.intellij.psi.scope.conflictResolvers,\n com.intellij.psi.scope.processor,\n com.intellij.psi.scope.util,\n com.intellij.psi.search,\n com.intellij.psi.search.searches,\n com.intellij.psi.stubs,\n com.intellij.psi.targets,\n com.intellij.psi.templateLanguages,\n com.intellij.psi.text,\n com.intellij.psi.tree,\n com.intellij.psi.tree.java,\n com.intellij.psi.util,\n com.intellij.reference,\n com.intellij.testFramework,\n com.intellij.ui,\n com.intellij.util,\n com.intellij.util.cls,\n com.intellij.util.codeInsight,\n com.intellij.util.concurrency,\n com.intellij.util.containers,\n com.intellij.util.containers.hash,\n com.intellij.util.diff,\n com.intellij.util.execution,\n com.intellij.util.graph,\n com.intellij.util.indexing,\n com.intellij.util.io,\n com.intellij.util.keyFMap,\n com.intellij.util.lang,\n com.intellij.util.messages,\n com.intellij.util.messages.impl,\n com.intellij.util.pico,\n com.intellij.util.text,\n com.intellij.util.xmlb,\n com.intellij.util.xmlb.annotations,\n gnu.trove,\n kotlin,\n kotlin.collections,\n kotlin.comparisons,\n kotlin.concurrent,\n kotlin.coroutines,\n kotlin.coroutines.intrinsics,\n kotlin.coroutines.jvm.internal,\n kotlin.internal;x-internal:=true,\n kotlin.io,\n kotlin.jvm,\n kotlin.jvm.functions,\n kotlin.jvm.internal;x-internal:=true,\n kotlin.jvm.internal.unsafe;x-internal:=true,\n kotlin.properties,\n kotlin.ranges,\n kotlin.reflect,\n kotlin.reflect.full,\n kotlin.reflect.jvm.internal.impl.load.kotlin,\n kotlin.script.dependencies,\n kotlin.script.experimental.annotations,\n kotlin.script.experimental.api,\n kotlin.script.experimental.dependencies,\n kotlin.script.experimental.host,\n kotlin.script.experimental.jvm,\n kotlin.script.experimental.util,\n kotlin.script.extensions,\n kotlin.script.templates,\n kotlin.script.templates.standard,\n kotlin.sequences,\n kotlin.text,\n kotlinx.coroutines,\n org.jetbrains.annotations,\n org.jetbrains.kotlin,\n org.jetbrains.kotlin.analyzer,\n org.jetbrains.kotlin.analyzer.common,\n org.jetbrains.kotlin.asJava,\n org.jetbrains.kotlin.asJava.classes,\n org.jetbrains.kotlin.asJava.finder,\n org.jetbrains.kotlin.backend.common,\n org.jetbrains.kotlin.backend.common.bridges,\n org.jetbrains.kotlin.backend.common.output,\n org.jetbrains.kotlin.builtins,\n org.jetbrains.kotlin.builtins.jvm,\n org.jetbrains.kotlin.caches.resolve,\n org.jetbrains.kotlin.cfg,\n org.jetbrains.kotlin.cfg.pseudocode,\n org.jetbrains.kotlin.cfg.pseudocode.instructions,\n org.jetbrains.kotlin.cfg.pseudocode.instructions.eval,\n org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps,\n org.jetbrains.kotlin.cfg.pseudocode.instructions.special,\n org.jetbrains.kotlin.cfg.pseudocodeTraverser,\n org.jetbrains.kotlin.checkers,\n org.jetbrains.kotlin.checkers.diagnostics,\n org.jetbrains.kotlin.checkers.diagnostics.factories,\n org.jetbrains.kotlin.checkers.utils,\n org.jetbrains.kotlin.cli.common,\n org.jetbrains.kotlin.cli.common.arguments,\n org.jetbrains.kotlin.cli.common.messages,\n org.jetbrains.kotlin.cli.common.modules,\n org.jetbrains.kotlin.cli.js,\n org.jetbrains.kotlin.cli.jvm,\n org.jetbrains.kotlin.cli.jvm.compiler,\n org.jetbrains.kotlin.cli.jvm.index,\n org.jetbrains.kotlin.codegen,\n org.jetbrains.kotlin.codegen.binding,\n org.jetbrains.kotlin.codegen.context,\n org.jetbrains.kotlin.codegen.extensions,\n org.jetbrains.kotlin.codegen.inline,\n org.jetbrains.kotlin.codegen.intrinsics,\n org.jetbrains.kotlin.codegen.optimization,\n org.jetbrains.kotlin.codegen.optimization.boxing,\n org.jetbrains.kotlin.codegen.optimization.common,\n org.jetbrains.kotlin.codegen.optimization.transformer,\n org.jetbrains.kotlin.codegen.signature,\n org.jetbrains.kotlin.codegen.state,\n org.jetbrains.kotlin.codegen.when,\n org.jetbrains.kotlin.compiler.plugin,\n org.jetbrains.kotlin.config,\n org.jetbrains.kotlin.container,\n org.jetbrains.kotlin.context,\n org.jetbrains.kotlin.contracts,\n org.jetbrains.kotlin.descriptors,\n org.jetbrains.kotlin.descriptors.annotations,\n org.jetbrains.kotlin.descriptors.impl,\n org.jetbrains.kotlin.descriptors.java,\n org.jetbrains.kotlin.diagnostics,\n org.jetbrains.kotlin.diagnostics.rendering,\n org.jetbrains.kotlin.extensions,\n org.jetbrains.kotlin.fileClasses,\n org.jetbrains.kotlin.frontend.di,\n org.jetbrains.kotlin.frontend.java.di,\n org.jetbrains.kotlin.idea,\n org.jetbrains.kotlin.idea.codeInsight,\n org.jetbrains.kotlin.idea.core.formatter,\n org.jetbrains.kotlin.idea.formatter,\n org.jetbrains.kotlin.idea.imports,\n org.jetbrains.kotlin.idea.kdoc,\n org.jetbrains.kotlin.idea.resolve,\n org.jetbrains.kotlin.idea.util,\n org.jetbrains.kotlin.incremental,\n org.jetbrains.kotlin.incremental.components,\n org.jetbrains.kotlin.j2k,\n org.jetbrains.kotlin.js.resolve.diagnostics,\n org.jetbrains.kotlin.kdoc.lexer,\n org.jetbrains.kotlin.kdoc.parser,\n org.jetbrains.kotlin.kdoc.psi.api,\n org.jetbrains.kotlin.kdoc.psi.impl,\n org.jetbrains.kotlin.lexer,\n org.jetbrains.kotlin.load.java,\n org.jetbrains.kotlin.load.java.components,\n org.jetbrains.kotlin.load.java.descriptors,\n org.jetbrains.kotlin.load.java.lazy,\n org.jetbrains.kotlin.load.java.lazy.descriptors,\n org.jetbrains.kotlin.load.java.lazy.types,\n org.jetbrains.kotlin.load.java.sam,\n org.jetbrains.kotlin.load.java.sources,\n org.jetbrains.kotlin.load.java.structure,\n org.jetbrains.kotlin.load.java.structure.impl,\n org.jetbrains.kotlin.load.java.typeEnhancement,\n org.jetbrains.kotlin.load.kotlin,\n org.jetbrains.kotlin.load.kotlin.header,\n org.jetbrains.kotlin.load.kotlin.incremental,\n org.jetbrains.kotlin.metadata.jvm.deserialization,\n org.jetbrains.kotlin.name,\n org.jetbrains.kotlin.parsing,\n org.jetbrains.kotlin.platform,\n org.jetbrains.kotlin.platform.jvm,\n org.jetbrains.kotlin.progress,\n org.jetbrains.kotlin.psi,\n org.jetbrains.kotlin.psi.addRemoveModifier,\n org.jetbrains.kotlin.psi.codeFragmentUtil,\n org.jetbrains.kotlin.psi.debugText,\n org.jetbrains.kotlin.psi.findDocComment,\n org.jetbrains.kotlin.psi.psiUtil,\n org.jetbrains.kotlin.psi.stubs,\n org.jetbrains.kotlin.psi.stubs.elements,\n org.jetbrains.kotlin.psi.stubs.impl,\n org.jetbrains.kotlin.psi.typeRefHelpers,\n org.jetbrains.kotlin.renderer,\n org.jetbrains.kotlin.resolve,\n org.jetbrains.kotlin.resolve.annotations,\n org.jetbrains.kotlin.resolve.bindingContextUtil,\n org.jetbrains.kotlin.resolve.calls,\n org.jetbrains.kotlin.resolve.calls.callUtil,\n org.jetbrains.kotlin.resolve.calls.checkers,\n org.jetbrains.kotlin.resolve.calls.context,\n org.jetbrains.kotlin.resolve.calls.inference,\n org.jetbrains.kotlin.resolve.calls.inference.constraintPosition,\n org.jetbrains.kotlin.resolve.calls.model,\n org.jetbrains.kotlin.resolve.calls.results,\n org.jetbrains.kotlin.resolve.calls.smartcasts,\n org.jetbrains.kotlin.resolve.calls.tasks,\n org.jetbrains.kotlin.resolve.calls.util,\n org.jetbrains.kotlin.resolve.checkers,\n org.jetbrains.kotlin.resolve.constants,\n org.jetbrains.kotlin.resolve.constants.evaluate,\n org.jetbrains.kotlin.resolve.deprecation,\n org.jetbrains.kotlin.resolve.descriptorUtil,\n org.jetbrains.kotlin.resolve.diagnostics,\n org.jetbrains.kotlin.resolve.extensions,\n org.jetbrains.kotlin.resolve.jvm,\n org.jetbrains.kotlin.resolve.jvm.diagnostics,\n org.jetbrains.kotlin.resolve.jvm.extensions,\n org.jetbrains.kotlin.resolve.jvm.jvmSignature,\n org.jetbrains.kotlin.resolve.jvm.kotlinSignature,\n org.jetbrains.kotlin.resolve.jvm.modules,\n org.jetbrains.kotlin.resolve.jvm.platform,\n org.jetbrains.kotlin.resolve.lazy,\n org.jetbrains.kotlin.resolve.lazy.data,\n org.jetbrains.kotlin.resolve.lazy.declarations,\n org.jetbrains.kotlin.resolve.lazy.descriptors,\n org.jetbrains.kotlin.resolve.sam,\n org.jetbrains.kotlin.resolve.scopes,\n org.jetbrains.kotlin.resolve.scopes.receivers,\n org.jetbrains.kotlin.resolve.scopes.utils,\n org.jetbrains.kotlin.resolve.source,\n org.jetbrains.kotlin.resolve.typeBinding,\n org.jetbrains.kotlin.scripting.configuration,\n org.jetbrains.kotlin.scripting.definitions,\n org.jetbrains.kotlin.scripting.extensions,\n org.jetbrains.kotlin.scripting.resolve,\n org.jetbrains.kotlin.serialization,\n org.jetbrains.kotlin.serialization.builtins,\n org.jetbrains.kotlin.serialization.deserialization,\n org.jetbrains.kotlin.serialization.deserialization.builtins,\n org.jetbrains.kotlin.serialization.deserialization.descriptors,\n org.jetbrains.kotlin.storage,\n org.jetbrains.kotlin.synthetic,\n org.jetbrains.kotlin.types,\n org.jetbrains.kotlin.types.checker,\n org.jetbrains.kotlin.types.error,\n org.jetbrains.kotlin.types.expressions,\n org.jetbrains.kotlin.types.typeUtil,\n org.jetbrains.kotlin.types.typesApproximation,\n org.jetbrains.kotlin.util,\n org.jetbrains.kotlin.util.collectionUtils,\n org.jetbrains.kotlin.util.slicedMap,\n org.jetbrains.kotlin.utils,\n org.jetbrains.kotlin.utils.addToStdlib,\n org.jetbrains.kotlin.utils.concurrent.block,\n org.jetbrains.kotlin.utils.fileUtils,\n org.jetbrains.kotlin.utils.intellij,\n org.jetbrains.kotlin.utils.strings,\n org.jetbrains.org.objectweb.asm,\n org.jetbrains.org.objectweb.asm.commons,\n org.jetbrains.org.objectweb.asm.signature,\n org.jetbrains.org.objectweb.asm.tree,\n org.jetbrains.org.objectweb.asm.tree.analysis,\n org.jetbrains.org.objectweb.asm.util\n"
  },
  {
    "path": "kotlin-bundled-compiler/build.gradle.kts",
    "content": "import com.intellij.buildsupport.dependencies.PackageListFromSimpleFile\nimport com.intellij.buildsupport.resolve.http.HttpArtifact\nimport com.intellij.buildsupport.resolve.http.HttpArtifactsResolver\nimport com.intellij.buildsupport.resolve.http.idea.IntellijIdeaArtifactsResolver\nimport com.intellij.buildsupport.utils.FileUtils\n\napply(plugin = \"base\")\n\n// constants\nval teamcityBaseUrl =\"https://teamcity.jetbrains.com\"\nval ideaSdkUrl = \"https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea\"\n\n// properties that might/should be modifiable\n\n//val kotlinCompilerTcBuildId: String = project.findProperty(\"kotlinCompilerTcBuildId\") as String? ?: \"3546752\"\nval kotlinPluginUpdateId = project.findProperty(\"kotlinPluginUpdateId\") as String? ?: \"169248\" // Kotlin Plugin 1.6.21 for Idea 2021.3\n\nval kotlinCompilerVersion: String = project.findProperty(\"kotlinCompilerVersion\") as String? ?: \"1.6.21\"\nval kotlinxVersion: String = project.findProperty(\"kolinxVersion\") as String? ?: \"1.5.2\"\nval tcArtifactsPath: String = project.findProperty(\"tcArtifactsPath\") as String? ?: \"\"\nval ideaVersion: String = project.findProperty(\"ideaVersion\") as String? ?: \"213.5744.223\" //Idea 2021.3\nval kotlinIdeaCompatibleVersionMinor: String = project.findProperty(\"kotlinIdeaCompatibleVersionMinor\") as String? ?: \"2021.3\"\nval ignoreSources: Boolean = true//project.hasProperty(\"ignoreSources\")\n\n//directories\nval testDataDir = file(\"${projectDir.parentFile}/kotlin-eclipse-ui-test/common_testData\")\n//TODO later refactor to the proper project dir\nval testModuleLibDir = file(\"${projectDir.parentFile}/kotlin-eclipse-ui-test/lib\")\n//TODO later refactor to the proper project dir\n\nval downloadDirName = \"downloads$ideaVersion-$kotlinCompilerVersion\"\n\nval teamCityWorkingDir = project.findProperty(\"teamcity.buildsupport.workingDir\")\nval libDir = if (teamCityWorkingDir != null) file(\"$teamCityWorkingDir/lib\") else file(\"lib\")\n\nval localTCArtifacts: Boolean = tcArtifactsPath.isNotBlank()\nval downloadDir = if(localTCArtifacts) file(tcArtifactsPath) else file(\"$libDir/$downloadDirName\")\n\n/*val tcArtifactsResolver = KotlinCompilerTCArtifactsResolver(teamcityBaseUrl,\n        project.hasProperty(\"lastSuccessfulBuild\"),\n        kotlinCompilerTcBuildId,\n        kotlinCompilerVersion,\n        kotlinIdeaCompatibleVersionMinor)*/\n\nHttpArtifactsResolver.getProxyProps()[\"https.proxyHost\"] = project.findProperty(\"https.proxyHost\") ?: System.getProperty(\"https.proxyHost\")\nHttpArtifactsResolver.getProxyProps()[\"https.proxyPort\"] = project.findProperty(\"https.proxyPort\") ?: System.getProperty(\"https.proxyPort\")\nHttpArtifactsResolver.getProxyProps()[\"https.proxyUser\"] = project.findProperty(\"https.proxyUser\") ?: System.getProperty(\"https.proxyUser\")\nHttpArtifactsResolver.getProxyProps()[\"https.proxyPassword\"] = project.findProperty(\"https.proxyPassword\") ?: System.getProperty(\"https.proxyPassword\")\n\nval ideaArtifactsResolver = IntellijIdeaArtifactsResolver(ideaSdkUrl, ideaVersion)\nval kotlinPluginArtifactsResolver = HttpArtifactsResolver(\"https://plugins.jetbrains.com\")\n\nval tempKotlinHttpArtifact = HttpArtifact(\"plugin/download?rel=true&updateId=$kotlinPluginUpdateId\")\n\ntasks.withType<Wrapper> {\n    gradleVersion = \"5.5.1\"\n}\n\nval testFrameworkDependencies by configurations.creating\nval kotlinxLibraries by configurations.creating\n\ndependencies {\n    testFrameworkDependencies(\"com.google.code.gson:gson:2.3.1\")\n    kotlinxLibraries(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxVersion\") { isTransitive = false }\n    kotlinxLibraries(\"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxVersion\") { isTransitive = false }\n}\n\nrepositories {\n    mavenCentral()\n}\n\ntasks.named<Delete>(\"clean\") {\n    doLast {\n        FileUtils.cleanDir(testDataDir)\n        FileUtils.cleanDir(testModuleLibDir)\n        FileUtils.cleanDirExceptSubDirName(libDir, downloadDirName)\n    }\n}\n\nval deleteLibrariesFromLibFolder by tasks.registering {\n    doFirst {\n        libDir.listFiles()?.filter { it.isFile }?.forEach { it.deleteRecursively() }\n    }\n}\n\nval downloadTestData by tasks.registering {\n    val locallyDownloadedTestDataFile by extra {\n        if(localTCArtifacts){\n            file(\"$tcArtifactsPath/kotlin-test-data.zip\")\n        } else {\n            file(\"$testDataDir/kotlin-test-data.zip\")\n        }\n    }\n\n    doLast {\n        //TODO can we get the test data from somewhere?\n        if (!localTCArtifacts && !locallyDownloadedTestDataFile.exists()) {\n            //tcArtifactsResolver.downloadTo(tcArtifactsResolver.KOTLIN_TEST_DATA_ZIP, locallyDownloadedTestDataFile)\n        }\n\n        /*copy {\n            from(zipTree(locallyDownloadedTestDataFile))\n            into(testDataDir)\n        }*/\n    }\n}\n\nval downloadTestFrameworkDependencies by tasks.registering(Copy::class) {\n    from(testFrameworkDependencies)\n    into(testModuleLibDir)\n}\n\nval downloadKotlinCompilerPluginAndExtractSelectedJars by tasks.registering {\n    dependsOn(deleteLibrariesFromLibFolder)\n\n    val kotlinDownloadDir = file(\"$downloadDir/kotlin-$kotlinCompilerVersion/$kotlinIdeaCompatibleVersionMinor\")\n    val locallyDownloadedCompilerFile by extra {\n        file(kotlinDownloadDir).listFiles()?.firstOrNull { it.name.startsWith(\"kotlin-plugin-\") }\n                ?: file(\"$kotlinDownloadDir/kotlin-plugin.zip\")\n    }\n\n    doLast {\n        if (!localTCArtifacts && !locallyDownloadedCompilerFile.exists()) {\n            kotlinPluginArtifactsResolver.downloadTo(tempKotlinHttpArtifact, locallyDownloadedCompilerFile)\n            //tcArtifactsResolver.downloadTo(tcArtifactsResolver.KOTLIN_PLUGIN_ZIP, locallyDownloadedCompilerFile)\n        }\n\n        copy {\n            from(zipTree(locallyDownloadedCompilerFile))\n\n            setIncludes(setOf(\"Kotlin/lib/kotlin-plugin.jar\",\n                    \"Kotlin/lib/ide-common.jar\",\n                    \"Kotlin/lib/kotlin-core.jar\",\n                    \"Kotlin/lib/kotlin-idea.jar\",\n                    \"Kotlin/lib/kotlin-common.jar\",\n                    \"Kotlin/lib/kotlin-j2k-old.jar\",\n                    \"Kotlin/lib/kotlin-j2k-new.jar\",\n                    \"Kotlin/lib/kotlin-j2k-idea.jar\",\n                    \"Kotlin/lib/kotlin-j2k-services.jar\",\n                    \"Kotlin/lib/kotlin-frontend-independent.jar\",\n                    \"Kotlin/lib/kotlin-formatter.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-compiler.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-stdlib.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-reflect.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-script-runtime.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-scripting-compiler.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-scripting-common.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-scripting-jvm.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-scripting-compiler-impl.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-jdk-annotations.jar\",\n                    \"Kotlin/kotlinc/lib/kotlin-stdlib-sources.jar\",\n                    \"Kotlin/kotlinc/lib/allopen-compiler-plugin.jar\",\n                    \"Kotlin/kotlinc/lib/noarg-compiler-plugin.jar\",\n                    \"Kotlin/kotlinc/lib/sam-with-receiver-compiler-plugin.jar\",\n                    \"Kotlin/kotlinc/lib/annotations-13.0.jar\"))\n\n            includeEmptyDirs = false\n            into(libDir)\n\n            // flatten + rename\n            eachFile {\n                this.relativePath = RelativePath(true, this.name)\n            }\n        }\n    }\n}\n\nval extractPackagesFromPlugin by tasks.registering(Jar::class) {\n    dependsOn(downloadKotlinCompilerPluginAndExtractSelectedJars)\n\n    from(zipTree(\"$libDir/kotlin-plugin.jar\"))\n    destinationDirectory.set(libDir)\n    archiveFileName.set(\"kotlin-plugin-parts.jar\")\n    include(\"**\")\n    exclude(\"com/intellij/util/**\")\n\n    doLast {\n        file(\"$libDir/kotlin-plugin.jar\").delete()\n    }\n}\n\nval extractPackagesFromKTCompiler by tasks.registering(Jar::class) {\n    dependsOn(downloadKotlinCompilerPluginAndExtractSelectedJars)\n\n    from(zipTree(\"$libDir/kotlin-compiler.jar\"))\n    destinationDirectory.set(libDir)\n    archiveFileName.set(\"kotlin-compiler-tmp.jar\")\n    include(\"**\")\n    exclude(\"com/intellij/openapi/util/text/**\")\n    exclude(\"com/intellij/util/containers/MultiMap*\")\n\n    doLast {\n        file(\"$libDir/kotlin-compiler.jar\").delete()\n        file(\"$libDir/kotlin-compiler-tmp.jar\").renameTo(file(\"$libDir/kotlin-compiler.jar\"))\n    }\n}\n\nval downloadIntellijCoreAndExtractSelectedJars by tasks.registering {\n    dependsOn(deleteLibrariesFromLibFolder)\n    val ideaDownloadDir = file(\"$downloadDir/idea-$ideaVersion\")\n    val locallyDownloadedIntellijCoreFile by extra { file(\"$ideaDownloadDir/intellij-core.zip\") }\n\n    doLast {\n        if(!locallyDownloadedIntellijCoreFile.exists()) {\n            ideaArtifactsResolver.downloadTo(ideaArtifactsResolver.INTELLIJ_CORE_ZIP, locallyDownloadedIntellijCoreFile)\n        }\n        copy {\n            from(zipTree(locallyDownloadedIntellijCoreFile))\n\n            setIncludes(setOf(\"intellij-core.jar\"))\n\n            includeEmptyDirs = false\n\n            into(libDir)\n        }\n    }\n}\n\nval downloadIdeaDistributionZipAndExtractSelectedJars by tasks.registering {\n    dependsOn(deleteLibrariesFromLibFolder)\n    val ideaDownloadDir = file(\"$downloadDir/idea-$ideaVersion\")\n    val locallyDownloadedIdeaZipFile by extra { file(\"$ideaDownloadDir/ideaIC.zip\") }\n    val chosenJars by extra { setOf(//\"openapi\",\n            //\"platform-util-ui\",\n            \"util\",\n            \"idea\",\n            //\"trove4j\",\n            \"platform-api\",\n            \"platform-impl\") }\n\n    doLast {\n        if(!locallyDownloadedIdeaZipFile.exists()) {\n            ideaArtifactsResolver.downloadTo(ideaArtifactsResolver.IDEA_IC_ZIP, locallyDownloadedIdeaZipFile)\n        }\n        copy {\n            from(zipTree(locallyDownloadedIdeaZipFile))\n\n            setIncludes(chosenJars.map { \"lib/$it.jar\" }.toSet())\n\n            includeEmptyDirs = false\n\n            into(libDir)\n\n// flatten the files\n            eachFile {\n                this.relativePath = RelativePath(true, this.name)\n            }\n        }\n    }\n}\n\nval extractSelectedFilesFromIdeaJars by tasks.registering {\n    dependsOn(downloadIdeaDistributionZipAndExtractSelectedJars)\n\n    val packages by extra {\n        /*new PackageListFromManifest(\"META-INF/MANIFEST.MF\"),*/\n        PackageListFromSimpleFile(file(\"referencedPackages.txt\").path).pathsToInclude\n    }\n    val extractDir by extra { file(\"$downloadDir/dependencies\") }\n\n    doLast {\n        val chosenJars: Set<String> by downloadIdeaDistributionZipAndExtractSelectedJars.get().extra\n        for (library in chosenJars) {\n            copy {\n                from(zipTree(\"$libDir/$library.jar\"))\n                setIncludes(packages)\n                includeEmptyDirs = false\n                into(extractDir)\n            }\n            file(\"$libDir/$library.jar\").delete()\n        }\n    }\n}\n\nval createIdeDependenciesJar by tasks.registering(Jar::class) {\n    dependsOn(extractSelectedFilesFromIdeaJars)\n\n    val extractDir: File by extractSelectedFilesFromIdeaJars.get().extra\n\n    from(extractDir)\n    destinationDirectory.set(libDir)\n    archiveFileName.set(\"ide-dependencies.jar\")\n\n    manifest {\n        attributes(mapOf(\"Built-By\" to \"JetBrains\",\n                \"Implementation-Vendor\" to \"JetBrains\",\n                \"Implementation-Version\" to \"1.0\",\n                \"Implementation-Title\" to \"ide-dependencies\"))\n    }\n\n    doLast {\n        extractDir.deleteRecursively()\n    }\n}\n\nval downloadKotlinxLibraries by tasks.registering(Copy::class) {\n    from(kotlinxLibraries)\n    into(libDir)\n    rename(\"(kotlinx-coroutines-\\\\w+)-.*\", \"$1.jar\")\n}\n\nval downloadIdeaAndKotlinCompilerSources by tasks.registering {\n    val locallyDownloadedKotlinCompilerSourcesFile by extra { file(\"$downloadDir/kotlin-compiler-sources.jar\") }\n    val locallyDownloadedIdeaSourcesFile by extra { file(\"$downloadDir/idea-sdk-sources.jar\") }\n\n    doLast {\n        if(!locallyDownloadedKotlinCompilerSourcesFile.exists()) {\n            //TODO can we get the sources from somewhere?\n            //tcArtifactsResolver.downloadTo(tcArtifactsResolver.KOTLIN_COMPILER_SOURCES_JAR, locallyDownloadedKotlinCompilerSourcesFile)\n        }\n        if(!locallyDownloadedIdeaSourcesFile.exists()) {\n            ideaArtifactsResolver.downloadTo(ideaArtifactsResolver.IDEA_IC_SOURCES_JAR, locallyDownloadedIdeaSourcesFile)\n        }\n    }\n}\n\nval repackageIdeaAndKotlinCompilerSources by tasks.registering(Zip::class) {\n    dependsOn(downloadIdeaAndKotlinCompilerSources)\n\n    val locallyDownloadedKotlinCompilerSourcesFile: File by downloadIdeaAndKotlinCompilerSources.get().extra\n    val locallyDownloadedIdeaSourcesFile: File by downloadIdeaAndKotlinCompilerSources.get().extra\n\n    from(zipTree(locallyDownloadedKotlinCompilerSourcesFile))\n    from(zipTree(locallyDownloadedIdeaSourcesFile))\n\n    destinationDirectory.set(libDir)\n    archiveFileName.set(\"kotlin-compiler-sources.jar\")\n}\n\nval downloadBundled by tasks.registering {\n    libDir.listFiles()?.filter { it.isFile }?.forEach { it.deleteRecursively() }\n    if (localTCArtifacts) {\n        dependsOn(extractPackagesFromPlugin,\n                extractPackagesFromKTCompiler,\n                downloadIntellijCoreAndExtractSelectedJars,\n                createIdeDependenciesJar,\n                downloadKotlinxLibraries)\n    } else {\n        dependsOn(extractPackagesFromPlugin,\n                extractPackagesFromKTCompiler,\n                downloadIntellijCoreAndExtractSelectedJars,\n                createIdeDependenciesJar,\n                downloadKotlinxLibraries)\n    }\n\n    if (!ignoreSources) {\n        dependsOn(repackageIdeaAndKotlinCompilerSources)\n    }\n}\n\nval getBundled by tasks.registering {\n    dependsOn(downloadTestData, downloadTestFrameworkDependencies, downloadBundled)\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nsource.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               lib/kotlin-compiler.jar,\\\n               lib/kotlin-stdlib.jar,\\\n               lib/kotlin-reflect.jar,\\\n               lib/kotlin-stdlib-sources.jar,\\\n               lib/kotlin-script-runtime.jar,\\\n               lib/allopen-compiler-plugin.jar,\\\n               lib/kotlin-scripting-compiler.jar,\\\n               lib/sam-with-receiver-compiler-plugin.jar,\\\n               lib/noarg-compiler-plugin.jar,\\\n               lib/annotations-13.0.jar,\\\n               lib/kotlinx-coroutines-core.jar,\\\n               lib/kotlinx-coroutines-jdk8.jar,\\\n               lib/ide-dependencies.jar,\\\n               lib/kotlin-scripting-common.jar,\\\n               lib/kotlin-scripting-jvm.jar,\\\n               lib/kotlin-scripting-compiler-impl.jar,\\\n               lib/kotlin-plugin-parts.jar,\\\n               lib/kotlin-formatter.jar,\\\n               lib/kotlin-common.jar,\\\n               lib/kotlin-idea.jar,\\\n               lib/kotlin-core.jar,\\\n               lib/kotlin-j2k-old.jar,\\\n               lib/kotlin-j2k-new.jar,\\\n               lib/kotlin-j2k-idea.jar,\\\n               lib/kotlin-j2k-services.jar,\\\n               lib/kotlin-frontend-independent.jar,\\\n               lib/ide-common.jar\nsrc.includes = lib/\nbin.excludes = lib/kotlin-compiler-sources.jar,\\\n               lib/downloads/\nsrc.excludes = lib/downloads/,\\\n               lib/intellij-core.jar\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/build.gradle",
    "content": "apply plugin: 'groovy'\n\n\nrepositories {\n    jcenter()\n    mavenCentral()\n    maven { url 'https://jitpack.io' }\n}\n\n\ndependencies {\n    implementation 'org.jetbrains.teamcity:teamcity-rest-client:1.5.0'\n\n    testImplementation('org.spockframework:spock-core:2.2-groovy-3.0') {\n        exclude module : 'groovy-all'\n    }\n    testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'\n    testImplementation 'org.apache.commons:commons-lang3:3.8.1'\n\n}\n\ntest.enabled = false // otherwise integration tests will run always before the actual build\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/dependencies/PackageList.groovy",
    "content": "package com.intellij.buildsupport.dependencies\n\nabstract class PackageList {\n    List<String> getPathsToInclude() {\n        List<String> tempList = []\n        packageNames.forEach {\n            if(it.startsWith(\"custom:\")) {\n                tempList.add(it.replace(\"custom:\", \"\"))\n            } else {\n                tempList.add(it.replace('.', '/') + '/*.class')\n            }\n        }\n        return tempList\n    }\n\n    protected abstract List<String> getPackageNames()\n}"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/dependencies/PackageListFromManifest.groovy",
    "content": "package com.intellij.buildsupport.dependencies\n\nimport groovy.transform.TupleConstructor\n\nimport java.util.jar.Manifest\n\n@TupleConstructor\nclass PackageListFromManifest extends PackageList {\n    String path\n\n    @Override\n    protected List<String> getPackageNames() {\n        new Manifest(new FileInputStream(path)).mainAttributes\n                .getValue(\"Export-Package\")\n                .split(',')\n                *.takeWhile { it != ';' } as List<String>\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/dependencies/PackageListFromSimpleFile.groovy",
    "content": "package com.intellij.buildsupport.dependencies\n\nimport groovy.transform.TupleConstructor\n\nimport java.util.jar.Manifest\n\n@TupleConstructor\nclass PackageListFromSimpleFile extends PackageList {\n    String path\n\n    @Override\n    protected List<String> getPackageNames() {\n        new FileInputStream(path).readLines()\n                *.trim()\n                .findAll { !it.empty }\n                .findAll { it.take(1) != '#' }\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/http/HttpArtifact.groovy",
    "content": "package com.intellij.buildsupport.resolve.http\n\n\nimport groovy.transform.EqualsAndHashCode\nimport groovy.transform.ToString\nimport groovy.transform.TupleConstructor\n\n\n@TupleConstructor(includeFields = true)\n@EqualsAndHashCode\n@ToString\nclass HttpArtifact {\n\n    // relative to HTTP base URL\n    final String filePath // cannot contain any regex patterns\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/http/HttpArtifactsResolver.groovy",
    "content": "package com.intellij.buildsupport.resolve.http\n\n\nimport groovy.transform.TupleConstructor\n\n\n@TupleConstructor(includeFields = true)\nclass HttpArtifactsResolver {\n\n    // FIELDS =========================================================================================================\n    protected final String httpBaseUrl\n\n    static Map<String, Object> proxyProps = new HashMap<>()\n\n\n    // PUBLIC API =====================================================================================================\n    final void downloadTo(HttpArtifact httpArtifact, File outputFile) {\n        println \"Downloading artifact: $httpArtifact.filePath\"\n\n        downloadFileFromUrlInto \"$httpBaseUrl/$httpArtifact.filePath\", outputFile\n    }\n\n\n    // PRIVATE API ====================================================================================================\n    private void downloadFileFromUrlInto(String fileURL, File destinationFile) {\n        destinationFile.parentFile.mkdirs()\n\n        def ant = new AntBuilder()\n        if (!proxyProps.isEmpty() && proxyProps['https.proxyHost'] != null) {\n            if (proxyProps.get(\"https.proxyUser\") == null) {\n                ant.setproxy(proxyHost: proxyProps['https.proxyHost'], proxyPort: proxyProps['https.proxyPort'])\n            } else {\n                ant.setproxy(proxyHost: proxyProps['https.proxyHost'], proxyPort: proxyProps['https.proxyPort'], proxyUser: proxyProps['https.proxyUser'], proxyPassword: proxyProps['https.proxyPassword'])\n            }\n        }\n        ant.get(src: fileURL,\n                dest: destinationFile,\n                usetimestamp: true)\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/http/idea/IntellijIdeaArtifactsResolver.groovy",
    "content": "package com.intellij.buildsupport.resolve.http.idea\n\n\nimport com.intellij.buildsupport.resolve.http.HttpArtifact\nimport com.intellij.buildsupport.resolve.http.HttpArtifactsResolver\n\nimport groovy.transform.CompileStatic\n\n\n@CompileStatic\nclass IntellijIdeaArtifactsResolver extends HttpArtifactsResolver {\n\n    final String ideaVersion\n\n\n    IntellijIdeaArtifactsResolver(String httpBaseUrl, String ideaVersion) {\n        super(httpBaseUrl)\n\n        this.ideaVersion = ideaVersion\n    }\n\n\n    public final HttpArtifact INTELLIJ_CORE_ZIP   = new HttpArtifact(\"intellij-core/$ideaVersion/intellij-core-${ideaVersion}.zip\",)\n    public final HttpArtifact IDEA_IC_ZIP         = new HttpArtifact(\"ideaIC/$ideaVersion/ideaIC-${ideaVersion}.zip\",)\n    public final HttpArtifact IDEA_IC_SOURCES_JAR = new HttpArtifact(\"ideaIC/$ideaVersion/ideaIC-$ideaVersion-sources.jar\",)\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/tc/TCArtifact.groovy",
    "content": "package com.intellij.buildsupport.resolve.tc\n\n\nimport groovy.transform.EqualsAndHashCode\nimport groovy.transform.ToString\nimport groovy.transform.TupleConstructor\n\n\n@TupleConstructor(includeFields = true)\n@EqualsAndHashCode\n@ToString\nclass TCArtifact {\n\n    // relative to TeamCity base URL\n    final String fileParentPathRegex // might contain '*' pattern\n    final String fileNameRegex       // might contain '*' pattern\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/tc/TCArtifactsResolver.groovy",
    "content": "package com.intellij.buildsupport.resolve.tc\n\n\nimport groovy.transform.CompileStatic\nimport groovy.transform.TupleConstructor\n\nimport org.jetbrains.teamcity.rest.Build\nimport org.jetbrains.teamcity.rest.BuildArtifact\nimport org.jetbrains.teamcity.rest.BuildConfigurationId\nimport org.jetbrains.teamcity.rest.BuildId\nimport org.jetbrains.teamcity.rest.BuildLocator\nimport org.jetbrains.teamcity.rest.TeamCityConversationException\nimport org.jetbrains.teamcity.rest.TeamCityInstanceFactory\nimport org.jetbrains.teamcity.rest.TeamCityQueryException\n\n\n@TupleConstructor(includeFields = true, excludes = ['resolvedArtifactMap', 'untilDate'])\n@CompileStatic\nabstract class TCArtifactsResolver {\n\n    // FIELDS =========================================================================================================\n    protected final String teamcityBaseUrl\n\n    protected final boolean lastSuccessfulBuild\n\n    protected final String tcBuildId\n\n    protected final String tcBuildBranch\n\n\n    // for testing purposes only\n    protected Date untilDate = null\n\n\n    private Map<TCArtifact, BuildArtifact> resolvedArtifactMap = null\n\n\n    // ABSTRACT METHODS TO IMPLEMENT ==================================================================================\n    abstract List<TCArtifact> getRequiredArtifacts()\n\n    abstract String tcBuildTypeId()\n\n\n    // PUBLIC API =====================================================================================================\n    final void downloadTo(TCArtifact tcArtifact, File outputFile) {\n        if (resolvedArtifactMap == null) {\n            resolvedArtifactMap = lastSuccessfulBuild ? resolveFromLastSuccessfulBuild()\n                    : resolveFromBuildId()\n        }\n\n        BuildArtifact resolvedTCArtifact = resolvedArtifactMap.get(tcArtifact)\n\n        println \"Downloading artifact: $resolvedTCArtifact.fullName\"\n\n        resolvedTCArtifact.download(outputFile)\n    }\n\n    // PRIVATE API ====================================================================================================\n    private Map<TCArtifact, BuildArtifact> resolveFromBuildId() {\n        Build tcBuild = TeamCityInstanceFactory.guestAuth(teamcityBaseUrl)\n                .build(new BuildId(tcBuildId))\n\n        println \"Resolving TC build: $tcBuild\"\n        return resolveRequiredArtifacts(tcBuild)\n    }\n\n    private Map<TCArtifact, BuildArtifact> resolveFromLastSuccessfulBuild() {\n        BuildLocator builds = TeamCityInstanceFactory.guestAuth(teamcityBaseUrl)\n                .builds()\n                .fromConfiguration(new BuildConfigurationId(tcBuildTypeId()))\n                .includeFailed()\n\n        if (!tcBuildBranch.trim().isEmpty())\n            builds.withBranch(tcBuildBranch.trim())\n\n        if (untilDate != null)\n            builds.untilDate(untilDate)\n\n        for (Build tcBuild in iterable(builds.all())) {\n            println \"Resolving TC build: $tcBuild\"\n\n            Map <TCArtifact, BuildArtifact> resolvedArtifacts = resolveRequiredArtifacts(tcBuild)\n            if (resolvedArtifacts.isEmpty())\n                continue\n            else\n                return resolvedArtifacts\n        }\n    }\n\n    private Map<TCArtifact, BuildArtifact> resolveRequiredArtifacts(Build tcBuild) {\n        Map<TCArtifact, BuildArtifact> resolvedArtifactMap = [:] as HashMap\n\n        for (TCArtifact requiredTcArtifact in getRequiredArtifacts()) {\n            BuildArtifact resolvedTcArtifact\n\n            // search the build and dependencies of the build for the artifact (in case of an aggregate build)\n            for (build in [tcBuild] + tcBuild.snapshotDependencies) {\n                try {\n                    resolvedTcArtifact = build.findArtifact(requiredTcArtifact.fileNameRegex,\n                            requiredTcArtifact.fileParentPathRegex,true)\n                    break\n                }\n                catch (TeamCityConversationException ignored) {}\n                catch (TeamCityQueryException ignored) {}\n            }\n\n            // in the case the latest build does not contain any artifacts, we continue searching the previous build\n            if(resolvedTcArtifact == null)\n                return Collections.EMPTY_MAP\n\n            resolvedArtifactMap.put requiredTcArtifact, resolvedTcArtifact\n        }\n        return resolvedArtifactMap\n    }\n\n    private static <T> Iterable<T> iterable(kotlin.sequences.Sequence<T> sequence) {\n        return sequence.iterator() as Iterable<T>\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/tc/kotlin/CommonIDEArtifactsResolver.groovy",
    "content": "package com.intellij.buildsupport.resolve.tc.kotlin\n\nimport com.intellij.buildsupport.resolve.tc.TCArtifact\nimport com.intellij.buildsupport.resolve.tc.TCArtifactsResolver\nimport groovy.transform.CompileStatic\n\n@CompileStatic\nclass CommonIDEArtifactsResolver extends TCArtifactsResolver {\n\n    final String kotlinCompilerVersion\n\n\n    CommonIDEArtifactsResolver(\n            String teamcityBaseUrl,\n            boolean lastSuccessfulBuild,\n            String tcBuildId,\n            String kotlinCompilerVersion\n    ) {\n        super(teamcityBaseUrl, lastSuccessfulBuild, tcBuildId, kotlinCompilerVersion)\n\n        this.kotlinCompilerVersion = kotlinCompilerVersion\n    }\n\n    public final TCArtifact KOTLIN_FORMATTER_JAR = new TCArtifact('internal', 'kotlin-formatter.jar')\n    public final TCArtifact KOTLIN_IDE_COMMON_JAR = new TCArtifact('internal', 'kotlin-ide-common.jar')\n\n    @Override\n    List<TCArtifact> getRequiredArtifacts() {\n        return [\n                KOTLIN_IDE_COMMON_JAR,\n                KOTLIN_FORMATTER_JAR\n        ]\n    }\n\n    @Override\n    String tcBuildTypeId() {\n        String kotlinCompilerVersionInBuildId = kotlinCompilerVersion.replace('.', '') // '1.3.0'  => '130'\n                .replace('-', '') // '1.3-M2' => '13M2'\n\n        return \"Kotlin_${kotlinCompilerVersionInBuildId}_CompilerAllPlugins\"\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/resolve/tc/kotlin/KotlinCompilerTCArtifactsResolver.groovy",
    "content": "package com.intellij.buildsupport.resolve.tc.kotlin\n\n\nimport com.intellij.buildsupport.resolve.tc.TCArtifact\nimport com.intellij.buildsupport.resolve.tc.TCArtifactsResolver\n\nimport groovy.transform.CompileStatic\n\n\n@CompileStatic\nclass KotlinCompilerTCArtifactsResolver extends TCArtifactsResolver {\n\n    final String kotlinIdeaCompatibleVersionMinor\n\n    final String kotlinCompilerVersion\n\n\n    KotlinCompilerTCArtifactsResolver(String teamcityBaseUrl, boolean lastSuccessfulBuild, String tcBuildId,\n                                      String kotlinCompilerVersion, String kotlinIdeaCompatibleVersionMinor) {\n        super(teamcityBaseUrl,\n              lastSuccessfulBuild,\n              tcBuildId,\n              kotlinCompilerVersion)\n\n        this.kotlinCompilerVersion            = kotlinCompilerVersion\n        this.kotlinIdeaCompatibleVersionMinor = kotlinIdeaCompatibleVersionMinor\n    }\n\n\n    public final TCArtifact KOTLIN_PLUGIN_ZIP           = new TCArtifact('',                                           \"kotlin-plugin-*-IJ${kotlinIdeaCompatibleVersionMinor}*.zip\")\n    public final TCArtifact KOTLIN_TEST_DATA_ZIP        = new TCArtifact('internal',                                   'kotlin-test-data.zip')\n    public final TCArtifact KOTLIN_COMPILER_SOURCES_JAR = new TCArtifact('maven/org/jetbrains/kotlin/kotlin-compiler', 'kotlin-compiler-*-sources.jar')\n\n\n    @Override\n    List<TCArtifact> getRequiredArtifacts() {\n        return [KOTLIN_TEST_DATA_ZIP,\n                KOTLIN_PLUGIN_ZIP,\n                KOTLIN_COMPILER_SOURCES_JAR]\n    }\n\n    @Override\n    String tcBuildTypeId() {\n        String kotlinCompilerVersionInBuildId = kotlinCompilerVersion.replace('.', '') // '1.3.0'  => '130'\n                                                                     .replace('-', '') // '1.3-M2' => '13M2'\n\n        return \"Kotlin_${kotlinCompilerVersionInBuildId}_Aggregate\"\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/main/groovy/com/intellij/buildsupport/utils/FileUtils.groovy",
    "content": "package com.intellij.buildsupport.utils\n\n\nimport groovy.transform.CompileStatic\n\n\n@CompileStatic\nclass FileUtils {\n    private FileUtils() {}\n\n\n    static void cleanDir(File dir) {\n        dir.deleteDir()\n        dir.mkdirs()\n    }\n\n    static void cleanDirExceptSubDirName(File dir, String retainSubDirName) {\n        if (dir.exists()) {\n            dir.eachFile { File file ->\n                if (file.isFile())\n                    file.delete()\n                else if (file.isDirectory()) {\n                    if (file.name != retainSubDirName)\n                        file.deleteDir()\n                }\n            }\n        }\n\n        dir.mkdirs()\n\n        new File(\"$dir/$retainSubDirName\").mkdirs()\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/buildSrc/src/test/groovy/com/intellij/buildsupport/tc/kotlin/KotlinCompilerTCArtifactsResolverSpecification.groovy",
    "content": "package com.intellij.buildsupport.tc.kotlin\n\n\nimport com.intellij.buildsupport.resolve.tc.TCArtifactsResolver\nimport com.intellij.buildsupport.resolve.tc.kotlin.KotlinCompilerTCArtifactsResolver\n\nimport java.text.SimpleDateFormat\n\nimport org.junit.Rule\nimport org.junit.contrib.java.lang.system.SystemOutRule\n\nimport spock.lang.Specification\nimport spock.lang.Unroll\n\nimport static org.apache.commons.lang3.StringUtils.countMatches\n\n\nclass KotlinCompilerTCArtifactsResolverSpecification extends Specification {\n\n    private static final String TC_BASE_URL = 'https://teamcity.jetbrains.com'\n\n    @Rule\n    public final SystemOutRule systemOut = new SystemOutRule().enableLog()\n\n\n    @Unroll\n    def \"should resolve TC artifacts by buildId for version #releaseDescribeVersion\"() {\n        setup:\n            def tcArtifactResolver = tcArtifactResolverWithBuildId(tcBuildId,\n                                                                   kotlinIdeaCompatibleVersionMinor)\n\n            def temporaryFile = File.createTempFile(\"kotlin-compiler-$releaseDescribeVersion\", '.tmp')\n\n        expect:\n            tcArtifactResolver.downloadTo tcArtifactResolver.KOTLIN_PLUGIN_ZIP, temporaryFile\n\n            assert temporaryFile.exists()\n\n        where:\n            releaseDescribeVersion | tcBuildId | kotlinIdeaCompatibleVersionMinor\n            '1.2.72-release-68'    | '1646860' | '2017.3'\n            '1.3-M2-eap-105'       | '1572593' | '2017.3'\n            '1.3.0-rc-153'         | '1664232' | '2017.3'\n    }\n\n    @Unroll\n    def \"should resolve TC artifacts for latest successful build for version #kotlinCompilerVersion\"() {\n        setup:\n            def tcArtifactResolver = tcArtifactResolverWithLatestBuildAndKotlinCompilerVersion(kotlinCompilerVersion,\n                                                                                               kotlinIdeaCompatibleVersionMinor)\n\n            def temporaryFile = File.createTempFile(\"kotlin-compiler-latest-$kotlinCompilerVersion\", '.tmp')\n\n        expect:\n            tcArtifactResolver.downloadTo tcArtifactResolver.KOTLIN_PLUGIN_ZIP, temporaryFile\n\n            assert temporaryFile.exists()\n\n        where:\n            kotlinCompilerVersion | kotlinIdeaCompatibleVersionMinor\n            '1.2.70'              | '2017.3'\n            '1.3-M1'              | '2017.3'\n            '1.3-M2'              | '2017.3'\n            '1.3.0'               | '2017.3'\n    }\n\n    @Unroll\n    def \"should resolve TC artifacts for latest successful build without TC artifacts for version #kotlinCompilerVersion\"() {\n        setup:\n            def tcArtifactResolver = tcArtifactResolverWithLatestBuildAndKotlinCompilerVersion(kotlinCompilerVersion,\n                                                                                               kotlinIdeaCompatibleVersionMinor,\n                                                                                               untilDate)\n\n            def temporaryFile = File.createTempFile(\"kotlin-compiler-latest-$kotlinCompilerVersion\", '.tmp')\n\n        expect:\n            tcArtifactResolver.downloadTo tcArtifactResolver.KOTLIN_PLUGIN_ZIP, temporaryFile\n\n            assert temporaryFile.exists()\n\n            assert countMatches(systemOut.log, 'Resolving TC build') == expectednumberOfSearchedTcBuilds\n\n        where:\n            untilDate    | kotlinCompilerVersion | kotlinIdeaCompatibleVersionMinor || expectednumberOfSearchedTcBuilds\n            '2018-08-16' | '1.2.60'              | '2017.3'                         || 4\n            '2018-09-10' | '1.2.70'              | '2017.3'                         || 5\n            '2018-08-24' | '1.3-M2'              | '2017.3'                         || 4\n            '2018-10-03' | '1.3.0'               | '2017.3'                         || 11\n    }\n\n\n    private static TCArtifactsResolver tcArtifactResolverWithBuildId(String tcBuildId,\n                                                                     String kotlinIdeaCompatibleVersionMinor) {\n        return new KotlinCompilerTCArtifactsResolver(TC_BASE_URL,\n                                                     false,     // not searching for last successful build\n                                                     tcBuildId,\n                                                     '', // Kotlin compiler version determined automatically\n                                                     kotlinIdeaCompatibleVersionMinor)\n    }\n\n    private static TCArtifactsResolver tcArtifactResolverWithLatestBuildAndKotlinCompilerVersion(String kotlinCompilerVersion,\n                                                                                                 String kotlinIdeaCompatibleVersionMinor) {\n        return tcArtifactResolverWithLatestBuildAndKotlinCompilerVersion(kotlinCompilerVersion,\n                                                                         kotlinIdeaCompatibleVersionMinor,\n                                                                         null)\n    }\n\n    private static TCArtifactsResolver tcArtifactResolverWithLatestBuildAndKotlinCompilerVersion(String kotlinCompilerVersion,\n                                                                                                 String kotlinIdeaCompatibleVersionMinor,\n                                                                                                 String untilDate) {\n        TCArtifactsResolver tcArtifactsResolver =  new KotlinCompilerTCArtifactsResolver(TC_BASE_URL,\n                                                                                         true,  // searching for last successful build\n                                                                                         '', // buildId not used\n                                                                                         kotlinCompilerVersion,\n                                                                                         kotlinIdeaCompatibleVersionMinor)\n\n        if (untilDate != null)\n            tcArtifactsResolver.untilDate = new SimpleDateFormat(\"yyyy-MM-dd\").parse(untilDate)\n\n        return tcArtifactsResolver\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.5.1-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "kotlin-bundled-compiler/gradlew",
    "content": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "kotlin-bundled-compiler/gradlew.bat",
    "content": "@rem\n@rem Copyright 2015 the original author or authors.\n@rem\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\n@rem you may not use this file except in compliance with the License.\n@rem You may obtain a copy of the License at\n@rem\n@rem      https://www.apache.org/licenses/LICENSE-2.0\n@rem\n@rem Unless required by applicable law or agreed to in writing, software\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n@rem See the License for the specific language governing permissions and\n@rem limitations under the License.\n@rem\n\n@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windows variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "kotlin-bundled-compiler/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.bundled-compiler</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\t\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>3.10.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<release>17</release>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n\n\t<profiles>\n\t\t<profile>\n\t\t\t<id>with-gradle</id>\n\t\t\t<build>\n\t\t\t\t<plugins>\n\t\t\t\t\t<plugin>\n\t\t\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t\t\t<artifactId>exec-maven-plugin</artifactId>\n\t\t\t\t\t\t<version>3.0.0</version>\n\t\t\t\t\t\t<executions>\n\t\t\t\t\t\t\t<execution>\n\t\t\t\t\t\t\t\t<id>gradle-clean</id>\n\t\t\t\t\t\t\t\t<phase>clean</phase>\n\t\t\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t\t\t<goal>exec</goal>\n\t\t\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t\t\t<executable>${project.basedir}/gradlew</executable>\n\t\t\t\t\t\t\t\t\t<arguments>\n\t\t\t\t\t\t\t\t\t\t<argument>clean</argument>\n\t\t\t\t\t\t\t\t\t</arguments>\n\t\t\t\t\t\t\t\t</configuration>\n\t\t\t\t\t\t\t</execution>\n\t\t\t\t\t\t\t<execution>\n\t\t\t\t\t\t\t\t<id>gradle-getBundled</id>\n\t\t\t\t\t\t\t\t<phase>validate</phase>\n\t\t\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t\t\t<goal>exec</goal>\n\t\t\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t\t\t<executable>${project.basedir}/gradlew</executable>\n\t\t\t\t\t\t\t\t\t<arguments>\n\t\t\t\t\t\t\t\t\t\t<argument>getBundled</argument>\n\t\t\t\t\t\t\t\t\t</arguments>\n\t\t\t\t\t\t\t\t</configuration>\n\t\t\t\t\t\t\t</execution>\n\t\t\t\t\t\t</executions>\n\t\t\t\t\t</plugin>\n\t\t\t\t</plugins>\n\t\t\t</build>\n\t\t</profile>\n\t</profiles>\n</project>"
  },
  {
    "path": "kotlin-bundled-compiler/referencedPackages.txt",
    "content": "# List of packages that are referenced from other dependencies and should be included in plugin to avoid classpath issues\n\ncom.intellij.psi.codeStyle\ncom.intellij.psi.formatter\ncom.intellij.openapi.components\ncom.intellij.openapi.options\ncom.intellij.application.options\ncom.intellij.application.options.codeStyle.properties\ncom.intellij.formatting\ncom.intellij.formatting.engine\ncom.intellij.util.containers\ngnu.trove\ncom.intellij.openapi.util\ncom.intellij.openapi.util.text\ncom.intellij.psi.codeStyle.arrangement\ncom.intellij.configurationStore\ncom.intellij.openapi.progress\ncom.intellij.ui\ncom.intellij.util.text\ncustom:com/intellij/CodeStyleBundle.class\ncustom:com/intellij/DynamicBundle.class\ncustom:com/intellij/AbstractBundle.class\ncustom:messages/CodeStyleBundle.*\nit.unimi.dsi.fastutil.objects"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/codeInsight/CodeInsightBundle.java",
    "content": "package com.intellij.codeInsight;\n\npublic class CodeInsightBundle {\n    public static String message(String key, Object... params) {\n        return key;\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/codeInsight/KotlinNullableNotNullManager.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage com.intellij.codeInsight\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.PsiAnnotation\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiModifierListOwner\nimport org.jetbrains.annotations.Nullable\n\n\n// Dummy implementation. Will be changed to something more useful, when KE-277 is fixed.\nclass KotlinNullableNotNullManager(project: Project) : NullableNotNullManager(project) {\n    private val _nullables = mutableListOf<String>()\n    private val _notNulls = mutableListOf<String>()\n\n    override fun getNullables(): List<String> = _nullables\n\n    override fun setInstrumentedNotNulls(names: MutableList<String>) {}\n\n    override fun getInstrumentedNotNulls(): List<String> = emptyList()\n\n//    override fun isJsr305Default(annotation: PsiAnnotation, placeTargetTypes: Array<out PsiAnnotation.TargetType>): NullabilityAnnotationInfo? = null\n\n    override fun setNullables(vararg annotations: String) {\n        _nullables.clear()\n        _nullables.addAll(annotations)\n    }\n\n    override fun getNotNulls(): List<String> = _notNulls\n\n    override fun setDefaultNotNull(defaultNotNull: String) {\n    }\n\n    override fun getDefaultNullable(): String = \"Nullable\"\n\n    override fun getDefaultNotNull(): String {\n        return \"NotNullable\"\n    }\n\n    override fun getDefaultNullables(): MutableList<String> {\n        return mutableListOf(defaultNullable)\n    }\n\n    override fun getDefaultNotNulls(): MutableList<String> {\n        return mutableListOf(defaultNotNull)\n    }\n\n    override fun getAllDefaultAnnotations(): MutableList<String> {\n        return (defaultNullables + defaultNotNulls).toMutableList()\n    }\n\n    override fun setNotNulls(vararg annotations: String) {\n        _notNulls.clear()\n        _notNulls.addAll(annotations)\n    }\n\n    //    For now we get unresolved psi elements and as a result annotations qualified names are short\n    init {\n        setNotNulls(\"NotNull\")\n        setNullables(\"Nullable\")\n    }\n\n    override fun setDefaultNullable(defaultNullable: String) {\n    }\n\n    override fun hasHardcodedContracts(element: PsiElement): Boolean = false\n\n    override fun isNotNull(owner: PsiModifierListOwner, checkBases: Boolean): Boolean {\n        val notNullAnnotations = notNulls.toSet()\n        return owner.modifierList?.annotations?.any { annotation ->\n            annotation.qualifiedName in notNullAnnotations\n        } ?: false\n    }\n\n    @Nullable\n    override fun getNullityDefault(\n        container: PsiModifierListOwner,\n        placeTargetTypes: Array<PsiAnnotation.TargetType>,\n        context: PsiElement, superPackage: Boolean\n    ): NullabilityAnnotationInfo? {\n        return null\n    }\n\n    override fun isNullable(owner: PsiModifierListOwner, checkBases: Boolean) = !isNotNull(owner, checkBases)\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/codeInsight/actions/ReformatCodeProcessor.java",
    "content": "package com.intellij.codeInsight.actions;\n\npublic class ReformatCodeProcessor {\n    public static final String COMMAND_NAME = \"dummy\";\n\n    public static String getCommandName() {\n        return \"Reformat Code\";\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/codeInsight/generation/GenerateEqualsHelper.java",
    "content": "package com.intellij.codeInsight.generation;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.psi.PsiClassType;\nimport com.intellij.psi.PsiManager;\nimport com.intellij.psi.PsiSubstitutor;\nimport com.intellij.psi.PsiType;\nimport com.intellij.psi.PsiTypeParameter;\nimport com.intellij.psi.search.GlobalSearchScope;\nimport com.intellij.psi.util.MethodSignature;\nimport com.intellij.psi.util.MethodSignatureUtil;\n\n// Temp workaround for bad j2k classes politics\npublic class GenerateEqualsHelper {\n    public static MethodSignature getEqualsSignature(Project project, GlobalSearchScope scope) {\n    \tfinal PsiClassType javaLangObject = PsiType.getJavaLangObject(PsiManager.getInstance(project), scope);\n        return MethodSignatureUtil.createMethodSignature(\n        \t\t\"equals\", new PsiType[]{javaLangObject}, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);\n    }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/formatting/KotlinLanguageCodeStyleSettingsProvider.kt",
    "content": "package com.intellij.formatting\n\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport com.intellij.application.options.IndentOptionsEditor\nimport com.intellij.lang.Language\nimport com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable\nimport com.intellij.psi.codeStyle.CommonCodeStyleSettings\nimport com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider\nimport org.jetbrains.kotlin.idea.formatter.KotlinCommonCodeStyleSettings\n\nclass KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {\n    override fun getLanguage(): Language = KotlinLanguage.INSTANCE\n    \n    override fun getCodeSample(settingsType: SettingsType): String = \"\"\n    \n    override fun getLanguageName(): String = KotlinLanguage.NAME\n    \n    override fun customizeSettings(consumer:CodeStyleSettingsCustomizable, settingsType:SettingsType) {\n    }\n    \n    override fun getIndentOptionsEditor(): IndentOptionsEditor? = null\n    \n    override fun getDefaultCommonSettings(): CommonCodeStyleSettings {\n        val commonCodeStyleSettings = KotlinCommonCodeStyleSettings()\n        commonCodeStyleSettings.initIndentOptions()\n        return commonCodeStyleSettings\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/formatting/KotlinSettingsProvider.kt",
    "content": "package com.intellij.formatting\n\nimport com.intellij.lang.Language\nimport com.intellij.openapi.options.Configurable\nimport com.intellij.psi.codeStyle.CodeStyleSettings\nimport com.intellij.psi.codeStyle.CodeStyleSettingsProvider\nimport com.intellij.psi.codeStyle.CustomCodeStyleSettings\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings\n\nclass KotlinSettingsProvider : CodeStyleSettingsProvider() {\n    override fun getConfigurableDisplayName(): String = KotlinLanguage.NAME\n    \n    override fun getLanguage(): Language = KotlinLanguage.INSTANCE\n    \n    override fun createCustomSettings(settings: CodeStyleSettings): CustomCodeStyleSettings {\n        return KotlinCodeStyleSettings(settings).apply {\n            this.ALLOW_TRAILING_COMMA = true\n            this.ALLOW_TRAILING_COMMA_ON_CALL_SITE = true\n        }\n    }\n    \n    override fun createSettingsPage(settings: CodeStyleSettings, originalSettings: CodeStyleSettings): Configurable {\n        throw UnsupportedOperationException()\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/openapi/editor/Editor.java",
    "content": "package com.intellij.openapi.editor;\n\npublic class Editor {\n    \n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/openapi/extensions/ExtensionException.kt",
    "content": "package com.intellij.openapi.extensions\n\nclass ExtensionException(val extensionClass: Class<*>) : RuntimeException(extensionClass.getCanonicalName())"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/openapi/fileTypes/StdFileTypes.java",
    "content": "package com.intellij.openapi.fileTypes;\n\npublic class StdFileTypes {\n    public static final LanguageFileType JAVA = null;\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/openapi/util/text/StringUtil.java",
    "content": "// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.\npackage com.intellij.openapi.util.text;\n\nimport com.intellij.openapi.diagnostic.Logger;\nimport com.intellij.openapi.progress.ProcessCanceledException;\nimport com.intellij.openapi.util.Pair;\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.util.*;\nimport com.intellij.util.containers.ContainerUtil;\nimport com.intellij.util.text.*;\nimport org.jetbrains.annotations.Contract;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport javax.swing.text.MutableAttributeSet;\nimport javax.swing.text.html.HTML;\nimport javax.swing.text.html.HTMLEditorKit;\nimport javax.swing.text.html.parser.ParserDelegator;\nimport java.beans.Introspector;\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.io.StringReader;\nimport java.util.*;\nimport java.util.StringTokenizer;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n//TeamCity inherits StringUtil: do not add private constructors!!!\n@SuppressWarnings(\"MethodOverridesStaticMethodOfSuperclass\")\npublic class StringUtil extends StringUtilRt {\n    private static final Logger LOG = Logger.getInstance(\"#com.intellij.openapi.util.text.StringUtil\");\n\n    @SuppressWarnings(\"SpellCheckingInspection\") private static final String VOWELS = \"aeiouy\";\n    private static final Pattern EOL_SPLIT_KEEP_SEPARATORS = Pattern.compile(\"(?<=(\\r\\n|\\n))|(?<=\\r)(?=[^\\n])\");\n    private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(\" *(\\r|\\n|\\r\\n)+ *\");\n    private static final Pattern EOL_SPLIT_PATTERN_WITH_EMPTY = Pattern.compile(\" *(\\r|\\n|\\r\\n) *\");\n    private static final Pattern EOL_SPLIT_DONT_TRIM_PATTERN = Pattern.compile(\"(\\r|\\n|\\r\\n)+\");\n\n    @NotNull\n    public static MergingCharSequence replaceSubSequence(@NotNull CharSequence charSeq, int start, int end, @NotNull CharSequence replacement) {\n        return new MergingCharSequence(\n                new MergingCharSequence(charSeq.subSequence(0, start), replacement),\n                charSeq.subSequence(end, charSeq.length()));\n    }\n\n    @Contract(value = \"null -> null; !null->!null\", pure = true)\n    public static String internEmptyString(String s) {\n        return s == null ? null : (s.isEmpty() ? \"\" : s);\n    }\n\n    private static class MyHtml2Text extends HTMLEditorKit.ParserCallback {\n        @NotNull private final StringBuilder myBuffer = new StringBuilder();\n        private final boolean myIsSkipStyleTag;\n\n        private boolean myIsStyleTagOpened;\n\n        private MyHtml2Text(boolean isSkipStyleTag) {\n            myIsSkipStyleTag = isSkipStyleTag;\n        }\n\n        public void parse(@NotNull Reader in) throws IOException {\n            myBuffer.setLength(0);\n            new ParserDelegator().parse(in, this, Boolean.TRUE);\n        }\n\n        @Override\n        public void handleText(@NotNull char[] text, int pos) {\n            if (!myIsStyleTagOpened) {\n                myBuffer.append(text);\n            }\n        }\n\n        @Override\n        public void handleStartTag(@NotNull HTML.Tag tag, MutableAttributeSet set, int i) {\n            if (myIsSkipStyleTag && \"style\".equals(tag.toString())) {\n                myIsStyleTagOpened = true;\n            }\n            handleTag(tag);\n        }\n\n        @Override\n        public void handleEndTag(@NotNull HTML.Tag tag, int pos) {\n            if (myIsSkipStyleTag && \"style\".equals(tag.toString())) {\n                myIsStyleTagOpened = false;\n            }\n        }\n\n        @Override\n        public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet set, int i) {\n            handleTag(tag);\n        }\n\n        private void handleTag(@NotNull HTML.Tag tag) {\n            if (tag.breaksFlow() && myBuffer.length() > 0) {\n                myBuffer.append(SystemProperties.getLineSeparator());\n            }\n        }\n\n        @NotNull\n        public String getText() {\n            return myBuffer.toString();\n        }\n    }\n\n    private static final MyHtml2Text html2TextParser = new MyHtml2Text(false);\n\n    public static final NotNullFunction<String, String> QUOTER = new NotNullFunction<String, String>() {\n        @Override\n        @NotNull\n        public String fun(String s) {\n            return \"\\\"\" + s + \"\\\"\";\n        }\n    };\n\n    public static final NotNullFunction<String, String> SINGLE_QUOTER = new NotNullFunction<String, String>() {\n        @Override\n        @NotNull\n        public String fun(String s) {\n            return \"'\" + s + \"'\";\n        }\n    };\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> getWordsInStringLongestFirst(@NotNull String find) {\n        List<String> words = getWordsIn(find);\n        // hope long words are rare\n        Collections.sort(words, new Comparator<String>() {\n            @Override\n            public int compare(@NotNull final String o1, @NotNull final String o2) {\n                return o2.length() - o1.length();\n            }\n        });\n        return words;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapePattern(@NotNull final String text) {\n        return replace(replace(text, \"'\", \"''\"), \"{\", \"'{'\");\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static <T> Function<T, String> createToStringFunction(@SuppressWarnings(\"unused\") @NotNull Class<T> cls) {\n        return new Function<T, String>() {\n            @Override\n            public String fun(@NotNull T o) {\n                return o.toString();\n            }\n        };\n    }\n\n    @NotNull\n    public static final Function<String, String> TRIMMER = new Function<String, String>() {\n        @Nullable\n        @Override\n        public String fun(@Nullable String s) {\n            return trim(s);\n        }\n    };\n\n    // Unlike String.replace(CharSequence,CharSequence) does not allocate intermediate objects on non-match\n    // TODO revise when JDK9 arrives - its String.replace(CharSequence, CharSequence) is more optimized\n    @NotNull\n    @Contract(pure = true)\n    public static String replace(@NotNull String text, @NotNull String oldS, @NotNull String newS) {\n        return replace(text, oldS, newS, false);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String replaceIgnoreCase(@NotNull String text, @NotNull String oldS, @NotNull String newS) {\n        return replace(text, oldS, newS, true);\n    }\n\n    /**\n     * @deprecated Use {@link String#replace(char,char)} instead\n     */\n    @NotNull\n    @Contract(pure = true)\n    @Deprecated\n    public static String replaceChar(@NotNull String buffer, char oldChar, char newChar) {\n        return buffer.replace(oldChar, newChar);\n    }\n\n    @Contract(pure = true)\n    public static String replace(@NotNull final String text, @NotNull final String oldS, @NotNull final String newS, final boolean ignoreCase) {\n        if (text.length() < oldS.length()) return text;\n\n        StringBuilder newText = null;\n        int i = 0;\n\n        while (i < text.length()) {\n            final int index = ignoreCase? indexOfIgnoreCase(text, oldS, i) : text.indexOf(oldS, i);\n            if (index < 0) {\n                if (i == 0) {\n                    return text;\n                }\n\n                newText.append(text, i, text.length());\n                break;\n            }\n            else {\n                if (newText == null) {\n                    if (text.length() == oldS.length()) {\n                        return newS;\n                    }\n                    newText = new StringBuilder(text.length() - i);\n                }\n\n                newText.append(text, i, index);\n                newText.append(newS);\n                i = index + oldS.length();\n            }\n        }\n        return newText != null ? newText.toString() : \"\";\n    }\n\n    @Contract(pure = true)\n    public static int indexOfIgnoreCase(@NotNull String where, @NotNull String what, int fromIndex) {\n        return indexOfIgnoreCase((CharSequence)where, what, fromIndex);\n    }\n\n    /**\n     * Implementation copied from {@link String#indexOf(String, int)} except character comparisons made case insensitive\n     */\n    @Contract(pure = true)\n    public static int indexOfIgnoreCase(@NotNull CharSequence where, @NotNull CharSequence what, int fromIndex) {\n        int targetCount = what.length();\n        int sourceCount = where.length();\n\n        if (fromIndex >= sourceCount) {\n            return targetCount == 0 ? sourceCount : -1;\n        }\n\n        if (fromIndex < 0) {\n            fromIndex = 0;\n        }\n\n        if (targetCount == 0) {\n            return fromIndex;\n        }\n\n        char first = what.charAt(0);\n        int max = sourceCount - targetCount;\n\n        for (int i = fromIndex; i <= max; i++) {\n            /* Look for first character. */\n            if (!charsEqualIgnoreCase(where.charAt(i), first)) {\n                //noinspection StatementWithEmptyBody,AssignmentToForLoopParameter\n                while (++i <= max && !charsEqualIgnoreCase(where.charAt(i), first)) ;\n            }\n\n            /* Found first character, now look at the rest of v2 */\n            if (i <= max) {\n                int j = i + 1;\n                int end = j + targetCount - 1;\n                //noinspection StatementWithEmptyBody\n                for (int k = 1; j < end && charsEqualIgnoreCase(where.charAt(j), what.charAt(k)); j++, k++) ;\n\n                if (j == end) {\n                    /* Found whole string. */\n                    return i;\n                }\n            }\n        }\n\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int indexOfIgnoreCase(@NotNull String where, char what, int fromIndex) {\n        int sourceCount = where.length();\n        for (int i = Math.max(fromIndex, 0); i < sourceCount; i++) {\n            if (charsEqualIgnoreCase(where.charAt(i), what)) {\n                return i;\n            }\n        }\n\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int lastIndexOfIgnoreCase(@NotNull String where, char what, int fromIndex) {\n        for (int i = Math.min(fromIndex, where.length() - 1); i >= 0; i--) {\n            if (charsEqualIgnoreCase(where.charAt(i), what)) {\n                return i;\n            }\n        }\n\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static boolean containsIgnoreCase(@NotNull String where, @NotNull String what) {\n        return indexOfIgnoreCase(where, what, 0) >= 0;\n    }\n\n    @Contract(pure = true)\n    public static boolean endsWithIgnoreCase(@NotNull String str, @NotNull String suffix) {\n        return StringUtilRt.endsWithIgnoreCase(str, suffix);\n    }\n\n    @Contract(pure = true)\n    public static boolean startsWithIgnoreCase(@NotNull String str, @NotNull String prefix) {\n        return StringUtilRt.startsWithIgnoreCase(str, prefix);\n    }\n\n    @Contract(pure = true)\n    @NotNull\n    public static String stripHtml(@NotNull String html, boolean convertBreaks) {\n        if (convertBreaks) {\n            html = html.replaceAll(\"<br/?>\", \"\\n\\n\");\n        }\n\n        return html.replaceAll(\"<(.|\\n)*?>\", \"\");\n    }\n\n    @Contract(value = \"null -> null; !null -> !null\", pure = true)\n    public static String toLowerCase(@Nullable final String str) {\n        return str == null ? null : str.toLowerCase();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String getPackageName(@NotNull String fqName) {\n        return getPackageName(fqName, '.');\n    }\n\n    /**\n     * Given a fqName returns the package name for the type or the containing type.\n     * <p/>\n     * <ul>\n     * <li>{@code java.lang.String} -> {@code java.lang}</li>\n     * <li>{@code java.util.Map.Entry} -> {@code java.util.Map}</li>\n     * </ul>\n     *\n     * @param fqName    a fully qualified type name. Not supposed to contain any type arguments\n     * @param separator the separator to use. Typically '.'\n     * @return the package name of the type or the declarator of the type. The empty string if the given fqName is unqualified\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String getPackageName(@NotNull String fqName, char separator) {\n        int lastPointIdx = fqName.lastIndexOf(separator);\n        if (lastPointIdx >= 0) {\n            return fqName.substring(0, lastPointIdx);\n        }\n        return \"\";\n    }\n\n    @Contract(pure = true)\n    public static int getLineBreakCount(@NotNull CharSequence text) {\n        int count = 0;\n        for (int i = 0; i < text.length(); i++) {\n            char c = text.charAt(i);\n            if (c == '\\n') {\n                count++;\n            }\n            else if (c == '\\r') {\n                if (i + 1 < text.length() && text.charAt(i + 1) == '\\n') {\n                    //noinspection AssignmentToForLoopParameter\n                    i++;\n                }\n                count++;\n            }\n        }\n        return count;\n    }\n\n    @Contract(pure = true)\n    public static boolean containsLineBreak(@NotNull CharSequence text) {\n        for (int i = 0; i < text.length(); i++) {\n            char c = text.charAt(i);\n            if (isLineBreak(c)) return true;\n        }\n        return false;\n    }\n\n    @Contract(pure = true)\n    public static boolean isLineBreak(char c) {\n        return c == '\\n' || c == '\\r';\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeLineBreak(@NotNull String text) {\n        StringBuilder buffer = new StringBuilder(text.length());\n        for (int i = 0; i < text.length(); i++) {\n            char c = text.charAt(i);\n            switch (c) {\n                case '\\n':\n                    buffer.append(\"\\\\n\");\n                    break;\n                case '\\r':\n                    buffer.append(\"\\\\r\");\n                    break;\n                default:\n                    buffer.append(c);\n            }\n        }\n        return buffer.toString();\n    }\n\n    @Contract(pure = true)\n    public static boolean endsWithLineBreak(@NotNull CharSequence text) {\n        int len = text.length();\n        return len > 0 && isLineBreak(text.charAt(len - 1));\n    }\n\n    @Contract(pure = true)\n    public static int lineColToOffset(@NotNull CharSequence text, int line, int col) {\n        int curLine = 0;\n        int offset = 0;\n        while (line != curLine) {\n            if (offset == text.length()) return -1;\n            char c = text.charAt(offset);\n            if (c == '\\n') {\n                curLine++;\n            }\n            else if (c == '\\r') {\n                curLine++;\n                if (offset < text.length() - 1 && text.charAt(offset + 1) == '\\n') {\n                    offset++;\n                }\n            }\n            offset++;\n        }\n        return offset + col;\n    }\n\n    @Contract(pure = true)\n    public static int offsetToLineNumber(@NotNull CharSequence text, int offset) {\n        LineColumn lineColumn = offsetToLineColumn(text, offset);\n        return lineColumn != null ? lineColumn.line : -1;\n    }\n\n    @Contract(pure = true)\n    public static LineColumn offsetToLineColumn(@NotNull CharSequence text, int offset) {\n        int curLine = 0;\n        int curLineStart = 0;\n        int curOffset = 0;\n        while (curOffset < offset) {\n            if (curOffset == text.length()) return null;\n            char c = text.charAt(curOffset);\n            if (c == '\\n') {\n                curLine++;\n                curLineStart = curOffset + 1;\n            }\n            else if (c == '\\r') {\n                curLine++;\n                if (curOffset < text.length() - 1 && text.charAt(curOffset + 1) == '\\n') {\n                    curOffset++;\n                }\n                curLineStart = curOffset + 1;\n            }\n            curOffset++;\n        }\n\n        return LineColumn.of(curLine, offset - curLineStart);\n    }\n\n    /**\n     * Classic dynamic programming algorithm for string differences.\n     */\n    @Contract(pure = true)\n    public static int difference(@NotNull String s1, @NotNull String s2) {\n        int[][] a = new int[s1.length()][s2.length()];\n\n        for (int i = 0; i < s1.length(); i++) {\n            a[i][0] = i;\n        }\n\n        for (int j = 0; j < s2.length(); j++) {\n            a[0][j] = j;\n        }\n\n        for (int i = 1; i < s1.length(); i++) {\n            for (int j = 1; j < s2.length(); j++) {\n\n                a[i][j] = Math.min(Math.min(a[i - 1][j - 1] + (s1.charAt(i) == s2.charAt(j) ? 0 : 1), a[i - 1][j] + 1), a[i][j - 1] + 1);\n            }\n        }\n\n        return a[s1.length() - 1][s2.length() - 1];\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String wordsToBeginFromUpperCase(@NotNull String s) {\n        return fixCapitalization(s, ourPrepositions, true);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String wordsToBeginFromLowerCase(@NotNull String s) {\n        return fixCapitalization(s, ourPrepositions, false);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String toTitleCase(@NotNull String s) {\n        return fixCapitalization(s, ArrayUtil.EMPTY_STRING_ARRAY, true);\n    }\n\n    @NotNull\n    private static String fixCapitalization(@NotNull String s, @NotNull String[] prepositions, boolean title) {\n        StringBuilder buffer = null;\n        for (int i = 0; i < s.length(); i++) {\n            char prevChar = i == 0 ? ' ' : s.charAt(i - 1);\n            char currChar = s.charAt(i);\n            if (!Character.isLetterOrDigit(prevChar) && prevChar != '\\'') {\n                if (Character.isLetterOrDigit(currChar)) {\n                    if (title || Character.isUpperCase(currChar)) {\n                        int j = i;\n                        for (; j < s.length(); j++) {\n                            if (!Character.isLetterOrDigit(s.charAt(j))) {\n                                break;\n                            }\n                        }\n                        if (!title && j > i + 1 && !Character.isLowerCase(s.charAt(i + 1))) {\n                            // filter out abbreviations like I18n, SQL and CSS\n                            continue;\n                        }\n                        if (!isPreposition(s, i, j - 1, prepositions)) {\n                            if (buffer == null) {\n                                buffer = new StringBuilder(s);\n                            }\n                            buffer.setCharAt(i, title ? toUpperCase(currChar) : toLowerCase(currChar));\n                        }\n                    }\n                }\n            }\n        }\n        return buffer == null ? s : buffer.toString();\n    }\n\n    private static final String[] ourPrepositions = {\n            \"a\", \"an\", \"and\", \"as\", \"at\", \"but\", \"by\", \"down\", \"for\", \"from\", \"if\", \"in\", \"into\", \"not\", \"of\", \"on\", \"onto\", \"or\", \"out\", \"over\",\n            \"per\", \"nor\", \"the\", \"to\", \"up\", \"upon\", \"via\", \"with\"\n    };\n\n    @Contract(pure = true)\n    public static boolean isPreposition(@NotNull String s, int firstChar, int lastChar) {\n        return isPreposition(s, firstChar, lastChar, ourPrepositions);\n    }\n\n    @Contract(pure = true)\n    public static boolean isPreposition(@NotNull String s, int firstChar, int lastChar, @NotNull String[] prepositions) {\n        for (String preposition : prepositions) {\n            boolean found = false;\n            if (lastChar - firstChar + 1 == preposition.length()) {\n                found = true;\n                for (int j = 0; j < preposition.length(); j++) {\n                    if (toLowerCase(s.charAt(firstChar + j)) != preposition.charAt(j)) {\n                        found = false;\n                    }\n                }\n            }\n            if (found) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static NotNullFunction<String, String> escaper(final boolean escapeSlash, @Nullable final String additionalChars) {\n        return new NotNullFunction<String, String>() {\n            @NotNull\n            @Override\n            public String fun(@NotNull String dom) {\n                final StringBuilder builder = new StringBuilder(dom.length());\n                escapeStringCharacters(dom.length(), dom, additionalChars, escapeSlash, builder);\n                return builder.toString();\n            }\n        };\n    }\n\n\n    public static void escapeStringCharacters(int length, @NotNull String str, @NotNull StringBuilder buffer) {\n        escapeStringCharacters(length, str, \"\\\"\", buffer);\n    }\n\n    @NotNull\n    public static StringBuilder escapeStringCharacters(int length,\n                                                       @NotNull String str,\n                                                       @Nullable String additionalChars,\n                                                       @NotNull StringBuilder buffer) {\n        return escapeStringCharacters(length, str, additionalChars, true, buffer);\n    }\n\n    @NotNull\n    public static StringBuilder escapeStringCharacters(int length,\n                                                       @NotNull String str,\n                                                       @Nullable String additionalChars,\n                                                       boolean escapeSlash,\n                                                       @NotNull StringBuilder buffer) {\n        return escapeStringCharacters(length, str, additionalChars, escapeSlash, true, buffer);\n    }\n\n    @NotNull\n    public static StringBuilder escapeStringCharacters(int length,\n                                                       @NotNull String str,\n                                                       @Nullable String additionalChars,\n                                                       boolean escapeSlash,\n                                                       boolean escapeUnicode,\n                                                       @NotNull StringBuilder buffer) {\n        char prev = 0;\n        for (int idx = 0; idx < length; idx++) {\n            char ch = str.charAt(idx);\n            switch (ch) {\n                case '\\b':\n                    buffer.append(\"\\\\b\");\n                    break;\n\n                case '\\t':\n                    buffer.append(\"\\\\t\");\n                    break;\n\n                case '\\n':\n                    buffer.append(\"\\\\n\");\n                    break;\n\n                case '\\f':\n                    buffer.append(\"\\\\f\");\n                    break;\n\n                case '\\r':\n                    buffer.append(\"\\\\r\");\n                    break;\n\n                default:\n                    if (escapeSlash && ch == '\\\\') {\n                        buffer.append(\"\\\\\\\\\");\n                    }\n                    else if (additionalChars != null && additionalChars.indexOf(ch) > -1 && (escapeSlash || prev != '\\\\')) {\n                        buffer.append(\"\\\\\").append(ch);\n                    }\n                    else if (escapeUnicode && !isPrintableUnicode(ch)) {\n                        CharSequence hexCode = toUpperCase(Integer.toHexString(ch));\n                        buffer.append(\"\\\\u\");\n                        int paddingCount = 4 - hexCode.length();\n                        while (paddingCount-- > 0) {\n                            buffer.append(0);\n                        }\n                        buffer.append(hexCode);\n                    }\n                    else {\n                        buffer.append(ch);\n                    }\n            }\n            prev = ch;\n        }\n        return buffer;\n    }\n\n    @Contract(pure = true)\n    public static boolean isPrintableUnicode(char c) {\n        int t = Character.getType(c);\n        return t != Character.UNASSIGNED && t != Character.LINE_SEPARATOR && t != Character.PARAGRAPH_SEPARATOR &&\n                t != Character.CONTROL && t != Character.FORMAT && t != Character.PRIVATE_USE && t != Character.SURROGATE;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeStringCharacters(@NotNull String s) {\n        StringBuilder buffer = new StringBuilder(s.length());\n        escapeStringCharacters(s.length(), s, \"\\\"\", buffer);\n        return buffer.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeCharCharacters(@NotNull String s) {\n        StringBuilder buffer = new StringBuilder(s.length());\n        escapeStringCharacters(s.length(), s, \"\\'\", buffer);\n        return buffer.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String unescapeStringCharacters(@NotNull String s) {\n        StringBuilder buffer = new StringBuilder(s.length());\n        unescapeStringCharacters(s.length(), s, buffer);\n        return buffer.toString();\n    }\n\n    private static boolean isQuoteAt(@NotNull String s, int ind) {\n        char ch = s.charAt(ind);\n        return ch == '\\'' || ch == '\\\"';\n    }\n\n    @Contract(pure = true)\n    public static boolean isQuotedString(@NotNull String s) {\n        return StringUtilRt.isQuotedString(s);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String unquoteString(@NotNull String s) {\n        return StringUtilRt.unquoteString(s);\n    }\n\n    private static void unescapeStringCharacters(int length, @NotNull String s, @NotNull StringBuilder buffer) {\n        boolean escaped = false;\n        for (int idx = 0; idx < length; idx++) {\n            char ch = s.charAt(idx);\n            if (!escaped) {\n                if (ch == '\\\\') {\n                    escaped = true;\n                }\n                else {\n                    buffer.append(ch);\n                }\n            }\n            else {\n                int octalEscapeMaxLength = 2;\n                switch (ch) {\n                    case 'n':\n                        buffer.append('\\n');\n                        break;\n\n                    case 'r':\n                        buffer.append('\\r');\n                        break;\n\n                    case 'b':\n                        buffer.append('\\b');\n                        break;\n\n                    case 't':\n                        buffer.append('\\t');\n                        break;\n\n                    case 'f':\n                        buffer.append('\\f');\n                        break;\n\n                    case '\\'':\n                        buffer.append('\\'');\n                        break;\n\n                    case '\\\"':\n                        buffer.append('\\\"');\n                        break;\n\n                    case '\\\\':\n                        buffer.append('\\\\');\n                        break;\n\n                    case 'u':\n                        if (idx + 4 < length) {\n                            try {\n                                int code = Integer.parseInt(s.substring(idx + 1, idx + 5), 16);\n                                //noinspection AssignmentToForLoopParameter\n                                idx += 4;\n                                buffer.append((char)code);\n                            }\n                            catch (NumberFormatException e) {\n                                buffer.append(\"\\\\u\");\n                            }\n                        }\n                        else {\n                            buffer.append(\"\\\\u\");\n                        }\n                        break;\n\n                    case '0':\n                    case '1':\n                    case '2':\n                    case '3':\n                        octalEscapeMaxLength = 3;\n                        //noinspection fallthrough\n                    case '4':\n                    case '5':\n                    case '6':\n                    case '7':\n                        int escapeEnd = idx + 1;\n                        while (escapeEnd < length && escapeEnd < idx + octalEscapeMaxLength && isOctalDigit(s.charAt(escapeEnd))) escapeEnd++;\n                        try {\n                            buffer.append((char)Integer.parseInt(s.substring(idx, escapeEnd), 8));\n                        }\n                        catch (NumberFormatException e) {\n                            throw new RuntimeException(\"Couldn't parse \" + s.substring(idx, escapeEnd), e); // shouldn't happen\n                        }\n                        //noinspection AssignmentToForLoopParameter\n                        idx = escapeEnd - 1;\n                        break;\n\n                    default:\n                        buffer.append(ch);\n                        break;\n                }\n                escaped = false;\n            }\n        }\n\n        if (escaped) buffer.append('\\\\');\n    }\n\n//  @NotNull\n//  @Contract(pure = true)\n//  public static String pluralize(@NotNull String word) {\n//    String plural = Pluralizer.PLURALIZER.plural(word);\n//    if (plural != null) return plural;\n//    if (word.endsWith(\"s\")) return Pluralizer.restoreCase(word, word + \"es\");\n//    return Pluralizer.restoreCase(word, word + \"s\");\n//  }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String capitalizeWords(@NotNull String text,\n                                         boolean allWords) {\n        return capitalizeWords(text, \" \\t\\n\\r\\f\", allWords, false);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String capitalizeWords(@NotNull String text,\n                                         @NotNull String tokenizerDelim,\n                                         boolean allWords,\n                                         boolean leaveOriginalDelims) {\n        final StringTokenizer tokenizer = new StringTokenizer(text, tokenizerDelim, leaveOriginalDelims);\n        final StringBuilder out = new StringBuilder(text.length());\n        boolean toCapitalize = true;\n        while (tokenizer.hasMoreTokens()) {\n            final String word = tokenizer.nextToken();\n            if (!leaveOriginalDelims && out.length() > 0) {\n                out.append(' ');\n            }\n            out.append(toCapitalize ? capitalize(word) : word);\n            if (!allWords) {\n                toCapitalize = false;\n            }\n        }\n        return out.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String decapitalize(@NotNull String s) {\n        return Introspector.decapitalize(s);\n    }\n\n    @Contract(pure = true)\n    public static boolean isVowel(char c) {\n        return VOWELS.indexOf(c) >= 0;\n    }\n\n    /**\n     * Capitalize the first letter of the sentence.\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String capitalize(@NotNull String s) {\n        if (s.isEmpty()) return s;\n        if (s.length() == 1) return toUpperCase(s).toString();\n\n        // Optimization\n        if (Character.isUpperCase(s.charAt(0))) return s;\n        return toUpperCase(s.charAt(0)) + s.substring(1);\n    }\n\n    @Contract(value = \"null -> false\", pure = true)\n    public static boolean isCapitalized(@Nullable String s) {\n        return s != null && !s.isEmpty() && Character.isUpperCase(s.charAt(0));\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String capitalizeWithJavaBeanConvention(@NotNull String s) {\n        if (s.length() > 1 && Character.isUpperCase(s.charAt(1))) {\n            return s;\n        }\n        return capitalize(s);\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCode(@NotNull CharSequence chars) {\n        if (chars instanceof String || chars instanceof CharSequenceWithStringHash) {\n            // we know for sure these classes have conformant (and maybe faster) hashCode()\n            return chars.hashCode();\n        }\n\n        return stringHashCode(chars, 0, chars.length());\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCode(@NotNull CharSequence chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            h = 31 * h + chars.charAt(off);\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCode(char[] chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            h = 31 * h + chars[off];\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeInsensitive(@NotNull char[] chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            h = 31 * h + toLowerCase(chars[off]);\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeInsensitive(@NotNull CharSequence chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            h = 31 * h + toLowerCase(chars.charAt(off));\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeInsensitive(@NotNull CharSequence chars) {\n        return stringHashCodeInsensitive(chars, 0, chars.length());\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeIgnoreWhitespaces(@NotNull char[] chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            char c = chars[off];\n            if (!isWhiteSpace(c)) {\n                h = 31 * h + c;\n            }\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeIgnoreWhitespaces(@NotNull CharSequence chars, int from, int to) {\n        int h = 0;\n        for (int off = from; off < to; off++) {\n            char c = chars.charAt(off);\n            if (!isWhiteSpace(c)) {\n                h = 31 * h + c;\n            }\n        }\n        return h;\n    }\n\n    @Contract(pure = true)\n    public static int stringHashCodeIgnoreWhitespaces(@NotNull CharSequence chars) {\n        return stringHashCodeIgnoreWhitespaces(chars, 0, chars.length());\n    }\n\n    /**\n     * Equivalent to string.startsWith(prefixes[0] + prefixes[1] + ...) but avoids creating an object for concatenation.\n     */\n    @Contract(pure = true)\n    public static boolean startsWithConcatenation(@NotNull String string, @NotNull String... prefixes) {\n        int offset = 0;\n        for (String prefix : prefixes) {\n            int prefixLen = prefix.length();\n            if (!string.regionMatches(offset, prefix, 0, prefixLen)) {\n                return false;\n            }\n            offset += prefixLen;\n        }\n        return true;\n    }\n\n    @Contract(value = \"null -> null; !null -> !null\", pure = true)\n    public static String trim(@Nullable String s) {\n        return s == null ? null : s.trim();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimEnd(@NotNull String s, @NotNull String suffix) {\n        return trimEnd(s, suffix, false);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimEnd(@NotNull String s, @NotNull String suffix, boolean ignoreCase) {\n        boolean endsWith = ignoreCase ? endsWithIgnoreCase(s, suffix) : s.endsWith(suffix);\n        if (endsWith) {\n            return s.substring(0, s.length() - suffix.length());\n        }\n        return s;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimEnd(@NotNull String s, char suffix) {\n        if (endsWithChar(s, suffix)) {\n            return s.substring(0, s.length() - 1);\n        }\n        return s;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimLog(@NotNull final String text, final int limit) {\n        if (limit > 5 && text.length() > limit) {\n            return text.substring(0, limit - 5) + \" ...\\n\";\n        }\n        return text;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimLeading(@NotNull String string) {\n        return trimLeading((CharSequence)string).toString();\n    }\n    @NotNull\n    @Contract(pure = true)\n    public static CharSequence trimLeading(@NotNull CharSequence string) {\n        int index = 0;\n        while (index < string.length() && Character.isWhitespace(string.charAt(index))) index++;\n        return string.subSequence(index, string.length());\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimLeading(@NotNull String string, char symbol) {\n        int index = 0;\n        while (index < string.length() && string.charAt(index) == symbol) index++;\n        return string.substring(index);\n    }\n\n    @NotNull\n    public static StringBuilder trimLeading(@NotNull StringBuilder builder, char symbol) {\n        int index = 0;\n        while (index < builder.length() && builder.charAt(index) == symbol) index++;\n        if (index > 0) builder.delete(0, index);\n        return builder;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimTrailing(@NotNull String string) {\n        return trimTrailing((CharSequence)string).toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static CharSequence trimTrailing(@NotNull CharSequence string) {\n        int index = string.length() - 1;\n        while (index >= 0 && Character.isWhitespace(string.charAt(index))) index--;\n        return string.subSequence(0, index + 1);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimTrailing(@NotNull String string, char symbol) {\n        int index = string.length() - 1;\n        while (index >= 0 && string.charAt(index) == symbol) index--;\n        return string.substring(0, index + 1);\n    }\n\n    @NotNull\n    public static StringBuilder trimTrailing(@NotNull StringBuilder builder, char symbol) {\n        int index = builder.length() - 1;\n        while (index >= 0 && builder.charAt(index) == symbol) index--;\n        builder.setLength(index + 1);\n        return builder;\n    }\n\n    @Contract(pure = true)\n    public static boolean startsWithChar(@Nullable CharSequence s, char prefix) {\n        return s != null && s.length() != 0 && s.charAt(0) == prefix;\n    }\n\n    @Contract(pure = true)\n    public static boolean endsWithChar(@Nullable CharSequence s, char suffix) {\n        return StringUtilRt.endsWithChar(s, suffix);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimStart(@NotNull String s, @NotNull String prefix) {\n        if (s.startsWith(prefix)) {\n            return s.substring(prefix.length());\n        }\n        return s;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimExtensions(@NotNull String name) {\n        int index = name.indexOf('.');\n        return index < 0 ? name : name.substring(0, index);\n    }\n\n//  @NotNull\n//  @Contract(pure = true)\n//  public static String pluralize(@NotNull String base, int count) {\n//    if (count == 1) return base;\n//    return pluralize(base);\n//  }\n\n    public static void repeatSymbol(@NotNull Appendable buffer, char symbol, int times) {\n        assert times >= 0 : times;\n        try {\n            for (int i = 0; i < times; i++) {\n                buffer.append(symbol);\n            }\n        }\n        catch (IOException e) {\n            LOG.error(e);\n        }\n    }\n\n    @Contract(pure = true)\n    public static String defaultIfEmpty(@Nullable String value, String defaultValue) {\n        return isEmpty(value) ? defaultValue : value;\n    }\n\n    @Contract(value = \"null -> false\", pure = true)\n    public static boolean isNotEmpty(@Nullable String s) {\n        return !isEmpty(s);\n    }\n\n    @Contract(value = \"null -> true\", pure = true)\n    public static boolean isEmpty(@Nullable String s) {\n        return s == null || s.isEmpty();\n    }\n\n    @Contract(value = \"null -> true\",pure = true)\n    public static boolean isEmpty(@Nullable CharSequence cs) {\n        return StringUtilRt.isEmpty(cs);\n    }\n\n    @Contract(pure = true)\n    public static int length(@Nullable CharSequence cs) {\n        return cs == null ? 0 : cs.length();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String notNullize(@Nullable String s) {\n        return StringUtilRt.notNullize(s);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String notNullize(@Nullable String s, @NotNull String defaultValue) {\n        return StringUtilRt.notNullize(s, defaultValue);\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String nullize(@Nullable String s) {\n        return nullize(s, false);\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String nullize(@Nullable String s, boolean nullizeSpaces) {\n        boolean empty = nullizeSpaces ? isEmptyOrSpaces(s) : isEmpty(s);\n        return empty ? null : s;\n    }\n\n    @Contract(value = \"null -> true\",pure = true)\n    // we need to keep this method to preserve backward compatibility\n    public static boolean isEmptyOrSpaces(@Nullable String s) {\n        return isEmptyOrSpaces((CharSequence)s);\n    }\n\n    @Contract(value = \"null -> true\", pure = true)\n    public static boolean isEmptyOrSpaces(@Nullable CharSequence s) {\n        return StringUtilRt.isEmptyOrSpaces(s);\n    }\n\n    /**\n     * Allows to answer if given symbol is white space, tabulation or line feed.\n     *\n     * @param c symbol to check\n     * @return {@code true} if given symbol is white space, tabulation or line feed; {@code false} otherwise\n     */\n    @Contract(pure = true)\n    public static boolean isWhiteSpace(char c) {\n        return c == '\\n' || c == '\\t' || c == ' ';\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String getThrowableText(@NotNull Throwable aThrowable) {\n        return ExceptionUtil.getThrowableText(aThrowable);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String repeatSymbol(final char aChar, final int count) {\n        char[] buffer = new char[count];\n        Arrays.fill(buffer, aChar);\n        return StringFactory.createShared(buffer);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String repeat(@NotNull String s, int count) {\n        assert count >= 0 : count;\n        StringBuilder sb = new StringBuilder(s.length() * count);\n        for (int i = 0; i < count; i++) {\n            sb.append(s);\n        }\n        return sb.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> split(@NotNull String s, @NotNull String separator) {\n        return split(s, separator, true);\n    }\n    @NotNull\n    @Contract(pure = true)\n    public static List<CharSequence> split(@NotNull CharSequence s, @NotNull CharSequence separator) {\n        return split(s, separator, true, true);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> split(@NotNull String s, @NotNull String separator, boolean excludeSeparator) {\n        return split(s, separator, excludeSeparator, true);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    @SuppressWarnings(\"unchecked\")\n    public static List<String> split(@NotNull String s, @NotNull String separator, boolean excludeSeparator, boolean excludeEmptyStrings) {\n        return (List)split((CharSequence)s, separator, excludeSeparator, excludeEmptyStrings);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<CharSequence> split(@NotNull CharSequence s, @NotNull CharSequence separator, boolean excludeSeparator, boolean excludeEmptyStrings) {\n        if (separator.length() == 0) {\n            return Collections.singletonList(s);\n        }\n        List<CharSequence> result = new ArrayList<CharSequence>();\n        int pos = 0;\n        while (true) {\n            int index = indexOf(s, separator, pos);\n            if (index == -1) break;\n            final int nextPos = index + separator.length();\n            CharSequence token = s.subSequence(pos, excludeSeparator ? index : nextPos);\n            if (token.length() != 0 || !excludeEmptyStrings) {\n                result.add(token);\n            }\n            pos = nextPos;\n        }\n        if (pos < s.length() || !excludeEmptyStrings && pos == s.length()) {\n            result.add(s.subSequence(pos, s.length()));\n        }\n        return result;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static Iterable<String> tokenize(@NotNull String s, @NotNull String separators) {\n        final com.intellij.util.text.StringTokenizer tokenizer = new com.intellij.util.text.StringTokenizer(s, separators);\n        return new Iterable<String>() {\n            @NotNull\n            @Override\n            public Iterator<String> iterator() {\n                return new Iterator<String>() {\n                    @Override\n                    public boolean hasNext() {\n                        return tokenizer.hasMoreTokens();\n                    }\n\n                    @Override\n                    public String next() {\n                        return tokenizer.nextToken();\n                    }\n\n                    @Override\n                    public void remove() {\n                        throw new UnsupportedOperationException();\n                    }\n                };\n            }\n        };\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static Iterable<String> tokenize(@NotNull final StringTokenizer tokenizer) {\n        return new Iterable<String>() {\n            @NotNull\n            @Override\n            public Iterator<String> iterator() {\n                return new Iterator<String>() {\n                    @Override\n                    public boolean hasNext() {\n                        return tokenizer.hasMoreTokens();\n                    }\n\n                    @Override\n                    public String next() {\n                        return tokenizer.nextToken();\n                    }\n\n                    @Override\n                    public void remove() {\n                        throw new UnsupportedOperationException();\n                    }\n                };\n            }\n        };\n    }\n\n    /**\n     * @return list containing all words in {@code text}, or {@link ContainerUtil#emptyList()} if there are none.\n     * The <b>word</b> here means the maximum sub-string consisting entirely of characters which are {@code Character.isJavaIdentifierPart(c)}.\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> getWordsIn(@NotNull String text) {\n        List<String> result = null;\n        int start = -1;\n        for (int i = 0; i < text.length(); i++) {\n            char c = text.charAt(i);\n            boolean isIdentifierPart = Character.isJavaIdentifierPart(c);\n            if (isIdentifierPart && start == -1) {\n                start = i;\n            }\n            if (isIdentifierPart && i == text.length() - 1) {\n                if (result == null) {\n                    result = new SmartList<String>();\n                }\n                result.add(text.substring(start, i + 1));\n            }\n            else if (!isIdentifierPart && start != -1) {\n                if (result == null) {\n                    result = new SmartList<String>();\n                }\n                result.add(text.substring(start, i));\n                start = -1;\n            }\n        }\n        if (result == null) {\n            return ContainerUtil.emptyList();\n        }\n        return result;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<TextRange> getWordIndicesIn(@NotNull String text) {\n        return getWordIndicesIn(text, null);\n    }\n\n    /**\n     * @param text text to get word ranges in.\n     * @param separatorsSet if not null, only these characters will be considered as separators (i.e. not a part of word).\n     *                   Otherwise {@link Character#isJavaIdentifierPart(char)} will be used to determine whether a symbol is part of word.\n     * @return ranges ranges of words in passed text.\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static List<TextRange> getWordIndicesIn(@NotNull String text, @Nullable Set<Character> separatorsSet) {\n        List<TextRange> result = new SmartList<TextRange>();\n        int start = -1;\n        for (int i = 0; i < text.length(); i++) {\n            char c = text.charAt(i);\n            boolean isIdentifierPart = separatorsSet == null ? Character.isJavaIdentifierPart(c) : !separatorsSet.contains(c);\n            if (isIdentifierPart && start == -1) {\n                start = i;\n            }\n            if (isIdentifierPart && i == text.length() - 1) {\n                result.add(new TextRange(start, i + 1));\n            }\n            else if (!isIdentifierPart && start != -1) {\n                result.add(new TextRange(start, i));\n                start = -1;\n            }\n        }\n        return result;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String join(@NotNull final String[] strings, @NotNull final String separator) {\n        return join(strings, 0, strings.length, separator);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String join(@NotNull final String[] strings, int startIndex, int endIndex, @NotNull final String separator) {\n        final StringBuilder result = new StringBuilder();\n        for (int i = startIndex; i < endIndex; i++) {\n            if (i > startIndex) result.append(separator);\n            result.append(strings[i]);\n        }\n        return result.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String[] zip(@NotNull String[] strings1, @NotNull String[] strings2, String separator) {\n        if (strings1.length != strings2.length) throw new IllegalArgumentException();\n\n        String[] result = ArrayUtil.newStringArray(strings1.length);\n        for (int i = 0; i < result.length; i++) {\n            result[i] = strings1[i] + separator + strings2[i];\n        }\n\n        return result;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String[] surround(@NotNull String[] strings, @NotNull String prefix, @NotNull String suffix) {\n        String[] result = ArrayUtil.newStringArray(strings.length);\n        for (int i = 0; i < result.length; i++) {\n            result[i] = prefix + strings[i] + suffix;\n        }\n        return result;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static <T> String join(@NotNull T[] items, @NotNull Function<? super T, String> f, @NotNull String separator) {\n        return join(Arrays.asList(items), f, separator);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static <T> String join(@NotNull Collection<? extends T> items,\n                                  @NotNull Function<? super T, String> f,\n                                  @NotNull String separator) {\n        if (items.isEmpty()) return \"\";\n        if (items.size() == 1) return notNullize(f.fun(items.iterator().next()));\n        return join((Iterable<? extends T>)items, f, separator);\n    }\n\n    @Contract(pure = true)\n    public static String join(@NotNull Iterable<?> items, @NotNull String separator) {\n        StringBuilder result = new StringBuilder();\n        for (Object item : items) {\n            result.append(item).append(separator);\n        }\n        if (result.length() > 0) {\n            result.setLength(result.length() - separator.length());\n        }\n        return result.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static <T> String join(@NotNull Iterable<? extends T> items,\n                                  @NotNull Function<? super T, String> f,\n                                  @NotNull String separator) {\n        StringBuilder result = new StringBuilder();\n        join(items, f, separator, result);\n        return result.toString();\n    }\n\n    public static <T> void join(@NotNull Iterable<? extends T> items,\n                                @NotNull Function<? super T, String> f,\n                                @NotNull String separator,\n                                @NotNull StringBuilder result) {\n        boolean isFirst = true;\n        for (T item : items) {\n            String string = f.fun(item);\n            if (!isEmpty(string)) {\n                if (isFirst) {\n                    isFirst = false;\n                }\n                else {\n                    result.append(separator);\n                }\n                result.append(string);\n            }\n        }\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String join(@NotNull Collection<String> strings, @NotNull String separator) {\n        if (strings.size() <= 1) {\n            return notNullize(ContainerUtil.getFirstItem(strings));\n        }\n        StringBuilder result = new StringBuilder();\n        join(strings, separator, result);\n        return result.toString();\n    }\n\n    public static void join(@NotNull Collection<String> strings, @NotNull String separator, @NotNull StringBuilder result) {\n        boolean isFirst = true;\n        for (String string : strings) {\n            if (string != null) {\n                if (isFirst) {\n                    isFirst = false;\n                }\n                else {\n                    result.append(separator);\n                }\n                result.append(string);\n            }\n        }\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String join(@NotNull final int[] strings, @NotNull final String separator) {\n        final StringBuilder result = new StringBuilder();\n        for (int i = 0; i < strings.length; i++) {\n            if (i > 0) result.append(separator);\n            result.append(strings[i]);\n        }\n        return result.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String join(@NotNull final String... strings) {\n        if (strings.length == 0) return \"\";\n\n        final StringBuilder builder = new StringBuilder();\n        for (final String string : strings) {\n            builder.append(string);\n        }\n        return builder.toString();\n    }\n\n    /**\n     * Consider using {@link StringUtil#unquoteString(String)} instead.\n     * Note: this method has an odd behavior:\n     *   Quotes are removed even if leading and trailing quotes are different or\n     *                           if there is only one quote (leading or trailing).\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String stripQuotesAroundValue(@NotNull String text) {\n        final int len = text.length();\n        if (len > 0) {\n            final int from = isQuoteAt(text, 0) ? 1 : 0;\n            final int to = len > 1 && isQuoteAt(text, len - 1) ? len - 1 : len;\n            if (from > 0 || to < len) {\n                return text.substring(from, to);\n            }\n        }\n        return text;\n    }\n\n    /** Formats given duration as a sum of time units (example: {@code formatDuration(123456) = \"2 m 3 s 456 ms\"}). */\n    @NotNull\n    @Contract(pure = true)\n    public static String formatDuration(long duration) {\n        return formatDuration(duration, \" \");\n    }\n\n    private static final String[] TIME_UNITS = {\"ms\", \"s\", \"m\", \"h\", \"d\", \"mo\", \"yr\", \"c\", \"ml\", \"ep\"};\n    private static final long[] TIME_MULTIPLIERS = {1, 1000, 60, 60, 24, 30, 12, 100, 10, 10000};\n\n    /** Formats given duration as a sum of time units (example: {@code formatDuration(123456, \"\") = \"2m 3s 456ms\"}). */\n    @NotNull\n    @Contract(pure = true)\n    public static String formatDuration(long duration, @NotNull String unitSeparator) {\n        String[] units = TIME_UNITS;\n\n        StringBuilder sb = new StringBuilder();\n        long count = duration;\n        int i = 1;\n        for (; i < units.length && count > 0; i++) {\n            long multiplier = TIME_MULTIPLIERS[i];\n            if (count < multiplier) break;\n            long remainder = count % multiplier;\n            count /= multiplier;\n            if (remainder != 0 || sb.length() > 0) {\n                if (!units[i - 1].isEmpty()) {\n                    sb.insert(0, units[i - 1]);\n                    sb.insert(0, unitSeparator);\n                }\n                sb.insert(0, remainder).insert(0, \" \");\n            }\n            else {\n                remainder = Math.round(remainder * 100 / (double)multiplier);\n                count += remainder / 100;\n            }\n        }\n        if (!units[i - 1].isEmpty()) {\n            sb.insert(0, units[i - 1]);\n            sb.insert(0, unitSeparator);\n        }\n        sb.insert(0, count);\n        return sb.toString();\n    }\n\n    @Contract(pure = true)\n    public static boolean containsAlphaCharacters(@NotNull String value) {\n        for (int i = 0; i < value.length(); i++) {\n            if (Character.isLetter(value.charAt(i))) return true;\n        }\n        return false;\n    }\n\n    @Contract(pure = true)\n    public static boolean containsAnyChar(@NotNull final String value, @NotNull final String chars) {\n        return chars.length() > value.length()\n                ? containsAnyChar(value, chars, 0, value.length())\n                : containsAnyChar(chars, value, 0, chars.length());\n    }\n\n    @Contract(pure = true)\n    public static boolean containsAnyChar(@NotNull final String value,\n                                          @NotNull final String chars,\n                                          final int start, final int end) {\n        for (int i = start; i < end; i++) {\n            if (chars.indexOf(value.charAt(i)) >= 0) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    @Contract(pure = true)\n    public static boolean containsChar(@NotNull final String value, final char ch) {\n        return value.indexOf(ch) >= 0;\n    }\n\n    /**\n     * @deprecated use #capitalize(String)\n     */\n    @Deprecated\n    @Contract(value = \"null -> null; !null -> !null\", pure = true)\n    public static String firstLetterToUpperCase(@Nullable final String displayString) {\n        if (displayString == null || displayString.isEmpty()) return displayString;\n        char firstChar = displayString.charAt(0);\n        char uppedFirstChar = toUpperCase(firstChar);\n\n        if (uppedFirstChar == firstChar) return displayString;\n\n        char[] buffer = displayString.toCharArray();\n        buffer[0] = uppedFirstChar;\n        return StringFactory.createShared(buffer);\n    }\n\n    /**\n     * Strip out all characters not accepted by given filter\n     *\n     * @param s      e.g. \"/n    my string \"\n     * @param filter e.g. {@link CharFilter#NOT_WHITESPACE_FILTER}\n     * @return stripped string e.g. \"mystring\"\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String strip(@NotNull final String s, @NotNull final CharFilter filter) {\n        final StringBuilder result = new StringBuilder(s.length());\n        for (int i = 0; i < s.length(); i++) {\n            char ch = s.charAt(i);\n            if (filter.accept(ch)) {\n                result.append(ch);\n            }\n        }\n        return result.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> findMatches(@NotNull String s, @NotNull Pattern pattern) {\n        return findMatches(s, pattern, 1);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<String> findMatches(@NotNull String s, @NotNull Pattern pattern, int groupIndex) {\n        List<String> result = new SmartList<String>();\n        Matcher m = pattern.matcher(s);\n        while (m.find()) {\n            String group = m.group(groupIndex);\n            if (group != null) {\n                result.add(group);\n            }\n        }\n        return result;\n    }\n\n    /**\n     * Find position of the first character accepted by given filter.\n     *\n     * @param s      the string to search\n     * @param filter search filter\n     * @return position of the first character accepted or -1 if not found\n     */\n    @Contract(pure = true)\n    public static int findFirst(@NotNull final CharSequence s, @NotNull CharFilter filter) {\n        for (int i = 0; i < s.length(); i++) {\n            char ch = s.charAt(i);\n            if (filter.accept(ch)) {\n                return i;\n            }\n        }\n        return -1;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String replaceSubstring(@NotNull String string, @NotNull TextRange range, @NotNull String replacement) {\n        return range.replace(string, replacement);\n    }\n\n    @Contract(pure = true)\n    public static boolean startsWithWhitespace(@NotNull String text) {\n        return !text.isEmpty() && Character.isWhitespace(text.charAt(0));\n    }\n\n    @Contract(pure = true)\n    public static boolean isChar(CharSequence seq, int index, char c) {\n        return index >= 0 && index < seq.length() && seq.charAt(index) == c;\n    }\n\n    @Contract(pure = true)\n    public static boolean startsWith(@NotNull CharSequence text, @NotNull CharSequence prefix) {\n        int l1 = text.length();\n        int l2 = prefix.length();\n        if (l1 < l2) return false;\n\n        for (int i = 0; i < l2; i++) {\n            if (text.charAt(i) != prefix.charAt(i)) return false;\n        }\n\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static boolean startsWith(@NotNull CharSequence text, int startIndex, @NotNull CharSequence prefix) {\n        int tl = text.length();\n        if (startIndex < 0 || startIndex > tl) {\n            throw new IllegalArgumentException(\"Index is out of bounds: \" + startIndex + \", length: \" + tl);\n        }\n        int l1 = tl - startIndex;\n        int l2 = prefix.length();\n        if (l1 < l2) return false;\n\n        for (int i = 0; i < l2; i++) {\n            if (text.charAt(i + startIndex) != prefix.charAt(i)) return false;\n        }\n\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static boolean endsWith(@NotNull CharSequence text, @NotNull CharSequence suffix) {\n        int l1 = text.length();\n        int l2 = suffix.length();\n        if (l1 < l2) return false;\n\n        for (int i = l1 - 1; i >= l1 - l2; i--) {\n            if (text.charAt(i) != suffix.charAt(i + l2 - l1)) return false;\n        }\n\n        return true;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String commonPrefix(@NotNull String s1, @NotNull String s2) {\n        return s1.substring(0, commonPrefixLength(s1, s2));\n    }\n\n    @Contract(pure = true)\n    public static int commonPrefixLength(@NotNull CharSequence s1, @NotNull CharSequence s2) {\n        return commonPrefixLength(s1, s2, false);\n    }\n\n    @Contract(pure = true)\n    public static int commonPrefixLength(@NotNull CharSequence s1, @NotNull CharSequence s2, boolean ignoreCase) {\n        int i;\n        int minLength = Math.min(s1.length(), s2.length());\n        for (i = 0; i < minLength; i++) {\n            if (!charsMatch(s1.charAt(i), s2.charAt(i), ignoreCase)) {\n                break;\n            }\n        }\n        return i;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String commonSuffix(@NotNull String s1, @NotNull String s2) {\n        return s1.substring(s1.length() - commonSuffixLength(s1, s2));\n    }\n\n    @Contract(pure = true)\n    public static int commonSuffixLength(@NotNull CharSequence s1, @NotNull CharSequence s2) {\n        int s1Length = s1.length();\n        int s2Length = s2.length();\n        if (s1Length == 0 || s2Length == 0) return 0;\n        int i;\n        for (i = 0; i < s1Length && i < s2Length; i++) {\n            if (s1.charAt(s1Length - i - 1) != s2.charAt(s2Length - i - 1)) {\n                break;\n            }\n        }\n        return i;\n    }\n\n    /**\n     * Allows to answer if target symbol is contained at given char sequence at {@code [start; end)} interval.\n     *\n     * @param s     target char sequence to check\n     * @param start start offset to use within the given char sequence (inclusive)\n     * @param end   end offset to use within the given char sequence (exclusive)\n     * @param c     target symbol to check\n     * @return {@code true} if given symbol is contained at the target range of the given char sequence;\n     * {@code false} otherwise\n     */\n    @Contract(pure = true)\n    public static boolean contains(@NotNull CharSequence s, int start, int end, char c) {\n        return indexOf(s, c, start, end) >= 0;\n    }\n\n    @Contract(pure = true)\n    public static boolean containsWhitespaces(@Nullable CharSequence s) {\n        if (s == null) return false;\n\n        for (int i = 0; i < s.length(); i++) {\n            if (Character.isWhitespace(s.charAt(i))) return true;\n        }\n        return false;\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence s, char c) {\n        return indexOf(s, c, 0, s.length());\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence s, char c, int start) {\n        return indexOf(s, c, start, s.length());\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence s, char c, int start, int end) {\n        end = Math.min(end, s.length());\n        for (int i = Math.max(start, 0); i < end; i++) {\n            if (s.charAt(i) == c) return i;\n        }\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static boolean contains(@NotNull CharSequence sequence, @NotNull CharSequence infix) {\n        return indexOf(sequence, infix) >= 0;\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence sequence, @NotNull CharSequence infix) {\n        return indexOf(sequence, infix, 0);\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence sequence, @NotNull CharSequence infix, int start) {\n        return indexOf(sequence, infix, start, sequence.length());\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence sequence, @NotNull CharSequence infix, int start, int end) {\n        for (int i = start; i <= end - infix.length(); i++) {\n            if (startsWith(sequence, i, infix)) {\n                return i;\n            }\n        }\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull CharSequence s, char c, int start, int end, boolean caseSensitive) {\n        end = Math.min(end, s.length());\n        for (int i = Math.max(start, 0); i < end; i++) {\n            if (charsMatch(s.charAt(i), c, !caseSensitive)) return i;\n        }\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int indexOf(@NotNull char[] s, char c, int start, int end, boolean caseSensitive) {\n        end = Math.min(end, s.length);\n        for (int i = Math.max(start, 0); i < end; i++) {\n            if (charsMatch(s[i], c, !caseSensitive)) return i;\n        }\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int indexOfSubstringEnd(@NotNull String text, @NotNull String subString) {\n        int i = text.indexOf(subString);\n        if (i == -1) return -1;\n        return i + subString.length();\n    }\n\n    @Contract(pure = true)\n    public static int indexOfAny(@NotNull final String s, @NotNull final String chars) {\n        return indexOfAny(s, chars, 0, s.length());\n    }\n\n    @Contract(pure = true)\n    public static int indexOfAny(@NotNull final CharSequence s, @NotNull final String chars) {\n        return indexOfAny(s, chars, 0, s.length());\n    }\n\n    @Contract(pure = true)\n    public static int indexOfAny(@NotNull final String s, @NotNull final String chars, final int start, final int end) {\n        return indexOfAny((CharSequence)s, chars, start, end);\n    }\n\n    @Contract(pure = true)\n    public static int indexOfAny(@NotNull final CharSequence s, @NotNull final String chars, final int start, int end) {\n        end = Math.min(end, s.length());\n        for (int i = Math.max(start, 0); i < end; i++) {\n            if (containsChar(chars, s.charAt(i))) return i;\n        }\n        return -1;\n    }\n\n    @Contract(pure = true)\n    public static int lastIndexOfAny(@NotNull CharSequence s, @NotNull final String chars) {\n        for (int i = s.length() - 1; i >= 0; i--) {\n            if (containsChar(chars, s.charAt(i))) return i;\n        }\n        return -1;\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String substringBefore(@NotNull String text, @NotNull String subString) {\n        int i = text.indexOf(subString);\n        if (i == -1) return null;\n        return text.substring(0, i);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String substringBeforeLast(@NotNull String text, @NotNull String subString) {\n        int i = text.lastIndexOf(subString);\n        if (i == -1) return text;\n        return text.substring(0, i);\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String substringAfter(@NotNull String text, @NotNull String subString) {\n        int i = text.indexOf(subString);\n        if (i == -1) return null;\n        return text.substring(i + subString.length());\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String substringAfterLast(@NotNull String text, @NotNull String subString) {\n        int i = text.lastIndexOf(subString);\n        if (i == -1) return null;\n        return text.substring(i + subString.length());\n    }\n\n    /**\n     * Allows to retrieve index of last occurrence of the given symbols at {@code [start; end)} sub-sequence of the given text.\n     *\n     * @param s     target text\n     * @param c     target symbol which last occurrence we want to check\n     * @param start start offset of the target text (inclusive)\n     * @param end   end offset of the target text (exclusive)\n     * @return index of the last occurrence of the given symbol at the target sub-sequence of the given text if any;\n     * {@code -1} otherwise\n     */\n    @Contract(pure = true)\n    public static int lastIndexOf(@NotNull CharSequence s, char c, int start, int end) {\n        return StringUtilRt.lastIndexOf(s, c, start, end);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String first(@NotNull String text, final int maxLength, final boolean appendEllipsis) {\n        return text.length() > maxLength ? text.substring(0, maxLength) + (appendEllipsis ? \"...\" : \"\") : text;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static CharSequence first(@NotNull CharSequence text, final int length, final boolean appendEllipsis) {\n        if (text.length() <= length) {\n            return text;\n        }\n        if (appendEllipsis) {\n            return text.subSequence(0, length) + \"...\";\n        }\n        return text.subSequence(0, length);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static CharSequence last(@NotNull CharSequence text, final int length, boolean prependEllipsis) {\n        if (text.length() <= length) {\n            return text;\n        }\n        if (prependEllipsis) {\n            return \"...\" + text.subSequence(text.length() - length, text.length());\n        }\n        return text.subSequence(text.length() - length, text.length());\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String firstLast(@NotNull String text, int length) {\n        return text.length() > length\n                ? text.subSequence(0, length / 2) + \"\\u2026\" + text.subSequence(text.length() - length / 2 - 1, text.length())\n                : text;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeChar(@NotNull final String str, final char character) {\n        return escapeChars(str, character);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeChars(@NotNull final String str, final char... character) {\n        final StringBuilder buf = new StringBuilder(str);\n        for (char c : character) {\n            escapeChar(buf, c);\n        }\n        return buf.toString();\n    }\n\n    public static void escapeChar(@NotNull final StringBuilder buf, final char character) {\n        int idx = 0;\n        while ((idx = indexOf(buf, character, idx)) >= 0) {\n            buf.insert(idx, \"\\\\\");\n            idx += 2;\n        }\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeQuotes(@NotNull final String str) {\n        return escapeChar(str, '\"');\n    }\n\n    public static void escapeQuotes(@NotNull final StringBuilder buf) {\n        escapeChar(buf, '\"');\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeSlashes(@NotNull final String str) {\n        return escapeChar(str, '/');\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeBackSlashes(@NotNull final String str) {\n        return escapeChar(str, '\\\\');\n    }\n\n    public static void escapeSlashes(@NotNull final StringBuilder buf) {\n        escapeChar(buf, '/');\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String unescapeSlashes(@NotNull final String str) {\n        final StringBuilder buf = new StringBuilder(str.length());\n        unescapeChar(buf, str, '/');\n        return buf.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String unescapeBackSlashes(@NotNull final String str) {\n        final StringBuilder buf = new StringBuilder(str.length());\n        unescapeChar(buf, str, '\\\\');\n        return buf.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String unescapeChar(@NotNull final String str, char unescapeChar) {\n        final StringBuilder buf = new StringBuilder(str.length());\n        unescapeChar(buf, str, unescapeChar);\n        return buf.toString();\n    }\n\n    private static void unescapeChar(@NotNull StringBuilder buf, @NotNull String str, char unescapeChar) {\n        final int length = str.length();\n        final int last = length - 1;\n        for (int i = 0; i < length; i++) {\n            char ch = str.charAt(i);\n            if (ch == '\\\\' && i != last) {\n                //noinspection AssignmentToForLoopParameter\n                i++;\n                ch = str.charAt(i);\n                if (ch != unescapeChar) buf.append('\\\\');\n            }\n\n            buf.append(ch);\n        }\n    }\n\n    public static void quote(@NotNull final StringBuilder builder) {\n        quote(builder, '\\\"');\n    }\n\n    public static void quote(@NotNull final StringBuilder builder, final char quotingChar) {\n        builder.insert(0, quotingChar);\n        builder.append(quotingChar);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String wrapWithDoubleQuote(@NotNull String str) {\n        return '\\\"' + str + \"\\\"\";\n    }\n\n    private static final List<String> REPLACES_REFS = Arrays.asList(\"&lt;\", \"&gt;\", \"&amp;\", \"&#39;\", \"&quot;\");\n    private static final List<String> REPLACES_DISP = Arrays.asList(\"<\", \">\", \"&\", \"'\", \"\\\"\");\n\n    /**\n     * @deprecated Use {@link #unescapeXmlEntities(String)} instead\n     */\n    @Contract(value = \"null -> null; !null -> !null\",pure = true)\n    @Deprecated\n    public static String unescapeXml(@Nullable final String text) {\n        return text == null ? null : unescapeXmlEntities(text);\n    }\n\n    /**\n     * @deprecated Use {@link #escapeXmlEntities(String)} instead\n     */\n    @Contract(value = \"null -> null; !null -> !null\",pure = true)\n    @Deprecated\n    public static String escapeXml(@Nullable final String text) {\n        return text == null ? null : escapeXmlEntities(text);\n    }\n\n    /**\n     * @return {@code text} with some standard XML entities replaced with corresponding characters, e.g. '{@code &lt;}' replaced with '<'\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String unescapeXmlEntities(@NotNull String text) {\n        return replace(text, REPLACES_REFS, REPLACES_DISP);\n    }\n\n    /**\n     * @return {@code text} with some characters replaced with standard XML entities, e.g. '<' replaced with '{@code &lt;}'\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeXmlEntities(@NotNull String text) {\n        return replace(text, REPLACES_DISP, REPLACES_REFS);\n    }\n\n    @NotNull\n    public static String removeHtmlTags(@NotNull String htmlString) {\n        return removeHtmlTags(htmlString, false);\n    }\n\n    @NotNull\n    public static String removeHtmlTags(@NotNull String htmlString, boolean isRemoveStyleTag) {\n        if (isEmpty(htmlString)) {\n            return \"\";\n        }\n\n        final MyHtml2Text parser = isRemoveStyleTag ? new MyHtml2Text(true) : html2TextParser;\n        try {\n            parser.parse(new StringReader(htmlString));\n        }\n        catch (IOException e) {\n            LOG.error(e);\n        }\n        return parser.getText();\n    }\n\n    private static final List<String> MN_QUOTED = Arrays.asList(\"&&\", \"__\");\n    private static final List<String> MN_CHARS = Arrays.asList(\"&\", \"_\");\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeMnemonics(@NotNull String text) {\n        return replace(text, MN_CHARS, MN_QUOTED);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String htmlEmphasize(@NotNull String text) {\n        return \"<b><code>\" + escapeXmlEntities(text) + \"</code></b>\";\n    }\n\n\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeToRegexp(@NotNull String text) {\n        final StringBuilder result = new StringBuilder(text.length());\n        return escapeToRegexp(text, result).toString();\n    }\n\n    @NotNull\n    public static StringBuilder escapeToRegexp(@NotNull CharSequence text, @NotNull StringBuilder builder) {\n        for (int i = 0; i < text.length(); i++) {\n            final char c = text.charAt(i);\n            if (c == ' ' || Character.isLetter(c) || Character.isDigit(c) || c == '_') {\n                builder.append(c);\n            }\n            else if (c == '\\n') {\n                builder.append(\"\\\\n\");\n            }\n            else if (c == '\\r') {\n                builder.append(\"\\\\r\");\n            }\n            else {\n                builder.append('\\\\').append(c);\n            }\n        }\n\n        return builder;\n    }\n\n    @Contract(pure = true)\n    public static boolean isEscapedBackslash(@NotNull char[] chars, int startOffset, int backslashOffset) {\n        if (chars[backslashOffset] != '\\\\') {\n            return true;\n        }\n        boolean escaped = false;\n        for (int i = startOffset; i < backslashOffset; i++) {\n            if (chars[i] == '\\\\') {\n                escaped = !escaped;\n            }\n            else {\n                escaped = false;\n            }\n        }\n        return escaped;\n    }\n\n    @Contract(pure = true)\n    public static boolean isEscapedBackslash(@NotNull CharSequence text, int startOffset, int backslashOffset) {\n        if (text.charAt(backslashOffset) != '\\\\') {\n            return true;\n        }\n        boolean escaped = false;\n        for (int i = startOffset; i < backslashOffset; i++) {\n            if (text.charAt(i) == '\\\\') {\n                escaped = !escaped;\n            }\n            else {\n                escaped = false;\n            }\n        }\n        return escaped;\n    }\n\n    /**\n     * @deprecated Use {@link #replace(String, List, List)}\n     */\n    @Deprecated\n    @NotNull\n    @Contract(pure = true)\n    public static String replace(@NotNull String text, @NotNull String[] from, @NotNull String[] to) {\n        return replace(text, Arrays.asList(from), Arrays.asList(to));\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String replace(@NotNull String text, @NotNull List<String> from, @NotNull List<String> to) {\n        assert from.size() == to.size();\n        StringBuilder result = null;\n        replace:\n        for (int i = 0; i < text.length(); i++) {\n            for (int j = 0; j < from.size(); j += 1) {\n                String toReplace = from.get(j);\n                String replaceWith = to.get(j);\n\n                final int len = toReplace.length();\n                if (text.regionMatches(i, toReplace, 0, len)) {\n                    if (result == null) {\n                        result = new StringBuilder(text.length());\n                        result.append(text, 0, i);\n                    }\n                    result.append(replaceWith);\n                    //noinspection AssignmentToForLoopParameter\n                    i += len - 1;\n                    continue replace;\n                }\n            }\n\n            if (result != null) {\n                result.append(text.charAt(i));\n            }\n        }\n        return result == null ? text : result.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String[] filterEmptyStrings(@NotNull String[] strings) {\n        int emptyCount = 0;\n        for (String string : strings) {\n            if (string == null || string.isEmpty()) emptyCount++;\n        }\n        if (emptyCount == 0) return strings;\n\n        String[] result = ArrayUtil.newStringArray(strings.length - emptyCount);\n        int count = 0;\n        for (String string : strings) {\n            if (string == null || string.isEmpty()) continue;\n            result[count++] = string;\n        }\n\n        return result;\n    }\n\n    @Contract(pure = true)\n    public static int countNewLines(@NotNull CharSequence text) {\n        return countChars(text, '\\n');\n    }\n\n    @Contract(pure = true)\n    public static int countChars(@NotNull CharSequence text, char c) {\n        return countChars(text, c, 0, false);\n    }\n\n    @Contract(pure = true)\n    public static int countChars(@NotNull CharSequence text, char c, int offset, boolean stopAtOtherChar) {\n        return countChars(text, c, offset, text.length(), stopAtOtherChar);\n    }\n\n    @Contract(pure = true)\n    public static int countChars(@NotNull CharSequence text, char c, int start, int end, boolean stopAtOtherChar) {\n        boolean forward = start <= end;\n        start = forward ? Math.max(0, start) : Math.min(text.length(), start);\n        end = forward ? Math.min(text.length(), end) : Math.max(0, end);\n        int count = 0;\n        for (int i = forward ? start : start - 1; forward == i < end; i += forward ? 1 : -1) {\n            if (text.charAt(i) == c) {\n                count++;\n            }\n            else if (stopAtOtherChar) {\n                break;\n            }\n        }\n        return count;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String capitalsOnly(@NotNull String s) {\n        StringBuilder b = new StringBuilder();\n        for (int i = 0; i < s.length(); i++) {\n            if (Character.isUpperCase(s.charAt(i))) {\n                b.append(s.charAt(i));\n            }\n        }\n\n        return b.toString();\n    }\n\n    /**\n     * @param args Strings to join.\n     * @return {@code null} if any of given Strings is {@code null}.\n     */\n    @Nullable\n    @Contract(pure = true)\n    public static String joinOrNull(@NotNull String... args) {\n        StringBuilder r = new StringBuilder();\n        for (String arg : args) {\n            if (arg == null) return null;\n            r.append(arg);\n        }\n        return r.toString();\n    }\n\n    @Nullable\n    @Contract(pure = true)\n    public static String getPropertyName(@NotNull String methodName) {\n        if (methodName.startsWith(\"get\")) {\n            return Introspector.decapitalize(methodName.substring(3));\n        }\n        if (methodName.startsWith(\"is\")) {\n            return Introspector.decapitalize(methodName.substring(2));\n        }\n        if (methodName.startsWith(\"set\")) {\n            return Introspector.decapitalize(methodName.substring(3));\n        }\n        return null;\n    }\n\n    @Contract(pure = true)\n    public static boolean isJavaIdentifierStart(char c) {\n        return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || Character.isJavaIdentifierStart(c);\n    }\n\n    @Contract(pure = true)\n    public static boolean isJavaIdentifierPart(char c) {\n        return c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || Character.isJavaIdentifierPart(c);\n    }\n\n    @Contract(pure = true)\n    public static boolean isJavaIdentifier(@NotNull String text) {\n        int len = text.length();\n        if (len == 0) return false;\n\n        if (!isJavaIdentifierStart(text.charAt(0))) return false;\n\n        for (int i = 1; i < len; i++) {\n            if (!isJavaIdentifierPart(text.charAt(i))) return false;\n        }\n\n        return true;\n    }\n\n    /**\n     * Escape property name or key in property file. Unicode characters are escaped as well.\n     *\n     * @param input an input to escape\n     * @param isKey if true, the rules for key escaping are applied. The leading space is escaped in that case.\n     * @return an escaped string\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String escapeProperty(@NotNull String input, final boolean isKey) {\n        final StringBuilder escaped = new StringBuilder(input.length());\n        for (int i = 0; i < input.length(); i++) {\n            final char ch = input.charAt(i);\n            switch (ch) {\n                case ' ':\n                    if (isKey && i == 0) {\n                        // only the leading space has to be escaped\n                        escaped.append('\\\\');\n                    }\n                    escaped.append(' ');\n                    break;\n                case '\\t':\n                    escaped.append(\"\\\\t\");\n                    break;\n                case '\\r':\n                    escaped.append(\"\\\\r\");\n                    break;\n                case '\\n':\n                    escaped.append(\"\\\\n\");\n                    break;\n                case '\\f':\n                    escaped.append(\"\\\\f\");\n                    break;\n                case '\\\\':\n                case '#':\n                case '!':\n                case ':':\n                case '=':\n                    escaped.append('\\\\');\n                    escaped.append(ch);\n                    break;\n                default:\n                    if (20 < ch && ch < 0x7F) {\n                        escaped.append(ch);\n                    }\n                    else {\n                        escaped.append(\"\\\\u\");\n                        escaped.append(Character.forDigit((ch >> 12) & 0xF, 16));\n                        escaped.append(Character.forDigit((ch >> 8) & 0xF, 16));\n                        escaped.append(Character.forDigit((ch >> 4) & 0xF, 16));\n                        escaped.append(Character.forDigit((ch) & 0xF, 16));\n                    }\n                    break;\n            }\n        }\n        return escaped.toString();\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String getQualifiedName(@Nullable String packageName, @NotNull String className) {\n        if (packageName == null || packageName.isEmpty()) {\n            return className;\n        }\n        return packageName + '.' + className;\n    }\n\n    @Contract(pure = true)\n    public static int compareVersionNumbers(@Nullable String v1, @Nullable String v2) {\n        // todo duplicates com.intellij.util.text.VersionComparatorUtil.compare\n        // todo please refactor next time you make changes here\n        if (v1 == null && v2 == null) {\n            return 0;\n        }\n        if (v1 == null) {\n            return -1;\n        }\n        if (v2 == null) {\n            return 1;\n        }\n\n        String[] part1 = v1.split(\"[._\\\\-]\");\n        String[] part2 = v2.split(\"[._\\\\-]\");\n\n        int idx = 0;\n        for (; idx < part1.length && idx < part2.length; idx++) {\n            String p1 = part1[idx];\n            String p2 = part2[idx];\n\n            int cmp;\n            if (p1.matches(\"\\\\d+\") && p2.matches(\"\\\\d+\")) {\n                cmp = new Integer(p1).compareTo(new Integer(p2));\n            }\n            else {\n                cmp = part1[idx].compareTo(part2[idx]);\n            }\n            if (cmp != 0) return cmp;\n        }\n\n        if (part1.length != part2.length) {\n            boolean left = part1.length > idx;\n            String[] parts = left ? part1 : part2;\n\n            for (; idx < parts.length; idx++) {\n                String p = parts[idx];\n                int cmp;\n                if (p.matches(\"\\\\d+\")) {\n                    cmp = new Integer(p).compareTo(0);\n                }\n                else {\n                    cmp = 1;\n                }\n                if (cmp != 0) return left ? cmp : -cmp;\n            }\n        }\n        return 0;\n    }\n\n    @Contract(pure = true)\n    public static int getOccurrenceCount(@NotNull String text, final char c) {\n        int res = 0;\n        int i = 0;\n        while (i < text.length()) {\n            i = text.indexOf(c, i);\n            if (i >= 0) {\n                res++;\n                i++;\n            }\n            else {\n                break;\n            }\n        }\n        return res;\n    }\n\n    @Contract(pure = true)\n    public static int getOccurrenceCount(@NotNull String text, @NotNull String s) {\n        int res = 0;\n        int i = 0;\n        while (i < text.length()) {\n            i = text.indexOf(s, i);\n            if (i >= 0) {\n                res++;\n                i++;\n            }\n            else {\n                break;\n            }\n        }\n        return res;\n    }\n\n    @Contract(pure = true)\n    public static int getIgnoreCaseOccurrenceCount(@NotNull String text, @NotNull String s) {\n        int res = 0;\n        int i = 0;\n        while (i < text.length()) {\n            i = indexOfIgnoreCase(text, s, i);\n            if (i >= 0) {\n                res++;\n                i++;\n            }\n            else {\n                break;\n            }\n        }\n        return res;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String fixVariableNameDerivedFromPropertyName(@NotNull String name) {\n        if (isEmptyOrSpaces(name)) return name;\n        char c = name.charAt(0);\n        if (isVowel(c)) {\n            return \"an\" + Character.toUpperCase(c) + name.substring(1);\n        }\n        return \"a\" + Character.toUpperCase(c) + name.substring(1);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String sanitizeJavaIdentifier(@NotNull String name) {\n        final StringBuilder result = new StringBuilder(name.length());\n\n        for (int i = 0; i < name.length(); i++) {\n            final char ch = name.charAt(i);\n            if (Character.isJavaIdentifierPart(ch)) {\n                if (result.length() == 0 && !Character.isJavaIdentifierStart(ch)) {\n                    result.append(\"_\");\n                }\n                result.append(ch);\n            }\n        }\n\n        return result.toString();\n    }\n\n    public static void assertValidSeparators(@NotNull CharSequence s) {\n        char[] chars = CharArrayUtil.fromSequenceWithoutCopying(s);\n        int slashRIndex = -1;\n\n        if (chars != null) {\n            for (int i = 0, len = s.length(); i < len; ++i) {\n                if (chars[i] == '\\r') {\n                    slashRIndex = i;\n                    break;\n                }\n            }\n        }\n        else {\n            for (int i = 0, len = s.length(); i < len; i++) {\n                if (s.charAt(i) == '\\r') {\n                    slashRIndex = i;\n                    break;\n                }\n            }\n        }\n\n        if (slashRIndex != -1) {\n            String context =\n                    String.valueOf(last(s.subSequence(0, slashRIndex), 10, true)) + first(s.subSequence(slashRIndex, s.length()), 10, true);\n            context = escapeStringCharacters(context);\n            throw new AssertionError(\"Wrong line separators: '\" + context + \"' at offset \" + slashRIndex);\n        }\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String tail(@NotNull String s, final int idx) {\n        return idx >= s.length() ? \"\" : s.substring(idx);\n    }\n\n    /**\n     * Splits string by lines.\n     *\n     * @param string String to split\n     * @return array of strings\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String[] splitByLines(@NotNull String string) {\n        return splitByLines(string, true);\n    }\n\n    /**\n     * Splits string by lines. If several line separators are in a row corresponding empty lines\n     * are also added to result if {@code excludeEmptyStrings} is {@code false}.\n     *\n     * @param string String to split\n     * @return array of strings\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String[] splitByLines(@NotNull String string, boolean excludeEmptyStrings) {\n        return (excludeEmptyStrings ? EOL_SPLIT_PATTERN : EOL_SPLIT_PATTERN_WITH_EMPTY).split(string);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String[] splitByLinesDontTrim(@NotNull String string) {\n        return EOL_SPLIT_DONT_TRIM_PATTERN.split(string);\n    }\n\n    /**\n     * Splits string by lines, keeping all line separators at the line ends and in the empty lines.\n     * <br> E.g. splitting text\n     * <blockquote>\n     *   foo\\r\\n<br>\n     *   \\n<br>\n     *   bar\\n<br>\n     *   \\r\\n<br>\n     *   baz\\r<br>\n     *   \\r<br>\n     * </blockquote>\n     * will return the following array: foo\\r\\n, \\n, bar\\n, \\r\\n, baz\\r, \\r\n     *\n     */\n    @NotNull\n    @Contract(pure = true)\n    public static String[] splitByLinesKeepSeparators(@NotNull String string) {\n        return EOL_SPLIT_KEEP_SEPARATORS.split(string);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static List<Pair<String, Integer>> getWordsWithOffset(@NotNull String s) {\n        List<Pair<String, Integer>> res = ContainerUtil.newArrayList();\n        s += \" \";\n        StringBuilder name = new StringBuilder();\n        int startInd = -1;\n        for (int i = 0; i < s.length(); i++) {\n            if (Character.isWhitespace(s.charAt(i))) {\n                if (name.length() > 0) {\n                    res.add(Pair.create(name.toString(), startInd));\n                    name.setLength(0);\n                    startInd = -1;\n                }\n            }\n            else {\n                if (startInd == -1) {\n                    startInd = i;\n                }\n                name.append(s.charAt(i));\n            }\n        }\n        return res;\n    }\n\n    @Contract(pure = true)\n    public static int naturalCompare(@Nullable String string1, @Nullable String string2) {\n        return NaturalComparator.INSTANCE.compare(string1, string2);\n    }\n\n    @Contract(pure = true)\n    public static boolean isDecimalDigit(char c) {\n        return c >= '0' && c <= '9';\n    }\n\n    @Contract(\"null -> false\")\n    public static boolean isNotNegativeNumber(@Nullable CharSequence s) {\n        if (s == null) {\n            return false;\n        }\n        for (int i = 0; i < s.length(); i++) {\n            if (!isDecimalDigit(s.charAt(i))) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static int compare(@Nullable String s1, @Nullable String s2, boolean ignoreCase) {\n        //noinspection StringEquality\n        if (s1 == s2) return 0;\n        if (s1 == null) return -1;\n        if (s2 == null) return 1;\n        return ignoreCase ? s1.compareToIgnoreCase(s2) : s1.compareTo(s2);\n    }\n\n    @Contract(pure = true)\n    public static int comparePairs(@Nullable String s1, @Nullable String t1, @Nullable String s2, @Nullable String t2, boolean ignoreCase) {\n        final int compare = compare(s1, s2, ignoreCase);\n        return compare != 0 ? compare : compare(t1, t2, ignoreCase);\n    }\n\n    @Contract(pure = true)\n    public static int hashCode(@NotNull CharSequence s) {\n        return stringHashCode(s);\n    }\n\n    @Contract(pure = true)\n    public static boolean equals(@Nullable CharSequence s1, @Nullable CharSequence s2) {\n        if (s1 == null ^ s2 == null) {\n            return false;\n        }\n\n        if (s1 == null) {\n            return true;\n        }\n\n        if (s1.length() != s2.length()) {\n            return false;\n        }\n        for (int i = 0; i < s1.length(); i++) {\n            if (s1.charAt(i) != s2.charAt(i)) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static boolean equalsIgnoreCase(@Nullable CharSequence s1, @Nullable CharSequence s2) {\n        if (s1 == null ^ s2 == null) {\n            return false;\n        }\n\n        if (s1 == null) {\n            return true;\n        }\n\n        if (s1.length() != s2.length()) {\n            return false;\n        }\n        for (int i = 0; i < s1.length(); i++) {\n            if (!charsEqualIgnoreCase(s1.charAt(i), s2.charAt(i))) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static boolean equalsIgnoreWhitespaces(@Nullable CharSequence s1, @Nullable CharSequence s2) {\n        if (s1 == null ^ s2 == null) {\n            return false;\n        }\n\n        if (s1 == null) {\n            return true;\n        }\n\n        int len1 = s1.length();\n        int len2 = s2.length();\n\n        int index1 = 0;\n        int index2 = 0;\n        while (index1 < len1 && index2 < len2) {\n            if (s1.charAt(index1) == s2.charAt(index2)) {\n                index1++;\n                index2++;\n                continue;\n            }\n\n            boolean skipped = false;\n            while (index1 != len1 && isWhiteSpace(s1.charAt(index1))) {\n                skipped = true;\n                index1++;\n            }\n            while (index2 != len2 && isWhiteSpace(s2.charAt(index2))) {\n                skipped = true;\n                index2++;\n            }\n\n            if (!skipped) return false;\n        }\n\n        for (; index1 != len1; index1++) {\n            if (!isWhiteSpace(s1.charAt(index1))) return false;\n        }\n        for (; index2 != len2; index2++) {\n            if (!isWhiteSpace(s2.charAt(index2))) return false;\n        }\n\n        return true;\n    }\n\n    @Contract(pure = true)\n    public static boolean equalsTrimWhitespaces(@NotNull CharSequence s1, @NotNull CharSequence s2) {\n        int start1 = 0;\n        int end1 = s1.length();\n        int end2 = s2.length();\n\n        while (start1 < end1) {\n            char c = s1.charAt(start1);\n            if (!isWhiteSpace(c)) break;\n            start1++;\n        }\n\n        while (start1 < end1) {\n            char c = s1.charAt(end1 - 1);\n            if (!isWhiteSpace(c)) break;\n            end1--;\n        }\n\n        int start2 = 0;\n        while (start2 < end2) {\n            char c = s2.charAt(start2);\n            if (!isWhiteSpace(c)) break;\n            start2++;\n        }\n\n        while (start2 < end2) {\n            char c = s2.charAt(end2 - 1);\n            if (!isWhiteSpace(c)) break;\n            end2--;\n        }\n\n        CharSequence ts1 = new CharSequenceSubSequence(s1, start1, end1);\n        CharSequence ts2 = new CharSequenceSubSequence(s2, start2, end2);\n\n        return equals(ts1, ts2);\n    }\n\n    /**\n     * Collapses all white-space (including new lines) between non-white-space characters to a single space character.\n     * Leading and trailing white space is removed.\n     */\n    public static String collapseWhiteSpace(@NotNull CharSequence s) {\n        final StringBuilder result = new StringBuilder();\n        boolean space = false;\n        for (int i = 0, length = s.length(); i < length; i++) {\n            final char ch = s.charAt(i);\n            if (isWhiteSpace(ch)) {\n                if (!space) space = true;\n            }\n            else {\n                if (space && result.length() > 0) result.append(' ');\n                result.append(ch);\n                space = false;\n            }\n        }\n        return result.toString();\n    }\n\n    @Contract(pure = true)\n    public static boolean findIgnoreCase(@Nullable String toFind, @NotNull String... where) {\n        for (String string : where) {\n            if (equalsIgnoreCase(toFind, string)) return true;\n        }\n        return false;\n    }\n\n    @Contract(pure = true)\n    public static int compare(char c1, char c2, boolean ignoreCase) {\n        // duplicating String.equalsIgnoreCase logic\n        int d = c1 - c2;\n        if (d == 0 || !ignoreCase) {\n            return d;\n        }\n        // If characters don't match but case may be ignored,\n        // try converting both characters to uppercase.\n        // If the results match, then the comparison scan should\n        // continue.\n        char u1 = StringUtilRt.toUpperCase(c1);\n        char u2 = StringUtilRt.toUpperCase(c2);\n        d = u1 - u2;\n        if (d != 0) {\n            // Unfortunately, conversion to uppercase does not work properly\n            // for the Georgian alphabet, which has strange rules about case\n            // conversion.  So we need to make one last check before\n            // exiting.\n            d = StringUtilRt.toLowerCase(u1) - StringUtilRt.toLowerCase(u2);\n        }\n        return d;\n    }\n\n    @Contract(pure = true)\n    public static boolean charsMatch(char c1, char c2, boolean ignoreCase) {\n        return compare(c1, c2, ignoreCase) == 0;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String formatLinks(@NotNull String message) {\n        Pattern linkPattern = Pattern.compile(\"http://[a-zA-Z0-9./\\\\-+]+\");\n        StringBuffer result = new StringBuffer();\n        Matcher m = linkPattern.matcher(message);\n        while (m.find()) {\n            m.appendReplacement(result, \"<a href=\\\"\" + m.group() + \"\\\">\" + m.group() + \"</a>\");\n        }\n        m.appendTail(result);\n        return result.toString();\n    }\n\n    @Contract(pure = true)\n    public static boolean isHexDigit(char c) {\n        return '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F';\n    }\n\n    @Contract(pure = true)\n    public static boolean isOctalDigit(char c) {\n        return '0' <= c && c <= '7';\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String shortenTextWithEllipsis(@NotNull final String text, final int maxLength, final int suffixLength) {\n        return shortenTextWithEllipsis(text, maxLength, suffixLength, false);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String trimMiddle(@NotNull String text, int maxLength) {\n        return shortenTextWithEllipsis(text, maxLength, maxLength >> 1, true);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String shortenTextWithEllipsis(@NotNull final String text,\n                                                 final int maxLength,\n                                                 final int suffixLength,\n                                                 @NotNull String symbol) {\n        final int textLength = text.length();\n        if (textLength > maxLength) {\n            final int prefixLength = maxLength - suffixLength - symbol.length();\n            assert prefixLength > 0;\n            return text.substring(0, prefixLength) + symbol + text.substring(textLength - suffixLength);\n        }\n        else {\n            return text;\n        }\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String shortenTextWithEllipsis(@NotNull final String text,\n                                                 final int maxLength,\n                                                 final int suffixLength,\n                                                 boolean useEllipsisSymbol) {\n        String symbol = useEllipsisSymbol ? \"\\u2026\" : \"...\";\n        return shortenTextWithEllipsis(text, maxLength, suffixLength, symbol);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String shortenPathWithEllipsis(@NotNull final String path, final int maxLength, boolean useEllipsisSymbol) {\n        return shortenTextWithEllipsis(path, maxLength, (int)(maxLength * 0.7), useEllipsisSymbol);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String shortenPathWithEllipsis(@NotNull final String path, final int maxLength) {\n        return shortenPathWithEllipsis(path, maxLength, false);\n    }\n\n    @Contract(pure = true)\n    public static boolean charsEqualIgnoreCase(char a, char b) {\n        return charsMatch(a, b, true);\n    }\n\n    @Contract(pure = true)\n    public static char toUpperCase(char a) {\n        return StringUtilRt.toUpperCase(a);\n    }\n\n    @Contract(value = \"null -> null; !null -> !null\", pure = true)\n    public static String toUpperCase(String a) {\n        if (a == null)\n            return null;\n\n        StringBuilder answer = null;\n        for (int i = 0; i < a.length(); i++) {\n            char c = a.charAt(i);\n            char upCased = toUpperCase(c);\n            if (answer == null && upCased != c) {\n                answer = new StringBuilder(a.length());\n                answer.append(a.subSequence(0, i));\n            }\n            if (answer != null) {\n                answer.append(upCased);\n            }\n        }\n        return answer == null ? a : answer.toString();\n    }\n\n    @Contract(pure = true)\n    public static char toLowerCase(final char a) {\n        return StringUtilRt.toLowerCase(a);\n    }\n\n    @Contract(pure = true)\n    public static boolean isUpperCase(@NotNull CharSequence sequence) {\n        for (int i = 0; i < sequence.length(); i++) {\n            if (!Character.isUpperCase(sequence.charAt(i))) return false;\n        }\n        return true;\n    }\n\n    @Nullable\n    public static LineSeparator detectSeparators(@NotNull CharSequence text) {\n        int index = indexOfAny(text, \"\\n\\r\");\n        if (index == -1) return null;\n        LineSeparator lineSeparator = getLineSeparatorAt(text, index);\n        if (lineSeparator == null) {\n            throw new AssertionError();\n        }\n        return lineSeparator;\n    }\n\n    @Nullable\n    public static LineSeparator getLineSeparatorAt(@NotNull CharSequence text, int index) {\n        if (index < 0 || index >= text.length()) {\n            return null;\n        }\n        char ch = text.charAt(index);\n        if (ch == '\\r') {\n            return index + 1 < text.length() && text.charAt(index + 1) == '\\n' ? LineSeparator.CRLF : LineSeparator.CR;\n        }\n        return ch == '\\n' ? LineSeparator.LF : null;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String convertLineSeparators(@NotNull String text) {\n        return StringUtilRt.convertLineSeparators(text);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String convertLineSeparators(@NotNull String text, boolean keepCarriageReturn) {\n        return StringUtilRt.convertLineSeparators(text, keepCarriageReturn);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator) {\n        return StringUtilRt.convertLineSeparators(text, newSeparator);\n    }\n\n    @NotNull\n    public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep) {\n        return StringUtilRt.convertLineSeparators(text, newSeparator, offsetsToKeep);\n    }\n\n    @Contract(pure = true)\n    public static int parseInt(@Nullable String string, int defaultValue) {\n        return StringUtilRt.parseInt(string, defaultValue);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String getShortName(@NotNull String fqName) {\n        return StringUtilRt.getShortName(fqName);\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static String getShortName(@NotNull String fqName, char separator) {\n        return StringUtilRt.getShortName(fqName, separator);\n    }\n\n    /**\n     * Equivalent for {@code getShortName(fqName).equals(shortName)}, but could be faster.\n     *\n     * @param fqName    fully-qualified name (dot-separated)\n     * @param shortName a short name, must not contain dots\n     * @return true if specified short name is a short name of fully-qualified name\n     */\n    public static boolean isShortNameOf(@NotNull String fqName, @NotNull String shortName) {\n        if (fqName.length() < shortName.length()) return false;\n        if (fqName.length() == shortName.length()) return fqName.equals(shortName);\n        int diff = fqName.length() - shortName.length();\n        if (fqName.charAt(diff - 1) != '.') return false;\n        return fqName.regionMatches(diff, shortName, 0, shortName.length());\n    }\n\n    /**\n     * Strips class name from Object#toString if present.\n     * To be used as custom data type renderer for java.lang.Object.\n     * To activate just add {@code StringUtil.toShortString(this)}\n     * expression in <em>Settings | Debugger | Data Views</em>.\n     */\n    @Contract(\"null->null;!null->!null\")\n    @SuppressWarnings(\"UnusedDeclaration\")\n    static String toShortString(@Nullable Object o) {\n        if (o == null) return null;\n        if (o instanceof CharSequence) return o.toString();\n        String className = o.getClass().getName();\n        String s = o.toString();\n        if (!s.startsWith(className)) return s;\n        return s.length() > className.length() && !Character.isLetter(s.charAt(className.length())) ?\n                trimStart(s, className) : s;\n    }\n\n    @NotNull\n    @Contract(pure = true)\n    public static CharSequence newBombedCharSequence(@NotNull CharSequence sequence, long delay) {\n        final long myTime = System.currentTimeMillis() + delay;\n        return new BombedCharSequence(sequence) {\n            @Override\n            protected void checkCanceled() {\n                long l = System.currentTimeMillis();\n                if (l >= myTime) {\n                    throw new ProcessCanceledException();\n                }\n            }\n        };\n    }\n\n    public static boolean trimEnd(@NotNull StringBuilder buffer, @NotNull CharSequence end) {\n        if (endsWith(buffer, end)) {\n            buffer.delete(buffer.length() - end.length(), buffer.length());\n            return true;\n        }\n        return false;\n    }\n\n    /**\n     * Say smallPart = \"op\" and bigPart=\"open\". Method returns true for \"Ope\" and false for \"ops\"\n     */\n    @Contract(pure = true)\n    @SuppressWarnings(\"StringToUpperCaseOrToLowerCaseWithoutLocale\")\n    public static boolean isBetween(@NotNull String string, @NotNull String smallPart, @NotNull String bigPart) {\n        final String s = string.toLowerCase();\n        return s.startsWith(smallPart.toLowerCase()) && bigPart.toLowerCase().startsWith(s);\n    }\n\n    /**\n     * Does the string have an uppercase character?\n     * @param s  the string to test.\n     * @return   true if the string has an uppercase character, false if not.\n     */\n    public static boolean hasUpperCaseChar(String s) {\n        char[] chars = s.toCharArray();\n        for (char c : chars) {\n            if (Character.isUpperCase(c)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    /**\n     * Does the string have a lowercase character?\n     * @param s  the string to test.\n     * @return   true if the string has a lowercase character, false if not.\n     */\n    public static boolean hasLowerCaseChar(String s) {\n        char[] chars = s.toCharArray();\n        for (char c : chars) {\n            if (Character.isLowerCase(c)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    private static final Pattern UNICODE_CHAR = Pattern.compile(\"\\\\\\\\u[0-9a-fA-F]{4}\");\n\n    public static String replaceUnicodeEscapeSequences(String text) {\n        if (text == null) return null;\n\n        final Matcher matcher = UNICODE_CHAR.matcher(text);\n        if (!matcher.find()) return text; // fast path\n\n        matcher.reset();\n        int lastEnd = 0;\n        final StringBuilder sb = new StringBuilder(text.length());\n        while (matcher.find()) {\n            sb.append(text, lastEnd, matcher.start());\n            final char c = (char)Integer.parseInt(matcher.group().substring(2), 16);\n            sb.append(c);\n            lastEnd = matcher.end();\n        }\n        sb.append(text.substring(lastEnd));\n        return sb.toString();\n    }\n\n    /**\n     * Expirable CharSequence. Very useful to control external library execution time,\n     * i.e. when java.util.regex.Pattern match goes out of control.\n     */\n    public abstract static class BombedCharSequence implements CharSequence {\n        private final CharSequence delegate;\n        private int i;\n        private boolean myDefused;\n\n        public BombedCharSequence(@NotNull CharSequence sequence) {\n            delegate = sequence;\n        }\n\n        @Override\n        public int length() {\n            check();\n            return delegate.length();\n        }\n\n        @Override\n        public char charAt(int i) {\n            check();\n            return delegate.charAt(i);\n        }\n\n        protected void check() {\n            if (myDefused) {\n                return;\n            }\n            if ((++i & 1023) == 0) {\n                checkCanceled();\n            }\n        }\n\n        public final void defuse() {\n            myDefused = true;\n        }\n\n        @NotNull\n        @Override\n        public String toString() {\n            check();\n            return delegate.toString();\n        }\n\n        protected abstract void checkCanceled();\n\n        @NotNull\n        @Override\n        public CharSequence subSequence(int i, int i1) {\n            check();\n            return delegate.subSequence(i, i1);\n        }\n    }\n\n    @Contract(pure = true)\n    @NotNull\n    public static String toHexString(@NotNull byte[] bytes) {\n        @SuppressWarnings(\"SpellCheckingInspection\") String digits = \"0123456789abcdef\";\n        StringBuilder sb = new StringBuilder(2 * bytes.length);\n        for (byte b : bytes) sb.append(digits.charAt((b >> 4) & 0xf)).append(digits.charAt(b & 0xf));\n        return sb.toString();\n    }\n\n    @Contract(pure = true)\n    @NotNull\n    public static byte[] parseHexString(@NotNull String str) {\n        int len = str.length();\n        if (len % 2 != 0) throw new IllegalArgumentException(\"Non-even-length: \" + str);\n        byte[] bytes = new byte[len / 2];\n        for (int i = 0; i < len; i += 2) {\n            bytes[i / 2] = (byte)((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16));\n        }\n        return bytes;\n    }\n\n    /** @deprecated use {@link #startsWithConcatenation(String, String...)} (to remove in IDEA 15) */\n    @Deprecated\n    public static boolean startsWithConcatenationOf(@NotNull String string, @NotNull String firstPrefix, @NotNull String secondPrefix) {\n        return startsWithConcatenation(string, firstPrefix, secondPrefix);\n    }\n\n    /**\n     * @return {@code true} if the passed string is not {@code null} and not empty\n     * and contains only latin upper- or lower-case characters and digits; {@code false} otherwise.\n     */\n    @Contract(pure = true)\n    public static boolean isLatinAlphanumeric(@Nullable CharSequence str) {\n        if (isEmpty(str)) {\n            return false;\n        }\n        for (int i = 0; i < str.length(); i++) {\n            char c = str.charAt(i);\n            if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || Character.isDigit(c)) {\n                continue;\n            }\n            return false;\n        }\n        return true;\n    }\n\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/SequentialModalProgressTask.java",
    "content": "package com.intellij.util;\n\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport com.intellij.openapi.diagnostic.Logger;\nimport com.intellij.openapi.progress.ProgressIndicator;\nimport com.intellij.openapi.progress.Task;\nimport com.intellij.openapi.project.Project;\n\npublic class SequentialModalProgressTask extends Task.Modal {\n    private static final Logger LOG = Logger.getInstance(\"#\" + SequentialModalProgressTask.class.getName());\n    \n    private static final long DEFAULT_MIN_ITERATION_MIN_TIME = 500;\n    \n    /**\n     * We want to perform the task by big chunks at EDT. However, there is a\n     * possible case that particular task iteration is executed in short amount\n     * of time. Hence, we may want to execute more than one chunk during single\n     * EDT iteration. This field holds min amount of time (in milliseconds) to\n     * spend to performing the task.\n     */\n    private long myMinIterationTime = DEFAULT_MIN_ITERATION_MIN_TIME;\n    \n    private final String myTitle;\n    \n    private ProgressIndicator myIndicator;\n    private SequentialTask myTask;\n    \n    public SequentialModalProgressTask(@Nullable Project project, @NotNull String title) {\n        this(project, title, true);\n    }\n    \n    public SequentialModalProgressTask(@Nullable Project project, @NotNull String title, boolean canBeCancelled) {\n        super(project, title, canBeCancelled);\n        myTitle = title;\n    }\n    \n    @Override\n    public void run(@NotNull ProgressIndicator indicator) {\n        try {\n            doRun(indicator);\n        } catch (Exception e) {\n            LOG.info(\"Unexpected exception occurred during processing sequential task '\" + myTitle + \"'\", e);\n        } finally {\n            indicator.stop();\n        }\n    }\n    \n    public void doRun(@NotNull ProgressIndicator indicator) throws InvocationTargetException, InterruptedException {\n        final SequentialTask task = myTask;\n        if (task == null) {\n            return;\n        }\n        \n        myIndicator = indicator;\n        prepare(task);\n        \n        // We need to sync background thread and EDT here in order to avoid\n        // situation when event queue is full of processing requests.\n        while (!task.isDone()) {\n            if (indicator.isCanceled()) {\n                task.stop();\n                break;\n            }\n            long start = System.currentTimeMillis();\n            try {\n                while (!task.isDone() && System.currentTimeMillis() - start < myMinIterationTime) {\n                    task.iteration();\n                }\n            } catch (RuntimeException e) {\n                task.stop();\n                throw e;\n            }\n        }\n    }\n    \n    public void setMinIterationTime(long minIterationTime) {\n        myMinIterationTime = minIterationTime;\n    }\n    \n    public void setTask(@Nullable SequentialTask task) {\n        myTask = task;\n    }\n    \n    public ProgressIndicator getIndicator() {\n        return myIndicator;\n    }\n    \n    /**\n     * Executes preliminary jobs prior to the target sequential task processing\n     * ({@link SequentialTask#prepare()} by default).\n     * \n     * @param task\n     *            task to be executed\n     */\n    protected void prepare(@NotNull SequentialTask task) {\n        task.prepare();\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/SequentialTask.java",
    "content": "package com.intellij.util;\n\npublic interface SequentialTask {\n    \n    /**\n     * Callback method that is assumed to be called before the processing.\n     */\n    void prepare();\n    \n    /**\n     * @return <code>true</code> if the processing is complete;\n     *         <code>false</code> otherwise\n     */\n    boolean isDone();\n    \n    /**\n     * Asks current task to perform one more processing iteration.\n     * \n     * @return <code>true</code> if the processing is done; <code>false</code>\n     *         otherwise\n     */\n    boolean iteration();\n    \n    /**\n     * Asks current task to stop the processing (if any).\n     */\n    void stop();\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/SingletonSet.java",
    "content": "/*\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.intellij.util;\n\nimport com.intellij.util.containers.SingletonIterator;\nimport gnu.trove.TObjectHashingStrategy;\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.Collection;\nimport java.util.Iterator;\nimport java.util.Set;\n\n/**\n * Read-only set consisting of the only element\n */\npublic class SingletonSet<E> implements Set<E> {\n  private final E theElement;\n\n  public SingletonSet(E e) {\n    theElement = e;\n  }\n\n  @Override\n  public int size() {\n    return 1;\n  }\n\n  @Override\n  public boolean contains(Object elem) {\n    //noinspection unchecked\n    return getStrategy().equals(theElement, (E)elem);\n  }\n\n  @NotNull\n  @Override\n  public Iterator<E> iterator() {\n    return new SingletonIterator<>(theElement);\n  }\n\n  @NotNull\n  @Override\n  public Object[] toArray() {\n    return new Object[]{theElement};\n  }\n\n  @NotNull\n  @Override\n  public <T> T[] toArray(@NotNull T[] a) {\n    if (a.length == 0) {\n      a = ArrayUtil.newArray(ArrayUtil.getComponentType(a), 1);\n    }\n    //noinspection unchecked\n    a[0] = (T)theElement;\n    if (a.length > 1) {\n        a[1] = null;\n    }\n    return a;\n  }\n\n  @Override\n  public boolean add(E t) {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public boolean remove(Object o) {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public boolean containsAll(@NotNull Collection<?> c) {\n    for (Object e : c) {\n      if (!contains(e)) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  @Override\n  public boolean addAll(@NotNull Collection<? extends E> c) {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public boolean retainAll(@NotNull Collection<?> c) {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public boolean removeAll(@NotNull Collection<?> c) {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public void clear() {\n    throw new IncorrectOperationException();\n  }\n\n  @Override\n  public boolean isEmpty() {\n    return false;\n  }\n\n  @NotNull\n  protected TObjectHashingStrategy<E> getStrategy() {\n    //noinspection unchecked\n    return TObjectHashingStrategy.CANONICAL;\n  }\n\n  @NotNull\n  public static <T> Set<T> withCustomStrategy(T o, @NotNull TObjectHashingStrategy<T> strategy) {\n    return new CustomStrategySingletonSet<>(o, strategy);\n  }\n\n  private static class CustomStrategySingletonSet<E> extends SingletonSet<E> {\n    @NotNull private final TObjectHashingStrategy<E> strategy;\n\n    private CustomStrategySingletonSet(E e, @NotNull final TObjectHashingStrategy<E> strategy) {\n      super(e);\n      this.strategy = strategy;\n    }\n\n\n    @Override\n    @NotNull\n    protected TObjectHashingStrategy<E> getStrategy() {\n      return strategy;\n    }\n  }\n}\n"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/containers/LinkedMultiMap.java",
    "content": "package com.intellij.util.containers;\n\n@Deprecated\npublic class LinkedMultiMap<K, V> extends MultiMap<K, V> {\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/containers/MultiMap.java",
    "content": "// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.\n\npackage com.intellij.util.containers;\n\nimport com.intellij.util.SmartList;\nimport gnu.trove.THashMap;\nimport gnu.trove.TObjectHashingStrategy;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.io.Serializable;\nimport java.util.HashMap;\nimport java.util.*;\nimport java.util.concurrent.ConcurrentHashMap;\n\n/**\n * Consider to use factory methods {@link #createLinked()}, {@link #createSet()}, {@link #createSmart()}, {@link #create(TObjectHashingStrategy)} instead of override.\n * @see BidirectionalMultiMap\n * @see ConcurrentMultiMap\n * @author Dmitry Avdeev\n */\npublic class MultiMap<K, V> implements Serializable {\n  public static final MultiMap EMPTY = new EmptyMap();\n  private static final long serialVersionUID = -2632269270151455493L;\n\n  protected final Map<K, Collection<V>> myMap;\n  private Collection<V> values;\n\n  public MultiMap() {\n    myMap = createMap();\n  }\n\n  public MultiMap(@NotNull Map<K, Collection<V>> mapImpl) {\n    myMap = mapImpl;\n  }\n\n  public MultiMap(@NotNull MultiMap<? extends K, ? extends V> toCopy) {\n    this();\n    putAllValues(toCopy);\n  }\n\n  @NotNull\n  public MultiMap<K, V> copy() {\n    return new MultiMap<>(this);\n  }\n  \n  public MultiMap(int initialCapacity, float loadFactor) {\n    myMap = createMap(initialCapacity, loadFactor);\n  }\n\n  @NotNull\n  protected Map<K, Collection<V>> createMap() {\n    return new java.util.HashMap<K, Collection<V>>();\n  }\n\n  @NotNull\n  protected Map<K, Collection<V>> createMap(int initialCapacity, float loadFactor) {\n    return new HashMap<K, Collection<V>>(initialCapacity, loadFactor);\n  }\n\n  @NotNull\n  protected Collection<V> createCollection() {\n    return new SmartList<V>();\n  }\n\n  @NotNull\n  protected Collection<V> createEmptyCollection() {\n    return Collections.emptyList();\n  }\n\n  public void putAllValues(@NotNull MultiMap<? extends K, ? extends V> from) {\n    for (Map.Entry<? extends K, ? extends Collection<? extends V>> entry : from.entrySet()) {\n      putValues(entry.getKey(), entry.getValue());\n    }\n  }\n\n  public void putAllValues(@NotNull Map<? extends K, ? extends V> from) {\n    for (Map.Entry<? extends K, ? extends V> entry : from.entrySet()) {\n      putValue(entry.getKey(), entry.getValue());\n    }\n  }\n\n  public void putValues(K key, @NotNull Collection<? extends V> values) {\n    Collection<V> list = myMap.get(key);\n    if (list == null) {\n      list = createCollection();\n      myMap.put(key, list);\n    }\n    list.addAll(values);\n  }\n\n  public void putValue(@Nullable K key, V value) {\n    Collection<V> list = myMap.get(key);\n    if (list == null) {\n      list = createCollection();\n      myMap.put(key, list);\n    }\n    list.add(value);\n  }\n\n  @NotNull\n  public Set<Map.Entry<K, Collection<V>>> entrySet() {\n    return myMap.entrySet();\n  }\n\n  public boolean isEmpty() {\n    if (myMap.isEmpty()) return true;\n\n    for(Collection<V> valueList: myMap.values()) {\n      if (!valueList.isEmpty()) {\n        return false;\n      }\n    }\n    return true;    \n  }\n\n  public boolean containsKey(K key) {\n    return myMap.containsKey(key);\n  }\n  \n  public boolean containsScalarValue(V value) {\n    for(Collection<V> valueList: myMap.values()) {\n      if (valueList.contains(value)) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  @NotNull\n  public Collection<V> get(final K key) {\n    final Collection<V> collection = myMap.get(key);\n    return collection == null ? createEmptyCollection() : collection;\n  }\n\n  @NotNull\n  public Collection<V> getModifiable(final K key) {\n    Collection<V> collection = myMap.get(key);\n    if (collection == null) {\n      myMap.put(key, collection = createCollection());\n    }\n    return collection;\n  }\n\n  @NotNull\n  public Set<K> keySet() {\n    return myMap.keySet();\n  }\n\n  public int size() {\n    return myMap.size();\n  }\n\n  public void put(final K key, Collection<V> values) {\n    myMap.put(key, values);\n  }\n\n  /**\n   * @deprecated use {@link #remove(Object, Object)} instead\n   */\n  @Deprecated\n  public void removeValue(K key, V value) {\n    remove(key, value);\n  }\n\n  public boolean remove(final K key, final V value) {\n    final Collection<V> values = myMap.get(key);\n    if (values != null) {\n      boolean removed = values.remove(value);\n      if (values.isEmpty()) {\n        myMap.remove(key);\n      }\n      return removed;\n    }\n    return false;\n  }\n\n  @NotNull\n  public Collection<? extends V> values() {\n    if (values == null) {\n      values = new AbstractCollection<V>() {\n        @NotNull\n        @Override\n        public Iterator<V> iterator() {\n          return new Iterator<V>() {\n\n            private final Iterator<Collection<V>> mapIterator = myMap.values().iterator();\n\n            private Iterator<V> itr = EmptyIterator.getInstance();\n\n            @Override\n            public boolean hasNext() {\n              do {\n                if (itr.hasNext()) return true;\n                if (!mapIterator.hasNext()) return false;\n                itr = mapIterator.next().iterator();\n              } while (true);\n            }\n\n            @Override\n            public V next() {\n              do {\n                if (itr.hasNext()) return itr.next();\n                if (!mapIterator.hasNext()) throw new NoSuchElementException();\n                itr = mapIterator.next().iterator();\n              } while (true);\n            }\n\n            @Override\n            public void remove() {\n              itr.remove();\n            }\n          };\n        }\n\n        @Override\n        public int size() {\n          int res = 0;\n          for (Collection<V> vs : myMap.values()) {\n            res += vs.size();\n          }\n\n          return res;\n        }\n\n        // Don't remove this method!!!\n        @Override\n        public boolean contains(Object o) {\n          for (Collection<V> vs : myMap.values()) {\n            if (vs.contains(o)) return true;\n          }\n\n          return false;\n        }\n      };\n    }\n\n    return values;\n  }\n\n  public void clear() {\n    myMap.clear();\n  }\n\n  @Nullable\n  public Collection<V> remove(K key) {\n    return myMap.remove(key);\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> emptyInstance() {\n    @SuppressWarnings(\"unchecked\") final MultiMap<K, V> empty = EMPTY;\n    return empty;\n  }\n\n  /**\n   * Null keys supported.\n   */\n  @NotNull\n  public static <K, V> MultiMap<K, V> create() {\n    return new MultiMap<K, V>();\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> create(@NotNull final TObjectHashingStrategy<K> strategy) {\n    return new MultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Map<K, Collection<V>> createMap() {\n        return new THashMap<K, Collection<V>>(strategy);\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createLinked() {\n    return new LinkedMultiMap<K, V>();\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createLinkedSet() {\n    return new LinkedMultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Collection<V> createCollection() {\n        return new LinkedHashSet<V>();\n      }\n\n      @NotNull\n      @Override\n      protected Collection<V> createEmptyCollection() {\n        return Collections.emptySet();\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createOrderedSet() {\n    return new LinkedMultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Collection<V> createCollection() {\n        return new OrderedSet<V>();\n      }\n\n      @NotNull\n      @Override\n      protected Collection<V> createEmptyCollection() {\n        return Collections.emptySet();\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createSmart() {\n    return new MultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Map<K, Collection<V>> createMap() {\n        return new THashMap<K, Collection<V>>();\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createConcurrent() {\n    return new MultiMap<K, V>(new ConcurrentHashMap<>()) {\n      @NotNull\n      protected Collection<V> createCollection() {\n        return ContainerUtil.createLockFreeCopyOnWriteList();\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createConcurrentSet() {\n    return new ConcurrentMultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Collection<V> createCollection() {\n          return Collections.newSetFromMap(new ConcurrentHashMap<>());\n      }\n\n      @NotNull\n      @Override\n      protected Collection<V> createEmptyCollection() {\n        return Collections.emptySet();\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createSet() {\n    return createSet(ContainerUtil.<K>canonicalStrategy());\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createSet(@NotNull final TObjectHashingStrategy<K> strategy) {\n    return new MultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Collection<V> createCollection() {\n        return new SmartHashSet<V>();\n      }\n\n      @NotNull\n      @Override\n      protected Collection<V> createEmptyCollection() {\n        return Collections.emptySet();\n      }\n\n      @NotNull\n      @Override\n      protected Map<K, Collection<V>> createMap() {\n        return new THashMap<K, Collection<V>>(strategy);\n      }\n    };\n  }\n\n  @NotNull\n  public static <K, V> MultiMap<K, V> createWeakKey() {\n    return new MultiMap<K, V>() {\n      @NotNull\n      @Override\n      protected Map<K, Collection<V>> createMap() {\n        return ContainerUtil.createWeakMap();\n      }\n    };\n  }\n\n  public static <K, V> MultiMap<K, V> create(int initialCapacity, float loadFactor) {\n    return new MultiMap<K, V>(initialCapacity, loadFactor);\n  }\n\n  @Override\n  public boolean equals(Object o) {\n    return this == o || o instanceof MultiMap && myMap.equals(((MultiMap)o).myMap);\n  }\n\n  @Override\n  public int hashCode() {\n    return myMap.hashCode();\n  }\n\n  @Override\n  public String toString() {\n    return new java.util.HashMap<K, Collection<V>>(myMap).toString();\n  }\n\n  /**\n   * @return immutable empty multi-map\n   */\n  public static <K, V> MultiMap<K, V> empty() {\n    //noinspection unchecked\n    return EMPTY;\n  }\n\n  private static class EmptyMap extends MultiMap {\n    @NotNull\n    @Override\n    protected Map createMap() {\n      return Collections.emptyMap();\n    }\n\n    @Override\n    public void putValues(Object key, @NotNull Collection values) {\n      throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void putValue(@Nullable Object key, Object value) {\n      throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void put(Object key, Collection values) {\n      throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public boolean remove(Object key, Object value) {\n      throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void clear() {\n      throw new UnsupportedOperationException();\n    }\n\n    @Nullable\n    @Override\n    public Collection remove(Object key) {\n      throw new UnsupportedOperationException();\n    }\n  }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/com/intellij/util/containers/ObjectIntHashMap.java",
    "content": "package com.intellij.util.containers;\n\nimport gnu.trove.TObjectHashingStrategy;\nimport gnu.trove.TObjectIntHashMap;\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Set;\n\npublic class ObjectIntHashMap<K> extends TObjectIntHashMap<K> implements ObjectIntMap<K> {\n    public ObjectIntHashMap(int initialCapacity) {\n        super(initialCapacity);\n    }\n\n    public ObjectIntHashMap(@NotNull TObjectHashingStrategy<K> strategy) {\n        super(strategy);\n    }\n\n    public ObjectIntHashMap(int initialCapacity, @NotNull TObjectHashingStrategy<K> strategy) {\n        super(initialCapacity, strategy);\n    }\n\n    public ObjectIntHashMap() {\n        super();\n    }\n\n    public final int get(@NotNull K key) {\n        return this.get(key, -1);\n    }\n\n    @Override\n    public @NotNull\n    Set<K> keySet() {\n        return Collections.emptySet();\n    }\n\n    @NotNull\n    @Override\n    public int[] values() {\n        return Arrays.copyOf(_values, _values.length);\n    }\n\n    @Override\n    public @NotNull\n    Iterable<Entry<K>> entries() {\n        return Collections.emptySet();\n    }\n\n    public final int get(K key, int defaultValue) {\n        int index = this.index(key);\n        return index < 0 ? defaultValue : this._values[index];\n    }\n\n    public int put(K key, int value, int defaultValue) {\n        int index = this.index(key);\n        int prev = super.put(key, value);\n        return index >= 0 ? prev : defaultValue;\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/it/unimi/dsi/fastutil/ints/IntOpenHashSet.java",
    "content": "package it.unimi.dsi.fastutil.ints;\n\nimport it.unimi.dsi.fastutil.Hash;\nimport it.unimi.dsi.fastutil.HashCommon;\nimport java.io.Serializable;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.NoSuchElementException;\n\npublic class IntOpenHashSet extends AbstractIntSet implements Hash, Serializable, Cloneable {\n    private static final long serialVersionUID = 0L;\n    protected transient int[] key;\n    protected transient int mask;\n    protected transient boolean containsNull;\n    protected transient int n;\n    protected transient int maxFill;\n    protected final transient int minN;\n    protected int size;\n    protected final float f;\n\n    public IntOpenHashSet(int expected, float f) {\n        if (!(f <= 0.0F) && !(f >= 1.0F)) {\n            if (expected < 0) {\n                throw new IllegalArgumentException(\"The expected number of elements must be nonnegative\");\n            } else {\n                this.f = f;\n                this.minN = this.n = HashCommon.arraySize(expected, f);\n                this.mask = this.n - 1;\n                this.maxFill = HashCommon.maxFill(this.n, f);\n                this.key = new int[this.n + 1];\n            }\n        } else {\n            throw new IllegalArgumentException(\"Load factor must be greater than 0 and smaller than 1\");\n        }\n    }\n\n    public IntOpenHashSet(int expected) {\n        this(expected, 0.75F);\n    }\n\n    public IntOpenHashSet() {\n        this(16, 0.75F);\n    }\n\n    private int realSize() {\n        return this.containsNull ? this.size - 1 : this.size;\n    }\n\n    private void ensureCapacity(int capacity) {\n        int needed = HashCommon.arraySize(capacity, this.f);\n        if (needed > this.n) {\n            this.rehash(needed);\n        }\n\n    }\n\n    private void tryCapacity(long capacity) {\n        int needed = (int)Math.min(1073741824L, Math.max(2L, HashCommon.nextPowerOfTwo((long)Math.ceil((double)((float)capacity / this.f)))));\n        if (needed > this.n) {\n            this.rehash(needed);\n        }\n\n    }\n\n    public boolean addAll(Collection<? extends Integer> c) {\n        if ((double)this.f <= 0.5D) {\n            this.ensureCapacity(c.size());\n        } else {\n            this.tryCapacity((long)(this.size() + c.size()));\n        }\n\n        return super.addAll(c);\n    }\n\n    public boolean add(int k) {\n        if (k == 0) {\n            if (this.containsNull) {\n                return false;\n            }\n\n            this.containsNull = true;\n        } else {\n            int[] key = this.key;\n            int pos;\n            int curr;\n            if ((curr = key[pos = HashCommon.mix(k) & this.mask]) != 0) {\n                if (curr == k) {\n                    return false;\n                }\n\n                while((curr = key[pos = pos + 1 & this.mask]) != 0) {\n                    if (curr == k) {\n                        return false;\n                    }\n                }\n            }\n\n            key[pos] = k;\n        }\n\n        if (this.size++ >= this.maxFill) {\n            this.rehash(HashCommon.arraySize(this.size + 1, this.f));\n        }\n\n        return true;\n    }\n\n    protected final void shiftKeys(int pos) {\n        int[] key = this.key;\n\n        while(true) {\n            int last = pos;\n            pos = pos + 1 & this.mask;\n\n            int curr;\n            while(true) {\n                if ((curr = key[pos]) == 0) {\n                    key[last] = 0;\n                    return;\n                }\n\n                int slot = HashCommon.mix(curr) & this.mask;\n                if (last <= pos) {\n                    if (last >= slot || slot > pos) {\n                        break;\n                    }\n                } else if (last >= slot && slot > pos) {\n                    break;\n                }\n\n                pos = pos + 1 & this.mask;\n            }\n\n            key[last] = curr;\n        }\n    }\n\n    private boolean removeEntry(int pos) {\n        --this.size;\n        this.shiftKeys(pos);\n        if (this.n > this.minN && this.size < this.maxFill / 4 && this.n > 16) {\n            this.rehash(this.n / 2);\n        }\n\n        return true;\n    }\n\n    private boolean removeNullEntry() {\n        this.containsNull = false;\n        this.key[this.n] = 0;\n        --this.size;\n        if (this.n > this.minN && this.size < this.maxFill / 4 && this.n > 16) {\n            this.rehash(this.n / 2);\n        }\n\n        return true;\n    }\n\n    public boolean remove(int k) {\n        if (k == 0) {\n            return this.containsNull ? this.removeNullEntry() : false;\n        } else {\n            int[] key = this.key;\n            int curr;\n            int pos;\n            if ((curr = key[pos = HashCommon.mix(k) & this.mask]) == 0) {\n                return false;\n            } else if (k == curr) {\n                return this.removeEntry(pos);\n            } else {\n                while((curr = key[pos = pos + 1 & this.mask]) != 0) {\n                    if (k == curr) {\n                        return this.removeEntry(pos);\n                    }\n                }\n\n                return false;\n            }\n        }\n    }\n\n    public boolean contains(int k) {\n        if (k == 0) {\n            return this.containsNull;\n        } else {\n            int[] key = this.key;\n            int curr;\n            int pos;\n            if ((curr = key[pos = HashCommon.mix(k) & this.mask]) == 0) {\n                return false;\n            } else if (k == curr) {\n                return true;\n            } else {\n                while((curr = key[pos = pos + 1 & this.mask]) != 0) {\n                    if (k == curr) {\n                        return true;\n                    }\n                }\n\n                return false;\n            }\n        }\n    }\n\n    public void clear() {\n        if (this.size != 0) {\n            this.size = 0;\n            this.containsNull = false;\n            Arrays.fill(this.key, 0);\n        }\n    }\n\n    public int size() {\n        return this.size;\n    }\n\n    public boolean isEmpty() {\n        return this.size == 0;\n    }\n\n    public IntIterator iterator() {\n        return new IntOpenHashSet.SetIterator();\n    }\n\n    protected void rehash(int newN) {\n        int[] key = this.key;\n        int mask = newN - 1;\n        int[] newKey = new int[newN + 1];\n        int i = this.n;\n\n        int pos;\n        for(int var7 = this.realSize(); var7-- != 0; newKey[pos] = key[i]) {\n            do {\n                --i;\n            } while(key[i] == 0);\n\n            if (newKey[pos = HashCommon.mix(key[i]) & mask] != 0) {\n                while(newKey[pos = pos + 1 & mask] != 0) {\n                }\n            }\n        }\n\n        this.n = newN;\n        this.mask = mask;\n        this.maxFill = HashCommon.maxFill(this.n, this.f);\n        this.key = newKey;\n    }\n\n    public IntOpenHashSet clone() {\n        IntOpenHashSet c;\n        try {\n            c = (IntOpenHashSet)super.clone();\n        } catch (CloneNotSupportedException var3) {\n            throw new InternalError();\n        }\n\n        c.key = (int[])this.key.clone();\n        c.containsNull = this.containsNull;\n        return c;\n    }\n\n    public int hashCode() {\n        int h = 0;\n        int j = this.realSize();\n\n        for(int i = 0; j-- != 0; ++i) {\n            while(this.key[i] == 0) {\n                ++i;\n            }\n\n            h += this.key[i];\n        }\n\n        return h;\n    }\n\n    private class SetIterator implements IntIterator {\n        int pos;\n        int last;\n        int c;\n        boolean mustReturnNull;\n        IntArrayList wrapped;\n\n        private SetIterator() {\n            this.pos = IntOpenHashSet.this.n;\n            this.last = -1;\n            this.c = IntOpenHashSet.this.size;\n            this.mustReturnNull = IntOpenHashSet.this.containsNull;\n        }\n\n        public boolean hasNext() {\n            return this.c != 0;\n        }\n\n        public int nextInt() {\n            if (!this.hasNext()) {\n                throw new NoSuchElementException();\n            } else {\n                --this.c;\n                if (this.mustReturnNull) {\n                    this.mustReturnNull = false;\n                    this.last = IntOpenHashSet.this.n;\n                    return IntOpenHashSet.this.key[IntOpenHashSet.this.n];\n                } else {\n                    int[] key = IntOpenHashSet.this.key;\n\n                    while(--this.pos >= 0) {\n                        if (key[this.pos] != 0) {\n                            return key[this.last = this.pos];\n                        }\n                    }\n\n                    this.last = -2147483648;\n                    return this.wrapped.getInt(-this.pos - 1);\n                }\n            }\n        }\n\n        private final void shiftKeys(int pos) {\n            int[] key = IntOpenHashSet.this.key;\n\n            while(true) {\n                int last = pos;\n                pos = pos + 1 & IntOpenHashSet.this.mask;\n\n                int curr;\n                while(true) {\n                    if ((curr = key[pos]) == 0) {\n                        key[last] = 0;\n                        return;\n                    }\n\n                    int slot = HashCommon.mix(curr) & IntOpenHashSet.this.mask;\n                    if (last <= pos) {\n                        if (last >= slot || slot > pos) {\n                            break;\n                        }\n                    } else if (last >= slot && slot > pos) {\n                        break;\n                    }\n\n                    pos = pos + 1 & IntOpenHashSet.this.mask;\n                }\n\n                if (pos < last) {\n                    if (this.wrapped == null) {\n                        this.wrapped = new IntArrayList(2);\n                    }\n\n                    this.wrapped.add(key[pos]);\n                }\n\n                key[last] = curr;\n            }\n        }\n\n        public void remove() {\n            if (this.last == -1) {\n                throw new IllegalStateException();\n            } else {\n                if (this.last == IntOpenHashSet.this.n) {\n                    IntOpenHashSet.this.containsNull = false;\n                    IntOpenHashSet.this.key[IntOpenHashSet.this.n] = 0;\n                } else {\n                    if (this.pos < 0) {\n                        IntOpenHashSet.this.remove(this.wrapped.getInt(-this.pos - 1));\n                        this.last = -1;\n                        return;\n                    }\n\n                    this.shiftKeys(this.last);\n                }\n\n                --IntOpenHashSet.this.size;\n                this.last = -1;\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-bundled-compiler/src/org/jetbrains/kotlin/idea/core/formatter/KotlinPackageEntry.kt",
    "content": "package org.jetbrains.kotlin.idea.core.formatter\n\nclass KotlinPackageEntry(\n        packageName: String,\n        val withSubpackages: Boolean\n) {\n    val packageName = packageName.removeSuffix(\".*\")\n\n    companion object {\n        @JvmField\n        val ALL_OTHER_IMPORTS_ENTRY =\n                KotlinPackageEntry(\"import all other imports\", withSubpackages = true)\n\n        @JvmField\n        val ALL_OTHER_ALIAS_IMPORTS_ENTRY = KotlinPackageEntry(\"<all other alias imports>\", withSubpackages = true)\n    }\n\n    fun matchesPackageName(otherPackageName: String): Boolean {\n        if (otherPackageName.startsWith(packageName)) {\n            if (otherPackageName.length == packageName.length) return true\n            if (withSubpackages) {\n                if (otherPackageName[packageName.length] == '.') return true\n            }\n        }\n        return false\n    }\n\n    val isSpecial: Boolean get() = this == ALL_OTHER_IMPORTS_ENTRY || this == ALL_OTHER_ALIAS_IMPORTS_ENTRY\n\n    override fun toString(): String {\n        return packageName\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-aspects\nBundle-SymbolicName: org.jetbrains.kotlin.aspects\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.aspects.Activator\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime,\n org.aspectj.runtime,\n org.jetbrains.kotlin.core,\n org.eclipse.jdt.ui,\n org.eclipse.pde.launching,\n org.eclipse.jdt.core,\n org.eclipse.ltk.core.refactoring,\n org.jetbrains.kotlin.ui,\n org.eclipse.debug.core,\n org.eclipse.jdt.debug,\n org.eclipse.jdt.core.manipulation\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ActivationPolicy: lazy\nBundle-Vendor: JetBrains\nImport-Package: org.eclipse.core.resources,\n org.eclipse.debug.core,\n org.eclipse.debug.core.sourcelookup,\n org.eclipse.jdt.core,\n org.eclipse.jdt.debug.core,\n org.eclipse.jdt.internal.core,\n org.eclipse.jdt.internal.debug.core,\n org.eclipse.jdt.internal.debug.core.refactoring,\n org.eclipse.jdt.internal.debug.ui,\n org.eclipse.jdt.internal.ui.packageview,\n org.eclipse.jdt.internal.ui.viewsupport,\n org.eclipse.jdt.launching,\n org.eclipse.jdt.launching.sourcelookup.containers,\n org.eclipse.jface.text,\n org.eclipse.swt.graphics,\n org.eclipse.ui.ide\nEclipse-SupplementBundle: \n org.eclipse.jdt.debug.ui,\n org.eclipse.jdt.debug,\n org.eclipse.jdt.launching,\n org.eclipse.jdt.ui,\n org.eclipse.jdt.internal.debug.core,\n org.eclipse.debug.core,\n org.eclipse.pde.launching,\n org.eclipse.jdt.core\nExport-Package: org.jetbrains.kotlin.aspects.debug.ui,\n org.jetbrains.kotlin.aspects.debug.core,\n org.jetbrains.kotlin.aspects.navigation,\n org.jetbrains.kotlin.aspects.refactoring,\n org.jetbrains.kotlin.aspects.ui\n"
  },
  {
    "path": "kotlin-eclipse-aspects/META-INF/aop.xml",
    "content": "<aspectj>\n    <aspects>\n        <aspect name=\"org.jetbrains.kotlin.aspects.debug.ui.SuppressBreakpointMarkerUpdaterAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.debug.core.KotlinSourceLookupAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.debug.core.KotlinStackFrameFilterAspect\" />\n        <aspect name=\"org.jetbrains.kotlin.aspects.navigation.KotlinOpenEditorAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.navigation.KotlinSearchEditorOpenerAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.navigation.KotlinFindSourceAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinRefactoringChecksAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinBreakpointRenamingParticipantAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinRefactoringTypeAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinBinaryReferencesAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinRippleMethodFinderAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinRemoveDeclarationUpdateAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinRenameFromJavaAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.refactoring.KotlinJavaDescriptorAspect\"/>\n        <aspect name=\"org.jetbrains.kotlin.aspects.ui.PackageExplorerLabelProviderAspect\"/>\n    </aspects>\n\t<weaver options=\"-Xlint:ignore\">\n         <include within=\"com.sun.jdi..*\"/>\n    </weaver>\n</aspectj>"
  },
  {
    "path": "kotlin-eclipse-aspects/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "kotlin-eclipse-aspects/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.aspects</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\n\t<build>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<!-- have the tycho compiler skip the aspect files -->\n\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t<artifactId>tycho-compiler-plugin</artifactId>\n\t\t\t\t<configuration>\n\t\t\t\t\t<excludeResources>\n\t\t\t\t\t\t<exludeResource>**/*.aj</exludeResource>\n\t\t\t\t\t</excludeResources>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t<artifactId>aspectj-maven-plugin</artifactId>\n\t\t\t\t<version>1.14.0</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<source>16</source>\n\t\t\t\t\t\t\t<complianceLevel>16</complianceLevel>\n\t\t\t\t\t\t\t<aspectDirectory>src</aspectDirectory>\n\t\t\t\t\t\t\t<Xlint>ignore</Xlint>\n\t\t\t\t\t\t\t<deprecation>true</deprecation>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/Activator.java",
    "content": "package org.jetbrains.kotlin.aspects;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"org.jetbrains.kotlin.aspects\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/debug/core/KotlinSourceLookupAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.debug.core;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.debug.core.IJavaStackFrame;\nimport org.jetbrains.kotlin.core.debug.KotlinSourceLookupNavigator;\n\npublic aspect KotlinSourceLookupAspect {\n\tpointcut getSourceElement(Object object) : \n\t\targs(object) \n\t\t&& execution(Object ISourceLookupDirector.getSourceElement(Object));\n\t\n\t@SuppressAjWarnings({\"adviceDidNotMatch\"})\n\tObject around(Object object) : getSourceElement(object) {\n\t\tObject result = proceed(object);\n\t\tif (result instanceof IFile) {\n\t\t\tString fileName = ((IFile) result).getName();\n\t\t\tif (JavaCore.isJavaLikeFileName(fileName)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (object instanceof IJavaStackFrame) {\n\t\t\tIJavaStackFrame frame = (IJavaStackFrame) object;\n\t\t\tIFile kotlinSourceFile = KotlinSourceLookupNavigator.INSTANCE.findKotlinSourceFile(frame);\n\t\t\t\n\t\t\treturn kotlinSourceFile != null ? kotlinSourceFile : result;\n\t\t}\n\t\t\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/debug/core/KotlinStackFrameFilterAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.debug.core;\n\nimport java.util.stream.Stream;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.debug.core.DebugException;\nimport org.eclipse.debug.core.model.IStackFrame;\nimport org.eclipse.debug.core.model.IVariable;\nimport org.jetbrains.kotlin.core.utils.DebugUtils;\n\npublic aspect KotlinStackFrameFilterAspect {\n    pointcut getVariables(IStackFrame receiver) :\n\t\texecution(* IStackFrame.getVariables()) &&\n\t\ttarget(receiver);\n\n    @SuppressAjWarnings({ \"adviceDidNotMatch\" })\n    IVariable[] around(IStackFrame receiver) throws DebugException : getVariables(receiver) {\n        IVariable[] result = proceed(receiver);\n\n        if (DebugUtils.hasKotlinSource(receiver)) {\n            result = Stream.of(result)\n                    .filter(DebugUtils::isVisible)\n                    .toArray(IVariable[]::new);\n        }\n\n        return result;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/debug/ui/SuppressBreakpointMarkerUpdaterAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.debug.ui;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.jdt.internal.debug.ui.BreakpointMarkerUpdater;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.Position;\nimport org.jetbrains.kotlin.ui.builder.AspectsUtils;\n\npublic aspect SuppressBreakpointMarkerUpdaterAspect {\n\n\tpointcut updateMarker(BreakpointMarkerUpdater markerUpdater, IMarker marker, IDocument document, Position position): \n\t\t\t\targs(marker, document, position) \n\t\t\t\t&& execution(boolean BreakpointMarkerUpdater.updateMarker(IMarker, IDocument, Position))\n\t\t\t\t&& target(markerUpdater);\n\n\t@SuppressAjWarnings({\"adviceDidNotMatch\"})\n\tboolean around(BreakpointMarkerUpdater markerUpdater, IMarker marker, IDocument document, Position position):  \n\t\t\tupdateMarker(markerUpdater, marker, document, position) {\n\t\tIFile resource = (IFile) marker.getResource();\n\t\tif (resource != null && (AspectsUtils.existsSourceFile(resource) || AspectsUtils.isScript(resource))) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn proceed(markerUpdater, marker, document, position);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/navigation/KotlinFindSourceAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.navigation;\n\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.internal.core.SourceMapper;\nimport org.jetbrains.kotlin.core.resolve.KotlinSourceIndex;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinFindSourceAspect {\n    pointcut findSource(SourceMapper mapper, IType type, String simpleSourceFileName) :\n        target(mapper) &&\n        args(type, simpleSourceFileName)\n        && call(char[] findSource(IType, String));\n    \n    char[] around(SourceMapper mapper, IType type, String simpleSourceFileName) : findSource(mapper, type, simpleSourceFileName) {\n        char[] result = proceed(mapper, type, simpleSourceFileName);\n        if (result == null && KotlinSourceIndex.isKotlinSource(simpleSourceFileName)) {\n            return KotlinSourceIndex.getSource(mapper, type, simpleSourceFileName);\n        }\n        return result;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/navigation/KotlinOpenEditorAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.navigation;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;\nimport org.eclipse.ui.IEditorPart;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor;\n\npublic aspect KotlinOpenEditorAspect {\n\tpointcut openInEditor(Object inputElement, boolean activate) :\n\t\targs(inputElement, activate)\n\t\t&& execution(IEditorPart EditorUtility.openInEditor(Object, boolean));\n\t\n\t@SuppressAjWarnings({\"adviceDidNotMatch\"})\n\tIEditorPart around(Object inputElement, boolean activate) : openInEditor(inputElement, activate) {\n\t\tif (inputElement instanceof IJavaElement) {\n\t\t\tIJavaElement javaElement = (IJavaElement) inputElement;\n\t\t\t\n\t\t\tif (EclipseJavaElementUtil.isKotlinLightClass(javaElement)) {\n\t\t\t\treturn KotlinOpenEditor.openKotlinEditor(javaElement, activate);\n\t\t\t}\t\n\t\t\t\n\t\t\tif (EclipseJavaElementUtil.isKotlinBinaryElement(javaElement)) {\n\t\t\t    return KotlinOpenEditor.openKotlinClassFileEditor(javaElement, activate);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn proceed(inputElement, activate);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/navigation/KotlinSearchEditorOpenerAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.navigation;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;\nimport org.eclipse.jdt.internal.ui.search.JavaSearchEditorOpener;\nimport org.eclipse.ui.IEditorPart;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor;\n\npublic aspect KotlinSearchEditorOpenerAspect {\n    pointcut openElement(Object element) :\n        args(element)\n        && execution(IEditorPart JavaSearchEditorOpener.openElement(Object));\n    \n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    IEditorPart around(Object element) : openElement(element) {\n        if (element instanceof IJavaElement) {\n            IJavaElement javaElement = (IJavaElement) element;\n            \n            if (EclipseJavaElementUtil.isKotlinLightClass(javaElement)) {\n                IEditorPart kotlinEditor = KotlinOpenEditor.openKotlinEditor(javaElement, true);\n                EditorUtility.revealInEditor(kotlinEditor, javaElement);\n                \n                return null;\n            }\n        }\n        \n        return proceed(element);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinBinaryReferencesAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.search.SearchMatch;\nimport org.eclipse.jdt.internal.corext.refactoring.base.ReferencesInBinaryContext;\nimport org.eclipse.ltk.core.refactoring.RefactoringStatus;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinBinaryReferencesAspect {\n    pointcut addErrorIfNecessary(RefactoringStatus status) :\n        args(status)\n        && execution(void ReferencesInBinaryContext.addErrorIfNecessary(RefactoringStatus));\n    \n    // JDT report about error if there are binary references for rename\n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    void around(RefactoringStatus status) : addErrorIfNecessary(status) {\n        ReferencesInBinaryContext targetObject = (ReferencesInBinaryContext) thisJoinPoint.getTarget();\n        boolean hasKotlinReference = false;\n        for (SearchMatch match : targetObject.getMatches()) {\n            Object element = match.getElement();\n            if (element instanceof IJavaElement && EclipseJavaElementUtil.isKotlinLightClass((IJavaElement) element)) {\n                hasKotlinReference = true;\n                break;\n            }\n        }\n        \n        if (!hasKotlinReference) {\n            proceed(status);\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinBreakpointRenamingParticipantAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.internal.debug.core.refactoring.BreakpointChange;\nimport org.jetbrains.kotlin.ui.builder.AspectsUtils;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinBreakpointRenamingParticipantAspect {\n    pointcut findElement(IJavaElement parent, IJavaElement element): \n                args(parent, element) \n                && execution(IJavaElement BreakpointChange.findElement(IJavaElement, IJavaElement));\n\n    // BreakpointRenameParticipant operates with compilation unit to rename breakpoint configuration\n    // Thus we disable it for Kotlin files\n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    IJavaElement around(IJavaElement parent, IJavaElement element): findElement(parent, element) {\n        IResource resource = parent.getResource();\n        if (resource instanceof IFile && AspectsUtils.isKotlinFile((IFile) resource)) {\n            return null;\n        }\n        \n        return proceed(parent, element);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinJavaDescriptorAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.WorkingCopyOwner;\nimport org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringDescriptorUtil;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\nimport org.jetbrains.kotlin.ui.refactorings.rename.KotlinLightElementsFactory;\n\npublic aspect KotlinJavaDescriptorAspect {\n    pointcut handleToElement(final WorkingCopyOwner owner, final String project, final String handle, final boolean check) :\n        args(owner, project, handle, check)\n        && execution(IJavaElement JavaRefactoringDescriptorUtil.handleToElement(WorkingCopyOwner, String, String, boolean));\n    \n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    IJavaElement around(final WorkingCopyOwner owner, final String project, final String handle, final boolean check) : \n            handleToElement(owner, project, handle, check) {\n        IJavaElement javaElement = proceed(owner, project, handle, check);\n        if (EclipseJavaElementUtil.isKotlinLightClass(javaElement)) {\n            return KotlinLightElementsFactory.createLightElement(javaElement);\n        }\n        return javaElement;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinRefactoringChecksAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IMember;\nimport org.eclipse.jdt.internal.corext.refactoring.Checks;\nimport org.eclipse.ltk.core.refactoring.RefactoringStatus;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\n\npublic aspect KotlinRefactoringChecksAspect {\n    pointcut checkIfCuBroken(IMember member) :\n        args(member)\n        && execution(RefactoringStatus Checks.checkIfCuBroken(IMember));\n    \n    // Disable checking of compilation unit for Kotlin files\n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    RefactoringStatus around(IMember member) : checkIfCuBroken(member) {\n        if (EclipseJavaElementUtil.isKotlinLightClass(member)) {\n            return new RefactoringStatus();\n        }\n        \n        return proceed(member);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinRefactoringTypeAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor;\nimport org.eclipse.jdt.internal.corext.refactoring.util.TextChangeManager;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinRefactoringTypeAspect {\n    pointcut addTypeDeclarationUpdate(TextChangeManager manager) :\n        args(manager)\n        && execution(void RenameTypeProcessor.addTypeDeclarationUpdate(TextChangeManager));\n    \n    // Prohibit renaming Kotlin type declaration from JDT\n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    void around(TextChangeManager manager) : addTypeDeclarationUpdate(manager) {\n        try {\n            Method method = RenameTypeProcessor.class.getDeclaredMethod(\"getType\");\n            IType type = (IType) method.invoke(thisJoinPoint.getTarget());\n            if (!EclipseJavaElementUtil.isKotlinLightClass(type)) {\n                proceed(manager);\n            }\n        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | \n                IllegalArgumentException | InvocationTargetException e) {\n            // skip\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinRemoveDeclarationUpdateAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor;\nimport org.eclipse.jdt.internal.corext.refactoring.util.TextChangeManager;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinRemoveDeclarationUpdateAspect {\n    pointcut addDeclarationUpdate(TextChangeManager manager) :\n        args(manager)\n        && execution(void RenameNonVirtualMethodProcessor.addDeclarationUpdate(TextChangeManager));\n    \n    // Prohibit renaming Kotlin method declaration from JDT\n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    void around(TextChangeManager manager) : addDeclarationUpdate(manager) {\n        RenameNonVirtualMethodProcessor processor = (RenameNonVirtualMethodProcessor) thisJoinPoint.getTarget();\n        if (EclipseJavaElementUtil.isKotlinLightClass(processor.getMethod())) {\n            return;\n        }\n        \n        proceed(manager);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinRenameFromJavaAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\nimport org.jetbrains.kotlin.ui.refactorings.rename.KotlinLightElementsFactory;\n\npublic aspect KotlinRenameFromJavaAspect {\n    pointcut getJavaElementFromEditor() :\n        args()\n        && execution(IJavaElement RenameJavaElementAction.getJavaElementFromEditor());\n    \n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    IJavaElement around() : getJavaElementFromEditor() {\n        IJavaElement javaElement = proceed();\n        if (EclipseJavaElementUtil.isKotlinLightClass(javaElement)) {\n            return KotlinLightElementsFactory.createLightElement(javaElement);\n        }\n        return javaElement;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/refactoring/KotlinRippleMethodFinderAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.refactoring;\n\nimport org.aspectj.lang.annotation.SuppressAjWarnings;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.WorkingCopyOwner;\nimport org.eclipse.jdt.internal.corext.refactoring.base.ReferencesInBinaryContext;\nimport org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil;\n\n@SuppressWarnings(\"restriction\")\npublic aspect KotlinRippleMethodFinderAspect {\n    pointcut getRelatedMethods(IMethod method, ReferencesInBinaryContext binaryRefs, IProgressMonitor pm, WorkingCopyOwner owner) :\n        args(method, binaryRefs, pm, owner)\n        && execution(IMethod[] RippleMethodFinder2.getRelatedMethods(IMethod, ReferencesInBinaryContext, \n                IProgressMonitor, WorkingCopyOwner));\n    \n    @SuppressAjWarnings({\"adviceDidNotMatch\"})\n    IMethod[] around(IMethod method, ReferencesInBinaryContext binaryRefs, IProgressMonitor pm, WorkingCopyOwner owner) : \n            getRelatedMethods(method, binaryRefs, pm, owner) {\n        if (EclipseJavaElementUtil.isKotlinLightClass(method)) {\n            return new IMethod[] { method };\n        }\n        \n        return proceed(method, binaryRefs, pm, owner);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-aspects/src/org/jetbrains/kotlin/aspects/ui/PackageExplorerLabelProviderAspect.aj",
    "content": "package org.jetbrains.kotlin.aspects.ui;\n\nimport org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider;\nimport org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider;\nimport org.jetbrains.kotlin.ui.KotlinAwarePackageExplorerLabelProvider;\n\n@SuppressWarnings(\"restriction\")\npublic aspect PackageExplorerLabelProviderAspect {\n    \n    /**\n     * Replaces all instances of {@link PackageExplorerLabelProvider}\n     * with instances of {@link KotlinAwarePackageExplorerLabelProvider}\n     * \n     * It affects classes {@link JavaNavigatorLabelProvider} and {@link PackageExplorerPart},\n     * which provides icons for Project Explorer and Package Explorer, respectively. \n     */\n    PackageExplorerLabelProvider around(PackageExplorerContentProvider cp) \n        : call(PackageExplorerLabelProvider.new(PackageExplorerContentProvider)) && args(cp) {\n        return new KotlinAwarePackageExplorerLabelProvider(cp);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-core\nBundle-SymbolicName: org.jetbrains.kotlin.core;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.core.Activator\nBundle-Vendor: JetBrains\nRequire-Bundle: org.jetbrains.kotlin.bundled-compiler,\n org.eclipse.core.runtime,\n org.eclipse.jdt.core,\n org.eclipse.jdt.launching,\n org.eclipse.debug.core,\n org.eclipse.core.filesystem,\n org.eclipse.core.expressions,\n org.eclipse.jdt.junit\nBundle-ActivationPolicy: lazy\nImport-Package: com.intellij.codeInsight,\n com.intellij.openapi.components,\n kotlin.script.experimental.annotations,\n kotlin.script.experimental.api,\n kotlin.script.experimental.dependencies,\n kotlin.script.experimental.host,\n kotlin.script.experimental.util,\n kotlin.script.experimental.jvm,\n org.eclipse.core.filesystem,\n org.eclipse.core.resources,\n org.eclipse.debug.internal.ui.viewers,\n org.eclipse.jdt.core,\n org.eclipse.jdt.debug.core,\n org.eclipse.jdt.internal.core,\n org.eclipse.jdt.internal.corext.dom,\n org.eclipse.jdt.internal.debug.core,\n org.eclipse.jdt.internal.debug.core.breakpoints,\n org.eclipse.jdt.junit.launcher,\n org.eclipse.jdt.ui,\n org.eclipse.jface.text,\n org.jetbrains.kotlin.resolve.sam\nExport-Package: org.jetbrains.kotlin.core,\n org.jetbrains.kotlin.core.asJava,\n org.jetbrains.kotlin.core.builder,\n org.jetbrains.kotlin.core.compiler,\n org.jetbrains.kotlin.core.debug,\n org.jetbrains.kotlin.core.filesystem,\n org.jetbrains.kotlin.core.formatting,\n org.jetbrains.kotlin.core.imports,\n org.jetbrains.kotlin.core.launch,\n org.jetbrains.kotlin.core.log,\n org.jetbrains.kotlin.core.model,\n org.jetbrains.kotlin.core.preferences,\n org.jetbrains.kotlin.core.references,\n org.jetbrains.kotlin.core.resolve,\n org.jetbrains.kotlin.core.resolve.lang.java.resolver,\n org.jetbrains.kotlin.core.resolve.lang.java.structure,\n org.jetbrains.kotlin.core.resolve.lang.kotlin,\n org.jetbrains.kotlin.core.script,\n org.jetbrains.kotlin.core.utils\nBundle-RequiredExecutionEnvironment: JavaSE-17\n"
  },
  {
    "path": "kotlin-eclipse-core/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nsource.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               schema/,\\\n               preferences.ini\n"
  },
  {
    "path": "kotlin-eclipse-core/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension-point id=\"org.jetbrains.kotlin.core.predefinedKotlinCodeStyle\" name=\"Predefined Kotlin Code Style\" schema=\"schema/org.jetbrains.kotlin.core.predefinedKotlinCodeStyle.exsd\"/>\n   <extension-point id=\"org.jetbrains.kotlin.core.scriptTemplateContribution\" name=\"Kotlin Script Teplate Contribution\" schema=\"schema/org.jetbrains.kotlin.core.scriptTemplateContribution.exsd\"/>\n   <extension\n         id=\"org.jetbrains.kotlin.core.kotlinNature\"\n         name=\"KotlinNature\"\n         point=\"org.eclipse.core.resources.natures\">\n      <runtime>\n         <run\n               class=\"org.jetbrains.kotlin.core.model.KotlinNature\">\n         </run>\n      </runtime>\n   </extension>\n   <extension point=\"org.eclipse.team.core.fileTypes\">\n      <fileTypes extension=\"kt\" type=\"text\"/>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.filesystem.filesystems\">\n      <filesystem\n            scheme=\"org.jetbrains.kotlin.core.filesystem\">\n         <run\n               class=\"org.jetbrains.kotlin.core.filesystem.KotlinFileSystem\">\n         </run>\n      </filesystem>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.filesystem.filesystems\">\n      <filesystem\n            scheme=\"org.jetbrains.kotlin.script\">\n         <run\n               class=\"org.jetbrains.kotlin.core.filesystem.KotlinScriptFileSystem\">\n         </run>\n      </filesystem>\n   </extension>\n   <extension\n         point=\"org.eclipse.jdt.core.classpathContainerInitializer\">\n      <classpathContainerInitializer\n            class=\"org.jetbrains.kotlin.core.KotlinClasspathContainerInitializer\"\n            id=\"org.jetbrains.kotlin.core.KOTLIN_CONTAINER\">\n      </classpathContainerInitializer>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.expressions.definitions\">\n      <definition\n            id=\"org.jetbrains.kotlin.core.hasNature\">\n         <adapt\n               type=\"org.eclipse.core.resources.IProject\">\n            <test\n                  property=\"org.eclipse.core.resources.projectNature\"\n                  value=\"org.jetbrains.kotlin.core.kotlinNature\">\n            </test>\n         </adapt>\n      </definition>\n   </extension>\n   <extension\n         point=\"org.eclipse.jdt.launching.classpathProviders\">\n      <classpathProvider\n            class=\"org.jetbrains.kotlin.core.KotlinClasspathProvider\"\n            id=\"org.jetbrains.kotlin.core.kotlinClasspathProvider\">\n      </classpathProvider>\n   </extension>\n   <extension\n         point=\"org.jetbrains.kotlin.core.predefinedKotlinCodeStyle\">\n      <codeStyle\n            class=\"org.jetbrains.kotlin.idea.formatter.KotlinObsoleteCodeStyle\"\n            nameInBuildsystem=\"obsolete\">\n      </codeStyle>\n      <codeStyle\n            class=\"org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle\"\n            nameInBuildsystem=\"official\">\n      </codeStyle>\n   </extension>\n   <extension\n         point=\"org.jetbrains.kotlin.core.scriptTemplateContribution\">\n      <template\n            class=\"org.jetbrains.kotlin.core.script.template.ProjectScriptTemplateContribution\">\n      </template>\n   </extension>\n</plugin>\n"
  },
  {
    "path": "kotlin-eclipse-core/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.core</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>3.10.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<release>17</release>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n\t\n</project>"
  },
  {
    "path": "kotlin-eclipse-core/preferences.ini",
    "content": "jvmTarget=JVM_1_6\ncompilerPlugins/all-open/active=false\ncompilerPlugins/all-open/jarPath=$KOTLIN_HOME/lib/allopen-compiler-plugin.jar\ncompilerPlugins/spring/active=false\ncompilerPlugins/spring/jarPath=$KOTLIN_HOME/lib/allopen-compiler-plugin.jar\ncompilerPlugins/spring/args=org.jetbrains.kotlin.allopen:preset=spring\ncompilerPlugins/no-arg/active=false\ncompilerPlugins/no-arg/jarPath=$KOTLIN_HOME/lib/noarg-compiler-plugin.jar\ncompilerPlugins/jpa/active=false\ncompilerPlugins/jpa/jarPath=$KOTLIN_HOME/lib/noarg-compiler-plugin.jar\ncompilerPlugins/jpa/args=org.jetbrains.kotlin.noarg:preset=jpa\ncompilerPlugins/sam-with-receiver/active=false\ncompilerPlugins/sam-with-receiver/jarPath=$KOTLIN_HOME/lib/sam-with-receiver-compiler-plugin.jar\ncodeStyle/codeStyleId=KOTLIN_OFFICIAL\n"
  },
  {
    "path": "kotlin-eclipse-core/schema/org.jetbrains.kotlin.core.predefinedKotlinCodeStyle.exsd",
    "content": "<?xml version='1.0' encoding='UTF-8'?>\n<!-- Schema file written by PDE -->\n<schema targetNamespace=\"org.jetbrains.kotlin.core\" xmlns=\"http://www.w3.org/2001/XMLSchema\">\n<annotation>\n      <appinfo>\n         <meta.schema plugin=\"org.jetbrains.kotlin.core\" id=\"org.jetbrains.kotlin.core.predefinedKotlinCodeStyle\" name=\"Predefined Kotlin Code Style\"/>\n      </appinfo>\n      <documentation>\n         [Enter description of this extension point.]\n      </documentation>\n   </annotation>\n\n   <element name=\"extension\">\n      <annotation>\n         <appinfo>\n            <meta.element />\n         </appinfo>\n      </annotation>\n      <complexType>\n         <choice minOccurs=\"1\" maxOccurs=\"unbounded\">\n            <element ref=\"codeStyle\"/>\n         </choice>\n         <attribute name=\"point\" type=\"string\" use=\"required\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"id\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"name\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n               <appinfo>\n                  <meta.attribute translatable=\"true\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <element name=\"codeStyle\">\n      <complexType>\n         <attribute name=\"class\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n               <appinfo>\n                  <meta.attribute kind=\"java\" basedOn=\"org.jetbrains.kotlin.idea.formatter.KotlinPredefinedCodeStyle:\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"since\"/>\n      </appinfo>\n      <documentation>\n         [Enter the first release in which this extension point appears.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"examples\"/>\n      </appinfo>\n      <documentation>\n         [Enter extension point usage example here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"apiinfo\"/>\n      </appinfo>\n      <documentation>\n         [Enter API information here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"implementation\"/>\n      </appinfo>\n      <documentation>\n         [Enter information about supplied implementation of this extension point.]\n      </documentation>\n   </annotation>\n\n\n</schema>\n"
  },
  {
    "path": "kotlin-eclipse-core/schema/org.jetbrains.kotlin.core.scriptTemplateContribution.exsd",
    "content": "<?xml version='1.0' encoding='UTF-8'?>\n<!-- Schema file written by PDE -->\n<schema targetNamespace=\"org.jetbrains.kotlin.core\" xmlns=\"http://www.w3.org/2001/XMLSchema\">\n<annotation>\n      <appinfo>\n         <meta.schema plugin=\"org.jetbrains.kotlin.core\" id=\"org.jetbrains.kotlin.core.scriptTemplate\" name=\"Kotlin Script Teplate\"/>\n      </appinfo>\n      <documentation>\n         [Enter description of this extension point.]\n      </documentation>\n   </annotation>\n\n   <element name=\"extension\">\n      <annotation>\n         <appinfo>\n            <meta.element />\n         </appinfo>\n      </annotation>\n      <complexType>\n         <choice minOccurs=\"1\" maxOccurs=\"unbounded\">\n            <element ref=\"template\"/>\n         </choice>\n         <attribute name=\"point\" type=\"string\" use=\"required\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"id\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"name\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n               <appinfo>\n                  <meta.attribute translatable=\"true\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <element name=\"template\">\n      <complexType>\n         <attribute name=\"class\" type=\"string\" use=\"required\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n               <appinfo>\n                  <meta.attribute kind=\"java\" basedOn=\"org.jetbrains.kotlin.core.script.ScriptTemplateContribution:\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"since\"/>\n      </appinfo>\n      <documentation>\n         [Enter the first release in which this extension point appears.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"examples\"/>\n      </appinfo>\n      <documentation>\n         [Enter extension point usage example here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"apiinfo\"/>\n      </appinfo>\n      <documentation>\n         [Enter API information here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"implementation\"/>\n      </appinfo>\n      <documentation>\n         [Enter information about supplied implementation of this extension point.]\n      </documentation>\n   </annotation>\n\n\n</schema>\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/Activator.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core;\n\nimport org.eclipse.core.resources.IResourceChangeEvent;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.Plugin;\nimport org.eclipse.core.runtime.preferences.DefaultScope;\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache;\nimport org.jetbrains.kotlin.core.model.KotlinRefreshProjectListener;\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties;\nimport org.osgi.framework.BundleContext;\n\npublic class Activator extends Plugin {\n    \n\tprivate static Activator plugin;\n\t\n\tpublic static final String PLUGIN_ID = \"org.jetbrains.kotlin.core\";\n\n\tpublic Activator() {\n\t    plugin = this;\n\t}\n\t\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\t@Override\n    public void start(BundleContext bundleContext) throws Exception {\n\t\tsuper.start(bundleContext);\n\t\t\n\t\tResourcesPlugin.getWorkspace().addResourceChangeListener(KotlinAnalysisProjectCache.INSTANCE,\n\t\t        IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_BUILD);\n\t\tResourcesPlugin.getWorkspace().addResourceChangeListener(KotlinRefreshProjectListener.INSTANCE,\n\t\t        IResourceChangeEvent.PRE_REFRESH);\n\t\t\n\t\tKotlinProperties.init();\n\t}\n\n\t@Override\n    public void stop(BundleContext bundleContext) throws Exception {\n\t    ResourcesPlugin.getWorkspace().removeResourceChangeListener(KotlinAnalysisProjectCache.INSTANCE);\n\t    ResourcesPlugin.getWorkspace().removeResourceChangeListener(KotlinRefreshProjectListener.INSTANCE);\n\t    \n\t\tplugin = null;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/KotlinClasspathContainer.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core\n\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.IClasspathContainer\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.buildLibPath\nimport java.util.*\n\nval runtimeContainerId: IPath = Path(\"org.jetbrains.kotlin.core.KOTLIN_CONTAINER\")\n\nclass KotlinClasspathContainer(val javaProject: IJavaProject) : IClasspathContainer {\n    companion object {\n        val CONTAINER_ENTRY: IClasspathEntry = JavaCore.newContainerEntry(runtimeContainerId)\n        val LIB_RUNTIME_NAME = \"kotlin-stdlib\"\n        val LIB_RUNTIME_SRC_NAME = \"kotlin-stdlib-sources\"\n        val LIB_REFLECT_NAME = \"kotlin-reflect\"\n        val LIB_SCRIPT_RUNTIME_NAME = \"kotlin-script-runtime\"\n        val LIB_ANNOTATIONS_1_3 = \"annotations-13.0\"\n\n        @JvmStatic\n        fun getPathToLightClassesFolder(javaProject: IJavaProject): IPath {\n            return Path(javaProject.project.name).append(KotlinJavaManager.KOTLIN_BIN_FOLDER).makeAbsolute()\n        }\n    }\n\n    override fun getClasspathEntries(): Array<IClasspathEntry> {\n        val entries = ArrayList<IClasspathEntry>()\n                \n        val kotlinBinFolderEntry =\n            ProjectUtils.newExportedLibraryEntry(getPathToLightClassesFolder(javaProject))\n        entries.add(kotlinBinFolderEntry)\n\n        val project = javaProject.project\n        if (!ProjectUtils.isMavenProject(project) && !ProjectUtils.isGradleProject(project)) {\n            val kotlinRuntimeEntry = JavaCore.newLibraryEntry(\n                    LIB_RUNTIME_NAME.buildLibPath(),\n                    LIB_RUNTIME_SRC_NAME.buildLibPath(),\n                    null,\n                    true)\n            val kotlinReflectEntry =\n                ProjectUtils.newExportedLibraryEntry(LIB_REFLECT_NAME.buildLibPath())\n            val kotlinScriptRuntime =\n                ProjectUtils.newExportedLibraryEntry(LIB_SCRIPT_RUNTIME_NAME.buildLibPath())\n            val annotations13 =\n                ProjectUtils.newExportedLibraryEntry(LIB_ANNOTATIONS_1_3.buildLibPath())\n            \n            entries.add(kotlinRuntimeEntry)\n            entries.add(kotlinReflectEntry)\n            entries.add(kotlinScriptRuntime)\n            entries.add(annotations13)\n        }\n        \n        return entries.toTypedArray()\n    }\n\n    override fun getDescription(): String = \"Kotlin Runtime Library\"\n\n    override fun getKind(): Int = IClasspathContainer.K_APPLICATION\n\n    override fun getPath(): IPath = runtimeContainerId\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/KotlinClasspathContainerInitializer.kt",
    "content": "package org.jetbrains.kotlin.core\n\nimport org.eclipse.core.resources.IFolder\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.ClasspathContainerInitializer\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.filesystem.KotlinFileSystem\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager\nimport java.net.URI\n\nclass KotlinClasspathContainerInitializer : ClasspathContainerInitializer() {\n    override fun initialize(containerPath: IPath, javaProject: IJavaProject) {\n        if (JavaCore.getClasspathContainer(runtimeContainerId, javaProject) !is KotlinClasspathContainer) {\n            if (!KotlinJavaManager.hasLinkedKotlinBinFolder(javaProject.project)) {\n\t    \t\taddFolderForKotlinClassFiles(javaProject)\n\t    \t}\n            \n        \tJavaCore.setClasspathContainer(containerPath, arrayOf(javaProject), arrayOf(KotlinClasspathContainer(javaProject)), null)\n        }\n    }\n}\n\nprivate fun setKotlinFileSystemScheme(folder: IFolder) : URI {\n    val locationURI = folder.locationURI\n    val path = Path(folder.project.name).append(KotlinJavaManager.KOTLIN_BIN_FOLDER).makeAbsolute()\n    return URI(\n    \t\tKotlinFileSystem.SCHEME, \n    \t\tlocationURI.userInfo,\n    \t\tlocationURI.host,\n\t        locationURI.port,\n\t        path.toPortableString(), \n\t        locationURI.query,\n\t        locationURI.fragment)\n}\n    \nprivate fun addFolderForKotlinClassFiles(javaProject: IJavaProject) {\n    val folder = javaProject.project.getFolder(KotlinJavaManager.KOTLIN_BIN_FOLDER)\n    folder.createLink(setKotlinFileSystemScheme(folder), IResource.REPLACE or IResource.ALLOW_MISSING_LOCAL, null)\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/KotlinClasspathProvider.kt",
    "content": "package org.jetbrains.kotlin.core\n\nimport org.eclipse.debug.core.ILaunchConfiguration\nimport org.eclipse.jdt.launching.IRuntimeClasspathEntry\nimport org.eclipse.jdt.launching.JavaRuntime\nimport org.eclipse.jdt.launching.StandardClasspathProvider\n\nconst val KOTLIN_CLASSPATH_PROVIDER_ID = \"org.jetbrains.kotlin.core.kotlinClasspathProvider\"\n\nclass KotlinClasspathProvider : StandardClasspathProvider() {\n    override fun computeUnresolvedClasspath(configuration: ILaunchConfiguration): Array<IRuntimeClasspathEntry> =\n            super.computeUnresolvedClasspath(configuration)\n                    .filterNot { it.location != null && it.location == configuration.lightClassPath }\n                    .toTypedArray()\n\n    private val ILaunchConfiguration.lightClassPath: String?\n        get() = JavaRuntime.getJavaProject(this)\n                ?.let { KotlinClasspathContainer.getPathToLightClassesFolder(it) }\n                ?.toPortableString()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/BinaryClassWriter.java",
    "content": "package org.jetbrains.kotlin.core.asJava;\n\nimport org.jetbrains.org.objectweb.asm.ClassWriter;\n\npublic class BinaryClassWriter extends ClassWriter {\n    public BinaryClassWriter() {\n        super(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);\n    }\n\n    @Override\n    protected String getCommonSuperClass(String type1, String type2) {\n        try {\n            return super.getCommonSuperClass(type1, type2);\n        }\n        catch (Throwable t) {\n            // TODO: we might need at some point do more sophisticated handling\n            return \"java/lang/Object\";\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/KotlinLightClassGeneration.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.asJava\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.codegen.KotlinCodegenFacade\nimport org.jetbrains.kotlin.codegen.state.GenerationState\nimport org.jetbrains.kotlin.config.CommonConfigurationKeys\nimport org.jetbrains.kotlin.config.CompilerConfiguration\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.psi.KtCodeFragment\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtScript\n\nobject KotlinLightClassGeneration {\n\n    fun updateLightClasses(project: IProject, affectedFiles: Set<IFile>, resourcesTreeBlocked: Boolean = false) {\n        if (!KotlinJavaManager.hasLinkedKotlinBinFolder(project)) return\n\n        KotlinPsiManager.recreateSourcesForProject(JavaCore.create(project))\n\n        KotlinLightClassManager.getInstance(project).computeLightClassesSources()\n        KotlinLightClassManager.getInstance(project).updateLightClasses(affectedFiles, resourcesTreeBlocked)\n    }\n\n    fun buildLightClasses(\n            analysisResult: AnalysisResult,\n            eclipseProject: IProject,\n            jetFiles: List<KtFile>,\n            requestedClassName: String): GenerationState {\n\n        val tempProps = KotlinEnvironment.getEnvironment(eclipseProject).compilerProperties\n\n        val tempConfig = CompilerConfiguration().apply {\n            put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, tempProps.languageVersionSettings)\n        }\n\n        val state = GenerationState.Builder(\n                KotlinEnvironment.getEnvironment(eclipseProject).project,\n                LightClassBuilderFactory(),\n                analysisResult.moduleDescriptor,\n                analysisResult.bindingContext,\n                jetFiles,\n                tempConfig)\n        \t.generateDeclaredClassFilter(object : GenerationState.GenerateClassFilter() {\n\n                    override fun shouldGenerateCodeFragment(script: KtCodeFragment): Boolean = false\n\n                    override fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean = true\n\n                    override fun shouldGenerateClass(processingClassOrObject: KtClassOrObject): Boolean {\n                        val internalName = KotlinLightClassManager.getInternalName(processingClassOrObject)\n                        return checkByInternalName(internalName, requestedClassName)\n                    }\n\n                    override fun shouldGeneratePackagePart(ktFile: KtFile): Boolean {\n                        val internalName = JvmFileClassUtil.getFileClassInternalName(ktFile)\n                        return checkByInternalName(internalName, requestedClassName)\n                    }\n\n                    override fun shouldGenerateScript(script: KtScript): Boolean = false\n\n                    override fun shouldGenerateClassMembers(processingClassOrObject: KtClassOrObject): Boolean {\n\t\t\t\t\t\treturn super.shouldGenerateClassMembers(processingClassOrObject) ||\n\t\t\t\t\t\t\t\tprocessingClassOrObject.hasModifier(KtTokens.COMPANION_KEYWORD)\n\t\t\t\t\t}\n\t\t\t}).build()\n\n        KotlinCodegenFacade.compileCorrectFiles(state)\n\n        return state\n    }\n\n    private fun checkByInternalName(internalName: String?, requestedClassFileName: String): Boolean {\n        if (internalName == null) return false\n\n        val classFileName = Path(internalName).lastSegment()\n        val requestedInternalName = requestedClassFileName.dropLast(\".class\".length)\n\n        if (requestedInternalName.startsWith(classFileName)) {\n            if (requestedInternalName.length == classFileName.length) return true\n\n            if (requestedInternalName[classFileName.length] == '$') return true\n        }\n\n        return false\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/LightClassBuilderFactory.java",
    "content": "package org.jetbrains.kotlin.core.asJava;\n\nimport java.util.Collections;\nimport java.util.Set;\nimport java.util.concurrent.ConcurrentHashMap;\n\nimport kotlin.Pair;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.codegen.AbstractClassBuilder;\nimport org.jetbrains.kotlin.codegen.ClassBuilder;\nimport org.jetbrains.kotlin.codegen.ClassBuilderFactory;\nimport org.jetbrains.kotlin.codegen.ClassBuilderMode;\nimport org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;\nimport org.jetbrains.org.objectweb.asm.ClassWriter;\nimport org.jetbrains.org.objectweb.asm.FieldVisitor;\nimport org.jetbrains.org.objectweb.asm.MethodVisitor;\n\nimport com.intellij.openapi.util.Key;\nimport com.intellij.psi.PsiElement;\n\npublic class LightClassBuilderFactory implements ClassBuilderFactory {\n    public static final Key<Set<Pair<String, String>>> JVM_SIGNATURE = Key.create(\"JVM_SIGNATURE\");\n\n    @Override\n    @NotNull\n    public ClassBuilderMode getClassBuilderMode() {\n        return ClassBuilderMode.LIGHT_CLASSES;\n    }\n\n    @Override\n    @NotNull\n    public ClassBuilder newClassBuilder(@NotNull JvmDeclarationOrigin origin) {\n        return new AbstractClassBuilder.Concrete(new BinaryClassWriter()) {\n            @Override\n            @NotNull\n            public MethodVisitor newMethod(@NotNull JvmDeclarationOrigin origin, int access, @NotNull String name,\n                    @NotNull String desc, @Nullable String signature, @Nullable String[] exceptions) {\n                saveJvmSignature(origin, name, desc);\n                return super.newMethod(origin, access, name, desc, signature, exceptions);\n            }\n\n            @Override\n            @NotNull\n            public FieldVisitor newField(@NotNull JvmDeclarationOrigin origin, int access, @NotNull String name,\n                    @NotNull String desc, @Nullable String signature, @Nullable Object value) {\n                saveJvmSignature(origin, name, desc);\n                return super.newField(origin, access, name, desc, signature, value);\n            }\n            \n            private void saveJvmSignature(@NotNull JvmDeclarationOrigin origin, @NotNull String name, @NotNull String desc) {\n                PsiElement element = origin.getElement();\n                if (element != null) {\n                    Set<Pair<String, String>> userData = element.getUserData(JVM_SIGNATURE);\n                    if (userData == null) {\n                        userData = Collections.newSetFromMap(new ConcurrentHashMap<Pair<String, String>, Boolean>());\n                        element.putUserData(JVM_SIGNATURE, userData);\n                    }\n                    userData.add(new Pair<String, String>(desc, name));\n                }\n            }\n        };\n    }\n    \n    @Override\n    public String asText(ClassBuilder builder) {\n        throw new UnsupportedOperationException(\"BINARIES generator asked for text\");\n    }\n\n    @Override\n    public byte[] asBytes(ClassBuilder builder) {\n        ClassWriter visitor = (ClassWriter) builder.getVisitor();\n        return visitor.toByteArray();\n    }\n\n    @Override\n    public void close() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/LightClassFile.java",
    "content": "package org.jetbrains.kotlin.core.asJava;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.File;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\n\npublic class LightClassFile {\n    private final IFile file;\n    \n    public LightClassFile(@NotNull IFile file) {\n        this.file = file;\n    }\n    \n    public boolean exists() {\n        return file.exists();\n    }\n    \n    public boolean createIfNotExists() {\n        try {\n            if (!file.exists()) {\n                file.create(new ByteArrayInputStream(new byte[0]), false, null);\n                return true;\n            }\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return false;\n    }\n    \n    public void touchFile() {\n        try {\n            file.touch(null);\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    @NotNull\n    public File asFile() {\n        return file.getFullPath().toFile();\n    }\n    \n    @NotNull\n    public IFile getResource() {\n        return file;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/asJava/elementUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.asJava\n\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.eclipse.jdt.core.IMember\nimport org.eclipse.jdt.core.IField\nimport org.eclipse.jdt.core.IMethod\nimport org.jetbrains.kotlin.psi.KtClass\nimport org.jetbrains.kotlin.psi.KtConstructor\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.jetbrains.kotlin.name.FqName\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\n\nfun equalsJvmSignature(KtElement: KtElement, javaMember: IMember): Boolean {\n    val jetSignatures = KtElement.getUserData(LightClassBuilderFactory.JVM_SIGNATURE)\n    if (jetSignatures == null) return false\n    \n    val memberSignature = when (javaMember) {\n        is IField -> javaMember.getTypeSignature().replace(\"\\\\.\".toRegex(), \"/\") // Hack\n        is IMethod -> javaMember.getSignature()\n        else -> null\n    }\n    \n    return jetSignatures.any { \n        if (it.first == memberSignature) {\n            return@any when {\n                javaMember is IMethod && javaMember.isConstructor() -> \n                KtElement is KtClass || KtElement is KtConstructor<*>\n                else -> it.second == javaMember.getElementName()\n            }\n        }\n        \n        false\n    }\n}\n\nfun getDeclaringTypeFqName(KtElement: KtElement): FqName? {\n    val parent = PsiTreeUtil.getParentOfType(KtElement, KtClassOrObject::class.java, KtFile::class.java)\n    return if (parent != null) getTypeFqName(parent) else null\n}\n\nfun getTypeFqName(element: PsiElement): FqName? {\n    return when (element) {\n        is KtClassOrObject -> element.getFqName()\n        is KtFile -> JvmFileClassUtil.getFileClassInfoNoResolve(element).fileClassFqName\n        else -> null\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/builder/KotlinPsiManager.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.builder\n\nimport com.intellij.openapi.application.ApplicationManager\nimport com.intellij.openapi.util.io.FileUtil\nimport com.intellij.openapi.util.text.StringUtil\nimport com.intellij.openapi.util.text.StringUtilRt\nimport com.intellij.openapi.vfs.CharsetToolkit\nimport com.intellij.psi.PsiFileFactory\nimport com.intellij.psi.impl.PsiFileFactoryImpl\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.IResourceDelta\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreApplicationEnvironment\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.*\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asFile\nimport org.jetbrains.kotlin.core.utils.javaProject\nimport org.jetbrains.kotlin.core.utils.sourceFolders\nimport org.jetbrains.kotlin.idea.KotlinFileType\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider\nimport java.io.File\nimport java.util.Collections\nimport java.util.HashSet\nimport java.util.concurrent.ConcurrentHashMap\nimport kotlin.script.experimental.host.FileScriptSource\n\ninterface PsiFilesStorage {\n    fun getPsiFile(eclipseFile: IFile): KtFile\n    \n    fun getPsiFile(file: IFile, expectedSourceCode: String): KtFile\n    \n    fun isApplicable(file: IFile): Boolean\n    \n    fun removeFile(file: IFile)\n}\n\nprivate class ScriptsFilesStorage : PsiFilesStorage {\n    private val cachedKtFiles = ConcurrentHashMap<IFile, KtFile>()\n    \n    override fun getPsiFile(eclipseFile: IFile): KtFile {\n        assert(isApplicable(eclipseFile)) { \"$eclipseFile is not applicable for Kotlin scripts storage\" }\n        \n        return cachedKtFiles.getOrPut(eclipseFile) { KotlinPsiManager.parseFile(eclipseFile)!! }\n    }\n\n    @Synchronized\n    override fun getPsiFile(file: IFile, expectedSourceCode: String): KtFile {\n        val sourceCodeWithouCR = StringUtilRt.convertLineSeparators(expectedSourceCode)\n        \n        val currentParsedFile = getPsiFile(file)\n        if (currentParsedFile.getText() != sourceCodeWithouCR) {\n            val jetFile = KotlinPsiManager.parseText(sourceCodeWithouCR, file)!!\n            cachedKtFiles.put(file, jetFile)\n        }\n        \n        return getPsiFile(file)\n    }\n\n    override fun isApplicable(file: IFile): Boolean =\n            EclipseScriptDefinitionProvider.isScript(FileScriptSource(file.asFile))\n\n    override fun removeFile(file: IFile) {\n        cachedKtFiles.remove(file)\n    }\n}\n\nprivate class ProjectSourceFiles : PsiFilesStorage {\n    companion object {\n        @JvmStatic\n        fun isKotlinFile(file: IFile): Boolean = KotlinFileType.INSTANCE.getDefaultExtension() == file.fileExtension\n    }\n    \n    private val projectFiles = hashMapOf<IProject, HashSet<IFile>>()\n    private val cachedKtFiles = hashMapOf<IFile, KtFile>()\n    private val mapOperationLock = Any()\n    \n    override fun getPsiFile(eclipseFile: IFile): KtFile {\n        synchronized (mapOperationLock) {\n            updateProjectPsiSourcesIfNeeded(eclipseFile.getProject())\n\n            assert(existsInProjectSources(eclipseFile), { \"File(\" + eclipseFile.getName() + \") does not contain in the psiFiles\" })\n\n            return cachedKtFiles.getOrPut(eclipseFile) {\n                KotlinPsiManager.parseFile(eclipseFile) ?: throw IllegalStateException(\"Can't parse file $eclipseFile\")\n            }\n        }\n    }\n    \n    override fun getPsiFile(file: IFile, expectedSourceCode: String): KtFile {\n        synchronized (mapOperationLock) {\n            updatePsiFile(file, expectedSourceCode)\n            return getPsiFile(file)\n        }\n    }\n    \n    override fun isApplicable(file: IFile): Boolean = existsInProjectSources(file)\n\n    fun existsInProjectSources(file: IFile, update: Boolean = true): Boolean {\n        synchronized (mapOperationLock) {\n            return file.project?.let {\n                if (update) {\n                    updateProjectPsiSourcesIfNeeded(it)\n                }\n                projectFiles[it]?.contains(file)\n            } ?: false\n        }\n    }\n    \n    fun containsProject(project: IProject): Boolean {\n        return synchronized (mapOperationLock) {\n            projectFiles.containsKey(project)\n        }\n    }\n    \n    fun getFilesByProject(project: IProject): Set<IFile> {\n        synchronized (mapOperationLock) {\n            updateProjectPsiSourcesIfNeeded(project)\n            \n            if (projectFiles.containsKey(project)) {\n                return Collections.unmodifiableSet(projectFiles[project])\n            }\n            \n            return emptySet()\n        }\n    }\n    \n    fun addFile(file: IFile) {\n        synchronized (mapOperationLock) {\n            assert(KotlinNature.hasKotlinNature(file.getProject()),\n                    { \"Project (\" + file.getProject().getName() + \") does not have Kotlin nature\" })\n            \n            assert(!existsInProjectSources(file, false), { \"File(\" + file.getName() + \") is already added\" })\n            \n            projectFiles\n                    .getOrPut(file.project) { hashSetOf() }\n                    .add(file)\n        }\n    }\n    \n    override fun removeFile(file: IFile) {\n        synchronized (mapOperationLock) {\n            assert(existsInProjectSources(file), { \"File(\" + file.getName() + \") does not contain in the psiFiles\" })\n            \n            cachedKtFiles.remove(file)\n            projectFiles.get(file.project)?.remove(file)\n        }\n    }\n    \n    fun addProject(project: IProject) {\n        synchronized (mapOperationLock) {\n            if (ProjectUtils.isAccessibleKotlinProject(project)) {\n                addFilesToParse(JavaCore.create(project))\n            }\n        }\n    }\n    \n    fun removeProject(project: IProject) {\n        synchronized (mapOperationLock) {\n            val files = getFilesByProject(project)\n            \n            projectFiles.remove(project)\n            for (file in files) {\n                cachedKtFiles.remove(file)\n            }\n        }\n    }\n    \n    fun addFilesToParse(javaProject: IJavaProject) {\n        try {\n            projectFiles.put(javaProject.getProject(), HashSet<IFile>())\n            \n            for (sourceFolder in javaProject.sourceFolders) {\n                sourceFolder.resource.accept { resource ->\n                    if (resource is IFile && isKotlinFile(resource)) {\n                        addFile(resource)\n                    }\n                    \n                    true\n                }\n            }\n        } catch (e: CoreException) {\n            KotlinLogger.logError(e)\n        }\n    }\n    \n    fun updateProjectPsiSourcesIfNeeded(project: IProject) {\n        if (projectFiles.containsKey(project)) {\n            return\n        }\n        \n        if (ProjectUtils.isAccessibleKotlinProject(project)) {\n            updateProjectPsiSources(project, IResourceDelta.ADDED)\n        }\n    }\n    \n    fun updateProjectPsiSources(project: IProject, flag: Int) {\n        when (flag) {\n            IResourceDelta.ADDED -> addProject(project)\n            IResourceDelta.REMOVED -> removeProject(project)\n        }\n    }\n    \n    fun invalidateProjectSourceFiles() {\n        cachedKtFiles.clear()\n    }\n    \n    private fun updatePsiFile(file: IFile, sourceCode: String) {\n        val sourceCodeWithouCR = StringUtilRt.convertLineSeparators(sourceCode)\n        \n        synchronized (mapOperationLock) {\n            assert(existsInProjectSources(file), { \"File(\" + file.getName() + \") does not contain in the psiFiles\" })\n            \n            val currentParsedFile = getPsiFile(file)\n            if (!currentParsedFile.getText().equals(sourceCodeWithouCR)) {\n                val jetFile = KotlinPsiManager.parseText(sourceCodeWithouCR, file)!!\n                cachedKtFiles.put(file, jetFile)\n            }\n        }\n    }\n\n    fun addFilesIfNotPresent(project: IJavaProject) {\n        try {\n            with(projectFiles.getOrPut(project.project) { hashSetOf() }) {\n                for (sourceFolder in project.sourceFolders) {\n                    sourceFolder.resource.accept { resource ->\n                        if (resource is IFile && isKotlinFile(resource) && !contains(resource)) {\n                            add(resource)\n                        }\n                        true\n                    }\n                }\n            }\n        } catch (e: CoreException) {\n            KotlinLogger.logError(e)\n        }\n    }\n}\n\nobject KotlinPsiManager {\n    private val projectSourceFiles = ProjectSourceFiles()\n    private val scriptsFiles = ScriptsFilesStorage()\n    \n    fun getParsedFile(file: IFile): KtFile {\n        return storage(file).getPsiFile(file)\n    }\n    \n    private fun isApplicable(file: IFile): Boolean {\n        return applicableStorage(file)?.isApplicable(file) ?: false\n    }\n    \n    fun updateProjectPsiSources(file: IFile, flag: Int) {\n        when (flag) {\n            IResourceDelta.ADDED -> projectSourceFiles.addFile(file)\n            IResourceDelta.REMOVED -> removeFile(file)\n            else -> throw IllegalArgumentException()\n        }\n    }\n    \n    fun invalidateCachedProjectSourceFiles() {\n        projectSourceFiles.invalidateProjectSourceFiles()\n    }\n    \n    fun removeFile(file: IFile) {\n        storage(file).removeFile(file)\n    }\n\n    fun removeProjectFromManager(project: IProject) {\n        projectSourceFiles.updateProjectPsiSources(project, IResourceDelta.REMOVED)\n    }\n\n    fun getFilesByProject(project: IProject): Set<IFile> {\n        return projectSourceFiles.getFilesByProject(project)\n    }\n\n    fun existsSourceFile(file: IFile): Boolean {\n        return projectSourceFiles.existsInProjectSources(file)\n    }\n\n    fun getFilesByProject(projectName: String): Set<IFile> {\n        val project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)\n        \n        updateProjectPsiSourcesIfNeeded(project)\n        \n        return getFilesByProject(project)\n    }\n    \n    private fun storage(file: IFile): PsiFilesStorage {\n        return applicableStorage(file) ?: throw IllegalStateException(\"There is not applicable storage for file: $file\")\n    }\n    \n    private fun applicableStorage(file: IFile): PsiFilesStorage? {\n        return when {\n            scriptsFiles.isApplicable(file) -> scriptsFiles\n            projectSourceFiles.isApplicable(file) -> projectSourceFiles\n            else -> null\n        }\n    }\n    \n    private fun updateProjectPsiSourcesIfNeeded(project: IProject) {\n        projectSourceFiles.updateProjectPsiSourcesIfNeeded(project)\n    }\n\n    private fun getParsedFile(file: IFile, expectedSourceCode: String): KtFile {\n        return storage(file).getPsiFile(file, expectedSourceCode)\n    }\n\n    @JvmOverloads\n    @JvmStatic\n    fun isKotlinSourceFile(\n            resource: IResource,\n            javaProject: IJavaProject = JavaCore.create(resource.project)): Boolean {\n        \n        if (!(resource is IFile) || !KotlinFileType.INSTANCE.getDefaultExtension().equals(resource.getFileExtension())) {\n            return false\n        }\n        if (!javaProject.exists()) {\n            return false\n        }\n        if (!KotlinNature.hasKotlinNature(javaProject.getProject())) {\n            return false\n        }\n        \n        val classpathEntries = javaProject.getRawClasspath()\n        val resourceRoot = resource.getFullPath().segment(1)\n        return classpathEntries.any { classpathEntry ->\n            classpathEntry.entryKind == IClasspathEntry.CPE_SOURCE && resourceRoot == classpathEntry.path.segment(1)\n        }\n    }\n    \n    fun parseFile(file: IFile): KtFile? {\n        if (!file.exists()) {\n            return null\n        }\n        \n        val ioFile = File(file.getRawLocation().toOSString())\n        return parseText(FileUtil.loadFile(ioFile, null, true), file)\n    }\n    \n    fun parseText(text: String, file: IFile): KtFile? {\n        StringUtil.assertValidSeparators(text)\n        \n        val project = getEnvironment(file).project\n        \n        val virtualFile = KotlinLightVirtualFile(file, text)\n        virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET)\n        \n        val psiFileFactory = PsiFileFactory.getInstance(project) as PsiFileFactoryImpl\n        \n        return psiFileFactory.trySetupPsiForFile(virtualFile, KotlinLanguage.INSTANCE, true, false) as? KtFile\n    }\n\n    @JvmStatic\n    fun isKotlinFile(file: IFile): Boolean = KotlinFileType.INSTANCE.getDefaultExtension() == file.fileExtension\n\n    @JvmStatic\n    fun getKotlinParsedFile(file: IFile): KtFile? {\n        return if (isApplicable(file)) getParsedFile(file) else null\n    }\n\n    @JvmStatic\n    fun getKotlinFileIfExist(file: IFile, sourceCode: String): KtFile? {\n        return if (isApplicable(file)) getParsedFile(file, sourceCode) else null\n    }\n\n    @JvmStatic\n    fun getEclipseFile(jetFile: KtFile): IFile? {\n        val virtualFile = jetFile.getVirtualFile()\n        return if (virtualFile != null)\n            ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path(virtualFile.getPath()))\n        else\n            null\n    }\n\n    @JvmStatic\n    fun getJavaProject(jetElement: KtElement): IJavaProject? {\n        return getEclipseFile(jetElement.getContainingKtFile())?.let { eclipseFile ->\n            JavaCore.create(eclipseFile.project)\n        }\n    }\n\n    @JvmStatic\n    fun commitFile(file: IFile, document: IDocument) {\n        getKotlinFileIfExist(file, document.get())\n    }\n\n    @JvmStatic\n    fun recreateSourcesForProject(project: IJavaProject) {\n        if (projectSourceFiles.containsProject(project.project)) {\n            projectSourceFiles.addFilesIfNotPresent(project)\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/compiler/KotlinCompiler.kt",
    "content": "package org.jetbrains.kotlin.core.compiler\n\nimport com.intellij.openapi.util.Disposer\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.cli.common.CLIConfigurationKeys\nimport org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.EXCEPTION\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation\nimport org.jetbrains.kotlin.cli.common.messages.MessageCollector\nimport org.jetbrains.kotlin.cli.jvm.K2JVMCompiler\nimport org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment\nimport org.jetbrains.kotlin.config.CompilerConfiguration\nimport org.jetbrains.kotlin.config.JVMConfigurationKeys\nimport org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager.Companion.KOTLIN_TOUCHED_FILES_FILE_NAME\nimport org.jetbrains.kotlin.core.launch.CompilerOutputData\nimport org.jetbrains.kotlin.core.launch.CompilerOutputParser\nimport org.jetbrains.kotlin.core.launch.KotlinCLICompiler\nimport org.jetbrains.kotlin.core.model.KOTLIN_COMPILER_PATH\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.CompilerPlugin\nimport org.jetbrains.kotlin.core.utils.DependencyResolverException\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.incremental.makeIncrementally\nimport java.io.*\n\nobject KotlinCompiler {\n\n    private fun compileKotlinFiles(\n            javaProject: IJavaProject,\n            compilation: (IJavaProject, File, List<File>) -> KotlinCompilerResult\n    ): KotlinCompilerResult =\n            ProjectUtils.getSrcOutDirectories(javaProject)\n                    .groupingBy { it.second }.fold(mutableListOf<File>()) { list, key ->\n                        list.apply { add(key.first) }\n                    }.onEach { (out) ->\n                        val tempFile = File(out, KOTLIN_TOUCHED_FILES_FILE_NAME).takeIf { it.exists() }\n                        tempFile?.readLines()?.map(::File)?.flatMap { tempFileToDelete ->\n                            val tempName = tempFileToDelete.nameWithoutExtension\n                            val tempFiles = tempFileToDelete.parentFile?.listFiles(FileFilter { it.name == \"$tempName.class\" || (it.name.startsWith(\"$tempName$\") && it.name.endsWith(\".class\")) })\n                            tempFiles?.toList() ?: emptyList()\n                        }?.distinct()?.forEach(File::delete)\n                        tempFile?.delete()\n                        out.walkTopDown().filter { it.extension == \"kt\" }.forEach { it.delete() }\n                    }.map { (out, sources) ->\n                        compilation(javaProject, out, sources)\n                    }.fold(KotlinCompilerResult(true, CompilerOutputData())) { previous, current ->\n                        KotlinCompilerResult(previous.result and current.result, CompilerOutputData().apply {\n                            previous.compilerOutput.list.union(current.compilerOutput.list).forEach {\n                                add(it.messageSeverity, it.message, it.messageLocation)\n                            }\n                        })\n                    }\n\n    @JvmStatic\n    fun compileKotlinFiles(javaProject: IJavaProject): KotlinCompilerResult =\n            compileKotlinFiles(javaProject) { project, path, sources ->\n                execKotlinCompiler(configureCompilerArguments(project, path.absolutePath, sources))\n            }\n\n    @JvmStatic\n    fun compileIncrementallyFiles(\n            javaProject: IJavaProject\n    ): KotlinCompilerResult =\n            compileKotlinFiles(javaProject) { project, path, sources ->\n                execIncrementalKotlinCompiler(project, path.absoluteFile, sources)\n            }\n\n    private fun execIncrementalKotlinCompiler(\n            javaProject: IJavaProject,\n            outputDir: File,\n            sourceDirs: List<File>\n    ): KotlinCompilerResult {\n        val arguments = getCompilerArguments(javaProject, outputDir)\n        val messageCollector = CompilerMessageCollector()\n        val disposable = Disposer.newDisposable(\"Incremental compilation\")\n        val config = CompilerConfiguration().apply {\n            put(JVMConfigurationKeys.NO_JDK, true)\n            put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)\n            put(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, KOTLIN_COMPILER_PATH)\n        }\n        KotlinCoreEnvironment.getOrCreateApplicationEnvironmentForProduction(disposable, config)\n        val cacheDir = File(\"${outputDir.parentFile.absolutePath}/cache\").also { it.mkdirs() }\n        makeIncrementally(cacheDir, sourceDirs, arguments, messageCollector)\n        return messageCollector.getCompilerResult()\n    }\n\n    private fun execKotlinCompiler(arguments: Array<String>): KotlinCompilerResult = with(ByteArrayOutputStream()) {\n        KotlinCLICompiler.doMain(K2JVMCompiler(), PrintStream(this), arguments)\n        parseCompilerOutput(BufferedReader(StringReader(this.toString())))\n    }\n\n    private fun getCompilerArguments(javaProject: IJavaProject, outputDir: File) = K2JVMCompilerArguments().apply {\n        val kotlinProperties =\n                KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties\n\n        kotlinHome = ProjectUtils.ktHome\n        destination = outputDir.absolutePath\n        moduleName = \"kotlin-eclipse-plugin\"\n\n        val jdkUndefined = kotlinProperties.isJDKHomUndefined()\n        kotlinProperties.jdkHome?.takeUnless { jdkUndefined }?.let { jdkHomePath ->\n            jdkHome = jdkHomePath\n        } ?: {\n            noJdk = true\n        }()\n\n        noStdlib = true\n        jvmTarget = kotlinProperties.jvmTarget.description\n        intellijPluginRoot = KOTLIN_COMPILER_PATH\n        languageVersion = kotlinProperties.languageVersion.versionString\n        apiVersion = kotlinProperties.apiVersion.versionString\n\n        val pluginClasspathsList = mutableListOf<String>()\n        val pluginOptionsList = mutableListOf<String>()\n\n        kotlinProperties.compilerPlugins.entries.forEach { plugin ->\n            plugin.jarPath?.takeIf { plugin.active }?.let { jarPath ->\n                pluginClasspathsList.add(jarPath.replace(\"\\$KOTLIN_HOME\", ProjectUtils.ktHome))\n                plugin.args.forEach { arg ->\n                    pluginOptionsList.add(\"plugin: $arg\")\n                }\n            }\n        }\n\n        pluginClasspaths = pluginClasspathsList.toTypedArray()\n        pluginOptions = pluginOptionsList.toTypedArray()\n\n        val tempFiles = try {\n            ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)\n        } catch (e: DependencyResolverException) {\n            e.resolvedFiles\n        }\n\n        classpath = tempFiles.joinToString(separator = System.getProperty(\"path.separator\")) { it.absolutePath }\n    }\n\n    private fun configureCompilerArguments(\n            javaProject: IJavaProject, outputDir: String, sourceDirs: List<File>\n    ): Array<String> = with(mutableListOf<String>()) {\n        val kotlinProperties =\n                KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties\n\n        add(\"-kotlin-home\")\n        add(ProjectUtils.ktHome)\n\n        val jdkUndefined = kotlinProperties.isJDKHomUndefined()\n        kotlinProperties.jdkHome?.takeUnless { jdkUndefined }?.let { jdkHomePath ->\n            add(\"-jdk-home\")\n            add(jdkHomePath)\n        } ?: add(\"-no-jdk\")\n\n\n        add(\"-no-stdlib\") // Because we add runtime into the classpath\n\n        add(\"-jvm-target\")\n        add(kotlinProperties.jvmTarget.description)\n\n        add(\"-language-version\")\n        add(kotlinProperties.languageVersion.versionString)\n\n        add(\"-api-version\")\n        add(kotlinProperties.apiVersion.versionString)\n\n        kotlinProperties.compilerPlugins.entries.forEach { plugin ->\n            addAll(configurePlugin(plugin))\n        }\n\n        kotlinProperties.compilerFlags?.takeUnless { it.isBlank() }?.split(\"\\\\s+\".toRegex())?.let {\n            addAll(it)\n        }\n\n        add(\"-classpath\")\n\n        val tempFiles = try {\n            ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)\n        } catch (e: DependencyResolverException) {\n            e.resolvedFiles\n        }\n\n        add(tempFiles.joinToString(separator = System.getProperty(\"path.separator\")) { it.absolutePath })\n\n        add(\"-d\")\n        add(outputDir)\n\n        addAll(sourceDirs.map {\n            it.absolutePath\n        })\n\n        toTypedArray()\n    }\n\n    private fun configurePlugin(plugin: CompilerPlugin): Collection<String> = mutableListOf<String>().apply {\n        plugin.jarPath?.takeIf { plugin.active }?.let { jarPath ->\n            add(\"-Xplugin=${jarPath.replace(\"\\$KOTLIN_HOME\", ProjectUtils.ktHome)}\")\n            plugin.args.forEach { arg ->\n                add(\"-P\")\n                add(\"plugin: $arg\")\n            }\n        }\n    }\n\n    private class CompilerMessageCollector : MessageCollector {\n        var hasErrors = false\n        val severities: MutableList<CompilerMessageSeverity> = mutableListOf()\n        val compilerOutput = CompilerOutputData()\n\n        override fun report(\n                severity: CompilerMessageSeverity,\n                message: String,\n                location: CompilerMessageSourceLocation?\n        ) {\n            hasErrors == hasErrors || severity.isError\n            severities.add(severity)\n            if (location != null) {\n                val messageLocation = CompilerMessageLocation.create(location.path, location.line, location.column, location.lineContent)\n                compilerOutput.add(severity, message, messageLocation)\n            } else {\n                compilerOutput.add(severity, message, null)\n            }\n        }\n\n        override fun hasErrors(): Boolean = hasErrors\n\n        override fun clear() {\n            hasErrors = false\n        }\n\n        fun getCompilerResult(): KotlinCompilerResult =\n                KotlinCompilerResult(severities.firstOrNull { it == ERROR || it == EXCEPTION } == null, compilerOutput)\n    }\n\n    private fun parseCompilerOutput(reader: Reader): KotlinCompilerResult {\n        val messageCollector = CompilerMessageCollector()\n\n        CompilerOutputParser.parseCompilerMessagesFromReader(messageCollector, reader)\n\n        return messageCollector.getCompilerResult()\n    }\n}\n\nclass KotlinCompilerResult(val result: Boolean, val compilerOutput: CompilerOutputData) {\n\n    fun compiledCorrectly() = result\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/compiler/KotlinCompiler2.java",
    "content": "package org.jetbrains.kotlin.core.compiler;\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/compiler/KotlinCompilerUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2010-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.jetbrains.kotlin.core.compiler\n\nimport org.jetbrains.kotlin.core.compiler.KotlinCompiler.compileKotlinFiles\nimport org.jetbrains.kotlin.core.compiler.KotlinCompiler.compileIncrementallyFiles\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.debug.core.IStatusHandler\nimport org.eclipse.debug.core.DebugPlugin\nimport org.jetbrains.kotlin.core.Activator\nimport org.jetbrains.kotlin.core.launch.CompilerOutputData\n\nobject KotlinCompilerUtils {\n\n    fun compileWholeProject(javaProject: IJavaProject): KotlinCompilerResult = compileKotlinFiles(javaProject)\n\n    fun compileProjectIncrementally(javaProject: IJavaProject): KotlinCompilerResult =\n            compileIncrementallyFiles(javaProject)\n\n    fun handleCompilerOutput(compilerOutput: CompilerOutputWithProject) {\n        val status: IStatus = Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, \"\", null)\n        val handler = DebugPlugin.getDefault().getStatusHandler(status)\n        handler?.handleStatus(status, compilerOutput)\n    }\n\n    data class CompilerOutputWithProject(val data: CompilerOutputData, val project: IJavaProject)\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/debug/KotlinSourceLookupNavigator.java",
    "content": "/*\n * Copyright 2010-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.jetbrains.kotlin.core.debug;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.debug.core.model.ISourceLocator;\nimport org.eclipse.debug.core.sourcelookup.ISourceContainer;\nimport org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;\nimport org.eclipse.jdt.debug.core.IJavaStackFrame;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.psi.KtFile;\n\npublic class KotlinSourceLookupNavigator {\n\tpublic static final KotlinSourceLookupNavigator INSTANCE = new KotlinSourceLookupNavigator();\n\t\n\tprivate KotlinSourceLookupNavigator() {\n\t}\n\t\n//\tFrom JDI model we obtain path to file as \"some/pckg/File.kt\" and Java seeks file in folder some/pckg what might be wrong\n\t@Nullable\n\tpublic IFile findKotlinSourceFile(@NotNull IJavaStackFrame frame) {\n\t    ISourceLocator sourceLocator = frame.getLaunch().getSourceLocator();\n\t    if (!(sourceLocator instanceof ISourceLookupDirector)) {\n\t    \treturn null;\n\t    }\n\t    \n\t    try {\n            return findKotlinSourceFile(frame, (ISourceLookupDirector) sourceLocator);\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n\t    \n\t    return null;\n\t}\n\n    private IFile findKotlinSourceFile(IJavaStackFrame frame, ISourceLookupDirector lookupDirector) throws CoreException {\n        boolean isFindDuplicates = lookupDirector.isFindDuplicates();\n\t    try {\n\t        lookupDirector.setFindDuplicates(true);\n\t        return findKotlinSourceFile(lookupDirector, frame);\n\t    } finally {\n\t        lookupDirector.setFindDuplicates(isFindDuplicates);\n\t    }\n    }\n\t\n\t@Nullable\n\tprivate IFile findKotlinSourceFile(@NotNull ISourceLookupDirector lookupDirector, @NotNull IJavaStackFrame frame) throws CoreException {\n\t\tString sourceName = frame.getSourceName();\n\t\tif (sourceName == null) return null;\n\t\t\n\t\tFqName declaringPackage = new FqName(frame.getDeclaringTypeName()).parent();\n\t\t\n\t    for (ISourceContainer sourceContainer : lookupDirector.getSourceContainers()) {\n            Object[] elements = sourceContainer.findSourceElements(sourceName);\n            for (Object element : elements) {\n            \tif (!(element instanceof IFile)) {\n            \t\tcontinue;\n            \t}\n            \t\n            \tIFile kotlinFile = (IFile) element;\n            \tif (fileMatches(kotlinFile, declaringPackage, sourceName)) {\n            \t\treturn kotlinFile;\n            \t}\n            }\n        }\n\t    \n\t    return null;\n\t}\n\t\n\tprivate boolean fileMatches(@NotNull IFile kotlinFile, @NotNull FqName packageName, @NotNull String sourceName) {\n\t\tboolean isKotlinSourceFile = kotlinFile.getName().equals(sourceName) && KotlinPsiManager.INSTANCE.existsSourceFile(kotlinFile);\n        if (isKotlinSourceFile) {\n\t\t    KtFile jetFile = KotlinPsiManager.INSTANCE.getParsedFile(kotlinFile);\n\t\t    if (jetFile.getPackageFqName().equals(packageName)) {\n\t\t        return true;\n\t\t    }\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/EnvironmentRemnantNature.kt",
    "content": "/*\n * Copyright 2019 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.jetbrains.kotlin.core.filesystem\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IProjectNature\n\nclass EnvironmentRemnantNature: IProjectNature {\n    companion object {\n        const val NATURE_ID = \"org.jetbrains.kotlin.core.environmentRemnant\"\n    }\n\n    private lateinit var _project: IProject\n\n    override fun setProject(project: IProject) {\n        _project = project\n    }\n\n    override fun configure() {\n        // nothing to do\n    }\n\n    override fun deconfigure() {\n        // nothing to do\n    }\n\n    override fun getProject() = _project\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinFileStore.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.filesystem\n\nimport org.eclipse.core.filesystem.IFileInfo\nimport org.eclipse.core.filesystem.IFileStore\nimport org.eclipse.core.filesystem.IFileSystem\nimport org.eclipse.core.filesystem.provider.FileInfo\nimport org.eclipse.core.internal.filesystem.local.LocalFile\nimport org.eclipse.core.resources.IContainer\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.jdt.internal.compiler.util.Util\nimport org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport java.io.ByteArrayInputStream\nimport java.io.ByteArrayOutputStream\nimport java.io.File\nimport java.io.InputStream\nimport java.io.OutputStream\nimport java.net.URI\n\npublic class KotlinFileStore(file: File) : LocalFile(file) {\n    override public fun openInputStream(options: Int, monitor: IProgressMonitor?): InputStream {\n        val project = getProject()\n        if (project == null) {\n            throw CoreException(Status.CANCEL_STATUS)\n        }\n        \n        val lightClass = KotlinLightClassManager.getInstance(project).getCachedLightClass(file)\n        if (lightClass != null) {\n            return ByteArrayInputStream(lightClass)\n        }\n\n        val jetFiles = KotlinLightClassManager.getInstance(project).getSourceFiles(file)\n        if (jetFiles.isNotEmpty()) {\n            val analysisResult = KotlinAnalyzer.analyzeFiles(jetFiles).analysisResult\n\n            val requestedClassName = Path(file.getAbsolutePath()).lastSegment()\n            val state = KotlinLightClassGeneration.buildLightClasses(analysisResult, project, jetFiles, requestedClassName)\n            val generatedClass = state.factory.asList().find {\n                val generatedClassName = Path(it.relativePath).lastSegment()\n                requestedClassName == generatedClassName\n            }\n\n            if (generatedClass != null) {\n                val byteArray = generatedClass.asByteArray()\n                \n                KotlinLightClassManager.getInstance(project).cacheLightClass(file, byteArray)\n                return ByteArrayInputStream(byteArray)\n            }\n        }\n\n        throw CoreException(Status.CANCEL_STATUS)\n    }\n\n    override public fun fetchInfo(options: Int, monitor: IProgressMonitor?): IFileInfo {\n        val info = super.fetchInfo(options, monitor) as FileInfo\n        if (Util.isClassFileName(getName())) {\n            val workspaceFile = findFileInWorkspace()\n            if (workspaceFile != null) {\n                info.setExists(workspaceFile.exists())\n            }\n        } else {\n            val workspaceContainer = findFolderInWorkspace()\n            if (workspaceContainer != null) {\n                info.setExists(workspaceContainer.exists())\n                info.setDirectory(true)\n            }\n        }\n\n        return info\n    }\n\n    override public fun childNames(options: Int, monitor: IProgressMonitor?): Array<String> {\n        val folder = findFolderInWorkspace()\n        if (folder != null && folder.exists()) {\n            return folder.members()\n                    .map { it.getName() }\n                    .toTypedArray()\n        }\n\n        return emptyArray()\n    }\n\n    override fun getFileSystem(): IFileSystem = KotlinFileSystem.getInstance()\n\n    override public fun mkdir(options: Int, monitor: IProgressMonitor?): IFileStore = this\n\n    override public fun openOutputStream(options: Int, monitor: IProgressMonitor?): OutputStream = ByteArrayOutputStream()\n\n    override public fun getChild(name: String): IFileStore = KotlinFileStore(File(file, name))\n\n    override public fun getChild(path: IPath): IFileStore = KotlinFileStore(File(file, path.toOSString()))\n\n    override public fun getFileStore(path: IPath): IFileStore = KotlinFileStore(Path(file.getPath()).append(path).toFile())\n\n    override public fun getParent(): IFileStore? = file.getParentFile()?.let { KotlinFileStore(it) }\n\n    fun getProject(): IProject? = findFileInWorkspace()?.let { it.project }\n\n    private fun findFileInWorkspace(): IFile? {\n        return findResourceInWorkspace { ResourcesPlugin.getWorkspace().root.findFilesForLocationURI(it) }\n    }\n\n    private fun findFolderInWorkspace(): IContainer? {\n        return findResourceInWorkspace { ResourcesPlugin.getWorkspace().root.findContainersForLocationURI(it) }\n    }\n\n    private inline fun <reified T : IResource> findResourceInWorkspace(search: (URI) -> Array<T>?): T? {\n        val absolutePath = file.toURI().path\n        val pathRelatedToKtFileSystem = URI(KotlinFileSystem.SCHEME, null, absolutePath, null)\n        val resources = search(pathRelatedToKtFileSystem)\n        return if (resources != null && resources.isNotEmpty()) {\n            assert(resources.size == 1, { \"By ${pathRelatedToKtFileSystem} found more than one file\" })\n            resources[0]\n        } else {\n            null\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinFileSystem.java",
    "content": "package org.jetbrains.kotlin.core.filesystem;\n\nimport java.io.File;\nimport java.net.URI;\n\nimport org.eclipse.core.filesystem.IFileStore;\nimport org.eclipse.core.filesystem.IFileTree;\nimport org.eclipse.core.filesystem.provider.FileSystem;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IProgressMonitor;\n\npublic class KotlinFileSystem extends FileSystem {\n\n    public static final String SCHEME = \"org.jetbrains.kotlin.core.filesystem\";\n    \n    private static KotlinFileSystem instance;\n    \n    public KotlinFileSystem() {\n        instance = this;\n    }\n    \n    @Override\n    public IFileStore getStore(URI uri) {\n        return new KotlinFileStore(new File(uri.getSchemeSpecificPart()));\n    }\n    \n    @Override\n    public boolean canDelete() {\n        return true;\n    }\n\n    @Override\n    public boolean canWrite() {\n        return true;\n    }\n\n    public static KotlinFileSystem getInstance() {\n        return instance;\n    }\n\n    @Override\n    public IFileTree fetchFileTree(IFileStore root, IProgressMonitor monitor) throws CoreException {\n        return super.fetchFileTree(root, monitor);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinLightClassManager.kt",
    "content": "package org.jetbrains.kotlin.core.filesystem\n\nimport com.intellij.openapi.components.ServiceManager\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.internal.jobs.JobStatus\nimport org.eclipse.core.resources.*\nimport org.eclipse.core.runtime.*\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.internal.core.util.LRUCache\nimport org.jetbrains.kotlin.core.asJava.LightClassFile\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager.getFilesByProject\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager.getKotlinParsedFile\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager.getParsedFile\nimport org.jetbrains.kotlin.core.log.KotlinLogger.logAndThrow\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment.Companion.getEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager.getKotlinBinFolderFor\nimport org.jetbrains.kotlin.core.utils.ProjectUtils.cleanFolder\nimport org.jetbrains.kotlin.core.utils.ProjectUtils.getAllOutputFolders\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.psi.*\nimport java.io.File\nimport java.io.IOException\nimport java.util.concurrent.ConcurrentHashMap\nimport java.util.concurrent.ConcurrentMap\nimport kotlin.text.Charsets.UTF_8\n\nclass KotlinLightClassManager(private val project: IProject) {\n    private val cachedLightClasses = LRUCache<File, ByteArray>(LIGHT_CLASSES_CACHE_SIZE)\n    private val sourceFiles: ConcurrentMap<File, MutableSet<IFile>> = ConcurrentHashMap()\n\n    @Synchronized\n    fun getCachedLightClass(file: File): ByteArray? {\n        val lightClass: Any? = cachedLightClasses[file]\n        return if (lightClass != null) lightClass as ByteArray? else null\n    }\n\n    @Synchronized\n    fun cacheLightClass(file: File, lightClass: ByteArray) {\n        cachedLightClasses.put(file, lightClass)\n    }\n\n    @Synchronized\n    fun removeLightClass(file: File) {\n        cachedLightClasses.flush(file)\n        val tempFolders = getAllOutputFolders(JavaCore.create(project))\n        val tempSegments = file.path.split(\"[/\\\\\\\\]\".toRegex()).toTypedArray()\n        val tempRealPath = tempSegments.copyOfRange(3, tempSegments.size)\n        for (tempFolder in tempFolders) {\n            val tempRootFolder = tempFolder.location.toFile()\n            var tempCurrentFolder = tempRootFolder\n            for ((tempIndex, tempSegment) in tempRealPath.withIndex()) {\n                if (tempIndex == tempRealPath.lastIndex) {\n                    val tempFile = File(tempCurrentFolder, tempSegment).takeIf { it.exists() } ?: break\n                    val tempTouchedFilesFile = File(tempRootFolder, KOTLIN_TOUCHED_FILES_FILE_NAME)\n                    try {\n                        if (!tempTouchedFilesFile.exists()) tempTouchedFilesFile.createNewFile()\n\n                        val tempLines = tempTouchedFilesFile.readLines(UTF_8).toMutableSet()\n                        tempLines.add(tempFile.absolutePath)\n                        tempTouchedFilesFile.writeText(tempLines.joinToString(\"\\n\"), UTF_8)\n                    } catch (e: IOException) {\n                        e.printStackTrace()\n                    }\n                } else {\n                    tempCurrentFolder = File(tempCurrentFolder, tempSegment).takeIf { it.exists() } ?: break\n                }\n            }\n        }\n    }\n\n    fun computeLightClassesSources() {\n        val newSourceFilesMap: MutableMap<File, MutableSet<IFile>> = HashMap()\n        for (sourceFile in getFilesByProject(project)) {\n            val lightClassesPaths = getLightClassesPaths(sourceFile)\n            for (path in lightClassesPaths) {\n                val lightClassFile = LightClassFile(project.getFile(path))\n                val newSourceFiles = newSourceFilesMap.computeIfAbsent(lightClassFile.asFile()) { HashSet() }\n                newSourceFiles.add(sourceFile)\n            }\n        }\n        sourceFiles.clear()\n        sourceFiles.putAll(newSourceFilesMap)\n    }\n\n    fun updateLightClasses(affectedFiles: Set<IFile?>, resourceTreeBlocked: Boolean) {\n        val toCreate: MutableList<LightClassFile> = ArrayList()\n        val toRemove: MutableList<LightClassFile> = ArrayList()\n        for ((key, value) in sourceFiles) {\n            val lightClassIFile = ResourcesPlugin.getWorkspace().root.getFile(Path(key.path))\n                    ?: continue\n            val lightClassFile = LightClassFile(lightClassIFile)\n            if (!lightClassFile.exists()) {\n                toCreate.add(lightClassFile)\n            }\n            for (sourceFile in value) {\n                if (affectedFiles.contains(sourceFile)) {\n                    toRemove.add(lightClassFile)\n                    break\n                }\n            }\n        }\n        if (resourceTreeBlocked) {\n            if (toCreate.isNotEmpty() || toRemove.isNotEmpty()) {\n                val job: WorkspaceJob = object : WorkspaceJob(WORKSPACE_JOB_ID) {\n                    override fun runInWorkspace(monitor: IProgressMonitor): IStatus {\n                        monitor.beginTask(\"Light class generation started\", 0)\n                        updateLightClasses(toCreate, toRemove)\n                        monitor.done()\n                        return JobStatus(0, this, \"Light classes generation finished\")\n                    }\n                }\n                job.rule = ResourcesPlugin.getWorkspace().ruleFactory.createRule(\n                        project.getFolder(KotlinJavaManager.KOTLIN_BIN_FOLDER))\n                job.schedule()\n            }\n        } else {\n            updateLightClasses(toCreate, toRemove)\n        }\n    }\n\n    private fun updateLightClasses(toCreate: List<LightClassFile>, toRemove: List<LightClassFile>) {\n        for (lightClassFile in toCreate) {\n            createParentDirsFor(lightClassFile)\n            lightClassFile.createIfNotExists()\n        }\n        for (lightClassFile in toRemove) {\n            removeLightClass(lightClassFile.asFile())\n            lightClassFile.touchFile()\n        }\n        cleanOutdatedLightClasses(project)\n    }\n\n    fun getSourceFiles(file: File): List<KtFile> {\n        if (sourceFiles.isEmpty()) {\n            computeLightClassesSources()\n        }\n        return getSourceKtFiles(file)\n    }\n\n    private fun getSourceKtFiles(lightClass: File): List<KtFile> {\n        val sourceIOFiles: Set<IFile>? = sourceFiles[lightClass]\n        if (sourceIOFiles != null) {\n            val jetSourceFiles: MutableList<KtFile> = ArrayList()\n            for (sourceFile in sourceIOFiles) {\n                val jetFile = getKotlinParsedFile(sourceFile)\n                if (jetFile != null) {\n                    jetSourceFiles.add(jetFile)\n                }\n            }\n            return jetSourceFiles\n        }\n        return emptyList()\n    }\n\n    private fun getLightClassesPaths(sourceFile: IFile): List<IPath> {\n        val lightClasses: MutableList<IPath> = ArrayList()\n        val ktFile = getParsedFile(sourceFile)\n        for (classOrObject in findLightClasses(ktFile)) {\n            val internalName = getInternalName(classOrObject)\n            if (internalName != null) {\n                lightClasses.add(computePathByInternalName(internalName))\n            }\n        }\n        if (ktFile.hasTopLevelCallables()) {\n            val newFacadeInternalName = JvmFileClassUtil.getFileClassInternalName(ktFile)\n            lightClasses.add(computePathByInternalName(newFacadeInternalName))\n        }\n        return lightClasses\n    }\n\n    private fun findLightClasses(ktFile: KtFile): List<KtClassOrObject> {\n        val lightClasses = ArrayList<KtClassOrObject>()\n        ktFile.acceptChildren(object : KtVisitorVoid() {\n            override fun visitClassOrObject(classOrObject: KtClassOrObject) {\n                lightClasses.add(classOrObject)\n                super.visitClassOrObject(classOrObject)\n            }\n\n            override fun visitNamedFunction(function: KtNamedFunction) {}\n            override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) {}\n            override fun visitProperty(property: KtProperty) {}\n            override fun visitElement(element: PsiElement) {\n                element.acceptChildren(this)\n            }\n        })\n        return lightClasses\n    }\n\n    private fun computePathByInternalName(internalName: String): IPath {\n        val relativePath = Path(\"$internalName.class\")\n        return KotlinJavaManager.KOTLIN_BIN_FOLDER.append(relativePath)\n    }\n\n    private fun cleanOutdatedLightClasses(project: IProject) {\n        cleanFolder(getKotlinBinFolderFor(project)) { resource: IResource? ->\n            if (resource is IFile) {\n                val lightClass = LightClassFile(resource)\n                val sources: Set<IFile>? = sourceFiles[lightClass.asFile()]\n                val dropLightClass = sources == null || sources.isEmpty()\n                if (dropLightClass) {\n                    removeLightClass(lightClass.asFile())\n                }\n                return@cleanFolder dropLightClass\n            } else if (resource is IFolder) {\n                try {\n                    return@cleanFolder resource.members().isEmpty()\n                } catch (e: CoreException) {\n                    logAndThrow(e)\n                }\n            }\n            false\n        }\n    }\n\n    private fun createParentDirsFor(lightClassFile: LightClassFile) {\n        val parent = lightClassFile.resource.parent as? IFolder\n        if (parent != null && !parent.exists()) {\n            createParentDirs(parent)\n        }\n    }\n\n    private fun createParentDirs(folder: IFolder) {\n        val parent = folder.parent\n        if (!parent.exists()) {\n            createParentDirs(parent as IFolder)\n        }\n        try {\n            folder.create(true, true, null)\n        } catch (e: CoreException) {\n            logAndThrow(e)\n        }\n    }\n\n    companion object {\n        const val KOTLIN_TOUCHED_FILES_FILE_NAME = \"META-INF/kotlinTouchedFiles\"\n\n        private const val LIGHT_CLASSES_CACHE_SIZE = 300\n        private const val WORKSPACE_JOB_ID = \"updateLightClassesJob\"\n        fun getInstance(project: IProject): KotlinLightClassManager {\n            val ideaProject: Project = getEnvironment(project).project\n            return ServiceManager.getService(ideaProject, KotlinLightClassManager::class.java)\n        }\n\n        fun getInternalName(classOrObject: KtClassOrObject): String? {\n            val fullFqName = classOrObject.fqName ?: return null\n            val topmostClassOrObject = PsiTreeUtil.getTopmostParentOfType(classOrObject, KtClassOrObject::class.java)\n                    ?: return makeInternalByToplevel(fullFqName)\n            val topLevelFqName = topmostClassOrObject.fqName ?: return null\n            val nestedPart = fullFqName.asString().substring(topLevelFqName.asString().length).replace(\"\\\\.\".toRegex(), \"\\\\$\")\n            return makeInternalByToplevel(topLevelFqName) + nestedPart\n        }\n\n        private fun makeInternalByToplevel(fqName: FqName): String {\n            return fqName.asString().replace(\"\\\\.\".toRegex(), \"/\")\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/filesystem/KotlinScriptFIleSystem.kt",
    "content": "package org.jetbrains.kotlin.core.filesystem\n\nimport org.eclipse.core.filesystem.EFS\nimport org.eclipse.core.filesystem.provider.FileInfo\nimport org.eclipse.core.filesystem.provider.FileStore\nimport org.eclipse.core.filesystem.provider.FileSystem\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.jetbrains.kotlin.core.Activator\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.script.EnvironmentProjectsManager\nimport java.io.ByteArrayInputStream\nimport java.io.ByteArrayOutputStream\nimport java.io.InputStream\nimport java.io.OutputStream\nimport java.net.URI\nimport java.util.concurrent.ConcurrentHashMap\nimport java.util.concurrent.ConcurrentMap\n\nclass KotlinScriptFileSystem : FileSystem() {\n    private val handles: ConcurrentMap<URI, EnvironmentFileStore> = ConcurrentHashMap()\n\n    private val entries: MutableMap<String, FSEntry> = ConcurrentHashMap(mapOf(\"/environments\" to Directory(emptySet())))\n\n    override fun canWrite() = true\n\n    override fun canDelete() = true\n\n    override fun getStore(uri: URI): EnvironmentFileStore = handles.getOrPut(uri) { EnvironmentFileStore(uri) }\n\n    inner class EnvironmentFileStore(private val uri: URI) : FileStore() {\n        private val path = uri.path.dropLastWhile { it == '/' }\n\n        private val _parent: EnvironmentFileStore? =\n            path.substringBeforeLast('/', \"\")\n                .takeIf { it.isNotEmpty() }\n                ?.let { getStore(URI(uri.scheme, it, null)) }\n\n        private val isPlaceholderMetadata =\n            path.endsWith(\"/.project\") && _parent != null && !EnvironmentProjectsManager.wasCreated(_parent.name)\n\n        override fun getName() = path.substringAfterLast('/')\n\n        override fun toURI() = uri\n\n        override fun childNames(options: Int, monitor: IProgressMonitor?) =\n            (entries[path] as? Directory)?.children.orEmpty().toTypedArray()\n\n        override fun getParent() = _parent\n\n        override fun getChild(name: String?): EnvironmentFileStore = getStore(URI(uri.scheme, \"$path/$name\", null))\n\n        override fun openInputStream(options: Int, monitor: IProgressMonitor?): InputStream =\n            when (val entry = entries[path]) {\n                is File -> ByteArrayInputStream(entry.content)\n                is Directory -> error(EFS.ERROR_WRONG_TYPE, \"$uri is a directory\")\n                null -> if (isPlaceholderMetadata) {\n                    ByteArrayInputStream((\"\"\"\n                        <projectDescription>\n                            <name>${parent?.name}</name>\n                            <natures>\n                                <nature>${EnvironmentRemnantNature.NATURE_ID}</nature>\n                            </natures>\n                        </projectDescription>\n                        \"\"\".trimIndent()).toByteArray())\n                } else {\n                    error(EFS.ERROR_NOT_EXISTS, \"$uri is not existing\")\n                }\n            }\n\n        override fun fetchInfo(options: Int, monitor: IProgressMonitor?) = FileInfo(name).apply {\n            val entry = entries[path]\n            setExists(entry != null || isPlaceholderMetadata)\n            isDirectory = entry is Directory\n        }\n\n        override fun openOutputStream(options: Int, monitor: IProgressMonitor?): OutputStream {\n            val entry = entries[path]\n            if (entry is Directory) error(EFS.ERROR_WRONG_TYPE, \"$uri is a directory\")\n\n            return object: ByteArrayOutputStream() {\n                override fun close() {\n                    if (entry == null) {\n                        val parentDirectory = parent?.path?.let { entries[it] }\n                        if (parentDirectory is Directory) {\n                            entries[parent!!.path] = Directory(parentDirectory.children + name)\n                        } else {\n                            error(EFS.ERROR_NOT_EXISTS, \"$uri parent is not existing\")\n                        }\n                    }\n\n                    if (entry is File && options and EFS.APPEND != 0) {\n                        entries[path] = File(entry.content + this.toByteArray())\n                    } else {\n                        entries[path] = File(this.toByteArray())\n                    }\n                }\n            }\n\n        }\n\n        override fun delete(options: Int, monitor: IProgressMonitor?) {\n            entries.remove(path)\n            childStores(EFS.NONE, null).forEach { it.delete(options, monitor) }\n        }\n\n        override fun mkdir(options: Int, monitor: IProgressMonitor?): EnvironmentFileStore = apply {\n            val entry = entries[path]\n            if (entry is File) error(EFS.ERROR_WRONG_TYPE, \"$uri is a file\")\n\n            if (entry == null) {\n                if (options and EFS.SHALLOW == 0) {\n                    parent?.mkdir(options, monitor)\n                }\n\n                val parentDirectory = parent?.path?.let { entries[it] }\n                if (parentDirectory is Directory) {\n                    entries[parent!!.path] = Directory(parentDirectory.children + name)\n                } else {\n                    error(EFS.ERROR_NOT_EXISTS, \"$uri parent is not existing\")\n                }\n\n                entries[path] = Directory(emptySet())\n            }\n        }\n    }\n\n}\n\nprivate sealed class FSEntry\nprivate class File(val content: ByteArray) : FSEntry()\nprivate class Directory(val children: Set<String>) : FSEntry()\n\nprivate fun error(code: Int, message: String): Nothing =\n    throw CoreException(Status(IStatus.ERROR, Activator.PLUGIN_ID, code, message, null))\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/formatting/KotlinCodeStyleManager.kt",
    "content": "package org.jetbrains.kotlin.core.formatting\n\nimport com.intellij.psi.codeStyle.CodeStyleSettings\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.ProjectScope\nimport org.jetbrains.kotlin.core.model.EPAttribute\nimport org.jetbrains.kotlin.core.model.ExecutableExtensionPointDescriptor\nimport org.jetbrains.kotlin.core.model.loadExecutableEP\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.core.utils.pairOfNotNulls\nimport org.jetbrains.kotlin.idea.formatter.KotlinPredefinedCodeStyle\nimport java.util.concurrent.ConcurrentHashMap\n\nprivate const val CODESTYLE_EXTENSION_POINT = \"org.jetbrains.kotlin.core.predefinedKotlinCodeStyle\"\n\nobject KotlinCodeStyleManager {\n    private val extensions by lazy {\n        loadExecutableEP<KotlinPredefinedCodeStyle>(CODESTYLE_EXTENSION_POINT, isCaching = true)\n    }\n\n    private val stylesCache = ConcurrentHashMap<String, CodeStyleSettings>()\n\n    private val predefinedStyles: Map<String, KotlinPredefinedCodeStyle> by lazy {\n        extensions\n            .mapNotNull { it.createProvider() }\n            .map { it.codeStyleId to it }\n            .toMap()\n    }\n\n    val buildsystemAliases by lazy {\n        extensions.mapNotNull { pairOfNotNulls(it.nameInBuildsystem, it.createProvider()?.name) }\n            .toMap()\n    }\n\n    val styles: List<String>\n        get() = (predefinedStyles.keys + stylesCache.keys).sorted()\n\n    // Can be used in the future to provide user defined code styles\n    fun getOrCreate(id: String, settingsApplier: CodeStyleSettings.() -> Unit): CodeStyleSettings =\n        stylesCache.getOrPut(id) { CodeStyleSettings().also { it.settingsApplier() } }\n\n    fun get(id: String): CodeStyleSettings? = stylesCache[id] ?: createStyleFromPredef(id)\n\n    // Uses the same logic as ConcurrentHashMap.getOrPut() but due to possible nullability cannot be expressed by that method.\n    private fun createStyleFromPredef(id: String): CodeStyleSettings? = predefinedStyles[id]\n        ?.let { CodeStyleSettings().also(it::apply) }\n        ?.let { stylesCache.putIfAbsent(id, it) ?: it }\n\n    fun invalidate(id: String) {\n        stylesCache -= id\n    }\n\n    fun getStyleLabel(id: String?) =\n        id?.let { predefinedStyles[it]?.name ?: it } ?: \"unknown\"\n}\n\nprivate val IProject.codeStyleSettings\n    get() = KotlinCodeStyleProperties(ProjectScope(this))\n        .takeIf { it.globalsOverridden }\n        ?: KotlinCodeStyleProperties.workspaceInstance\n\nval IProject.codeStyle: CodeStyleSettings\n    get() {\n        val tempId = codeStyleSettings.codeStyleId ?: \"KOTLIN_OFFICIAL\"\n        return KotlinCodeStyleManager.get(tempId) ?: CodeStyleSettings()\n    }\n\nprivate val ExecutableExtensionPointDescriptor<KotlinPredefinedCodeStyle>.nameInBuildsystem: String? by EPAttribute"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/imports/FunctionImportFinder.kt",
    "content": "package org.jetbrains.kotlin.core.imports\n\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.resolve.scopes.MemberScope\n\nclass FunctionImportFinder(\n    val filter: (CallableDescriptor) -> Boolean\n) : DeclarationDescriptorVisitorEmptyBodies<List<CallableDescriptor>, List<String>>() {\n    override fun visitModuleDeclaration(\n        descriptor: ModuleDescriptor,\n        data: List<String>\n    ): List<CallableDescriptor> = descriptor.getPackage(FqName.ROOT).accept(this, data)\n\n    override fun visitPackageViewDescriptor(\n        descriptor: PackageViewDescriptor,\n        data: List<String>\n    ): List<CallableDescriptor> = visitMemberScope(descriptor.memberScope, data)\n\n    override fun visitFunctionDescriptor(\n        descriptor: FunctionDescriptor,\n        data: List<String>\n    ): List<CallableDescriptor> = visitMember(descriptor)\n\n    override fun visitPropertyDescriptor(\n        descriptor: PropertyDescriptor,\n        data: List<String>\n    ): List<CallableDescriptor> = visitMember(descriptor)\n\n    private fun visitMemberScope(\n        scope: MemberScope,\n        data: List<String>\n    ): List<CallableDescriptor> {\n        val possiblePackageLevelFunctions =\n            data.filter { it.substringBefore('.', \"\").endsWith(\"Kt\") }\n                .map { it.substringAfter('.') }\n\n        val groupedEntries = (data + possiblePackageLevelFunctions).groupByQualifier()\n        return scope.getContributedDescriptors { it.asString() in groupedEntries.keys }\n            .flatMap { it.accept(this, groupedEntries[it.name.asString()].orEmpty()) }\n    }\n\n    private fun visitMember(descriptor: CallableDescriptor): List<CallableDescriptor> =\n        if (filter(descriptor)) listOf(descriptor) else emptyList()\n\n\n    override fun visitDeclarationDescriptor(\n        descriptor: DeclarationDescriptor,\n        data: List<String>\n    ): List<FunctionDescriptor> =\n        emptyList()\n}\n\nprivate fun Iterable<String>.groupByQualifier() = groupBy(\n    keySelector = { it.substringBefore('.') },\n    valueTransform = { it.substringAfter('.', \"\") }\n)"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/imports/importCandidates.kt",
    "content": "package org.jetbrains.kotlin.core.imports\n\nimport org.eclipse.jdt.core.search.TypeNameMatch\nimport org.jetbrains.kotlin.descriptors.CallableDescriptor\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.idea.imports.importableFqName\n\nsealed class ImportCandidate {\n    abstract val fullyQualifiedName: String?\n    abstract val packageName: String?\n    abstract val simpleName: String\n}\n\nclass TypeCandidate(val match: TypeNameMatch) : ImportCandidate() {\n    override val fullyQualifiedName: String? = match.fullyQualifiedName\n    override val packageName: String? = match.packageName\n    override val simpleName: String = match.simpleTypeName\n}\n\nclass FunctionCandidate(val descriptor: CallableDescriptor) : ImportCandidate() {\n    override val fullyQualifiedName: String? = descriptor.importableFqName?.asString()\n\n    override val packageName: String? =\n        descriptor.importableFqName\n            ?.takeUnless { it.isRoot }\n            ?.parent()\n            ?.asString()\n\n    override val simpleName: String = descriptor.name.asString()\n}\n\ndata class UniqueAndAmbiguousImports(\n    val uniqueImports: List<ImportCandidate>,\n    val ambiguousImports: List<List<ImportCandidate>>\n)\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/imports/importServices.kt",
    "content": "package org.jetbrains.kotlin.core.imports\n\nimport com.intellij.psi.PsiElement\nimport org.eclipse.jdt.core.Flags\nimport org.eclipse.jdt.core.IMethod\nimport org.eclipse.jdt.core.search.*\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.core.resolve.KotlinResolutionFacade\nimport org.jetbrains.kotlin.core.utils.isImported\nimport org.jetbrains.kotlin.descriptors.CallableDescriptor\nimport org.jetbrains.kotlin.diagnostics.Errors\nimport org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport\nimport org.jetbrains.kotlin.idea.util.CallTypeAndReceiver\nimport org.jetbrains.kotlin.idea.util.ReceiverType\nimport org.jetbrains.kotlin.idea.util.receiverTypesWithIndex\nimport org.jetbrains.kotlin.load.java.JvmAbi\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.ImportPath\nimport org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.types.expressions.OperatorConventions\nimport org.jetbrains.kotlin.types.typeUtil.isSubtypeOf\n\nval FIXABLE_DIAGNOSTICS = setOf(Errors.UNRESOLVED_REFERENCE, Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER)\n\nfun findImportCandidates(\n    references: List<PsiElement>,\n    bindingContext: BindingContext,\n    resolutionFacade: KotlinResolutionFacade,\n    candidatesFilter: (ImportCandidate) -> Boolean\n): UniqueAndAmbiguousImports {\n    // Import candidates grouped by their ambiguity:\n    // 0 - no candidates found, 1 - exactly one candidate, 2 - multiple candidates\n    val groupedCandidates: Map<Int, List<List<ImportCandidate>>> =\n        references.map { findImportCandidatesForReference(it, bindingContext, resolutionFacade, candidatesFilter) }\n            .groupBy { it.size.coerceAtMost(2) }\n\n    return UniqueAndAmbiguousImports(\n        groupedCandidates[1].orEmpty().map { it.single() },\n        groupedCandidates[2].orEmpty()\n    )\n}\n\nfun findImportCandidatesForReference(\n    reference: PsiElement,\n\tbindingContext: BindingContext,\n    resolutionFacade: KotlinResolutionFacade,\n    candidatesFilter: (ImportCandidate) -> Boolean\n): List<ImportCandidate> =\n    (findApplicableTypes(reference.text) + findApplicableCallables(reference, bindingContext, resolutionFacade))\n        .filter(candidatesFilter)\n        .distinctBy { it.fullyQualifiedName }\n\n\nprivate fun findApplicableTypes(typeName: String): List<TypeCandidate> {\n    val scope = SearchEngine.createWorkspaceScope()\n\n    val foundTypes = arrayListOf<TypeNameMatch>()\n    val collector = object : TypeNameMatchRequestor() {\n        override fun acceptTypeNameMatch(match: TypeNameMatch) {\n            if (Flags.isPublic(match.modifiers)) {\n                foundTypes.add(match)\n            }\n        }\n    }\n\n    val searchEngine = SearchEngine()\n    searchEngine.searchAllTypeNames(\n        null,\n        SearchPattern.R_EXACT_MATCH,\n        typeName.toCharArray(),\n        SearchPattern.R_EXACT_MATCH or SearchPattern.R_CASE_SENSITIVE,\n        IJavaSearchConstants.TYPE,\n        scope,\n        collector,\n        IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,\n        null\n    )\n\n    return foundTypes.map(::TypeCandidate)\n}\n\nprivate fun findApplicableCallables(\n    element: PsiElement,\n\tbindingContext : BindingContext,\n    resolutionFacade: KotlinResolutionFacade\n): List<FunctionCandidate> {\n    val module = resolutionFacade.moduleDescriptor\n\n    val callTypeAndReceiver = (element as? KtSimpleNameExpression)\n        ?.let { CallTypeAndReceiver.detect(it) }\n        ?: return emptyList()\n\n    val descriptorKindFilter = callTypeAndReceiver.callType.descriptorKindFilter\n\n    val receiverTypes: Collection<ReceiverType> = callTypeAndReceiver\n        .receiverTypesWithIndex(bindingContext, element, module, resolutionFacade, false)\n        .orEmpty()\n\n    val visitor = FunctionImportFinder { descriptor ->\n        descriptor.canBeReferencedViaImport() && descriptorKindFilter.accepts(descriptor) && (\n                descriptor.extensionReceiverParameter == null\n                        || receiverTypes.any { descriptor.isReceiverTypeMatching(it.type) })\n    }\n\n    return searchCallableByName(element)\n        .let { module.accept(visitor, it) }\n        .map { FunctionCandidate(it) }\n}\n\nprivate fun CallableDescriptor.isReceiverTypeMatching(type: KotlinType): Boolean =\n    extensionReceiverParameter?.let { type.isSubtypeOf(it.type) } ?: true\n\nprivate fun searchCallableByName(element: PsiElement): List<String> {\n    val result = mutableListOf<String>()\n\n    val conventionOperatorName = tryFindConventionOperatorName(element)\n\n    if (conventionOperatorName != null) {\n        queryForCallables(conventionOperatorName) {\n            result += \"${it.declaringType.fullyQualifiedName}.$conventionOperatorName\"\n        }\n    } else {\n        queryForCallables(element.text) {\n            result += \"${it.declaringType.fullyQualifiedName}.${it.elementName}\"\n        }\n\n        if (element is KtNameReferenceExpression) {\n            // We have to look for properties even if reference expression is first element in call expression,\n            // because `something()` can mean `getSomething().invoke()`.\n            queryForCallables(JvmAbi.getterName(element.text)) {\n                result += \"${it.declaringType.fullyQualifiedName}.${element.text}\"\n            }\n        }\n    }\n\n    return result\n}\n\n\nprivate fun tryFindConventionOperatorName(element: PsiElement): String? {\n    val isBinary = element.parent is KtBinaryExpression\n    val isUnary = element.parent is KtPrefixExpression\n\n    if (!isBinary && !isUnary) return null\n\n    return (element as? KtOperationReferenceExpression)\n        ?.operationSignTokenType\n        ?.let { OperatorConventions.getNameForOperationSymbol(it, isUnary, isBinary) }\n        ?.asString()\n}\n\nprivate fun queryForCallables(name: String, collector: (IMethod) -> Unit) {\n    val pattern = SearchPattern.createPattern(\n        name,\n        IJavaSearchConstants.METHOD,\n        IJavaSearchConstants.DECLARATIONS,\n        SearchPattern.R_EXACT_MATCH\n    )\n\n    val requester = object : SearchRequestor() {\n        override fun acceptSearchMatch(match: SearchMatch?) {\n            (match?.element as? IMethod)?.also(collector)\n        }\n    }\n\n    SearchEngine().search(\n        pattern,\n        arrayOf(SearchEngine.getDefaultSearchParticipant()),\n        SearchEngine.createWorkspaceScope(),\n        requester,\n        null\n    )\n}\n\nclass DefaultImportPredicate(\n    platform: PlatformDependentAnalyzerServices,\n    languageVersionSettings: LanguageVersionSettings\n) : (ImportCandidate) -> Boolean {\n    private val defaultImports = platform.getDefaultImports(languageVersionSettings, true)\n\n    override fun invoke(candidate: ImportCandidate): Boolean =\n        candidate.fullyQualifiedName\n            ?.let { ImportPath.fromString(it) }\n            ?.isImported(defaultImports)\n            ?.not()\n            ?: false\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/launch/CompilerOutputData.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.launch;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation;\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;\n\npublic class CompilerOutputData {\n    \n    private final List<CompilerOutputElement> data = new ArrayList<CompilerOutputElement>();\n    \n    public void add(CompilerMessageSeverity messageSeverity, String message, CompilerMessageLocation messageLocation) {\n        data.add(new CompilerOutputElement(messageSeverity, message, messageLocation));\n    }\n    \n    public void clear() {\n        data.clear();\n    }\n    \n    public List<CompilerOutputElement> getList() {\n        return data;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/launch/CompilerOutputElement.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.launch;\n\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation;\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;\n\n\npublic class CompilerOutputElement {\n    \n    private final CompilerMessageSeverity messageSeverity;\n    private final String message;\n    private final CompilerMessageLocation messageLocation;\n    \n    public CompilerOutputElement (CompilerMessageSeverity messageSeverity, String message, CompilerMessageLocation messageLocation) {\n        this.messageSeverity = messageSeverity;\n        this.message = message;\n        this.messageLocation = messageLocation;\n    }\n    \n    public CompilerMessageSeverity getMessageSeverity() {\n        return messageSeverity;\n    }\n    \n    public String getMessage() {\n        return message;\n    }\n    \n    public CompilerMessageLocation getMessageLocation() {\n        return messageLocation;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/launch/CompilerOutputParser.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.launch;\n\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Stack;\n\nimport javax.xml.parsers.SAXParser;\nimport javax.xml.parsers.SAXParserFactory;\n\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation;\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;\nimport org.jetbrains.kotlin.cli.common.messages.MessageCollector;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.xml.sax.Attributes;\nimport org.xml.sax.InputSource;\nimport org.xml.sax.SAXException;\nimport org.xml.sax.helpers.DefaultHandler;\n\npublic class CompilerOutputParser {\n    \n    public static void parseCompilerMessagesFromReader(MessageCollector messageCollector, final Reader reader) {\n        final StringBuilder stringBuilder = new StringBuilder();\n        Reader wrappingReader = new Reader() {\n\n            @Override\n            public int read(char[] cbuf, int off, int len) throws IOException {\n                int read = reader.read(cbuf, off, len);\n                stringBuilder.append(cbuf, off, len);\n                return read;\n            }\n\n            @Override\n            public void close() throws IOException {\n            }\n        };\n        try {\n            SAXParserFactory factory = SAXParserFactory.newInstance();\n            SAXParser parser = factory.newSAXParser();\n            parser.parse(new InputSource(wrappingReader), new CompilerOutputSAXHandler(messageCollector));\n        }\n        catch (Throwable e) {\n            String message = stringBuilder.toString();\n            messageCollector.report(CompilerMessageSeverity.ERROR, message, null);\n        }\n        finally {\n            try {\n                reader.close();\n            }\n            catch (IOException e) {\n                KotlinLogger.logError(e);\n            }\n        }\n    }\n    \n    private static class CompilerOutputSAXHandler extends DefaultHandler {\n        private static final Map<String, CompilerMessageSeverity> CATEGORIES = new HashMap<String, CompilerMessageSeverity>();\n        \n        static {\n            CATEGORIES.put(\"error\", CompilerMessageSeverity.ERROR);\n            CATEGORIES.put(\"warning\", CompilerMessageSeverity.WARNING);\n            CATEGORIES.put(\"logging\", CompilerMessageSeverity.LOGGING);\n            CATEGORIES.put(\"output\", CompilerMessageSeverity.OUTPUT);\n            CATEGORIES.put(\"exception\", CompilerMessageSeverity.EXCEPTION);\n            CATEGORIES.put(\"info\", CompilerMessageSeverity.INFO);\n            CATEGORIES.put(\"messages\", CompilerMessageSeverity.INFO); \n        }\n             \n\n        private final MessageCollector messageCollector;\n\n        private final StringBuilder message = new StringBuilder();\n        private final Stack<String> tags = new Stack<String>();\n        private String path;\n        private int line;\n        private int column;\n\n        public CompilerOutputSAXHandler(MessageCollector messageCollector) {\n            this.messageCollector = messageCollector;\n        }\n\n        @Override\n        public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {\n            tags.push(qName);\n\n            message.setLength(0);\n\n            String rawPath = attributes.getValue(\"path\");\n            path = rawPath == null ? null : rawPath;\n            line = safeParseInt(attributes.getValue(\"line\"), -1);\n            column = safeParseInt(attributes.getValue(\"column\"), -1);\n        }\n\n        @Override\n        public void characters(char[] ch, int start, int length) throws SAXException {\n            if (tags.size() == 1) {\n                String message = new String(ch, start, length);\n                if (!message.trim().isEmpty()) {\n                    messageCollector.report(CompilerMessageSeverity.ERROR, \"Unhandled compiler output: \" + message, null);\n                }\n            }\n            else {\n                message.append(ch, start, length);\n            }\n        }\n\n        @Override\n        public void endElement(String uri, String localName, String qName) throws SAXException {\n            if (tags.size() == 1) {\n                return;\n            }\n            String qNameLowerCase = qName.toLowerCase();\n            CompilerMessageSeverity category = CATEGORIES.get(qNameLowerCase);\n            if (category == null) {\n                messageCollector.report(CompilerMessageSeverity.ERROR, \"Unknown compiler message tag: \" + qName, null);\n                category = CompilerMessageSeverity.INFO;\n            }\n            String text = message.toString();\n\n            messageCollector.report(category, text, CompilerMessageLocation.create(path, line, column, null));\n            \n            tags.pop();\n        }\n        \n        private static int safeParseInt(String value, int defaultValue) {\n            if (value == null) {\n                return defaultValue;\n            }\n            try {\n                return Integer.parseInt(value.trim());\n            }\n            catch (NumberFormatException e) {\n                return defaultValue;\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/launch/KotlinCLICompiler.kt",
    "content": "package org.jetbrains.kotlin.core.launch\n\nimport java.io.PrintStream\nimport org.jetbrains.kotlin.cli.common.CLICompiler\nimport org.jetbrains.kotlin.cli.common.ExitCode\nimport org.jetbrains.kotlin.cli.jvm.compiler.CompileEnvironmentException\nimport org.jetbrains.kotlin.config.Services\nimport kotlin.jvm.JvmStatic\nimport org.jetbrains.kotlin.core.model.KOTLIN_COMPILER_PATH\n\nobject KotlinCLICompiler {\n\tprivate val obligatoryCompilerFlags\n        get() = arrayOf(\n            \"-Xintellij-plugin-root=\" + KOTLIN_COMPILER_PATH\n\t\t)\n\t\n\t@JvmStatic\n\tfun doMain(compiler: CLICompiler<*>, errorStream: PrintStream, args: Array<String>): ExitCode {\n\t\tSystem.setProperty(\"java.awt.headless\", \"true\")\n\t\tval exitCode = doMainNoExitWithHtmlOutput(compiler, errorStream, args)\n\t\treturn exitCode\n\t}\n\n\tprivate fun doMainNoExitWithHtmlOutput(\n\t\t\tcompiler: CLICompiler<*>,\n\t\t\terrorStream: PrintStream,\n\t\t\targs: Array<String>): ExitCode =\n\t\ttry {\n\t\t\tcompiler.execAndOutputXml(\n\t\t\t\t\terrorStream,\n\t\t\t\t\tServices.EMPTY,\n\t\t\t\t\t*obligatoryCompilerFlags,\n\t\t\t\t\t*args)\n\t\t} catch (e: CompileEnvironmentException) {\n\t\t\terrorStream.println(e.message)\n\t\t\tExitCode.INTERNAL_ERROR\n\t\t}\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/log/kotlinLogger.kt",
    "content": "package org.jetbrains.kotlin.core.log\n\nimport org.jetbrains.kotlin.core.Activator\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport kotlin.jvm.JvmStatic\n\nobject KotlinLogger {\n\t@JvmStatic\n\tfun log(status: IStatus) {\n\t\tActivator.getDefault().log.log(status)\n\t}\n\t\n\t@JvmStatic\n    fun log(severity: Int, message: String, exception: Throwable?) {\n\t\tlog(Status(severity, Activator.PLUGIN_ID, message, exception))\n\t}\n\t\n\t@JvmStatic\n    fun logError(exception: Throwable) {\n\t\tlog(IStatus.ERROR, \"Unexpected Exception\", exception)\n\t}\n\t\n\t@JvmStatic\n    fun logError(message: String, exception: Throwable?) {\n\t\tlog(IStatus.ERROR, message, exception)\n\t}\n\t\n\t@JvmStatic\n    fun logInfo(message: String) {\n\t\tlog(IStatus.INFO, message, null)\n\t}\n\t\n\t@JvmStatic\n    fun logWarning(message: String) {\n\t\tlog(IStatus.WARNING, message, null)\n\t}\n\t\n\t@JvmStatic\n    fun logAndThrow(exception: Throwable): Nothing {\n\t\tlogError(exception)\n\t\tthrow exception\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/CachedEnvironment.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.openapi.util.Disposer\nimport com.intellij.openapi.vfs.impl.ZipHandler\nimport java.util.concurrent.ConcurrentHashMap\n\nclass CachedEnvironment<T: Any, E : KotlinCommonEnvironment> {\n    private val environmentLock = Any()\n\n    private val environmentCache = ConcurrentHashMap<T, E>()\n    private val ideaProjectToEclipseResource = ConcurrentHashMap<Project, T>()\n\n    fun putEnvironment(resource: T, environment: E): Unit = synchronized(environmentLock) {\n        environmentCache[resource] = environment\n        ideaProjectToEclipseResource[environment.project] = resource\n    }\n\n    fun getOrCreateEnvironment(resource: T, createEnvironment: (T) -> E): E = synchronized(environmentLock) {\n        environmentCache.getOrPut(resource) {\n            createEnvironment(resource).also { ideaProjectToEclipseResource[it.project] = resource }\n        }\n    }\n\n    fun removeEnvironment(resource: T) = synchronized(environmentLock) {\n        removeEnvironmentInternal(resource)\n    }\n\n\n    fun removeEnvironmentIf(check: (KotlinCommonEnvironment) -> Boolean): List<T> {\n        val tempToRemove = environmentCache.filter { check(it.value) }.map { it.key }\n        tempToRemove.forEach(::removeEnvironmentInternal)\n        return tempToRemove\n    }\n\n    fun removeAllEnvironments() = synchronized(environmentLock) {\n        environmentCache.keys.toList().forEach {\n            removeEnvironmentInternal(it)\n        }\n    }\n\n    private fun removeEnvironmentInternal(resource: T) {\n        environmentCache.remove(resource)?.also {\n            ideaProjectToEclipseResource.remove(it.project)\n\n            Disposer.dispose(it.projectEnvironment.parentDisposable)\n            ZipHandler.clearFileAccessorCache()\n        }\n    }\n\n    fun replaceEnvironment(resource: T, createEnvironment: (T) -> E): E = synchronized(environmentLock) {\n        removeEnvironment(resource)\n        getOrCreateEnvironment(resource, createEnvironment)\n    }\n\n    fun getEclipseResource(ideaProject: Project): T? = synchronized(environmentLock) {\n        ideaProjectToEclipseResource[ideaProject]\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/DummyCodeStyleManager.kt",
    "content": "package org.jetbrains.kotlin.core.model\n\nimport com.intellij.lang.ASTNode\nimport com.intellij.openapi.editor.Document\nimport com.intellij.openapi.fileTypes.FileType\nimport com.intellij.openapi.project.Project\nimport com.intellij.openapi.util.Computable\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiFile\nimport com.intellij.psi.codeStyle.ChangedRangesInfo\nimport com.intellij.psi.codeStyle.CodeStyleManager\nimport com.intellij.psi.codeStyle.Indent\nimport com.intellij.util.ThrowableRunnable\n\n@Suppress(\"DEPRECATION\")\nclass DummyCodeStyleManager : CodeStyleManager() {\n    override fun reformatTextWithContext(arg0: PsiFile, arg1: ChangedRangesInfo) {\n        throw UnsupportedOperationException()\n    }\n\n    override fun reformatNewlyAddedElement(block: ASTNode, addedElement: ASTNode) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun getProject(): Project {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun fillIndent(indent: Indent?, fileType: FileType?): String? {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun getLineIndent(file: PsiFile, offset: Int): String? {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun getLineIndent(document: Document, offset: Int): String? {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun getIndent(text: String?, fileType: FileType?): Indent? {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun zeroIndent(): Indent? {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun reformat(element: PsiElement): PsiElement {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun reformat(element: PsiElement, canChangeWhiteSpacesOnly: Boolean): PsiElement {\n        throw UnsupportedOperationException()\n    }\n\n    override fun reformatTextWithContext(file: PsiFile, ranges: MutableCollection<out TextRange>) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun isLineToBeIndented(file: PsiFile, offset: Int): Boolean {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun adjustLineIndent(file: PsiFile, rangeToAdjust: TextRange?) {\n        // TODO: implement \n    }\n    \n    override fun adjustLineIndent(file: PsiFile, offset: Int): Int {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun adjustLineIndent(document: Document, offset: Int): Int {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun isSequentialProcessingAllowed(): Boolean {\n        throw UnsupportedOperationException()\n    }\n\n    override fun reformatText(p0: PsiFile, p1: MutableCollection<out TextRange>) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun reformatText(file: PsiFile, startOffset: Int, endOffset: Int) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun reformatRange(element: PsiElement, startOffset: Int, endOffset: Int): PsiElement = element\n    \n    override fun reformatRange(element: PsiElement, startOffset: Int, endOffset: Int, canChangeWhiteSpacesOnly: Boolean): PsiElement = element\n    \n    override fun performActionWithFormatterDisabled(r: Runnable?) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Throwable?> performActionWithFormatterDisabled(r: ThrowableRunnable<T>?) {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any?> performActionWithFormatterDisabled(r: Computable<T>?): T {\n        throw UnsupportedOperationException()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/EclipseKotlinModuleResolver.kt",
    "content": "package org.jetbrains.kotlin.core.model\n\nimport com.intellij.openapi.vfs.VirtualFile\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver\n\nclass EclipseKotlinJavaModuleResolver : JavaModuleResolver {\n    override fun checkAccessibility(\n            fileFromOurModule: VirtualFile?,\n            referencedFile: VirtualFile,\n            referencedPackage: FqName?\n    ): JavaModuleResolver.AccessError? = null\n\n    override fun getAnnotationsForModuleOwnerOfClass(classId: ClassId): List<JavaAnnotation>? = null\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/EclipseScriptDefinitionProvider.kt",
    "content": "package org.jetbrains.kotlin.core.model\n\nimport org.eclipse.osgi.internal.loader.EquinoxClassLoader\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.script.ScriptTemplateContribution\nimport org.jetbrains.kotlin.core.script.template.ProjectScriptTemplate\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asResource\nimport org.jetbrains.kotlin.scripting.definitions.KotlinScriptDefinition\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinition\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider\nimport org.jetbrains.kotlin.scripting.resolve.KtFileScriptSource\nimport java.io.File\nimport java.net.URLClassLoader\nimport kotlin.reflect.KClass\nimport kotlin.reflect.full.hasAnnotation\nimport kotlin.script.experimental.annotations.KotlinScript\nimport kotlin.script.experimental.api.KotlinType\nimport kotlin.script.experimental.api.SourceCode\nimport kotlin.script.experimental.host.ScriptingHostConfiguration\nimport kotlin.script.experimental.host.configurationDependencies\nimport kotlin.script.experimental.host.getScriptingClass\nimport kotlin.script.experimental.jvm.JvmDependency\nimport kotlin.script.experimental.jvm.JvmGetScriptingClass\n\nprivate const val EXTENSION_POINT_ID = \"org.jetbrains.kotlin.core.scriptTemplateContribution\"\n\nclass EclipseScriptDefinitionProvider : ScriptDefinitionProvider {\n    override fun getDefaultDefinition() =\n            scriptDefinitions.first { it.baseClassType == KotlinType(ProjectScriptTemplate::class) }\n\n    override fun findDefinition(script: SourceCode): ScriptDefinition? =\n            scriptDefinitions.first { it.isScript(script) }\n\n    override fun findScriptDefinition(fileName: String): KotlinScriptDefinition? =\n            scriptDefinitions.map { it.legacyDefinition }.first { it.isScript(fileName) }\n\n    override fun getDefaultScriptDefinition() =\n            getDefaultDefinition().legacyDefinition\n\n    override fun getKnownFilenameExtensions(): Sequence<String> =\n            scriptDefinitions.map { it.fileExtension }\n\n    override fun isScript(script: SourceCode) = Companion.isScript(script)\n\n    companion object {\n        private val contributions: List<WrappedContribution> by lazy {\n            loadExecutableEP<ScriptTemplateContribution>(EXTENSION_POINT_ID)\n                    .mapNotNull { it.createProvider() }\n                    .sortedByDescending { it.priority }\n                    .map(::WrappedContribution)\n        }\n\n        private val scriptDefinitions: Sequence<ScriptDefinition>\n            get() = contributions.asSequence().mapNotNull { it.definition }\n\n        fun getContribution(script: SourceCode): ScriptTemplateContribution? = contributions.find { it.definition?.isScript(script) == true }?.contribution\n\n        fun isScript(script: SourceCode) = scriptDefinitions.any { it.isScript(script) }\n\n        fun getEnvironment(scriptFile: File) =\n                scriptFile.asResource\n                        ?.let { KotlinPsiManager.getKotlinParsedFile(it) }\n                        ?.let { KtFileScriptSource(it) }\n                        ?.let { source ->\n                            contributions.find { it.definition?.isScript(source) == true }\n                                    ?.contribution?.scriptEnvironment(scriptFile)\n                                    ?: emptyMap()\n                        }\n    }\n}\n\nprivate class WrappedContribution(val contribution: ScriptTemplateContribution) {\n\n    private var _definition: ScriptDefinition? = null\n\n    val definition: ScriptDefinition?\n        get() {\n            return _definition ?: run {\n                try {\n                    if (contribution.template.hasAnnotation<KotlinScript>()) {\n                        ScriptDefinition.FromTemplate(\n                                baseHostConfiguration = ScriptingHostConfiguration {\n                                    getScriptingClass(JvmGetScriptingClass())\n                                    configurationDependencies(JvmDependency(extractClasspath(contribution.template) + scriptingDependencies))\n                                },\n                                template = contribution.template,\n                                contextClass = contribution.template\n                        )\n                    } else {\n                        ScriptDefinition.FromLegacyTemplate(\n                                hostConfiguration = ScriptingHostConfiguration {\n                                    getScriptingClass(JvmGetScriptingClass())\n                                    configurationDependencies(JvmDependency(extractClasspath(contribution.template) + scriptingDependencies))\n                                },\n                                template = contribution.template\n                        )\n                    }\n                } catch (e: Exception) {\n                    null\n                }\n            }?.also { _definition = it }\n        }\n}\n\n// TODO: hack for now, will definitely need rethinking\nprivate fun extractClasspath(kClass: KClass<*>): List<File> {\n    return when (val tempLoader = kClass.java.classLoader) {\n        is EquinoxClassLoader -> tempLoader.classpathManager\n                .hostClasspathEntries\n                .map { entry -> entry.bundleFile.baseFile.resolve(\"bin\") }\n        is URLClassLoader -> tempLoader.urLs.mapNotNull { File(it.file).takeIf { it.exists() } }\n        else -> null\n    } ?: emptyList()\n}\n\nprivate val scriptingDependencies: List<File> by lazy {\n    listOf(\"kotlin-scripting-jvm\")\n            .map { File(ProjectUtils.buildLibPath(it)) }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinAnalysisFileCache.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport org.jetbrains.kotlin.core.resolve.AnalysisResultWithProvider\nimport org.jetbrains.kotlin.core.resolve.EclipseAnalyzerFacadeForJVM\nimport org.jetbrains.kotlin.psi.KtFile\n\ndata class FileAnalysisResults(val file: KtFile, val analysisResult: AnalysisResultWithProvider)\n\nobject KotlinAnalysisFileCache {\n    @Volatile\n    private var lastAnalysedFileCache: FileAnalysisResults? = null\n\n    @Synchronized fun getAnalysisResult(file: KtFile): AnalysisResultWithProvider {\n        return getImmediatlyFromCache(file) ?: run {\n            val environment = getEnvironment(file.project)!!\n            val analysisResult = resolve(file, environment)\n            \n            lastAnalysedFileCache = FileAnalysisResults(file, analysisResult)\n            lastAnalysedFileCache!!.analysisResult\n        }\n    }\n    \n    fun resetCache() {\n        lastAnalysedFileCache = null\n    }\n    \n    private fun resolve(file: KtFile, environment: KotlinCommonEnvironment): AnalysisResultWithProvider {\n        return when (environment) {\n            is KotlinScriptEnvironment -> EclipseAnalyzerFacadeForJVM.analyzeScript(environment, file)\n            is KotlinEnvironment -> EclipseAnalyzerFacadeForJVM.analyzeSources(environment, listOf(file))\n            else -> throw IllegalArgumentException(\"Could not analyze file with environment: $environment\")\n        }\n    }\n    \n    @Synchronized\n    private fun getImmediatlyFromCache(file: KtFile): AnalysisResultWithProvider? {\n        return if (lastAnalysedFileCache != null && lastAnalysedFileCache!!.file == file)\n            lastAnalysedFileCache!!.analysisResult\n        else\n            null\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinAnalysisProjectCache.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResourceChangeEvent\nimport org.eclipse.core.resources.IResourceChangeListener\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.resolve.EclipseAnalyzerFacadeForJVM\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport java.util.concurrent.ConcurrentHashMap\n\nobject KotlinAnalysisProjectCache : IResourceChangeListener {\n    private val cachedAnalysisResults = ConcurrentHashMap<IProject, AnalysisResult>()\n\n    fun resetCache(project: IProject) {\n        synchronized(project) {\n            cachedAnalysisResults.remove(project)\n        }\n    }\n\n    fun resetAllCaches() {\n        cachedAnalysisResults.keys.toList().forEach {\n            resetCache(it)\n        }\n    }\n\n    fun getAnalysisResult(javaProject: IJavaProject): AnalysisResult {\n        val project = javaProject.project\n        return synchronized(project) {\n            val analysisResult = cachedAnalysisResults.get(project) ?: run {\n                EclipseAnalyzerFacadeForJVM.analyzeSources(\n                        KotlinEnvironment.getEnvironment(project),\n                        ProjectUtils.getSourceFiles(javaProject.project)).analysisResult\n            }\n\n            cachedAnalysisResults.putIfAbsent(project, analysisResult) ?: analysisResult\n        }\n    }\n\n    @Synchronized\n    public fun getAnalysisResultIfCached(project: IProject): AnalysisResult? {\n        return cachedAnalysisResults.get(project)\n    }\n\n    override fun resourceChanged(event: IResourceChangeEvent) {\n        when (event.type) {\n            IResourceChangeEvent.PRE_DELETE,\n            IResourceChangeEvent.PRE_CLOSE,\n            IResourceChangeEvent.PRE_BUILD -> event.delta?.accept { delta ->\n                val resource = delta.resource\n                if (resource is IFile) {\n                    val javaProject = JavaCore.create(resource.getProject())\n                    if (KotlinPsiManager.isKotlinSourceFile(resource, javaProject)) {\n                        cachedAnalysisResults.remove(resource.getProject())\n                    }\n\n                    return@accept false\n                }\n\n                true\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinCommonEnvironment.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n@file:Suppress(\"DEPRECATION\")\n\npackage org.jetbrains.kotlin.core.model\n\nimport com.intellij.codeInsight.*\nimport com.intellij.codeInsight.runner.JavaMainMethodProvider\nimport com.intellij.core.CoreApplicationEnvironment\nimport com.intellij.core.CoreJavaFileManager\nimport com.intellij.core.JavaCoreProjectEnvironment\nimport com.intellij.formatting.Formatter\nimport com.intellij.formatting.FormatterImpl\nimport com.intellij.formatting.KotlinLanguageCodeStyleSettingsProvider\nimport com.intellij.formatting.KotlinSettingsProvider\nimport com.intellij.lang.MetaLanguage\nimport com.intellij.lang.jvm.facade.JvmElementProvider\nimport com.intellij.mock.MockProject\nimport com.intellij.openapi.Disposable\nimport com.intellij.openapi.components.ServiceManager\nimport com.intellij.openapi.extensions.ExtensionPointName\nimport com.intellij.openapi.extensions.Extensions\nimport com.intellij.openapi.extensions.ExtensionsArea\nimport com.intellij.openapi.fileTypes.PlainTextFileType\nimport com.intellij.openapi.util.Disposer\nimport com.intellij.openapi.util.SystemInfo\nimport com.intellij.openapi.vfs.VirtualFile\nimport com.intellij.psi.JavaModuleSystem\nimport com.intellij.psi.PsiElementFinder\nimport com.intellij.psi.PsiManager\nimport com.intellij.psi.augment.PsiAugmentProvider\nimport com.intellij.psi.codeStyle.CodeStyleManager\nimport com.intellij.psi.codeStyle.CodeStyleSettingsProvider\nimport com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider\nimport com.intellij.psi.compiled.ClassFileDecompilers\nimport com.intellij.psi.impl.PsiElementFinderImpl\nimport com.intellij.psi.impl.PsiTreeChangePreprocessor\nimport com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy\nimport com.intellij.psi.impl.file.impl.JavaFileManager\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.asJava.KotlinAsJavaSupport\nimport org.jetbrains.kotlin.asJava.LightClassGenerationSupport\nimport org.jetbrains.kotlin.asJava.finder.JavaElementFinder\nimport org.jetbrains.kotlin.caches.resolve.KotlinCacheService\nimport org.jetbrains.kotlin.cli.common.CliModuleVisibilityManagerImpl\nimport org.jetbrains.kotlin.cli.jvm.compiler.*\nimport org.jetbrains.kotlin.cli.jvm.index.JavaRoot\nimport org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesDynamicCompoundIndex\nimport org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex\nimport org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension\nimport org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension\nimport org.jetbrains.kotlin.config.CommonConfigurationKeys\nimport org.jetbrains.kotlin.config.CompilerConfiguration\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.resolve.BuiltInsReferenceResolver\nimport org.jetbrains.kotlin.core.resolve.KotlinCacheServiceImpl\nimport org.jetbrains.kotlin.core.resolve.KotlinSourceIndex\nimport org.jetbrains.kotlin.core.utils.KotlinImportInserterHelper\nimport org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages\nimport org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension\nimport org.jetbrains.kotlin.extensions.StorageComponentContainerContributor\nimport org.jetbrains.kotlin.idea.KotlinFileType\nimport org.jetbrains.kotlin.idea.j2k.J2KPostProcessingRegistrar\nimport org.jetbrains.kotlin.idea.j2k.J2KPostProcessingRegistrarImpl\nimport org.jetbrains.kotlin.idea.j2k.J2kPostProcessing\nimport org.jetbrains.kotlin.idea.util.ImportInsertHelper\nimport org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache\nimport org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager\nimport org.jetbrains.kotlin.parsing.KotlinParserDefinition\nimport org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer\nimport org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver\nimport org.jetbrains.kotlin.resolve.diagnostics.DiagnosticSuppressor\nimport org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension\nimport org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade\nimport org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm\nimport org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider\nimport org.jetbrains.kotlin.scripting.extensions.ScriptingResolveExtension\nimport java.io.File\nimport kotlin.reflect.KClass\nimport com.intellij.psi.codeStyle.CodeStyleSettingsService\nimport com.intellij.psi.codeStyle.CodeStyleSettingsServiceImpl\n\nprivate fun setIdeaIoUseFallback() {\n    if (SystemInfo.isWindows) {\n        val properties = System.getProperties()\n\n        properties.setProperty(\"idea.io.use.nio2\", java.lang.Boolean.TRUE.toString())\n\n        if (!(SystemInfo.isJavaVersionAtLeast(1, 7, 0) && \"1.7.0-ea\" != SystemInfo.JAVA_VERSION)) {\n            properties.setProperty(\"idea.io.use.fallback\", java.lang.Boolean.TRUE.toString())\n        }\n    }\n}\n\nabstract class KotlinCommonEnvironment(disposable: Disposable) {\n    val project: MockProject\n\n    var hasError = false\n\n    val projectEnvironment: JavaCoreProjectEnvironment\n    private val roots = LinkedHashSet<JavaRoot>()\n\n    val configuration = CompilerConfiguration()\n\n    abstract val javaProject: IJavaProject\n\n    init {\n        setIdeaIoUseFallback()\n\n        projectEnvironment = object : JavaCoreProjectEnvironment(disposable, kotlinCoreApplicationEnvironment) {\n            override fun preregisterServices() {\n                registerProjectExtensionPoints(project.extensionArea)\n                CoreApplicationEnvironment.registerExtensionPoint(\n                    project.extensionArea,\n                    JvmElementProvider.EP_NAME,\n                    JvmElementProvider::class.java\n                )\n            }\n\n            override fun createCoreFileManager() = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(project))\n        }\n\n        project = projectEnvironment.getProject()\n        DeclarationAttributeAltererExtension.registerExtensionPoint(project)\n        StorageComponentContainerContributor.registerExtensionPoint(project)\n\n        with(project) {\n            val scriptDefinitionProvider = EclipseScriptDefinitionProvider()\n            registerService(ScriptDefinitionProvider::class.java, scriptDefinitionProvider)\n            registerService(ModuleVisibilityManager::class.java, CliModuleVisibilityManagerImpl(true))\n\n            // For j2k converter\n            registerService(NullableNotNullManager::class.java, KotlinNullableNotNullManager(project))\n\n            registerService(\n                CoreJavaFileManager::class.java,\n                ServiceManager.getService(project, JavaFileManager::class.java) as CoreJavaFileManager\n            )\n\n            registerService(ModuleAnnotationsResolver::class.java, CliModuleAnnotationsResolver())\n            registerService(CodeStyleManager::class.java, DummyCodeStyleManager())\n            registerService(BuiltInsReferenceResolver::class.java, BuiltInsReferenceResolver(project))\n            registerService(KotlinSourceIndex::class.java, KotlinSourceIndex())\n            registerService(KotlinCacheService::class.java, KotlinCacheServiceImpl(project))\n            registerService(ImportInsertHelper::class.java, KotlinImportInserterHelper())\n\n            registerService(ExternalAnnotationsManager::class.java, MockExternalAnnotationsManager())\n            registerService(InferredAnnotationsManager::class.java, MockInferredAnnotationsManager())\n\n            val traceHolder = CliTraceHolder().also {\n                registerService(CodeAnalyzerInitializer::class.java, it)\n            }\n\n            CliLightClassGenerationSupport(traceHolder, project).also {\n                registerService(LightClassGenerationSupport::class.java, it)\n                registerService(CliLightClassGenerationSupport::class.java, it)\n            }\n\n            registerService(JavaModuleResolver::class.java, EclipseKotlinJavaModuleResolver())\n\n            val area = extensionArea\n            val javaFileManager = ServiceManager.getService(this, JavaFileManager::class.java)\n            (javaFileManager as KotlinCliJavaFileManagerImpl)\n                .initialize(\n                    JvmDependenciesDynamicCompoundIndex(),\n                    arrayListOf(),\n                    SingleJavaFileRootsIndex(arrayListOf()),\n                    false\n                )\n            area.getExtensionPoint(PsiElementFinder.EP_NAME)\n                .registerExtension(PsiElementFinderImpl(this, javaFileManager))\n            val kotlinAsJavaSupport = CliKotlinAsJavaSupport(this, traceHolder)\n            registerService(KotlinAsJavaSupport::class.java, kotlinAsJavaSupport)\n            area.getExtensionPoint(PsiElementFinder.EP_NAME)\n                .registerExtension(JavaElementFinder(this))\n            area.getExtensionPoint(SyntheticResolveExtension.extensionPointName)\n                .registerExtension(ScriptingResolveExtension())\n            registerService(KotlinJavaPsiFacade::class.java, KotlinJavaPsiFacade(this))\n        }\n\n        configuration.put(CommonConfigurationKeys.MODULE_NAME, project.name)\n\n        ExpressionCodegenExtension.Companion.registerExtensionPoint(project)\n        registerApplicationExtensionPointsAndExtensionsFrom()\n\n        ClassBuilderInterceptorExtension.registerExtensionPoint(project)\n    }\n\n    fun getRoots(): Set<JavaRoot> = roots\n\n    fun getVirtualFile(location: IPath): VirtualFile? {\n        return kotlinCoreApplicationEnvironment.localFileSystem.findFileByIoFile(location.toFile())\n    }\n\n    fun getVirtualFileInJar(pathToJar: IPath, relativePath: String): VirtualFile? {\n        return kotlinCoreApplicationEnvironment.jarFileSystem.findFileByPath(\"$pathToJar!/$relativePath\")\n    }\n\n    fun isJarFile(pathToJar: IPath): Boolean {\n        val jarFile = kotlinCoreApplicationEnvironment.jarFileSystem.findFileByPath(\"$pathToJar!/\")\n        return jarFile != null && jarFile.isValid\n    }\n\n    protected fun addToClasspath(path: File, rootType: JavaRoot.RootType? = null) {\n        if (path.isFile) {\n            val jarFile = kotlinCoreApplicationEnvironment.jarFileSystem.findFileByPath(\"$path!/\")\n            if (jarFile == null) {\n                KotlinLogger.logWarning(\"Can't find jar: $path\")\n                return\n            }\n\n            projectEnvironment.addJarToClassPath(path)\n\n            val type = rootType ?: JavaRoot.RootType.BINARY\n            roots.add(JavaRoot(jarFile, type))\n        } else {\n            val root = kotlinCoreApplicationEnvironment.localFileSystem.findFileByPath(path.absolutePath)\n            if (root == null) {\n                KotlinLogger.logWarning(\"Can't find jar: $path\")\n                return\n            }\n\n            projectEnvironment.addSourcesToClasspath(root)\n\n            val type = rootType ?: JavaRoot.RootType.SOURCE\n            roots.add(JavaRoot(root, type))\n        }\n    }\n\n    companion object {\n        val kotlinCoreApplicationEnvironment: KotlinCoreApplicationEnvironment by lazy {\n            createKotlinCoreApplicationEnvironment(Disposer.newDisposable(\"Root Disposable\"))\n        }\n    }\n}\n\nprivate fun createKotlinCoreApplicationEnvironment(disposable: Disposable): KotlinCoreApplicationEnvironment =\n    KotlinCoreApplicationEnvironment.create(disposable, false).apply {\n        registerAppExtensionPoints()\n\n        registerFileType(PlainTextFileType.INSTANCE, \"xml\")\n        registerFileType(KotlinFileType.INSTANCE, \"kt\")\n        registerFileType(KotlinFileType.INSTANCE, KotlinParserDefinition.STD_SCRIPT_SUFFIX)\n        registerParserDefinition(KotlinParserDefinition())\n\n        application.registerService(Formatter::class.java, FormatterImpl())\n        application.registerService(KotlinBinaryClassCache::class.java, KotlinBinaryClassCache())\n        application.registerService(ScriptDefinitionProvider::class.java, EclipseScriptDefinitionProvider())\n        application.registerService(J2KPostProcessingRegistrar::class.java, object : J2KPostProcessingRegistrar {\n            override val processings: Collection<J2kPostProcessing>\n                get() = emptyList()\n\n            override fun priority(processing: J2kPostProcessing): Int = 0\n        })\n        application.registerService(CodeStyleSettingsService::class.java, CodeStyleSettingsServiceImpl())\n    }\n\nprivate fun registerProjectExtensionPoints(area: ExtensionsArea) {\n    registerExtensionPoint(area, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor::class)\n    registerExtensionPoint(area, PsiElementFinder.EP_NAME, PsiElementFinder::class)\n    registerExtensionPoint(area, SyntheticResolveExtension.extensionPointName, SyntheticResolveExtension::class)\n}\n\n@Suppress(\"LocalVariableName\")\nprivate fun registerApplicationExtensionPointsAndExtensionsFrom() {\n    val EP_ERROR_MSGS =\n        ExtensionPointName.create<DefaultErrorMessages.Extension>(\"org.jetbrains.defaultErrorMessages.extension\")\n    registerExtensionPointInRoot(DiagnosticSuppressor.EP_NAME, DiagnosticSuppressor::class)\n    registerExtensionPointInRoot(EP_ERROR_MSGS, DefaultErrorMessages.Extension::class)\n\n    registerExtensionPointInRoot(CodeStyleSettingsProvider.EXTENSION_POINT_NAME, KotlinSettingsProvider::class)\n    registerExtensionPointInRoot(\n        LanguageCodeStyleSettingsProvider.EP_NAME,\n        KotlinLanguageCodeStyleSettingsProvider::class\n    )\n    registerExtensionPointInRoot(JavaModuleSystem.EP_NAME, JavaModuleSystem::class)\n\n    with(Extensions.getRootArea()) {\n        getExtensionPoint(EP_ERROR_MSGS).registerExtension(DefaultErrorMessagesJvm())\n        getExtensionPoint(CodeStyleSettingsProvider.EXTENSION_POINT_NAME).registerExtension(KotlinSettingsProvider())\n        getExtensionPoint(LanguageCodeStyleSettingsProvider.EP_NAME).registerExtension(\n            KotlinLanguageCodeStyleSettingsProvider()\n        )\n    }\n}\n\nprivate fun registerAppExtensionPoints() {\n    registerExtensionPointInRoot(ContainerProvider.EP_NAME, ContainerProvider::class)\n    registerExtensionPointInRoot(ClsCustomNavigationPolicy.EP_NAME, ClsCustomNavigationPolicy::class)\n    //TODO\n    //registerExtensionPointInRoot(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler::class)\n\n    // For j2k converter\n    registerExtensionPointInRoot(PsiAugmentProvider.EP_NAME, PsiAugmentProvider::class)\n    registerExtensionPointInRoot(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider::class)\n\n    CoreApplicationEnvironment.registerExtensionPoint(\n        Extensions.getRootArea(),\n        MetaLanguage.EP_NAME,\n        MetaLanguage::class.java\n    )\n}\n\nprivate fun <T : Any> registerExtensionPoint(\n    area: ExtensionsArea,\n    extensionPointName: ExtensionPointName<T>,\n    aClass: KClass<out T>\n) {\n    CoreApplicationEnvironment.registerExtensionPoint(area, extensionPointName, aClass.java)\n}\n\nprivate fun <T : Any> registerExtensionPointInRoot(extensionPointName: ExtensionPointName<T>, aClass: KClass<out T>) {\n    registerExtensionPoint(Extensions.getRootArea(), extensionPointName, aClass)\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinEnvironment.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport com.intellij.core.CoreJavaFileManager\nimport com.intellij.openapi.Disposable\nimport com.intellij.openapi.application.ApplicationManager\nimport com.intellij.openapi.components.ServiceManager\nimport com.intellij.openapi.project.Project\nimport com.intellij.openapi.util.Disposer\nimport com.intellij.psi.PsiElementFinder\nimport com.intellij.psi.impl.PsiElementFinderImpl\nimport com.intellij.psi.impl.file.impl.JavaFileManager\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.ProjectScope\nimport org.eclipse.jdt.core.IClasspathContainer\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.internal.core.JavaProject\nimport org.eclipse.osgi.internal.loader.EquinoxClassLoader\nimport org.jetbrains.kotlin.asJava.classes.FacadeCache\nimport org.jetbrains.kotlin.cli.jvm.compiler.CliVirtualFileFinderFactory\nimport org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl\nimport org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndexImpl\nimport org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex\nimport org.jetbrains.kotlin.compiler.plugin.CliOptionValue\nimport org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor\nimport org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar\nimport org.jetbrains.kotlin.compiler.plugin.parsePluginOption\nimport org.jetbrains.kotlin.config.CompilerConfiguration\nimport org.jetbrains.kotlin.config.JVMConfigurationKeys\nimport org.jetbrains.kotlin.container.ComponentProvider\nimport org.jetbrains.kotlin.container.StorageComponentContainer\nimport org.jetbrains.kotlin.container.useInstance\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.preferences.CompilerPlugin\nimport org.jetbrains.kotlin.core.preferences.KotlinBuildingProperties\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties\nimport org.jetbrains.kotlin.core.resolve.lang.kotlin.EclipseVirtualFileFinderFactory\nimport org.jetbrains.kotlin.core.utils.DependencyResolverException\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asFile\nimport org.jetbrains.kotlin.core.utils.buildLibPath\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.descriptors.ModuleDescriptor\nimport org.jetbrains.kotlin.extensions.AnnotationBasedExtension\nimport org.jetbrains.kotlin.extensions.StorageComponentContainerContributor\nimport org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory\nimport org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory\nimport org.jetbrains.kotlin.platform.TargetPlatform\nimport org.jetbrains.kotlin.platform.jvm.JvmPlatform\nimport org.jetbrains.kotlin.psi.KtModifierListOwner\nimport org.jetbrains.kotlin.resolve.sam.SamWithReceiverResolver\nimport org.jetbrains.kotlin.scripting.configuration.ScriptingConfigurationKeys\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinition\nimport org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider\nimport org.jetbrains.kotlin.scripting.definitions.annotationsForSamWithReceivers\nimport java.io.File\nimport java.net.URL\nimport java.net.URLClassLoader\nimport java.util.*\nimport kotlin.script.experimental.api.ScriptCompilationConfiguration\nimport kotlin.script.experimental.dependencies.ScriptDependencies\nimport kotlin.script.experimental.host.FileScriptSource\n\nval KOTLIN_COMPILER_PATH = ProjectUtils.buildLibPath(\"kotlin-compiler\")\n\nfun getEnvironment(eclipseFile: IFile): KotlinCommonEnvironment {\n    return if (KotlinScriptEnvironment.isScript(eclipseFile)) {\n        KotlinScriptEnvironment.getEnvironment(eclipseFile)\n    } else {\n        KotlinEnvironment.getEnvironment(eclipseFile.project)\n    }\n}\n\nfun getEnvironment(ideaProject: Project): KotlinCommonEnvironment? {\n    val eclipseResource = getEclipseResource(ideaProject) ?: return null\n    return when (eclipseResource) {\n        is IFile -> KotlinScriptEnvironment.getEnvironment(eclipseResource)\n        is IProject -> KotlinEnvironment.getEnvironment(eclipseResource)\n        else -> throw IllegalStateException(\"Could not get environment for resource: $eclipseResource\")\n    }\n}\n\nfun getEclipseResource(ideaProject: Project): IResource? {\n    val project = KotlinEnvironment.getJavaProject(ideaProject)\n    if (project != null) {\n        return project\n    }\n\n    return KotlinScriptEnvironment.getEclipseFile(ideaProject)\n}\n\nclass KotlinScriptEnvironment private constructor(\n        private val eclipseFile: IFile,\n        val dependencies: ScriptDependencies?,\n        disposable: Disposable\n) : KotlinCommonEnvironment(disposable) {\n\n    val definition: ScriptDefinition? = ScriptDefinitionProvider.getInstance(project)\n            ?.findDefinition(FileScriptSource(eclipseFile.asFile))\n\n    val definitionClasspath: Collection<File> = definition?.contextClassLoader?.let(::classpathFromClassloader).orEmpty()\n\n    override val javaProject: IJavaProject = JavaCore.create(eclipseFile.project)\n\n    init {\n        configureClasspath()\n\n        configuration.put(ScriptingConfigurationKeys.SCRIPT_DEFINITIONS, listOfNotNull(definition))\n\n        definition?.compilationConfiguration?.get(ScriptCompilationConfiguration.annotationsForSamWithReceivers)\n            ?.map { it.typeName }\n            ?.let { CliSamWithReceiverComponentContributor(it) }\n            ?.also { StorageComponentContainerContributor.registerExtension(project, it) }\n\n        val index = JvmDependenciesIndexImpl(getRoots().toList())\n\n        val area = project.extensionArea\n        with(area.getExtensionPoint(PsiElementFinder.EP_NAME)) {\n            registerExtension(PsiElementFinderImpl(project, ServiceManager.getService(project, JavaFileManager::class.java)))\n        }\n\n        index.indexedRoots.forEach {\n            projectEnvironment.addSourcesToClasspath(it.file)\n        }\n\n        val singleJavaFileRoots =\n                getRoots().filter { !it.file.isDirectory && it.file.extension == \"java\" }\n\n        val fileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java)\n        (fileManager as KotlinCliJavaFileManagerImpl).initialize(\n                index,\n                emptyList(),\n                SingleJavaFileRootsIndex(singleJavaFileRoots),\n                configuration.getBoolean(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING))\n\n        val finderFactory = CliVirtualFileFinderFactory(index)\n        project.registerService(MetadataFinderFactory::class.java, finderFactory)\n        project.registerService(VirtualFileFinderFactory::class.java, finderFactory)\n\n        project.registerService(FacadeCache::class.java, FacadeCache(project))\n        project.registerService(KotlinLightClassManager::class.java, KotlinLightClassManager(javaProject.project))\n\n//        definition?.dependencyResolver?.also { project.registerService(DependenciesResolver::class.java, it) }\n    }\n\n    companion object {\n        private val KOTLIN_RUNTIME_PATH = KotlinClasspathContainer.LIB_RUNTIME_NAME.buildLibPath()\n        private val KOTLIN_SCRIPT_RUNTIME_PATH = KotlinClasspathContainer.LIB_SCRIPT_RUNTIME_NAME.buildLibPath()\n\n        private val cachedEnvironment = CachedEnvironment<IFile, KotlinScriptEnvironment>()\n\n        @JvmStatic\n        fun getEnvironment(file: IFile): KotlinScriptEnvironment {\n            checkIsScript(file)\n\n            return cachedEnvironment.getOrCreateEnvironment(file) {\n                KotlinScriptEnvironment(it, null, Disposer.newDisposable(\"Scripting Env ${file.asFile.absolutePath}\"))\n            }\n        }\n\n        @JvmStatic\n        fun removeKotlinEnvironment(file: IFile) {\n            checkIsScript(file)\n            cachedEnvironment.removeEnvironment(file)\n        }\n\n        fun removeAllEnvironments() {\n            cachedEnvironment.removeAllEnvironments()\n        }\n\n        fun removeEnvironmentIf(check: (KotlinCommonEnvironment) -> Boolean) {\n            cachedEnvironment.removeEnvironmentIf(check)\n        }\n\n        @JvmStatic\n        fun getEclipseFile(project: Project): IFile? = cachedEnvironment.getEclipseResource(project)\n\n        fun isScript(file: IFile): Boolean =\n                EclipseScriptDefinitionProvider.isScript(FileScriptSource(file.asFile))\n\n        private fun checkIsScript(file: IFile) {\n            if (!isScript(file)) {\n                throw IllegalArgumentException(\"KotlinScriptEnvironment can work only with scripts, not ${file.name}\")\n            }\n        }\n\n        fun updateDependencies(file: IFile, newDependencies: ScriptDependencies?) {\n            cachedEnvironment.replaceEnvironment(file) {\n                KotlinScriptEnvironment(file, newDependencies, Disposer.newDisposable(\"Scripting Env ${file.asFile.absolutePath}\"))\n                    .apply { addDependenciesToClasspath(newDependencies) }\n            }\n            KotlinPsiManager.removeFile(file)\n        }\n    }\n\n    private fun configureClasspath() {\n        addToClasspath(KOTLIN_RUNTIME_PATH.toFile())\n        addToClasspath(KOTLIN_SCRIPT_RUNTIME_PATH.toFile())\n        definitionClasspath.forEach { addToClasspath(it) }\n\n        if (!javaProject.exists()) return\n\n        val tempFiles = try {\n            ProjectUtils.collectClasspathWithDependenciesForBuild(javaProject)\n        } catch (e: DependencyResolverException) {\n            hasError = true\n            e.resolvedFiles\n        }\n        tempFiles.forEach(::addToClasspath)\n    }\n\n    private fun addDependenciesToClasspath(dependencies: ScriptDependencies?) {\n        dependencies?.classpath?.forEach {\n            addToClasspath(it)\n        }\n    }\n\n    private fun addJREToClasspath() {\n        val project = eclipseFile.project\n        if (JavaProject.hasJavaNature(project)) {\n            val javaProject = JavaCore.create(project)\n            javaProject.rawClasspath.mapNotNull { entry ->\n                if (entry.entryKind == IClasspathEntry.CPE_CONTAINER) {\n                    val container = JavaCore.getClasspathContainer(entry.path, javaProject)\n                    if (container != null && container.kind == IClasspathContainer.K_DEFAULT_SYSTEM) {\n                        return@mapNotNull container\n                    }\n                }\n\n                null\n            }\n                    .flatMap { it.classpathEntries.toList() }\n                    .flatMap { ProjectUtils.getFileByEntry(it, javaProject) }\n                    .forEach { addToClasspath(it) }\n        }\n    }\n}\n\nprivate fun URL.toFile() =\n        try {\n            File(toURI().schemeSpecificPart)\n        } catch (e: java.net.URISyntaxException) {\n            if (protocol != \"file\") null\n            else File(file)\n        }\n\n\nprivate fun classpathFromClassloader(classLoader: ClassLoader): List<File> {\n    return when (classLoader) {\n        is URLClassLoader -> {\n            classLoader.urLs\n                    ?.mapNotNull { it.toFile() }\n                    ?: emptyList()\n        }\n        is EquinoxClassLoader -> {\n            classLoader.classpathManager.hostClasspathEntries.map { entry ->\n                if(entry.bundleFile.baseFile.isFile) {\n                    entry.bundleFile.baseFile\n                } else {\n                    entry.bundleFile.baseFile.resolve(\"bin\")\n                }\n            }\n        }\n        else -> {\n            KotlinLogger.logWarning(\"Could not get dependencies from $classLoader for script provider\")\n            emptyList()\n        }\n    }\n}\n\nclass CliSamWithReceiverComponentContributor(val annotations: List<String>) : StorageComponentContainerContributor {\n    override fun registerModuleComponents(container: StorageComponentContainer, platform: TargetPlatform, moduleDescriptor: ModuleDescriptor) {\n        if (platform.filterIsInstance<JvmPlatform>().isEmpty() ) return\n\n        container.useInstance(SamWithReceiverResolverExtension(annotations))\n    }\n}\n\ninline fun <reified T : Any> ComponentProvider.get(): T {\n    return getService(T::class.java)\n}\n\nfun <T : Any> ComponentProvider.getService(request: Class<T>): T {\n    return tryGetService(request) ?: throw IllegalArgumentException(\"Unresolved service: $request\")\n}\n\n@Suppress(\"UNCHECKED_CAST\")\nfun <T : Any> ComponentProvider.tryGetService(request: Class<T>): T? {\n    return resolve(request)?.getValue() as T?\n}\n\nclass SamWithReceiverResolverExtension(\n        private val annotations: List<String>\n) : SamWithReceiverResolver, AnnotationBasedExtension {\n    override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?) = annotations\n\n    override fun shouldConvertFirstSamParameterToReceiver(function: FunctionDescriptor): Boolean {\n        return (function.containingDeclaration as? ClassDescriptor)?.hasSpecialAnnotation(null) ?: false\n    }\n}\n\nclass KotlinEnvironment private constructor(val eclipseProject: IProject, disposable: Disposable) :\n        KotlinCommonEnvironment(disposable) {\n\n    override val javaProject = JavaCore.create(eclipseProject)\n\n    val projectCompilerProperties: KotlinProperties = KotlinProperties(ProjectScope(eclipseProject))\n\n    val compilerProperties: KotlinProperties\n        get() = projectCompilerProperties.takeIf { it.globalsOverridden } ?: KotlinProperties.workspaceInstance\n\n    val projectBuildingProperties: KotlinBuildingProperties = KotlinBuildingProperties(ProjectScope(eclipseProject))\n\n    val buildingProperties: KotlinBuildingProperties\n        get() = projectBuildingProperties.takeIf { it.globalsOverridden } ?: KotlinBuildingProperties.workspaceInstance\n\n    val index by lazy { JvmDependenciesIndexImpl(getRoots().toList()) }\n\n    init {\n        registerProjectDependenServices(javaProject)\n        configureClasspath(javaProject)\n\n        with(project) {\n            registerService(FacadeCache::class.java, FacadeCache(project))\n        }\n\n        registerCompilerPlugins()\n\n        cachedEnvironment.putEnvironment(eclipseProject, this)\n    }\n\n    private fun registerProjectDependenServices(javaProject: IJavaProject) {\n        val finderFactory = EclipseVirtualFileFinderFactory(javaProject)\n        project.registerService(VirtualFileFinderFactory::class.java, finderFactory)\n        project.registerService(MetadataFinderFactory::class.java, finderFactory)\n        project.registerService(KotlinLightClassManager::class.java, KotlinLightClassManager(javaProject.project))\n    }\n\n    private fun registerCompilerPlugins() {\n        compilerProperties.compilerPlugins.entries\n                .filter { it.active }\n                .forEach { registerCompilerPlugin(it) }\n    }\n\n    private fun registerCompilerPlugin(it: CompilerPlugin) {\n        val jarLoader = it.jarPath\n                ?.replace(\"\\$KOTLIN_HOME\", ProjectUtils.ktHome)\n                ?.let { URL(\"file://$it\") }\n                ?.let { URLClassLoader(arrayOf(it), this::class.java.classLoader) }\n\n        val cliProcessor = jarLoader?.loadService<CommandLineProcessor>()\n        val registrar = jarLoader?.loadService<ComponentRegistrar>()\n\n        if (cliProcessor != null && registrar != null) {\n            with(cliProcessor) {\n                val configuration = CompilerConfiguration().apply { applyOptionsFrom(parseOptions(it.args), pluginOptions) }\n                registrar.registerProjectComponents(project, configuration)\n            }\n        }\n    }\n\n    private inline fun <reified T : Any> ClassLoader.loadService(): T? =\n            ServiceLoader.load(T::class.java, this)\n                    .singleOrNull { it::class.java.classLoader == this }\n\n    private fun parseOptions(args: List<String>): Map<String, List<String>> =\n            args.asSequence()\n                    .map { parsePluginOption(\"plugin:$it\") }\n                    .filterNotNull()\n                    .groupBy(CliOptionValue::optionName, CliOptionValue::value)\n\n    private fun configureClasspath(javaProject: IJavaProject) {\n        if (!javaProject.exists()) return\n\n        val tempFiles = try {\n            ProjectUtils.collectClasspathWithDependenciesForBuild(javaProject)\n        } catch (e: DependencyResolverException) {\n            hasError = true\n            e.resolvedFiles\n            e.resolvedFiles\n        }\n        tempFiles.forEach(::addToClasspath)\n    }\n\n    companion object {\n        private val cachedEnvironment = CachedEnvironment<IProject, KotlinEnvironment>()\n        private val environmentCreation = { eclipseProject: IProject ->\n            KotlinEnvironment(eclipseProject, Disposer.newDisposable(\"Project Env ${eclipseProject.name}\"))\n        }\n\n        @JvmStatic\n        fun getEnvironment(eclipseProject: IProject): KotlinEnvironment =\n            cachedEnvironment.getOrCreateEnvironment(eclipseProject, environmentCreation)\n\n        @JvmStatic\n        fun removeEnvironment(eclipseProject: IProject) {\n            cachedEnvironment.removeEnvironment(eclipseProject)\n            KotlinPsiManager.invalidateCachedProjectSourceFiles()\n            KotlinAnalysisFileCache.resetCache()\n            KotlinAnalysisProjectCache.resetCache(eclipseProject)\n        }\n\n        fun removeEnvironmentIf(check: (KotlinCommonEnvironment) -> Boolean) {\n            val tempRemoved = cachedEnvironment.removeEnvironmentIf(check)\n            if(tempRemoved.isNotEmpty()) {\n                KotlinPsiManager.invalidateCachedProjectSourceFiles()\n                KotlinAnalysisFileCache.resetCache()\n                for (removedPrj in tempRemoved) {\n                    KotlinAnalysisProjectCache.resetCache(removedPrj)\n                }\n            }\n        }\n\n        @JvmStatic\n        fun removeAllEnvironments() {\n            cachedEnvironment.removeAllEnvironments()\n            KotlinPsiManager.invalidateCachedProjectSourceFiles()\n            KotlinAnalysisFileCache.resetCache()\n            KotlinAnalysisProjectCache.resetAllCaches()\n        }\n\n        @JvmStatic\n        fun getJavaProject(project: Project): IProject? = cachedEnvironment.getEclipseResource(project)\n\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinJavaManager.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.resources.IFolder\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.*\nimport org.eclipse.jdt.core.dom.IBinding\nimport org.eclipse.jdt.core.dom.IMethodBinding\nimport org.jetbrains.kotlin.core.asJava.equalsJvmSignature\nimport org.jetbrains.kotlin.core.asJava.getTypeFqName\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.filesystem.KotlinFileSystem\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElement\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\n\nobject KotlinJavaManager {\n    @JvmField\n    val KOTLIN_BIN_FOLDER: Path = Path(\"kotlin_bin\")\n    \n    fun getKotlinBinFolderFor(project: IProject): IFolder = project.getFolder(KOTLIN_BIN_FOLDER)\n    \n    fun findEclipseType(jetClass: KtClassOrObject, javaProject: IJavaProject): IType? {\n        return jetClass.fqName.let {\n            if (it != null) javaProject.findType(it.asString()) else null\n        }\n    }\n    \n    fun <T : IMember> findEclipseMembers(declaration: KtDeclaration, javaProject: IJavaProject,\n            klass: Class<T>): List<IMember> {\n        val containingElement = PsiTreeUtil.getParentOfType(declaration, KtClassOrObject::class.java, KtFile::class.java)\n        val seekInParent: Boolean = containingElement is KtObjectDeclaration && containingElement.isCompanion()\n        \n        if (containingElement == null) return emptyList()\n        \n        val declaringTypeFqName = getTypeFqName(containingElement) ?: return emptyList()\n\n        val eclipseType = javaProject.findType(declaringTypeFqName.asString()) ?: return emptyList()\n\n        val typeMembers = findMembersIn(eclipseType, declaration, klass)\n        return if (seekInParent) {\n                val parentMembers = findMembersIn(eclipseType.declaringType, declaration, klass)\n                typeMembers + parentMembers\n            } else {\n                typeMembers\n            }\n    }\n    \n    fun hasLinkedKotlinBinFolder(project: IProject): Boolean {\n        val folder = project.getFolder(KOTLIN_BIN_FOLDER)\n        return folder.isLinked && KotlinFileSystem.SCHEME == folder.locationURI.scheme\n    }\n    \n    private fun <T : IMember> findMembersIn(eclipseType: IType, declaration: KtDeclaration, klass: Class<T>): List<IMember> {\n        \n        fun check(member: IMember): Boolean { \n            return klass.isAssignableFrom(member.javaClass) && equalsJvmSignature(declaration, member)\n        }\n        \n        val methods = eclipseType.methods.filter { check(it) }\n        val fields = eclipseType.fields.filter { check(it) }\n        \n        return methods + fields\n    }\n}\n\nfun KtElement.toLightElements(): List<IJavaElement> {\n    val javaProject = KotlinPsiManager.getJavaProject(this)\n    if (javaProject == null) {\n        KotlinLogger.logWarning(\"Cannot resolve jetElement ($this) to light elements: there is no corresponding java project\")\n        return emptyList()\n    }\n    \n    if (!javaProject.isOpen) {\n        return emptyList()\n    }\n    \n    return when (this) {\n        is KtClassOrObject -> KotlinJavaManager.findEclipseType(this, javaProject)?.let(::listOf) ?: emptyList()\n        is KtNamedFunction,\n        is KtSecondaryConstructor,\n        is KtPrimaryConstructor,\n        is KtPropertyAccessor -> KotlinJavaManager.findEclipseMembers(this as KtDeclaration, javaProject, IMethod::class.java)\n        is KtProperty -> {\n            val list = KotlinJavaManager.findEclipseMembers(this, javaProject, IMember::class.java)\n            val getterList = getter?.toLightElements() ?: emptyList()\n            val setterList = setter?.toLightElements() ?: emptyList()\n            list + getterList + setterList\n        }\n        else -> emptyList()\n    }\n}\n\nfun SourceElement.toJavaElements(): List<IJavaElement> {\n    return when (this) {\n        is EclipseJavaSourceElement -> obtainJavaElement(elementBinding)?.let(::listOf) ?: emptyList()\n        is KotlinSourceElement -> psi.toLightElements()\n        else -> emptyList()\n    }\n}\n\nfun sourceElementsToLightElements(sourceElements: List<SourceElement>): List<IJavaElement> {\n    return sourceElements.flatMap { it.toJavaElements() }\n}\n\nprivate fun obtainJavaElement(binding: IBinding): IJavaElement? {\n    return if (binding is IMethodBinding && binding.isDefaultConstructor) {\n        binding.declaringClass.javaElement\n    } else {\n        binding.javaElement\n    }\n}\n\n\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinLightVirtualFile.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport com.intellij.testFramework.LightVirtualFile\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport org.eclipse.core.resources.IFile\n\npublic class KotlinLightVirtualFile(file: IFile, text: String) : \n        LightVirtualFile(file.getName(), KotlinLanguage.INSTANCE, text) {\n    private val path = file.getRawLocation().toOSString()\n    \n    override fun getPath(): String = path\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinNature.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport org.eclipse.core.resources.*\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport java.util.*\nimport kotlin.properties.Delegates\n\nclass KotlinNature : IProjectNature {\n    companion object {\n        val KOTLIN_NATURE: String = \"org.jetbrains.kotlin.core.kotlinNature\"\n        @JvmField\n        val KOTLIN_BUILDER: String = \"org.jetbrains.kotlin.ui.kotlinBuilder\"\n\n        @JvmStatic\n        fun hasKotlinNature(project: IProject): Boolean {\n            return project.hasNature(KOTLIN_NATURE)\n        }\n\n        @JvmStatic\n        fun hasKotlinBuilder(project: IProject): Boolean {\n            if (!project.isAccessible) return false\n\n            return project.description.buildSpec.any {\n                KOTLIN_BUILDER == it.builderName\n            }\n        }\n\n        @JvmStatic\n        fun addNature(project: IProject) {\n            if (hasKotlinNature(project)) return\n\n            project.modifyDescription {\n                natureIds += KOTLIN_NATURE\n            }\n        }\n\n        fun removeNature(project: IProject) {\n            if (!hasKotlinNature(project)) return\n\n            project.modifyDescription {\n                natureIds = natureIds.filterNot { it == KOTLIN_NATURE }.toTypedArray()\n            }\n        }\n\n        private fun IProject.modifyDescription(operation: IProjectDescription.() -> Unit) {\n            description.apply(operation)\n                .also { setDescription(it, null) }\n        }\n    }\n\n    var eclipseProject: IProject by Delegates.notNull()\n\n    override fun configure() {\n        addKotlinBuilder(eclipseProject)\n        setPreferredCodeStyle(eclipseProject)\n    }\n\n    override fun deconfigure() {\n        removeKotlinBuilder(eclipseProject)\n        KotlinPsiManager.removeProjectFromManager(eclipseProject)\n        KotlinAnalysisFileCache.resetCache()\n        KotlinAnalysisProjectCache.resetCache(eclipseProject)\n    }\n\n    override fun setProject(project: IProject) {\n        eclipseProject = project\n    }\n\n    override fun getProject(): IProject = eclipseProject\n\n    private fun addKotlinBuilder(project: IProject) {\n        if (!hasKotlinBuilder(project)) {\n            val description = project.description\n\n            val kotlinBuilderCommand = description.newCommand().apply { builderName = KOTLIN_BUILDER }\n\n            val newBuildCommands = description.buildSpec.toCollection(LinkedList())\n            newBuildCommands.addFirst(kotlinBuilderCommand)\n\n            description.buildSpec = newBuildCommands.toTypedArray()\n            project.setDescription(description, null)\n        }\n    }\n\n    private fun setPreferredCodeStyle(eclipseProject: IProject) {\n        KotlinCodeStyleProperties(ProjectScope(eclipseProject)).apply {\n            codeStyleId = \"KOTLIN_OFFICIAL\"\n            globalsOverridden = true\n            saveChanges()\n        }\n\n    }\n\n    private fun removeKotlinBuilder(project: IProject) {\n        if (hasKotlinBuilder(project)) {\n            val description = project.description\n            val newBuildCommands = description.buildSpec.filter { it.builderName != KotlinNature.KOTLIN_BUILDER }\n\n            description.buildSpec = newBuildCommands.toTypedArray()\n            project.setDescription(description, null)\n        }\n    }\n}\n\n// Place Kotlin Builder before Java Builder to avoid red code in Java about Kotlin references \nfun setKotlinBuilderBeforeJavaBuilder(project: IProject) {\n    val job = object : Job(\"Swap Kotlin builder with Java Builder\") {\n        override fun run(monitor: IProgressMonitor?): IStatus? {\n            val description = project.description\n\n            val builders = description.buildSpec.toCollection(LinkedList())\n            val kotlinBuilderIndex = builders.indexOfFirst { it.builderName == KotlinNature.KOTLIN_BUILDER }\n            val javaBuilderIndex = builders.indexOfFirst { it.builderName == JavaCore.BUILDER_ID }\n\n            if (kotlinBuilderIndex >= 0 && javaBuilderIndex >= 0 && javaBuilderIndex < kotlinBuilderIndex) {\n                Collections.swap(builders, kotlinBuilderIndex, javaBuilderIndex)\n\n                description.buildSpec = builders.toTypedArray()\n                project.setDescription(description, monitor)\n            }\n\n            return Status.OK_STATUS\n        }\n    }\n\n    job.rule = ResourcesPlugin.getWorkspace().root\n    job.schedule()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/KotlinRefreshProjectListener.kt",
    "content": "package org.jetbrains.kotlin.core.model\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.IResourceChangeEvent\nimport org.eclipse.core.resources.IResourceChangeListener\nimport org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration\n\npublic object KotlinRefreshProjectListener : IResourceChangeListener {\n    override fun resourceChanged(event: IResourceChangeEvent) {\n        if (event.type == IResourceChangeEvent.PRE_REFRESH) {\n            val delta = event.getDelta()\n            if (delta == null) {\n                tryUpdateLightClassesFor(event.resource)\n                return\n            }\n            \n            delta.accept { visitorDelta ->\n                val resource = visitorDelta.getResource()\n                if (resource is IProject) {\n                    tryUpdateLightClassesFor(resource)\n                    return@accept false\n                }\n                \n                true\n            }\n        }\n    }\n    \n    private fun tryUpdateLightClassesFor(resource: IResource?) {\n        if (resource is IProject && KotlinNature.hasKotlinNature(resource)) {\n            KotlinLightClassGeneration.updateLightClasses(resource, emptySet(), true)\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/executableEP.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IConfigurationElement\nimport org.eclipse.core.runtime.Platform\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\n\nfun <T> loadExecutableEP(extensionPointId: String, isCaching: Boolean = false): List<ExecutableExtensionPointDescriptor<T>> {\n    return Platform\n            .getExtensionRegistry()\n            .getConfigurationElementsFor(extensionPointId)\n            .map { ExecutableExtensionPointDescriptor<T>(it, isCaching) }\n}\n\nclass ExecutableExtensionPointDescriptor<T>(\n    private val configurationElement: IConfigurationElement,\n    private val isCaching: Boolean = false\n) {\n    companion object {\n        private const val CLASS = \"class\"\n    }\n\n    private var cachedProvider: T? = null\n\n    val attributes: Map<String, String> = configurationElement.run {\n        attributeNames\n            .map { it to getAttribute(it) }\n            .toMap()\n    }\n\n    @Suppress(\"UNCHECKED_CAST\")\n    fun createProvider(): T? {\n        return cachedProvider ?: try {\n            val provider = (configurationElement.createExecutableExtension(CLASS) as T?)\n            if (isCaching) {\n                cachedProvider = provider\n            }\n            provider\n        } catch(e: CoreException) {\n            KotlinLogger.logError(e)\n            null\n        }\n    }\n\n    fun providedClass(): KClass<out Any>? = configurationElement.getAttribute(CLASS)?.let { Class.forName(it).kotlin }\n}\n\nobject EPAttribute {\n    operator fun getValue(thisRef: ExecutableExtensionPointDescriptor<*>, property: KProperty<*>): String? =\n            thisRef.attributes[property.name]\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/model/kotlinModelUtils.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.model\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.jobs.IJobChangeEvent\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.core.runtime.jobs.JobChangeAdapter\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.eclipse.core.resources.ResourcesPlugin\n\nfun unconfigureKotlinProject(javaProject: IJavaProject) {\n    val project = javaProject.getProject()\n    \n    unconfigureKotlinNature(project)\n    unconfigureKotlinRuntime(javaProject)\n    removeKotlinBinFolder(project)\n}\n\nfun unconfigureKotlinNature(project: IProject) {\n    if (KotlinNature.hasKotlinNature(project)) {\n        val description = project.getDescription()\n        val newNatures = description.getNatureIds().filter { it != KotlinNature.KOTLIN_NATURE }\n        \n        description.setNatureIds(newNatures.toTypedArray())\n        project.setDescription(description, null)\n    }\n}\n\nfun unconfigureKotlinRuntime(javaProject: IJavaProject) {\n    if (ProjectUtils.hasKotlinRuntime(javaProject.getProject())) {\n        val newEntries = javaProject.getRawClasspath().filterNot {\n            ProjectUtils.equalsEntriesPaths(it, KotlinClasspathContainer.CONTAINER_ENTRY)\n        }\n        \n        javaProject.setRawClasspath(newEntries.toTypedArray(), null)\n    }\n}\n\nfun removeKotlinBinFolder(project: IProject) {\n    val kotlinBinFolder = KotlinJavaManager.getKotlinBinFolderFor(project)\n    kotlinBinFolder.delete(true, null)\n}\n\nfun canBeDeconfigured(project: IProject): Boolean {\n    return when {\n        KotlinNature.hasKotlinNature(project) || ProjectUtils.hasKotlinRuntime(project) -> true\n        else -> false\n    }\n}\n\nfun isConfigurationMissing(project: IProject): Boolean {\n    return when {\n        !KotlinNature.hasKotlinNature(project) || !ProjectUtils.hasKotlinRuntime(project) -> true\n        else -> false\n    }\n}\n\nfun runJob(name: String, priority: Int = Job.LONG, action: (IProgressMonitor) -> IStatus) {\n    runJob(name, priority, null, action, {})\n}\n\nfun runJob(\n        name: String,\n        priority: Int = Job.LONG,\n        jobFamily: Any? = null,\n        action: (IProgressMonitor) -> IStatus,\n        postTask: (IJobChangeEvent) -> Unit\n): Job {\n    val job = object : Job(name) {\n        override fun run(monitor: IProgressMonitor): IStatus {\n            return action(monitor)\n        }\n        \n        override fun belongsTo(family: Any?): Boolean {\n            return jobFamily?.equals(family) ?: super.belongsTo(family)\n        }\n    }\n    \n    job.setPriority(priority)\n    job.setRule(ResourcesPlugin.getWorkspace().getRoot());\n    \n    job.addJobChangeListener(object : JobChangeAdapter() {\n        override fun done(event: IJobChangeEvent) {\n            postTask(event)\n        }\n    })\n    \n    job.schedule()\n    \n    return job\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/preferences/KotlinBuildingProperties.kt",
    "content": "package org.jetbrains.kotlin.core.preferences\n\nimport org.eclipse.core.runtime.preferences.IScopeContext\nimport org.eclipse.core.runtime.preferences.InstanceScope\nimport org.jetbrains.kotlin.core.Activator\n\nclass KotlinBuildingProperties(scope: IScopeContext = InstanceScope.INSTANCE) :\n    Preferences(scope, Activator.PLUGIN_ID) {\n\n    var globalsOverridden by BooleanPreference()\n\n    var useIncremental by BooleanPreference()\n\n    companion object {\n        val workspaceInstance by lazy { KotlinBuildingProperties() }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/preferences/KotlinCodeStyleProperties.kt",
    "content": "package org.jetbrains.kotlin.core.preferences\n\nimport org.eclipse.core.resources.ProjectScope\nimport org.eclipse.core.runtime.preferences.IScopeContext\nimport org.eclipse.core.runtime.preferences.InstanceScope\nimport org.jetbrains.kotlin.core.Activator\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager\nimport org.jetbrains.kotlin.idea.formatter.KotlinPredefinedCodeStyle\nimport org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle\nimport org.jetbrains.kotlin.psi.KtFile\n\nclass KotlinCodeStyleProperties(scope: IScopeContext = InstanceScope.INSTANCE)\n    : Preferences(scope, \"${Activator.PLUGIN_ID}/codeStyle\"\n) {\n    var globalsOverridden by BooleanPreference()\n\n    var codeStyleId by StringPreference()\n\n    companion object {\n        val workspaceInstance by lazy { KotlinCodeStyleProperties() }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/preferences/KotlinProperties.kt",
    "content": "package org.jetbrains.kotlin.core.preferences\n\nimport org.eclipse.core.runtime.preferences.DefaultScope\nimport org.eclipse.core.runtime.preferences.IScopeContext\nimport org.eclipse.core.runtime.preferences.InstanceScope\nimport org.jetbrains.kotlin.config.ApiVersion\nimport org.jetbrains.kotlin.config.JvmTarget\nimport org.jetbrains.kotlin.config.LanguageVersion\nimport org.jetbrains.kotlin.core.Activator\nimport org.osgi.service.prefs.Preferences as InternalPreferences\n\nclass KotlinProperties(scope: IScopeContext = InstanceScope.INSTANCE) : Preferences(scope, Activator.PLUGIN_ID) {\n    var globalsOverridden by BooleanPreference()\n\n    // Note: default value is defined in preferences.ini\n    var jvmTarget by object : Preference<JvmTarget> {\n        override fun reader(text: String?) = text?.let { enumValueOf<JvmTarget>(it) } ?: JvmTarget.DEFAULT\n        override fun writer(value: JvmTarget) = value.name\n    }\n\n    var languageVersion by object : Preference<LanguageVersion> {\n        override fun reader(text: String?) = text\n                ?.let { LanguageVersion.fromVersionString(it) }\n                ?: LanguageVersion.LATEST_STABLE\n\n        override fun writer(value: LanguageVersion) = value.versionString\n    }\n\n    var apiVersion by object : Preference<ApiVersion> {\n        override fun reader(text: String?): ApiVersion {\n            val apiVersionByLanguageVersion = ApiVersion.createByLanguageVersion(languageVersion)\n            return text?.let { ApiVersion.parse(it) }\n                    ?.takeIf { it <= apiVersionByLanguageVersion }\n                    ?: apiVersionByLanguageVersion\n        }\n\n        override fun writer(value: ApiVersion) = value.versionString\n    }\n\n    var jdkHome by StringPreference()\n\n    val compilerPlugins by ChildCollection(::CompilerPlugin)\n\n    var compilerFlags by StringPreference()\n\n    fun isJDKHomUndefined() = jdkHome.isNullOrBlank()\n\n    companion object {\n        // Property object in instance scope (workspace) must be created after init()\n        val workspaceInstance by lazy { KotlinProperties() }\n\n        @JvmStatic\n        fun init() {\n            // Ensure 'preferences.ini' are loaded\n            DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID)\n        }\n    }\n}\n\nclass CompilerPlugin(scope: IScopeContext, path: String) : Preferences(scope, path) {\n    var jarPath by StringPreference()\n\n    var args by ListPreference()\n\n    var active by BooleanPreference()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/preferences/KotlinPropertiesExtensions.kt",
    "content": "package org.jetbrains.kotlin.core.preferences\n\nimport org.jetbrains.kotlin.config.*\n\nprivate enum class CompilerFlagsMapping(val flag: String, vararg val alternativeFlags: String) : (List<String>) -> Pair<AnalysisFlag<*>, *>? {\n    JVM_DEFAULT(\"-Xjvm-default\") {\n        override fun invoke(value: List<String>): Pair<AnalysisFlag<JvmDefaultMode>, JvmDefaultMode>? {\n            if (value.isEmpty()) return null\n            val tempSingle = value.single()\n            return JvmDefaultMode.fromStringOrNull(tempSingle)\n                ?.let { JvmAnalysisFlags.jvmDefaultMode to it }\n        }\n    },\n    OPT_IN(\"-opt-in\", \"-Xopt-in\") {\n        override fun invoke(value: List<String>): Pair<AnalysisFlag<*>, *>? {\n            if (value.isEmpty()) return null\n            return AnalysisFlags.optIn to value\n        }\n    },\n\n    USE_XR(\"-Xuse-ir\") {\n        override fun invoke(value: List<String>): Pair<AnalysisFlag<*>, *>? {\n            if (value.isEmpty()) return null\n            val tempSingle = value.single()\n            val tempUseIr = tempSingle.toBooleanStrictOrNull()\n            return when {\n                tempUseIr != null -> JvmAnalysisFlags.useIR to tempUseIr\n                else -> null\n            }\n        }\n    };\n\n    companion object {\n        fun flagByString(flag: String) = values().firstOrNull { it.flag == flag || flag in it.alternativeFlags }\n    }\n}\n\nprivate val KotlinProperties.analyzerCompilerFlags: Map<AnalysisFlag<*>, Any?>\n    get() = compilerFlags?.split(\"\\\\s+\".toRegex())?.mapNotNull { flagString ->\n        flagString.split(\"=\", limit = 2).takeIf { it.size == 2 }\n    }?.groupBy( { (key) ->\n        key\n    }, { (_, value) ->\n        value\n    })?.mapNotNull { (key, value) ->\n        CompilerFlagsMapping.flagByString(key)?.invoke(value)\n    }.orEmpty().toMap()\n\nval KotlinProperties.languageVersionSettings: LanguageVersionSettings\n    get() = LanguageVersionSettingsImpl(languageVersion, apiVersion, analyzerCompilerFlags)"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/preferences/Preferences.kt",
    "content": "package org.jetbrains.kotlin.core.preferences\n\nimport org.eclipse.core.runtime.preferences.ConfigurationScope\nimport org.eclipse.core.runtime.preferences.DefaultScope\nimport org.eclipse.core.runtime.preferences.IScopeContext\nimport org.eclipse.core.runtime.preferences.InstanceScope\nimport org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult\nimport kotlin.properties.ReadOnlyProperty\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KProperty\nimport org.osgi.service.prefs.Preferences as OsgiPreferences\n\nprivate val SCOPES = listOf(InstanceScope.INSTANCE, ConfigurationScope.INSTANCE, DefaultScope.INSTANCE)\n\n/**\n * Wrapper of a preference node ([OsgiPreferences]).\n * Allows querying a non-existent node without creating it.\n */\ninternal open class ReadableStore(protected val scope: IScopeContext, protected val path: String) {\n    protected var node: OsgiPreferences? =\n            if (scope.getNode(\"\").nodeExists(path)) scope.getNode(path)\n            else null\n\n    protected val guaranteedNode: OsgiPreferences\n        get() = node ?: scope.getNode(path).also { node = it }\n\n    val exists: Boolean\n        get() = node != null\n\n    val keysOfValues: Set<String>\n        get() = node?.keys()?.toSet() ?: emptySet()\n\n    val keysOfChildren: Set<String>\n        get() = node?.childrenNames()?.toSet() ?: emptySet()\n\n    fun getValue(key: String): String? = node?.get(key, null)\n}\n\n/**\n * Extends [ReadableStore] with [setValue], [removeValue] and [deleteSelf] operations.\n * These operations modify the node.\n */\ninternal class WritableStore(scope: IScopeContext, path: String) : ReadableStore(scope, path) {\n    fun setValue(key: String, value: String) {\n        // Create node if it doesn't exist\n        with(guaranteedNode) {\n            put(key, value)\n            flush()\n        }\n    }\n\n    fun removeValue(key: String) {\n        // Create node if it doesn't exist\n        with(guaranteedNode) {\n            remove(key)\n            flush()\n        }\n    }\n\n    fun deleteSelf() {\n        // Create and then delete node\n        with(guaranteedNode) {\n            val parent = parent()\n            removeNode()\n            parent.flush()\n        }\n        node = null\n    }\n}\n\nabstract class PreferencesBase(scope: IScopeContext, path: String) {\n    internal val mainStore = WritableStore(scope, path)\n    internal val inheritedStores = SCOPES.takeLastWhile { scope::class != it::class }\n            .map { ReadableStore(it, path) }\n\n    abstract fun loadDefaults() // Does not save changes\n\n    abstract fun saveChanges()\n    abstract fun cancelChanges()\n}\n\nabstract class Preferences(private val scope: IScopeContext, private val path: String) : PreferencesBase(scope, path) {\n\n    val key: String = path.takeLastWhile { it != '/' }\n\n    private val childPreferences: MutableList<PreferencesBase> = mutableListOf()\n\n    // Unsaved changes\n    private var markedForDeletion: Boolean = !mainStore.exists\n    private val modifiedValues: MutableMap<String, String> = hashMapOf()\n    private val removedValues: MutableSet<String> = hashSetOf()\n\n    val existsInOwnScope: Boolean\n        get() = !markedForDeletion\n\n    val keysInOwnScope: Set<String>\n        get() = mainStore.keysOfValues + modifiedValues.keys - removedValues\n\n    val keysInParentScopes: Set<String>\n        get() = inheritedStores.flatMap { it.keysOfValues }.toSet()\n\n    val keys: Set<String>\n        get() = keysInOwnScope + keysInParentScopes\n\n    // Does not save changes\n    fun getValue(key: String): String? =\n            when (key) {\n                in modifiedValues -> modifiedValues[key]\n                in removedValues -> null\n                else -> mainStore.getValue(key)\n            } ?: inheritedStores.firstNotNullOfOrNull { it.getValue(key) }\n\n    // Does not save changes\n    fun setValue(key: String, value: String) {\n        removedValues -= key\n        modifiedValues[key] = value\n        markedForDeletion = false\n    }\n\n    // Does not save changes\n    fun removeValue(key: String) {\n        modifiedValues -= key\n        removedValues += key\n        markedForDeletion = false\n    }\n\n    // Does not save changes\n    override fun loadDefaults() {\n        modifiedValues.clear()\n        removedValues.clear()\n\n        removedValues += mainStore.keysOfValues\n        markedForDeletion = false\n        childPreferences.forEach { it.loadDefaults() }\n    }\n\n    // Does not save changes\n    fun delete() {\n        loadDefaults()\n        markedForDeletion = true\n    }\n\n    override fun saveChanges() {\n        if (markedForDeletion) {\n            mainStore.deleteSelf()\n        } else {\n            modifiedValues.forEach { key, value -> mainStore.setValue(key, value) }\n            removedValues.forEach { key -> mainStore.removeValue(key) }\n            childPreferences.forEach { it.saveChanges() }\n        }\n        modifiedValues.clear()\n        removedValues.clear()\n    }\n\n    override fun cancelChanges() {\n        modifiedValues.clear()\n        removedValues.clear()\n        markedForDeletion = !mainStore.exists\n        childPreferences.forEach { it.cancelChanges() }\n    }\n\n    protected interface Preference<T> : ReadWriteProperty<Preferences, T> {\n        fun reader(text: String?): T\n        fun writer(value: T): String?\n\n        override operator fun getValue(thisRef: Preferences, property: KProperty<*>): T =\n                thisRef.getValue(property.name).let(::reader)\n\n        override operator fun setValue(thisRef: Preferences, property: KProperty<*>, value: T) =\n                writer(value).let {\n                    if (it != null) thisRef.setValue(property.name, it)\n                    else thisRef.removeValue(property.name)\n                }\n    }\n\n    protected class StringPreference : Preference<String?> {\n        override fun reader(text: String?) = text\n        override fun writer(value: String?) = value\n    }\n\n    protected class BooleanPreference : Preference<Boolean> {\n        override fun reader(text: String?) = text?.toBoolean() ?: false\n        override fun writer(value: Boolean) = value.toString()\n    }\n\n    protected class ListPreference(val separator: String = \"|\") : Preference<List<String>> {\n        override fun reader(text: String?) = text?.split(separator)?.filter(String::isNotEmpty) ?: listOf()\n        override fun writer(value: List<String>) = value.joinToString(separator)\n    }\n\n    protected inline fun <reified T : Enum<T>> EnumPreference(defaultValue: T): ReadWriteProperty<Preferences, T> =\n            object : Preference<T> {\n                override fun reader(text: String?) = text?.let { enumValueOf<T>(it) } ?: defaultValue\n                override fun writer(value: T) = value.name\n            }\n\n    protected class ChildCollection<T : Preferences>(val factory: (IScopeContext, String) -> T) {\n        operator fun provideDelegate(thisRef: Preferences, property: KProperty<*>) =\n                object : ReadOnlyProperty<Preferences, PreferencesCollection<T>> {\n                    val instance by lazy {\n                        PreferencesCollection(thisRef.scope, \"${thisRef.path}/${property.name}\", factory)\n                                .also { thisRef.childPreferences.add(it) }\n                    }\n\n                    override fun getValue(thisRef: Preferences, property: KProperty<*>): PreferencesCollection<T> = instance\n                }\n    }\n}\n\nclass PreferencesCollection<T : Preferences>(\n        private val scope: IScopeContext,\n        private val path: String,\n        private val elementFactory: (IScopeContext, String) -> T\n) : PreferencesBase(scope, path) {\n\n    private val cache = mutableMapOf<String, T>()\n\n    val entries: List<T>\n        get() = keys.map { get(it) }\n\n    private val keysInOwnScope: Set<String>\n        get() = mainStore.keysOfChildren + cache.keys - cache.filterValues { !it.existsInOwnScope }.keys\n\n    private val keysInParentScopes: Set<String>\n        get() = inheritedStores.flatMap { it.keysOfChildren }.toSet()\n\n    private val keys: Set<String>\n        get() = keysInOwnScope + keysInParentScopes\n\n    private fun makeCache(key: String): T = cache.getOrPut(key) { elementFactory(scope, \"$path/$key\") }\n\n    operator fun contains(key: String): Boolean = key in keys\n\n    operator fun get(key: String): T = makeCache(key)\n\n    // Does not save changes\n    override fun loadDefaults() {\n        cache.clear()\n        entries.forEach { it.delete() }\n    }\n\n    override fun saveChanges() {\n        cache.values.forEach { it.saveChanges() }\n    }\n\n    override fun cancelChanges() {\n        cache.clear()\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/references/KotlinReference.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.references\n\nimport com.intellij.util.SmartList\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors\nimport org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.getParentOfType\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall\nimport org.jetbrains.kotlin.resolve.calls.util.getCall\nimport org.jetbrains.kotlin.resolve.calls.util.getResolvedCall\nimport org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor\nimport org.jetbrains.kotlin.types.expressions.OperatorConventions\nimport org.jetbrains.kotlin.util.OperatorNameConventions\nimport org.jetbrains.kotlin.utils.addIfNotNull\n\ninline private fun <reified T : KtElement> ArrayList<KotlinReference<*>>.register(\n    e: KtElement,\n    action: (T) -> KotlinReference<T>\n) {\n    if (e is T) this.add(action(e))\n}\n\ninline private fun <reified T : KtElement> ArrayList<KotlinReference<*>>.registerMulti(\n    e: KtElement,\n    action: (T) -> List<KotlinReference<*>>\n) {\n    if (e is T) this.addAll(action(e))\n}\n\npublic fun createReferences(element: KtElement): List<KotlinReference<*>> {\n    return arrayListOf<KotlinReference<*>>().apply {\n        register(element, ::KotlinSimpleNameReference)\n\n        register(element, ::KotlinInvokeFunctionReference)\n\n        register(element, ::KotlinConstructorDelegationReference)\n\n        registerMulti<KtNameReferenceExpression>(element) {\n            if (it.getReferencedNameElementType() != KtTokens.IDENTIFIER) return@registerMulti emptyList()\n\n            when (it.readWriteAccess()) {\n                ReferenceAccess.READ -> listOf(KotlinSyntheticPropertyAccessorReference.Getter(it))\n                ReferenceAccess.WRITE -> listOf(KotlinSyntheticPropertyAccessorReference.Setter(it))\n                ReferenceAccess.READ_WRITE -> listOf(\n                    KotlinSyntheticPropertyAccessorReference.Getter(it),\n                    KotlinSyntheticPropertyAccessorReference.Setter(it)\n                )\n            }\n        }\n        register<KtArrayAccessExpression>(element, ::KotlinReferenceExpressionReference)\n\n        register(element, ::KotlinKtPropertyDelegateReference)\n    }\n}\n\npublic interface KotlinReference<in R : KtElement> {\n\n    val expression: KtElement\n\n    fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor>\n\n    val resolvesByNames: Collection<Name>\n}\n\nclass KotlinKtPropertyDelegateReference(override val expression: KtPropertyDelegate) :\n    KotlinReference<KtPropertyDelegate> {\n\n    override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {\n        val tempProperty = expression.getParentOfType<KtProperty>(false) ?: return emptyList()\n        val tempDescriptor =\n            tempProperty.resolveToDescriptorIfAny() as? VariableDescriptorWithAccessors ?: return emptyList()\n        val tempProviderDescriptor = context[BindingContext.PROVIDE_DELEGATE_RESOLVED_CALL, tempDescriptor]?.candidateDescriptor\n        val tempGetDescriptor = tempDescriptor.getter?.let { context[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, it]?.candidateDescriptor }\n        val tempSetDescriptor = tempDescriptor.setter?.let { context[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, it]?.candidateDescriptor }\n\n        return listOfNotNull(tempProviderDescriptor, tempGetDescriptor, tempSetDescriptor)\n    }\n\n    override val resolvesByNames: Collection<Name>\n        get() = emptyList()\n\n}\n\nopen class KotlinSimpleNameReference(override val expression: KtSimpleNameExpression) :\n    KotlinReference<KtSimpleNameExpression> {\n    override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {\n        return expression.getReferenceTargets(context)\n    }\n\n    override val resolvesByNames: Collection<Name>\n        get() {\n            val element = expression\n\n            if (element is KtOperationReferenceExpression) {\n                val tokenType = element.operationSignTokenType\n                if (tokenType != null) {\n                    val name = OperatorConventions.getNameForOperationSymbol(\n                        tokenType, element.parent is KtUnaryExpression, element.parent is KtBinaryExpression\n                    ) ?: return emptyList()\n                    val counterpart = OperatorConventions.ASSIGNMENT_OPERATION_COUNTERPARTS[tokenType]\n                    return if (counterpart != null) {\n                        val counterpartName = OperatorConventions.getNameForOperationSymbol(counterpart, false, true)!!\n                        listOf(name, counterpartName)\n                    } else {\n                        listOf(name)\n                    }\n                }\n            }\n\n            return listOf(element.getReferencedNameAsName())\n        }\n}\n\npublic class KotlinInvokeFunctionReference(override val expression: KtCallExpression) :\n    KotlinReference<KtCallExpression> {\n    override val resolvesByNames: Collection<Name>\n        get() = listOf(OperatorNameConventions.INVOKE)\n\n    override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {\n        val call = expression.getCall(context)\n        val resolvedCall = call.getResolvedCall(context)\n        return when {\n            resolvedCall is VariableAsFunctionResolvedCall -> listOf(resolvedCall.functionCall.getCandidateDescriptor())\n            call != null && resolvedCall != null && call.getCallType() == Call.CallType.INVOKE -> listOf(resolvedCall.getCandidateDescriptor())\n            else -> emptyList()\n        }\n    }\n}\n\nsealed class KotlinSyntheticPropertyAccessorReference(\n    expression: KtNameReferenceExpression,\n    private val getter: Boolean\n) : KotlinSimpleNameReference(expression) {\n    override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {\n        val descriptors = super.getTargetDescriptors(context)\n        if (descriptors.none { it is SyntheticJavaPropertyDescriptor }) return emptyList()\n\n        val result = SmartList<FunctionDescriptor>()\n        for (descriptor in descriptors) {\n            if (descriptor is SyntheticJavaPropertyDescriptor) {\n                if (getter) {\n                    result.add(descriptor.getMethod)\n                } else {\n                    result.addIfNotNull(descriptor.setMethod)\n                }\n            }\n        }\n        return result\n    }\n\n    override val resolvesByNames: Collection<Name>\n        get() = listOf(expression.getReferencedNameAsName())\n\n    class Getter(expression: KtNameReferenceExpression) : KotlinSyntheticPropertyAccessorReference(expression, true)\n    class Setter(expression: KtNameReferenceExpression) : KotlinSyntheticPropertyAccessorReference(expression, false)\n}\n\npublic class KotlinConstructorDelegationReference(override val expression: KtConstructorDelegationReferenceExpression) :\n    KotlinReference<KtConstructorDelegationReferenceExpression> {\n    override fun getTargetDescriptors(context: BindingContext) = expression.getReferenceTargets(context)\n\n    override val resolvesByNames: Collection<Name>\n        get() = emptyList()\n}\n\nclass KotlinReferenceExpressionReference(override val expression: KtReferenceExpression) :\n    KotlinReference<KtReferenceExpression> {\n    override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {\n        return expression.getReferenceTargets(context)\n    }\n\n    override val resolvesByNames: Collection<Name>\n        get() = emptyList()\n\n}\n\nfun KtReferenceExpression.getReferenceTargets(context: BindingContext): Collection<DeclarationDescriptor> {\n    val targetDescriptor = context[BindingContext.REFERENCE_TARGET, this]\n    return if (targetDescriptor != null) {\n        listOf(targetDescriptor)\n    } else {\n        context[BindingContext.AMBIGUOUS_REFERENCE_TARGET, this].orEmpty()\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/references/referenceUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.references\n\nimport com.intellij.openapi.util.Key\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.resolve.EclipseDescriptorUtils\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors\nimport org.jetbrains.kotlin.descriptors.accessors\nimport org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny\nimport org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport\nimport org.jetbrains.kotlin.idea.util.CallTypeAndReceiver\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS\nimport org.jetbrains.kotlin.psi.psiUtil.getParentOfType\nimport org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isExtension\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.utils.addToStdlib.constant\n\nval FILE_PROJECT: Key<IJavaProject> = Key.create(\"FILE_PROJECT\")\n\nfun List<KotlinReference<*>>.resolveToSourceElements(ktFile: KtFile): List<SourceElement> {\n    if (isEmpty()) return emptyList()\n\n    val javaProject = JavaCore.create(KotlinPsiManager.getEclipseFile(ktFile)?.project)\n        ?: ktFile.getUserData(FILE_PROJECT) ?: return emptyList()\n\n    return resolveToSourceElements(ktFile.getBindingContext(), javaProject)\n}\n\nfun List<KotlinReference<*>>.resolveToSourceElements(\n    context: BindingContext,\n    javaProject: IJavaProject\n): List<SourceElement> {\n    return flatMap { it.getTargetDescriptors(context) }\n        .flatMap { EclipseDescriptorUtils.descriptorToDeclarations(it, javaProject.project) }\n}\n\nfun getReferenceExpression(element: PsiElement): KtReferenceExpression? {\n    return PsiTreeUtil.getNonStrictParentOfType(element, KtReferenceExpression::class.java)\n}\n\nfun KtElement.resolveToSourceDeclaration(): List<SourceElement> {\n    return when (val jetElement = this) {\n        is KtDeclaration -> listOf(KotlinSourceElement(jetElement))\n        else -> {\n            // Try search declaration by reference\n            val referenceExpression = getReferenceExpression(jetElement) ?: jetElement\n            val reference = createReferences(referenceExpression)\n            reference.resolveToSourceElements(jetElement.containingKtFile)\n        }\n    }\n}\n\nenum class ReferenceAccess(val isRead: Boolean, val isWrite: Boolean) {\n    READ(true, false), WRITE(false, true), READ_WRITE(true, true)\n}\n\nfun KtExpression.readWriteAccess(): ReferenceAccess {\n    var expression = getQualifiedExpressionForSelectorOrThis()\n    loop@ while (true) {\n        when (val parent = expression.parent) {\n            is KtParenthesizedExpression, is KtAnnotatedExpression, is KtLabeledExpression -> expression =\n                parent as KtExpression\n            else -> break@loop\n        }\n    }\n\n    val assignment = expression.getAssignmentByLHS()\n    if (assignment != null) {\n        return when (assignment.operationToken) {\n            KtTokens.EQ -> ReferenceAccess.WRITE\n            else -> ReferenceAccess.READ_WRITE\n        }\n    }\n\n    return if ((expression.parent as? KtUnaryExpression)?.operationToken in constant {\n            setOf(\n                KtTokens.PLUSPLUS,\n                KtTokens.MINUSMINUS\n            )\n        })\n        ReferenceAccess.READ_WRITE\n    else\n        ReferenceAccess.READ\n}\n\n// TODO: obtain this function from referenceUtil.kt (org.jetbrains.kotlin.idea.references)\nfun KotlinReference<*>.canBeResolvedViaImport(target: DeclarationDescriptor): Boolean {\n    if (!target.canBeReferencedViaImport()) return false\n    if (target.isExtension) return true // assume that any type of reference can use imports when resolved to extension\n    val referenceExpression = this.expression as? KtNameReferenceExpression ?: return false\n    if (CallTypeAndReceiver.detect(referenceExpression).receiver != null) return false\n    if (expression.parent is KtThisExpression || expression.parent is KtSuperExpression) return false // TODO: it's a bad design of PSI tree, we should change it\n    return true\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/BuiltInsReferenceResolver.java",
    "content": "/*\n * Copyright 2010-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.jetbrains.kotlin.core.resolve;\n\nimport com.intellij.openapi.components.ServiceManager;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.SystemInfo;\nimport com.intellij.openapi.util.text.StringUtil;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.openapi.vfs.VirtualFileManager;\nimport com.intellij.psi.PsiDirectory;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.PsiManager;\nimport com.intellij.util.Function;\nimport com.intellij.util.containers.ContainerUtil;\nimport com.intellij.util.io.URLUtil;\nimport kotlin.collections.CollectionsKt;\nimport org.eclipse.core.resources.IProject;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.analyzer.common.CommonPlatformAnalyzerServices;\nimport org.jetbrains.kotlin.builtins.DefaultBuiltIns;\nimport org.jetbrains.kotlin.builtins.KotlinBuiltIns;\nimport org.jetbrains.kotlin.builtins.StandardNames;\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl;\nimport org.jetbrains.kotlin.container.DslKt;\nimport org.jetbrains.kotlin.container.StorageComponentContainer;\nimport org.jetbrains.kotlin.context.ContextKt;\nimport org.jetbrains.kotlin.context.MutableModuleContext;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\nimport org.jetbrains.kotlin.descriptors.*;\nimport org.jetbrains.kotlin.frontend.di.InjectionKt;\nimport org.jetbrains.kotlin.name.ClassId;\nimport org.jetbrains.kotlin.name.Name;\nimport org.jetbrains.kotlin.platform.CommonPlatforms;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer;\nimport org.jetbrains.kotlin.resolve.BindingTraceContext;\nimport org.jetbrains.kotlin.resolve.CompilerEnvironment;\nimport org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;\nimport org.jetbrains.kotlin.resolve.lazy.ResolveSession;\nimport org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;\nimport org.jetbrains.kotlin.resolve.scopes.MemberScope;\n\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.util.*;\n\npublic class BuiltInsReferenceResolver {\n    private static final String RUNTIME_SRC_DIR = \"jar:file:\"+ ProjectUtils.buildLibPath(\"kotlin-stdlib-sources\")+ \"!/kotlin\";\n\n    private volatile ModuleDescriptor moduleDescriptor;\n    private volatile PackageFragmentDescriptor builtinsPackageFragment = null;\n    private final Project myProject;\n\n    public BuiltInsReferenceResolver(Project project) {\n        myProject = project;\n        initialize();\n    }\n    \n    @NotNull\n    public static BuiltInsReferenceResolver getInstance(@NotNull IProject eclipseProject) {\n        Project ideaProject = KotlinEnvironment.Companion.getEnvironment(eclipseProject).getProject();\n        return ServiceManager.getService(ideaProject, BuiltInsReferenceResolver.class);\n    }\n\n    private void initialize() {\n        if (!areSourcesExist()) {\n            return;\n        }\n        \n        Set<KtFile> jetBuiltInsFiles = getBuiltInSourceFiles();\n        \n        //if the sources are present, then the value cannot be null\n        assert (jetBuiltInsFiles != null);\n\n        Map<ModuleCapability<?>, Object> tempCapabilities = Collections.emptyMap();\n        MutableModuleContext newModuleContext = ContextKt.ContextForNewModule(\n                ContextKt.ProjectContext(myProject, \"Context for built-ins resolver module\"),\n                Name.special(\"<built-ins resolver module>\"), \n                DefaultBuiltIns.getInstance(),\n                null, tempCapabilities);\n        newModuleContext.setDependencies(newModuleContext.getModule());\n\n        StorageComponentContainer container = InjectionKt.createContainerForLazyResolve(\n                newModuleContext,\n                new FileBasedDeclarationProviderFactory(newModuleContext.getStorageManager(), jetBuiltInsFiles),\n                new BindingTraceContext(),\n                CommonPlatforms.INSTANCE.getDefaultCommonPlatform(),\n                CommonPlatformAnalyzerServices.INSTANCE,\n                CompilerEnvironment.INSTANCE,\n                LanguageVersionSettingsImpl.DEFAULT);\n        \n        ResolveSession resolveSession = DslKt.getService(container, ResolveSession.class);\n        \n        newModuleContext.initializeModuleContents(resolveSession.getPackageFragmentProvider());\n        \n        PackageViewDescriptor packageView = newModuleContext.getModule().getPackage(\n                StandardNames.BUILT_INS_PACKAGE_FQ_NAME);\n        List<PackageFragmentDescriptor> fragments = packageView.getFragments();\n        \n        moduleDescriptor = newModuleContext.getModule();\n        builtinsPackageFragment = CollectionsKt.single(fragments);\n    }\n\n    @Nullable\n    private Set<KtFile> getBuiltInSourceFiles() {\n        URL url;\n        try {\n            url = new URL(RUNTIME_SRC_DIR);\n        } catch (MalformedURLException e) {\n            return null;\n        }\n        VirtualFile vf = getSourceVirtualFile();\n        assert vf != null : \"Virtual file not found by URL: \" + url;\n        \n        PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(vf);\n        assert psiDirectory != null : \"No PsiDirectory for \" + vf;\n        return new HashSet<KtFile>(ContainerUtil.mapNotNull(psiDirectory.getFiles(), new Function<PsiFile, KtFile>() {\n            @Override\n            public KtFile fun(PsiFile file) {\n                return file instanceof KtFile ? (KtFile) file : null;\n            }\n        }));\n    }\n    \n    @Nullable\n    private VirtualFile getSourceVirtualFile() {\n        URL runtimeUrl;\n        try {\n            runtimeUrl = new URL(RUNTIME_SRC_DIR);\n            String fromUrl = convertPathFromURL(runtimeUrl);\n            return VirtualFileManager.getInstance().findFileByUrl(fromUrl);\n        } catch (MalformedURLException e) {\n            return null;\n        }\n    }\n    \n    private boolean areSourcesExist() {\n        return getSourceVirtualFile() != null;\n    }\n\n    //the method is a copy of com.intellij.openapi.vfs.VfsUtilCore.convertFromUrl(URL)\n    private String convertPathFromURL(URL url) {\n        String protocol = url.getProtocol();\n        String path = url.getPath();\n        if (protocol.equals(\"jar\")) {\n          if (StringUtil.startsWith(path, \"file:\")) {\n            try {\n              URL subURL = new URL(path);\n              path = subURL.getPath();\n            }\n            catch (MalformedURLException e) {\n                //VfsBundle.message(\"url.parse.unhandled.exception\")\n              throw new RuntimeException(\"Malformed URL!\", e);\n            }\n          }\n          else {\n            throw new RuntimeException(new IOException(\"Url Parse Error\" + url.toExternalForm()));\n              //VfsBundle.message(\"url.parse.error\", url.toExternalForm())\n          }\n        }\n        if (SystemInfo.isWindows) {\n          while (!path.isEmpty() && path.charAt(0) == '/') {\n            path = path.substring(1, path.length());\n          }\n        }\n\n        path = URLUtil.unescapePercentSequences(path);\n        String fromUrl = protocol + \"://\" + path;\n        return fromUrl;\n    }\n\n    @Nullable\n    private DeclarationDescriptor findCurrentDescriptorForMember(@NotNull MemberDescriptor originalDescriptor) {\n        DeclarationDescriptor containingDeclaration = findCurrentDescriptor(originalDescriptor.getContainingDeclaration());\n        MemberScope memberScope = getMemberScope(containingDeclaration);\n        if (memberScope == null) return null;\n\n        String renderedOriginal = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(originalDescriptor);\n        Collection<? extends DeclarationDescriptor> descriptors;\n        if (originalDescriptor instanceof ConstructorDescriptor && containingDeclaration instanceof ClassDescriptor) {\n            descriptors = ((ClassDescriptor) containingDeclaration).getConstructors();\n        }\n        else {\n            descriptors = memberScope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());\n        }\n        for (DeclarationDescriptor member : descriptors) {\n            if (renderedOriginal.equals(DescriptorRenderer.FQ_NAMES_IN_TYPES.render(member))) {\n                return member;\n            }\n        }\n        return null;\n    }\n\n    @Nullable\n    public DeclarationDescriptor findCurrentDescriptor(@NotNull DeclarationDescriptor originalDescriptor) {\n        //if there's no sources\n        if (moduleDescriptor == null) {\n            return null;\n        }\n        \n        if (!KotlinBuiltIns.isBuiltIn(originalDescriptor)) {\n            return null;\n        }\n        \n        if (originalDescriptor instanceof ClassDescriptor) {\n            ClassId classId = DescriptorUtilsKt.getClassId((ClassDescriptor) originalDescriptor);\n            if (classId == null) return null;\n            \n            return FindClassInModuleKt.findClassAcrossModuleDependencies(moduleDescriptor, classId);\n        }\n        \n        if (originalDescriptor instanceof PackageFragmentDescriptor) {\n            return StandardNames.BUILT_INS_PACKAGE_FQ_NAME.equals(((PackageFragmentDescriptor) originalDescriptor).getFqName())\n                   ? builtinsPackageFragment\n                   : null;\n        }\n        \n        if (originalDescriptor instanceof MemberDescriptor) {\n            return findCurrentDescriptorForMember((MemberDescriptor) originalDescriptor);\n        }\n        \n        return null;\n    }\n\n    @Nullable\n    private static MemberScope getMemberScope(@Nullable DeclarationDescriptor parent) {\n        if (parent instanceof ClassDescriptor) {\n            return ((ClassDescriptor) parent).getDefaultType().getMemberScope();\n        }\n        else if (parent instanceof PackageFragmentDescriptor) {\n            return ((PackageFragmentDescriptor) parent).getMemberScope();\n        }\n        else {\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/DeserializedDescriptorUtils.kt",
    "content": "package org.jetbrains.kotlin.core.resolve;\n\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor\nimport org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor\nimport org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf\nimport org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor\nimport org.jetbrains.kotlin.resolve.DescriptorUtils\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\n\nfun isDeserialized(descriptor: DeclarationDescriptor) =\n\tdescriptor is DeserializedCallableMemberDescriptor || descriptor is DeserializedClassDescriptor\n\nfun getContainingClassOrPackage(descriptor: DeclarationDescriptor) =\n\tdescriptor.parentsWithSelf.firstOrNull() {\n\t\t(it is ClassDescriptor && DescriptorUtils.isTopLevelDeclaration(it)) ||\n\t\tit is PackageFragmentDescriptor\n\t}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/EclipseAnalyzerFacadeForJVM.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.PsiFileFactory\nimport com.intellij.psi.search.GlobalSearchScope\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns\nimport org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsPackageFragmentProvider\nimport org.jetbrains.kotlin.cli.jvm.compiler.CliBindingTrace\nimport org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM\nimport org.jetbrains.kotlin.config.CommonConfigurationKeys\nimport org.jetbrains.kotlin.config.CompilerConfiguration\nimport org.jetbrains.kotlin.config.JvmTarget\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl\nimport org.jetbrains.kotlin.container.ComponentProvider\nimport org.jetbrains.kotlin.context.ContextForNewModule\nimport org.jetbrains.kotlin.context.MutableModuleContext\nimport org.jetbrains.kotlin.context.ProjectContext\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.EclipseScriptDefinitionProvider\nimport org.jetbrains.kotlin.core.model.KotlinCommonEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asResource\nimport org.jetbrains.kotlin.descriptors.PackageFragmentProvider\nimport org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider\nimport org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport org.jetbrains.kotlin.incremental.components.LookupTracker\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.resolve.*\nimport org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver\nimport org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension\nimport org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver\nimport org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformConfigurator\nimport org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer\nimport org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory\nimport org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter\nimport org.jetbrains.kotlin.resolve.scopes.MemberScope\nimport org.jetbrains.kotlin.scripting.resolve.KtFileScriptSource\nimport org.jetbrains.kotlin.scripting.resolve.refineScriptCompilationConfiguration\nimport org.jetbrains.kotlin.storage.StorageManager\nimport org.jetbrains.kotlin.util.KotlinFrontEndException\nimport kotlin.math.absoluteValue\nimport kotlin.script.experimental.api.KotlinType\nimport kotlin.script.experimental.api.valueOrNull\nimport kotlin.script.experimental.util.PropertiesCollection\n\ndata class AnalysisResultWithProvider(val analysisResult: AnalysisResult, val componentProvider: ComponentProvider?) {\n    companion object {\n        val EMPTY = AnalysisResultWithProvider(AnalysisResult.EMPTY, null)\n    }\n}\n\nobject EclipseAnalyzerFacadeForJVM {\n    fun analyzeSources(\n        environment: KotlinEnvironment,\n        filesToAnalyze: Collection<KtFile>\n    ): AnalysisResultWithProvider {\n        val filesSet = filesToAnalyze.toSet()\n        if (filesSet.size != filesToAnalyze.size) {\n            KotlinLogger.logWarning(\"Analyzed files have duplicates\")\n        }\n\n        val allFiles = LinkedHashSet<KtFile>(filesSet)\n        val addedFiles = filesSet.mapNotNull { getPath(it) }.toSet()\n        ProjectUtils.getSourceFilesWithDependencies(environment.javaProject).filterNotTo(allFiles) {\n            getPath(it) in addedFiles\n        }\n\n        return analyzeKotlin(\n            filesToAnalyze = filesSet,\n            allFiles = allFiles,\n            environment = environment,\n            javaProject = environment.javaProject,\n            jvmTarget = environment.compilerProperties.jvmTarget\n        )\n    }\n\n    fun analyzeScript(\n        environment: KotlinScriptEnvironment,\n        scriptFile: KtFile\n    ): AnalysisResultWithProvider {\n        //TODO actually take dependencies from script configuration!\n        val javaProject = environment.javaProject/*.apply {\n            /*tempClasspath += JavaRuntime.getDefaultVMInstall()\n                    ?.let { JavaRuntime.getLibraryLocations(it) }\n                    ?.map { JavaCore.newLibraryEntry(it.systemLibraryPath, null, null) }\n                    .orEmpty()*/\n\n            /*tempClasspath += (environment.dependencies\n                    ?.classpath.orEmpty() + environment.definitionClasspath)\n                    .map { JavaCore.newLibraryEntry(Path(it.absolutePath), null, null) }*/\n\n            val tempClasspath = environment.getRoots().mapTo(hashSetOf()) {\n                val tempFile = it.file\n                if(it.type == JavaRoot.RootType.SOURCE) {\n                    JavaCore.newSourceEntry(Path(tempFile.path))\n                } else {\n                    JavaCore.newLibraryEntry(Path(tempFile.path), null, null)\n                }\n            }.toTypedArray()\n\n            setRawClasspath(tempClasspath, null)\n        }*/\n\n        val allFiles = LinkedHashSet<KtFile>().run {\n            add(scriptFile)\n            environment.dependencies?.sources?.toList()\n                .orEmpty()\n                .mapNotNull { it.asResource }\n                .mapNotNull { KotlinPsiManager.getKotlinParsedFile(it) }\n                .toCollection(this)\n        }\n\n        ProjectUtils.getSourceFilesWithDependencies(environment.javaProject).toCollection(allFiles)\n\n        val tempSourceCode = KtFileScriptSource(scriptFile)\n\n        val tempRefinedConfig = environment.definition?.let {\n            refineScriptCompilationConfiguration(tempSourceCode, it, environment.project)\n        }?.valueOrNull()?.configuration\n\n        val tempContribution = EclipseScriptDefinitionProvider.getContribution(tempSourceCode)\n\n        val tempDefaultImports =\n            tempRefinedConfig?.get(PropertiesCollection.Key(\"defaultImports\", emptyList<String>())) ?: emptyList()\n        val tempImports = ArrayList(tempDefaultImports)\n\n        val analyzerService = object : PlatformDependentAnalyzerServices() {\n\n            override val defaultLowPriorityImports: List<ImportPath> = listOf(ImportPath.fromString(\"java.lang.*\"))\n\n            override val platformConfigurator: PlatformConfigurator = JvmPlatformConfigurator\n\n            override fun computePlatformSpecificDefaultImports(\n                storageManager: StorageManager,\n                result: MutableList<ImportPath>\n            ) {\n                result.add(ImportPath.fromString(\"kotlin.jvm.*\"))\n                tempImports.map(ImportPath::fromString).toCollection(result)\n\n                fun addAllClassifiersFromScope(scope: MemberScope) {\n                    for (descriptor in scope.getContributedDescriptors(\n                        DescriptorKindFilter.CLASSIFIERS,\n                        MemberScope.ALL_NAME_FILTER\n                    )) {\n                        result.add(ImportPath(DescriptorUtils.getFqNameSafe(descriptor), false))\n                    }\n                }\n\n                for (builtInPackage in JvmBuiltIns(\n                    storageManager,\n                    JvmBuiltIns.Kind.FROM_CLASS_LOADER\n                ).builtInPackagesImportedByDefault) {\n                    addAllClassifiersFromScope(builtInPackage.memberScope)\n                }\n            }\n        }\n\n        val tempProperties =\n            tempRefinedConfig?.get(PropertiesCollection.Key(\"providedProperties\", emptyMap<String, KotlinType>()))\n\n        if (!tempProperties.isNullOrEmpty()) {\n            val tempPackageName = \"scriptParameters${scriptFile.virtualFilePath.hashCode().absoluteValue}\"\n            val tempContent =\n                \"package $tempPackageName\\n\" + tempProperties.entries.joinToString(separator = \"\\n\") { (key, value) ->\n                    val isNullable = tempContribution?.isNullable(key, tempRefinedConfig) ?: true\n                    \"\"\"\n                        |@Deprecated(message = \"Do not import this explicitly! Used only in eclipse as workaround for providedProperties in Scripts!\", level = DeprecationLevel.WARNING)\n                        |val $key: ${value.typeName}${if(isNullable) \"? = null\" else \" = TODO()\"}\n                    \"\"\".trimMargin(\"|\")\n                }\n\n            tempImports.add(\"$tempPackageName.*\")\n\n            val tempKtFile = PsiFileFactory.getInstance(environment.project)\n                .createFileFromText(\"scriptParameters.kt\", KotlinLanguage.INSTANCE, tempContent) as? KtFile\n\n            if (tempKtFile != null) {\n                allFiles.add(tempKtFile)\n            }\n        }\n\n        return analyzeKotlin(\n            filesToAnalyze = listOf(scriptFile),\n            allFiles = allFiles,\n            environment = environment,\n            javaProject = javaProject,\n            analyzerService = analyzerService\n        )\n    }\n\n    private fun analyzeKotlin(\n        filesToAnalyze: Collection<KtFile>,\n        allFiles: Collection<KtFile>,\n        environment: KotlinCommonEnvironment,\n        javaProject: IJavaProject?,\n        jvmTarget: JvmTarget = JvmTarget.DEFAULT,\n        analyzerService: PlatformDependentAnalyzerServices? = null\n    ): AnalysisResultWithProvider {\n        val project = environment.project\n        val moduleContext = createModuleContext(project, environment.configuration, true)\n        val storageManager = moduleContext.storageManager\n        val module = moduleContext.module\n\n        val providerFactory = FileBasedDeclarationProviderFactory(moduleContext.storageManager, allFiles)\n        val trace = CliBindingTrace()\n\n        val sourceScope = TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, filesToAnalyze)\n        val moduleClassResolver = TopDownAnalyzerFacadeForJVM.SourceOrBinaryModuleClassResolver(sourceScope)\n\n        val languageVersionSettings =\n            javaProject?.project?.let { KotlinEnvironment.getEnvironment(it).compilerProperties.languageVersionSettings }\n                ?: LanguageVersionSettingsImpl(\n                    LanguageVersionSettingsImpl.DEFAULT.languageVersion,\n                    LanguageVersionSettingsImpl.DEFAULT.apiVersion\n                )\n\n\n        val optionalBuiltInsModule = JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_CLASS_LOADER)\n            .apply { initialize(module, true) }\n            .builtInsModule\n\n        val dependencyModule = run {\n            val dependenciesContext = ContextForNewModule(\n                moduleContext, Name.special(\n                    \"<dependencies of ${\n                        environment.configuration.getNotNull(\n                            CommonConfigurationKeys.MODULE_NAME\n                        )\n                    }>\"\n                ),\n                module.builtIns, null\n            )\n\n            val dependencyScope = GlobalSearchScope.notScope(sourceScope)\n            val dependenciesContainer = createContainerForTopDownAnalyzerForJvm(\n                dependenciesContext,\n                trace,\n                DeclarationProviderFactory.EMPTY,\n                dependencyScope,\n                LookupTracker.DO_NOTHING,\n                KotlinPackagePartProvider(environment),\n                jvmTarget,\n                languageVersionSettings,\n                moduleClassResolver,\n                javaProject,\n                environment.project.getService(JavaModuleResolver::class.java),\n                null\n            )\n\n            moduleClassResolver.compiledCodeResolver = dependenciesContainer.get<JavaDescriptorResolver>()\n\n            dependenciesContext.setDependencies(listOfNotNull(dependenciesContext.module, optionalBuiltInsModule))\n            dependenciesContext.initializeModuleContents(\n                CompositePackageFragmentProvider(\n                    listOf(\n                        moduleClassResolver.compiledCodeResolver.packageFragmentProvider,\n                        dependenciesContainer.get<JvmBuiltInsPackageFragmentProvider>()\n                    ), \"\"\n                )\n            )\n            dependenciesContext.module\n        }\n\n        val container = createContainerForTopDownAnalyzerForJvm(\n            moduleContext,\n            trace,\n            providerFactory,\n            sourceScope,\n            LookupTracker.DO_NOTHING,\n            KotlinPackagePartProvider(environment),\n            jvmTarget,\n            languageVersionSettings,\n            moduleClassResolver,\n            javaProject,\n            environment.project.getService(JavaModuleResolver::class.java),\n            analyzerService\n        ).apply {\n            initJvmBuiltInsForTopDownAnalysis()\n        }\n\n        moduleClassResolver.sourceCodeResolver = container.get<JavaDescriptorResolver>()\n\n        val additionalProviders = ArrayList<PackageFragmentProvider>()\n        additionalProviders.add(container.get<JavaDescriptorResolver>().packageFragmentProvider)\n\n        PackageFragmentProviderExtension.getInstances(project).mapNotNullTo(additionalProviders) { extension ->\n            extension.getPackageFragmentProvider(project, module, storageManager, trace, null, LookupTracker.DO_NOTHING)\n        }\n\n        module.setDependencies(\n            listOfNotNull(module, dependencyModule, optionalBuiltInsModule),\n            setOf(dependencyModule)\n        )\n        module.initialize(\n            CompositePackageFragmentProvider(\n                listOf(container.get<KotlinCodeAnalyzer>().packageFragmentProvider) +\n                        additionalProviders, \"\"\n            )\n        )\n\n        try {\n            container.get<LazyTopDownAnalyzer>()\n                .analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, filesToAnalyze)\n        } catch (e: KotlinFrontEndException) {\n//          Editor will break if we do not catch this exception\n//          and will not be able to save content without reopening it.\n//          In IDEA this exception throws only in CLI\n            KotlinLogger.logError(e)\n        }\n\n        return AnalysisResultWithProvider(\n            AnalysisResult.success(trace.bindingContext, module),\n            container\n        )\n    }\n\n    private fun getPath(jetFile: KtFile): String? = jetFile.virtualFile?.path\n\n    private fun createModuleContext(\n        project: Project,\n        configuration: CompilerConfiguration,\n        createBuiltInsFromModule: Boolean\n    ): MutableModuleContext {\n        val projectContext = ProjectContext(project, \"context for project ${project.name}\")\n        val builtIns = JvmBuiltIns(\n            projectContext.storageManager,\n            if (createBuiltInsFromModule) JvmBuiltIns.Kind.FROM_DEPENDENCIES else JvmBuiltIns.Kind.FROM_CLASS_LOADER\n        )\n        return ContextForNewModule(\n            projectContext,\n            Name.special(\"<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>\"),\n            builtIns,\n            null\n        ).apply {\n            if (createBuiltInsFromModule) {\n                builtIns.builtInsModule = module\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/EclipseDescriptorUtils.java",
    "content": "package org.jetbrains.kotlin.core.resolve;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.HashSet;\nimport java.util.List;\n\nimport org.eclipse.core.resources.IProject;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.builtins.KotlinBuiltIns;\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind;\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor;\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor;\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource;\nimport org.jetbrains.kotlin.descriptors.SourceElement;\nimport org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;\n\n// Note: copied with some changes from DescriptorToSourceUtils\npublic class EclipseDescriptorUtils {\n    // NOTE this is also used by KDoc\n    @Nullable\n    public static SourceElement descriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {\n        if (descriptor instanceof CallableMemberDescriptor) {\n            return callableDescriptorToDeclaration((CallableMemberDescriptor) descriptor);\n        } else if (descriptor instanceof ClassDescriptor) {\n            return classDescriptorToDeclaration((ClassDescriptor) descriptor);\n        } else {\n            return doGetDescriptorToDeclaration(descriptor);\n        }\n    }\n\n    @NotNull\n    public static List<SourceElement> descriptorToDeclarations(@NotNull DeclarationDescriptor descriptor, @NotNull IProject project) {\n        if (KotlinBuiltIns.isBuiltIn(descriptor)) {\n            \n            Collection<DeclarationDescriptor> effectiveReferencedDescriptors = DescriptorToSourceUtils.getEffectiveReferencedDescriptors(descriptor);\n            \n            HashSet<SourceElement> result = new HashSet<SourceElement>();\n            BuiltInsReferenceResolver resolver = BuiltInsReferenceResolver.getInstance(project);\n            for (DeclarationDescriptor effectiveReferenced: effectiveReferencedDescriptors) {\n                DeclarationDescriptor resultDescriptor = resolver.findCurrentDescriptor(effectiveReferenced);\n                if (resultDescriptor != null && resultDescriptor instanceof DeclarationDescriptorWithSource) {\n                    SourceElement element = ((DeclarationDescriptorWithSource)resultDescriptor).getSource();\n                    if (!element.equals(SourceElement.NO_SOURCE)) {\n                        result.add(element);\n                    }\n                }\n            }\n            return new ArrayList<SourceElement>(result);\n        }\n        //TODO: this returns a source element for containing element with existing .class file. This logic should be moved to a caller.\n        if (DeserializedDescriptorUtilsKt.isDeserialized(descriptor)) {\n            DeclarationDescriptor containing = DeserializedDescriptorUtilsKt.getContainingClassOrPackage(descriptor);\n            if (containing != null) {\n                return Arrays.asList(descriptorToDeclaration(containing));\n            }\n        }\n        if (descriptor instanceof CallableMemberDescriptor) {\n            return callableDescriptorToDeclarations((CallableMemberDescriptor) descriptor);\n        } else {\n            SourceElement sourceElement = descriptorToDeclaration(descriptor);\n            if (sourceElement != null) {\n                return Arrays.asList(sourceElement);\n            } else {\n                return new ArrayList<SourceElement>();\n            }\n        }\n    }\n    \n    @Nullable\n    public static SourceElement callableDescriptorToDeclaration(@NotNull CallableMemberDescriptor callable) {\n        if (callable.getKind() == Kind.DECLARATION || callable.getKind() == Kind.SYNTHESIZED) {\n            return doGetDescriptorToDeclaration(callable);\n        }\n        //TODO: should not use this method for fake_override and delegation\n        Collection<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();\n        if (overriddenDescriptors.size() == 1) {\n            return callableDescriptorToDeclaration(overriddenDescriptors.iterator().next());\n        }\n        return null;\n    }\n\n    @NotNull\n    public static List<SourceElement> callableDescriptorToDeclarations(@NotNull CallableMemberDescriptor callable) {\n        if (callable.getKind() == Kind.DECLARATION || callable.getKind() == Kind.SYNTHESIZED) {\n            SourceElement sourceElement = doGetDescriptorToDeclaration(callable);\n            return sourceElement != null ? Arrays.asList(sourceElement) : Arrays.asList();\n        }\n\n        List<SourceElement> r = new ArrayList<>();\n        Collection<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();\n        for (CallableMemberDescriptor overridden : overriddenDescriptors) {\n            r.addAll(callableDescriptorToDeclarations(overridden));\n        }\n        return r;\n    }\n    \n    @Nullable\n    public static SourceElement classDescriptorToDeclaration(@NotNull ClassDescriptor clazz) {\n        return doGetDescriptorToDeclaration(clazz);\n    }\n    \n    @Nullable\n    private static SourceElement doGetDescriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {\n        DeclarationDescriptor original = descriptor.getOriginal();\n        if (!(original instanceof DeclarationDescriptorWithSource)) {\n            return null;\n        }\n        return ((DeclarationDescriptorWithSource) original).getSource();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinAnalyzer.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport org.eclipse.core.resources.IProject\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.model.getEnvironment\nimport org.jetbrains.kotlin.psi.KtFile\n\nobject KotlinAnalyzer {\n    fun analyzeFile(jetFile: KtFile): AnalysisResultWithProvider {\n        return KotlinAnalysisFileCache.getAnalysisResult(jetFile)\n    }\n    \n    fun analyzeFiles(files: Collection<KtFile>): AnalysisResultWithProvider {\n        return when {\n            files.isEmpty() -> throw IllegalStateException(\"There should be at least one file to analyze\")\n            \n            files.size == 1 -> analyzeFile(files.single())\n            \n            else -> {\n                val environment = getEnvironment(files.first().project)\n                if (environment == null) {\n                    throw IllegalStateException(\"There is no environment for project: ${files.first().project}\")\n                }\n                \n                if (environment !is KotlinEnvironment) {\n                    throw IllegalStateException(\"Only KotlinEnvironment can be used to analyze several files\")\n                }\n                \n                analyzeFiles(environment, files)\n            }\n        }\n    }\n    \n    fun analyzeProject(eclipseProject: IProject): AnalysisResultWithProvider {\n        val environment = KotlinEnvironment.getEnvironment(eclipseProject)\n        return analyzeFiles(environment, emptyList())\n    }\n\n    private fun analyzeFiles(kotlinEnvironment: KotlinEnvironment,\n                             filesToAnalyze: Collection<KtFile>): AnalysisResultWithProvider {\n        return EclipseAnalyzerFacadeForJVM.analyzeSources(kotlinEnvironment, filesToAnalyze)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinCacheServiceImpl.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiFile\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.analyzer.ModuleInfo\nimport org.jetbrains.kotlin.caches.resolve.KotlinCacheService\nimport org.jetbrains.kotlin.container.ComponentProvider\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.ModuleDescriptor\nimport org.jetbrains.kotlin.idea.resolve.ResolutionFacade\nimport org.jetbrains.kotlin.platform.TargetPlatform\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache\nimport org.jetbrains.kotlin.resolve.lazy.BodyResolveMode\nimport org.jetbrains.kotlin.analyzer.ResolverForProject\nimport org.jetbrains.kotlin.caches.resolve.PlatformAnalysisSettings\nimport org.jetbrains.kotlin.diagnostics.DiagnosticSink\nimport org.jetbrains.kotlin.idea.FrontendInternals\n\nclass KotlinCacheServiceImpl(private val ideaProject: Project) : KotlinCacheService {\n\n    override fun getResolutionFacadeWithForcedPlatform(\n        elements: List<KtElement>,\n        platform: TargetPlatform\n    ): ResolutionFacade {\n        return KotlinSimpleResolutionFacade(ideaProject, elements)\n    }\n\n    override fun getResolutionFacadeByFile(file: PsiFile, platform: TargetPlatform): ResolutionFacade {\n        throw UnsupportedOperationException()\n    }\n\n    override fun getResolutionFacadeByModuleInfo(\n        moduleInfo: ModuleInfo,\n        settings: PlatformAnalysisSettings\n    ): ResolutionFacade? {\n        throw UnsupportedOperationException()\n    }\n\n    override fun getSuppressionCache(): KotlinSuppressCache {\n        throw UnsupportedOperationException()\n    }\n\n    override fun getResolutionFacade(elements: List<KtElement>): ResolutionFacade {\n        return KotlinSimpleResolutionFacade(ideaProject, elements)\n    }\n\n    override fun getResolutionFacade(element: KtElement): ResolutionFacade = getResolutionFacade(listOf(element))\n\n\toverride fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade? =\n\t\tnull\n}\n\n@OptIn(FrontendInternals::class)\nclass KotlinSimpleResolutionFacade(\n        override val project: Project,\n        private val elements: List<KtElement>) : ResolutionFacade {\n\n    override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {\n        return null\n    }\n\n    override fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode): DeclarationDescriptor {\n        throw UnsupportedOperationException()\n    }\n\n    override val moduleDescriptor: ModuleDescriptor\n        get() = throw UnsupportedOperationException()\n    \n    override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext {\n        val ktFile = element.containingKtFile\n        return KotlinAnalysisFileCache.getAnalysisResult(ktFile).analysisResult.bindingContext\n    }\n\n    override fun analyzeWithAllCompilerChecks(\n        elements: Collection<KtElement>,\n        callback: DiagnosticSink.DiagnosticsCallback?\n    ): AnalysisResult {\n        val ktFile = elements.first().containingKtFile\n        return KotlinAnalysisFileCache.getAnalysisResult(ktFile).analysisResult\n    }\n\n    override fun analyze(elements: Collection<KtElement>, bodyResolveMode: BodyResolveMode): BindingContext {\n        if (elements.isEmpty()) {\n            return BindingContext.EMPTY\n        }\n        val ktFile = elements.first().containingKtFile\n        return KotlinAnalysisFileCache.getAnalysisResult(ktFile).analysisResult.bindingContext\n    }\n\n    override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any> getFrontendService(serviceClass: Class<T>): T {\n        val files = elements.map { it.containingKtFile }.toSet()\n        if (files.isEmpty()) throw IllegalStateException(\"Elements should not be empty\")\n        \n        val componentProvider = KotlinAnalyzer.analyzeFiles(files).componentProvider\n            ?: throw IllegalStateException(\"Trying to get service from non-initialized project\")\n\n        return componentProvider.getService(serviceClass)\n    }\n    \n    override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any> getIdeService(serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n\n    override fun getResolverForProject(): ResolverForProject<out ModuleInfo> {\n        throw UnsupportedOperationException()\n    }\n}\n\n@Suppress(\"UNCHECKED_CAST\") fun <T : Any> ComponentProvider.getService(request: Class<T>): T {\n    return resolve(request)!!.getValue() as T\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinPackagePartProvider.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport com.intellij.openapi.vfs.VirtualFile\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinCommonEnvironment\nimport org.jetbrains.kotlin.load.kotlin.PackagePartProvider\nimport org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping\nimport org.jetbrains.kotlin.metadata.jvm.deserialization.PackageParts\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration\nimport org.jetbrains.kotlin.serialization.deserialization.ClassData\nimport org.jetbrains.kotlin.utils.SmartList\nimport java.io.EOFException\nimport java.io.FileNotFoundException\n\npublic class KotlinPackagePartProvider(private val environment: KotlinCommonEnvironment) : PackagePartProvider {\n    private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping, val name: String)\n\n    private val notLoadedRoots by lazy(LazyThreadSafetyMode.NONE) {\n        environment.getRoots()\n                .map { it.file }\n                .filter { it.findChild(\"META-INF\") != null }\n                .toMutableList()\n    }\n\n    private val loadedModules: MutableList<ModuleMappingInfo> = SmartList()\n\n    private val deserializationConfiguration = CompilerDeserializationConfiguration(LanguageVersionSettingsImpl.DEFAULT)\n\n    override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> =\n            loadedModules.mapNotNull { (_, mapping, name) ->\n                mapping.moduleData.annotations.takeIf { name == moduleName }\n            }\n                    .flatten()\n                    .map { ClassId.fromString(it) }\n\n    override fun findPackageParts(packageFqName: String): List<String> {\n        val rootToPackageParts = getPackageParts(packageFqName)\n        if (rootToPackageParts.isEmpty()) return emptyList()\n\n        val result = linkedSetOf<String>()\n        val visitedMultifileFacades = linkedSetOf<String>()\n        for ((_, packageParts) in rootToPackageParts) {\n            for (name in packageParts.parts) {\n                val facadeName = packageParts.getMultifileFacadeName(name)\n                if (facadeName == null || facadeName !in visitedMultifileFacades) {\n                    result.add(name)\n                }\n            }\n            packageParts.parts.mapNotNullTo(visitedMultifileFacades) { packageParts.getMultifileFacadeName(it) }\n        }\n        return result.toList()\n    }\n\n    override fun getAllOptionalAnnotationClasses(): List<ClassData> =\n            emptyList()\n\n    fun findMetadataPackageParts(packageFqName: String): List<String> =\n            getPackageParts(packageFqName).values.flatMap(PackageParts::metadataParts).distinct()\n\n    @Synchronized\n    private fun getPackageParts(packageFqName: String): Map<VirtualFile, PackageParts> {\n        processNotLoadedRelevantRoots(packageFqName)\n\n        val result = mutableMapOf<VirtualFile, PackageParts>()\n        for ((root, mapping) in loadedModules) {\n            val newParts = mapping.findPackageParts(packageFqName) ?: continue\n            result[root]?.let { parts -> parts += newParts } ?: result.put(root, newParts)\n        }\n        return result\n    }\n\n    private fun processNotLoadedRelevantRoots(packageFqName: String) {\n        if (notLoadedRoots.isEmpty()) return\n\n        val pathParts = packageFqName.split('.')\n\n        val relevantRoots = notLoadedRoots.filter {\n            //filter all roots by package path existing\n            pathParts.fold(it) { parent, part ->\n                if (part.isEmpty()) parent\n                else parent.findChild(part) ?: return@filter false\n            }\n            true\n        }\n        notLoadedRoots.removeAll(relevantRoots)\n\n        for (root in relevantRoots) {\n            val metaInf = root.findChild(\"META-INF\") ?: continue\n            val moduleFiles = metaInf.children.filter { it.name.endsWith(ModuleMapping.MAPPING_FILE_EXT) }\n            for (moduleFile: VirtualFile in moduleFiles) {\n                val mapping = try {\n                    ModuleMapping.loadModuleMapping(\n                            moduleFile.contentsToByteArray(),\n                            moduleFile.toString(),\n                            deserializationConfiguration.skipMetadataVersionCheck,\n                            deserializationConfiguration.isJvmPackageNameSupported\n                    ) {\n                        KotlinLogger.logWarning(\"Incompatible version for '$moduleFile': $it\")\n                    }\n                } catch (e: EOFException) {\n                    throw RuntimeException(\"Error on reading package parts for '$packageFqName' package in '$moduleFile', \" +\n                            \"roots: $notLoadedRoots\", e)\n                } catch (e: FileNotFoundException) {\n                    notLoadedRoots.add(root)\n                    continue\n                }\n                loadedModules.add(ModuleMappingInfo(root, mapping, moduleFile.nameWithoutExtension))\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinResolutionFacade.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.PsiElement\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.analyzer.ModuleInfo\nimport org.jetbrains.kotlin.analyzer.ResolverForProject\nimport org.jetbrains.kotlin.container.ComponentProvider\nimport org.jetbrains.kotlin.container.getService\nimport org.jetbrains.kotlin.core.model.getEnvironment\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.ModuleDescriptor\nimport org.jetbrains.kotlin.diagnostics.DiagnosticSink\nimport org.jetbrains.kotlin.idea.FrontendInternals\nimport org.jetbrains.kotlin.idea.resolve.ResolutionFacade\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.lazy.BodyResolveMode\n\n@OptIn(FrontendInternals::class)\npublic class KotlinResolutionFacade(\n        val eclipseFile: IFile, \n        val componentProvider: ComponentProvider,\n        override val moduleDescriptor: ModuleDescriptor) : ResolutionFacade {\n    override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {\n        throw UnsupportedOperationException()\n    }\n\n    override fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode): DeclarationDescriptor {\n        throw UnsupportedOperationException()\n    }\n\n    override val project: Project\n        get() = getEnvironment(eclipseFile).project\n    \n    override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext {\n        throw UnsupportedOperationException()\n    }\n    override fun analyze(elements: Collection<KtElement>, bodyResolveMode: BodyResolveMode): BindingContext {\n        throw UnsupportedOperationException()\n    }\n\n    override fun analyzeWithAllCompilerChecks(\n        elements: Collection<KtElement>, callback: DiagnosticSink.DiagnosticsCallback?\n    ): AnalysisResult {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any> getFrontendService(serviceClass: Class<T>): T = componentProvider.getService(serviceClass)\n    \n    override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n    \n    override fun <T : Any> getIdeService(serviceClass: Class<T>): T {\n        throw UnsupportedOperationException()\n    }\n\n    override fun getResolverForProject(): ResolverForProject<out ModuleInfo> {\n        throw UnsupportedOperationException()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinSourceIndex.java",
    "content": "package org.jetbrains.kotlin.core.resolve;\n\nimport java.io.File;\nimport java.util.Map;\nimport java.util.WeakHashMap;\n\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.internal.core.PackageFragment;\nimport org.eclipse.jdt.internal.core.SourceMapper;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.resolve.sources.LibrarySourcesIndex;\nimport org.jetbrains.kotlin.core.resolve.sources.LibrarySourcesIndexKt;\nimport org.jetbrains.kotlin.idea.KotlinFileType;\n\nimport com.intellij.openapi.components.ServiceManager;\nimport com.intellij.openapi.project.Project;\n\npublic class KotlinSourceIndex {\n    \n    private final Map<IPackageFragmentRoot, LibrarySourcesIndex> packageIndexes = new WeakHashMap< >();\n    \n    public static KotlinSourceIndex getInstance(IJavaProject javaProject) {\n        Project ideaProject = KotlinEnvironment.Companion.getEnvironment(javaProject.getProject()).getProject();\n        return ServiceManager.getService(ideaProject, KotlinSourceIndex.class);\n    }\n    \n    public static boolean isKotlinSource(String shortFileName) {\n        return KotlinFileType.EXTENSION.equals(new Path(shortFileName).getFileExtension());\n    }\n    \n    @Nullable\n    public static char[] getSource(SourceMapper mapper, IType type, String simpleSourceFileName) {\n        IPackageFragment packageFragment = type.getPackageFragment();\n        if (packageFragment instanceof PackageFragment) {\n            KotlinSourceIndex index = KotlinSourceIndex.getInstance(type.getJavaProject());\n            String resolvedPath = index.resolvePath((PackageFragment) packageFragment, simpleSourceFileName);\n            return mapper.findSource(resolvedPath);\n        }\n        return null;\n    }\n    \n    @Nullable\n    public static char[] getSource(SourceMapper mapper, String sourceFileName, IPath packageFolder, IPath sourcePath) {\n        LibrarySourcesIndex index = createSourcesIndex(sourcePath);\n        String result = index != null ? index.resolve(sourceFileName, packageFolder) : null;\n        return result != null ? \n                mapper.findSource(result) : mapper.findSource(packageFolder.append(sourceFileName).toPortableString());\n    }\n    \n    public String resolvePath(PackageFragment packageFragment, String pathToSource) {\n        IPackageFragmentRoot packageFragmentRoot = packageFragment.getPackageFragmentRoot();\n        LibrarySourcesIndex packageIndex = getIndexForRoot(packageFragmentRoot);\n        if (packageIndex == null) {\n            return pathToSource;\n        }\n        String simpleName = new Path(pathToSource).lastSegment();\n        String result = packageIndex.resolve(simpleName, packageFragment.getElementName());\n        return result != null ? result : pathToSource;\n    }\n    \n    @Nullable\n    private LibrarySourcesIndex getIndexForRoot(IPackageFragmentRoot packageRoot) {\n        LibrarySourcesIndex result = packageIndexes.get(packageRoot);\n        if (result != null) {\n            return result;\n        }\n        try {\n            if (packageRoot.getKind() != IPackageFragmentRoot.K_BINARY) {\n                return null;\n            }\n            \n            IPath sourcePath = LibrarySourcesIndexKt.getSourcePath(packageRoot);\n            if (sourcePath == null) {\n                return null;\n            }\n            \n            LibrarySourcesIndex index = createSourcesIndex(sourcePath);\n            packageIndexes.put(packageRoot, index);\n            \n            return index;\n        } catch (JavaModelException e) {\n            KotlinLogger.logError(\"Unable to analyze sources for package\", e);\n        }\n        return null;\n    }\n    \n    @Nullable\n    private static LibrarySourcesIndex createSourcesIndex(IPath sourcePath) {\n        File jarFile = sourcePath.toFile();\n        return jarFile.exists() ? new LibrarySourcesIndex(jarFile) : null;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/injection.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve\n\nimport com.intellij.openapi.project.Project\nimport com.intellij.psi.search.GlobalSearchScope\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns\nimport org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsPackageFragmentProvider\nimport org.jetbrains.kotlin.config.JvmAnalysisFlags\nimport org.jetbrains.kotlin.config.JvmTarget\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.container.ComponentProvider\nimport org.jetbrains.kotlin.container.StorageComponentContainer\nimport org.jetbrains.kotlin.container.registerSingleton\nimport org.jetbrains.kotlin.container.useInstance\nimport org.jetbrains.kotlin.context.ModuleContext\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElementFactory\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseTraceBasedJavaResolverCache\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaPropertyInitializerEvaluator\nimport org.jetbrains.kotlin.frontend.di.configureModule\nimport org.jetbrains.kotlin.incremental.InlineConstTrackerImpl\nimport org.jetbrains.kotlin.incremental.components.LookupTracker\nimport org.jetbrains.kotlin.load.java.InternalFlexibleTypeTransformer\nimport org.jetbrains.kotlin.load.java.JavaClassesTracker\nimport org.jetbrains.kotlin.load.java.JavaModuleAnnotationsProvider\nimport org.jetbrains.kotlin.load.java.components.SignaturePropagatorImpl\nimport org.jetbrains.kotlin.load.java.components.TraceBasedErrorReporter\nimport org.jetbrains.kotlin.load.java.lazy.JavaResolverSettings\nimport org.jetbrains.kotlin.load.java.lazy.ModuleClassResolver\nimport org.jetbrains.kotlin.load.kotlin.DeserializationComponentsForJava\nimport org.jetbrains.kotlin.load.kotlin.PackagePartProvider\nimport org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory\nimport org.jetbrains.kotlin.platform.jvm.JvmPlatforms\nimport org.jetbrains.kotlin.resolve.*\nimport org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver\nimport org.jetbrains.kotlin.resolve.jvm.SyntheticJavaPartsProvider\nimport org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices\nimport org.jetbrains.kotlin.resolve.lazy.ResolveSession\nimport org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory\n\nfun StorageComponentContainer.configureJavaTopDownAnalysis(\n        moduleContentScope: GlobalSearchScope,\n        project: Project,\n        lookupTracker: LookupTracker,\n        languageFeatureSettings: LanguageVersionSettings) {\n    useInstance(moduleContentScope)\n    useInstance(lookupTracker)\n\n    useImpl<ResolveSession>()\n\n    useImpl<LazyTopDownAnalyzer>()\n    useImpl<JavaDescriptorResolver>()\n    useImpl<DeserializationComponentsForJava>()\n\n    useInstance(VirtualFileFinderFactory.SERVICE.getInstance(project).create(moduleContentScope))\n\n    useImpl<EclipseJavaPropertyInitializerEvaluator>()\n    useImpl<AnnotationResolverImpl>()\n    useImpl<SignaturePropagatorImpl>()\n    useImpl<TraceBasedErrorReporter>()\n    useInstance(InternalFlexibleTypeTransformer)\n}\n\nfun createContainerForLazyResolveWithJava(\n    moduleContext: ModuleContext,\n    bindingTrace: BindingTrace,\n    declarationProviderFactory: DeclarationProviderFactory,\n    moduleContentScope: GlobalSearchScope,\n    moduleClassResolver: ModuleClassResolver,\n    targetEnvironment: TargetEnvironment,\n    lookupTracker: LookupTracker,\n    packagePartProvider: PackagePartProvider,\n    jvmTarget: JvmTarget,\n    languageVersionSettings: LanguageVersionSettings,\n    javaProject: IJavaProject?,\n    useBuiltInsProvider: Boolean,\n    javaModuleAnnotationsProvider: JavaModuleAnnotationsProvider,\n    analyzerService: PlatformDependentAnalyzerServices?\n): StorageComponentContainer = createContainer(\"LazyResolveWithJava\", JvmPlatformAnalyzerServices) {\n    configureModule(\n        moduleContext,\n        JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget),\n        analyzerService ?: JvmPlatformAnalyzerServices,\n        bindingTrace,\n        languageVersionSettings\n    )\n    configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker, languageVersionSettings)\n\n    useImpl<EclipseJavaClassFinder>()\n    useImpl<EclipseTraceBasedJavaResolverCache>()\n    useImpl<EclipseJavaSourceElementFactory>()\n    useImpl<InlineConstTrackerImpl>()\n\n    useInstance(SyntheticJavaPartsProvider.EMPTY)\n    useInstance(packagePartProvider)\n    useInstance(moduleClassResolver)\n    useInstance(javaModuleAnnotationsProvider)\n    useInstance(declarationProviderFactory)\n    javaProject?.let { useInstance(it) }\n\n    //TODO???\n    useInstance(languageVersionSettings.getFlag(JvmAnalysisFlags.javaTypeEnhancementState))\n\n    if (useBuiltInsProvider) {\n        //TODO???\n        useInstance((moduleContext.module.builtIns as JvmBuiltIns).customizer)\n        useImpl<JvmBuiltInsPackageFragmentProvider>()\n    }\n\n    useInstance(JavaClassesTracker.Default)\n\n    targetEnvironment.configure(this)\n\n    useInstance(\n        JavaResolverSettings.create(\n            //isReleaseCoroutines = languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines),\n            correctNullabilityForNotNullTypeParameter = false,\n            typeEnhancementImprovementsInStrictMode = false,\n            ignoreNullabilityForErasedValueParameters = false\n        )\n    )\n}.apply {\n    get<EclipseJavaClassFinder>().initialize(bindingTrace, get(),languageVersionSettings, jvmTarget)\n}\n\nfun createContainerForTopDownAnalyzerForJvm(\n        moduleContext: ModuleContext,\n        bindingTrace: BindingTrace,\n        declarationProviderFactory: DeclarationProviderFactory,\n        moduleContentScope: GlobalSearchScope,\n        lookupTracker: LookupTracker,\n        packagePartProvider: PackagePartProvider,\n        jvmTarget: JvmTarget,\n        languageVersionSettings: LanguageVersionSettings,\n        moduleClassResolver: ModuleClassResolver,\n        javaProject: IJavaProject?,\n        javaModuleAnnotationsProvider: JavaModuleAnnotationsProvider,\n        analyzerService: PlatformDependentAnalyzerServices?\n): ComponentProvider = createContainerForLazyResolveWithJava(\n        moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope, moduleClassResolver,\n        CompilerEnvironment, lookupTracker, packagePartProvider, jvmTarget, languageVersionSettings, javaProject,\n        useBuiltInsProvider = true, javaModuleAnnotationsProvider, analyzerService\n)\n\n// Copy functions from Dsl.kt as they were shrinked by proguard\ninline fun <reified T : Any> StorageComponentContainer.useImpl() {\n    registerSingleton(T::class.java)\n}\n\ninline fun <reified T : Any> ComponentProvider.get(): T {\n    return getService(T::class.java)\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/EclipseJavaClassFinder.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java;\n\nimport com.intellij.mock.MockProject;\nimport org.eclipse.core.resources.IFolder;\nimport org.eclipse.jdt.core.*;\nimport org.eclipse.jdt.core.dom.*;\nimport org.eclipse.jdt.internal.core.JavaProject;\nimport org.eclipse.jdt.internal.core.NameLookup;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.config.JvmTarget;\nimport org.jetbrains.kotlin.config.LanguageVersionSettings;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaClass;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaPackage;\nimport org.jetbrains.kotlin.load.java.AbstractJavaClassFinder;\nimport org.jetbrains.kotlin.load.java.structure.JavaClass;\nimport org.jetbrains.kotlin.load.java.structure.JavaPackage;\nimport org.jetbrains.kotlin.name.ClassId;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.resolve.BindingTrace;\nimport org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer;\nimport org.jetbrains.kotlin.resolve.jvm.JvmCodeAnalyzerInitializer;\nimport org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;\n\nimport java.util.Arrays;\nimport java.util.Set;\n\npublic class EclipseJavaClassFinder extends AbstractJavaClassFinder {\n\n    private IJavaProject javaProject;\n\n    public EclipseJavaClassFinder(@NotNull IJavaProject project) {\n        javaProject = project;\n    }\n\n    @Override\n    public void initialize(@NotNull BindingTrace trace, @NotNull KotlinCodeAnalyzer codeAnalyzer, @NotNull LanguageVersionSettings languageVersionSettings, @NotNull JvmTarget jvmTarget) {\n        if (javaProject == null) {\n            return;\n        }\n\n        MockProject ideaProject = KotlinEnvironment.Companion.getEnvironment(javaProject.getProject()).getProject();\n        JvmCodeAnalyzerInitializer tempInitializer = (JvmCodeAnalyzerInitializer) CodeAnalyzerInitializer.Companion.getInstance(ideaProject);\n        //trace, codeAnalyzer.getModuleDescriptor(), codeAnalyzer, languageVersionSettings\n        tempInitializer.initialize(trace, codeAnalyzer.getModuleDescriptor(), codeAnalyzer, languageVersionSettings, jvmTarget);\n        //trace, codeAnalyzer.getModuleDescriptor(), codeAnalyzer\n    }\n\n    @Nullable\n    @Override\n    public JavaPackage findPackage(@NotNull FqName fqName, boolean b) {\n        IPackageFragment[] packageFragments = findPackageFragments(javaProject, fqName.asString(), false, false);\n        if (packageFragments != null && packageFragments.length > 0) {\n            return new EclipseJavaPackage(Arrays.asList(packageFragments));\n        }\n\n        return null;\n    }\n\n    @Override\n    @Nullable\n    public JavaClass findClass(@NotNull Request request) {\n        return findClass(request.getClassId());\n    }\n\n    @Override\n    @Nullable\n    public JavaClass findClass(@NotNull ClassId classId) {\n        ITypeBinding typeBinding = findType(classId.asSingleFqName(), javaProject);\n        if (typeBinding != null) {\n            return new EclipseJavaClass(typeBinding);\n        }\n        \n        return null;\n    }\n    \n    @Nullable\n    public static IPackageFragment[] findPackageFragments(IJavaProject javaProject, String name, \n            boolean partialMatch, boolean patternMatch) {\n        try {\n            NameLookup nameLookup = ((JavaProject) javaProject).newNameLookup((WorkingCopyOwner) null);\n            return nameLookup.findPackageFragments(name, partialMatch, patternMatch);\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    @Nullable\n    public static ITypeBinding findType(@NotNull FqName fqName, @NotNull IJavaProject javaProject) {\n        IType eclipseType = null;\n        try {\n            eclipseType = javaProject.findType(fqName.asString());\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        if (eclipseType != null) {\n            return !isInKotlinBinFolder(eclipseType) ? createTypeBinding(eclipseType) : null;\n        }\n        \n        return null;\n    }\n    \n    public static boolean isInKotlinBinFolder(@NotNull IType eclipseType) {\n        IFolder kotlinBinFolder = KotlinJavaManager.INSTANCE.getKotlinBinFolderFor(eclipseType.getJavaProject().getProject());\n        IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) eclipseType.getPackageFragment().getParent();\n        return kotlinBinFolder.equals(packageFragmentRoot.getResource());\n    }\n    \n    public static ITypeBinding createTypeBinding(IType type) {\n        ASTParser parser = ASTParser.newParser(AST.JLS8);\n        parser.setCompilerOptions(type.getJavaProject().getOptions(true));\n        parser.setIgnoreMethodBodies(true);\n        \n        if (type.getCompilationUnit() != null) {\n            parser.setSource(type.getCompilationUnit());\n        } else { // class file with no source\n            parser.setProject(type.getJavaProject());\n            IBinding[] bindings = parser.createBindings(new IJavaElement[] { type }, null);\n            if (bindings.length == 1 && bindings[0] instanceof ITypeBinding) {\n                return (ITypeBinding) bindings[0];\n            }\n            \n            return null;\n        }\n        \n        parser.setResolveBindings(true);\n        CompilationUnit root = (CompilationUnit) parser.createAST(null);\n        return getTypeBinding(root, type);\n    }\n    \n    private static ASTNode getParent(ASTNode node, Class<? extends ASTNode> parentClass) {\n        do {\n            node = node.getParent();\n        } while (node != null && !parentClass.isInstance(node));\n        return node;\n    }\n    \n    private static ITypeBinding getTypeBinding(CompilationUnit root, IType type) {\n        try {\n            if (type.isAnonymous()) {\n                final IJavaElement parent = type.getParent();\n                if (parent instanceof IField && Flags.isEnum(((IMember) parent).getFlags())) {\n                    final EnumConstantDeclaration constant = (EnumConstantDeclaration) NodeFinder.perform(root,\n                            ((ISourceReference) parent).getSourceRange());\n                    if (constant != null) {\n                        final AnonymousClassDeclaration declaration = constant.getAnonymousClassDeclaration();\n                        if (declaration != null) return declaration.resolveBinding();\n                    }\n                } else {\n                    final ClassInstanceCreation creation = (ClassInstanceCreation) getParent(\n                            NodeFinder.perform(root, type.getNameRange()), ClassInstanceCreation.class);\n                    if (creation != null) return creation.resolveTypeBinding();\n                }\n            } else {\n                final AbstractTypeDeclaration declaration = \n                        (AbstractTypeDeclaration) getParent(NodeFinder.perform(root, type.getNameRange()), AbstractTypeDeclaration.class);\n                if (declaration != null) return declaration.resolveBinding();\n            }\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n\n    @Override\n    @Nullable\n    public Set<String> knownClassNamesInPackage(@NotNull FqName packageFqName) {\n        // TODO Auto-generated method stub\n        return null;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/resolver/EclipseJavaSourceElement.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.resolver;\n\nimport org.eclipse.jdt.core.dom.IBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElement;\nimport org.jetbrains.kotlin.descriptors.SourceFile;\nimport org.jetbrains.kotlin.load.java.sources.JavaSourceElement;\nimport org.jetbrains.kotlin.load.java.structure.JavaElement;\n\npublic class EclipseJavaSourceElement implements JavaSourceElement {\n    private final JavaElement javaElement;\n    \n    public EclipseJavaSourceElement(JavaElement javaElement) {\n        this.javaElement = javaElement;\n    }\n    \n    @Override\n    @NotNull\n    public JavaElement getJavaElement() {\n        return javaElement;\n    }\n    \n    @NotNull\n    public IBinding getElementBinding() {\n        return ((EclipseJavaElement<?>) javaElement).getBinding();\n    }\n\n    @Override\n    @NotNull\n    public SourceFile getContainingFile() {\n        return SourceFile.NO_SOURCE_FILE;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/resolver/EclipseJavaSourceElementFactory.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.resolver;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.load.java.sources.JavaSourceElement;\nimport org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory;\nimport org.jetbrains.kotlin.load.java.structure.JavaElement;\n\npublic class EclipseJavaSourceElementFactory implements JavaSourceElementFactory {\n\n    @Override\n    @NotNull\n    public JavaSourceElement source(@NotNull JavaElement javaElement) {\n        return new EclipseJavaSourceElement(javaElement);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/resolver/EclipseTraceBasedJavaResolverCache.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.resolver\n\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.jetbrains.kotlin.descriptors.ConstructorDescriptor\nimport org.jetbrains.kotlin.descriptors.PropertyDescriptor\nimport org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor\nimport org.jetbrains.kotlin.load.java.components.JavaResolverCache\nimport org.jetbrains.kotlin.load.java.structure.*\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.tail\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.BindingTrace\nimport org.jetbrains.kotlin.resolve.lazy.ResolveSession\nimport org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils\nimport javax.inject.Inject\n\nclass EclipseTraceBasedJavaResolverCache(@Inject val trace: BindingTrace, @Inject val resolveSession: ResolveSession) : JavaResolverCache {\n\t\n    override fun getClassResolvedFromSource(fqName: FqName): ClassDescriptor? {\n        return trace[BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe()] ?: findInPackageFragments(fqName)\n    }\n\n    override fun recordMethod(p0: JavaMember, p1: SimpleFunctionDescriptor) {\n    }\n\n    override fun recordConstructor(element: JavaElement, descriptor: ConstructorDescriptor) {\n    }\n\n    override fun recordField(field: JavaField, descriptor: PropertyDescriptor) {\n    }\n\n    override fun recordClass(javaClass: JavaClass, descriptor: ClassDescriptor) {\n    }\n    \n    // Copied from org.jetbrains.kotlin.load.java.components.LazyResolveBasedCache\n    private fun findInPackageFragments(fullFqName: FqName): ClassDescriptor? {\n        var fqName = if (fullFqName.isRoot) fullFqName else fullFqName.parent()\n    \n        while (true) {\n            val packageDescriptor = resolveSession.getPackageFragment(fqName)\n            if (packageDescriptor == null) break\n    \n            val result = ResolveSessionUtils.findClassByRelativePath(\n                    packageDescriptor.getMemberScope(), fullFqName.tail(fqName))\n            if (result != null) return result\n    \n            if (fqName.isRoot) break\n            fqName = fqName.parent()\n        }\n    \n        return null\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaAnnotation.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.dom.IAnnotationBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument\nimport org.jetbrains.kotlin.load.java.structure.JavaClass\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.name.Name\nimport java.util.*\n\nclass EclipseJavaAnnotation(javaAnnotation: IAnnotationBinding) :\n    EclipseJavaElement<IAnnotationBinding>(javaAnnotation), JavaAnnotation\n{\n    private val javaProject: IJavaProject = javaAnnotation.annotationType.getPackage().javaElement.javaProject\n\n    override val arguments: Collection<JavaAnnotationArgument>\n        get() {\n            val arguments = ArrayList<JavaAnnotationArgument>()\n            for (memberValuePair in binding.declaredMemberValuePairs) {\n                arguments.add(\n                    EclipseJavaAnnotationArgument.create(\n                        memberValuePair.value,\n                        Name.identifier(memberValuePair.name),\n                        javaProject\n                    )\n                )\n            }\n\n            return arguments\n        }\n\n    override val classId: ClassId?\n        get() {\n            val annotationType = binding.annotationType\n            return if (annotationType != null) EclipseJavaElementUtil.computeClassId(annotationType) else null\n        }\n\n    override fun resolve(): JavaClass? {\n        val annotationType = binding.annotationType\n        return if (annotationType != null) EclipseJavaClass(annotationType) else null\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaAnnotationArgument.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.dom.IAnnotationBinding\nimport org.eclipse.jdt.core.dom.IBinding\nimport org.eclipse.jdt.core.dom.ITypeBinding\nimport org.eclipse.jdt.core.dom.IVariableBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument\nimport org.jetbrains.kotlin.name.Name\n\npublic abstract class EclipseJavaAnnotationArgument<T : IBinding>(javaElement: T) :\n\t\tEclipseJavaElement<T>(javaElement), JavaAnnotationArgument {\n\n\toverride val name: Name?\n\t\tget() = Name.identifier(binding.getName())\n\n\tcompanion object {\n\t\t@JvmStatic\n\t\tfun create(value: Any, name: Name, javaProject: IJavaProject): JavaAnnotationArgument {\n\t\t\treturn when (value) {\n\t\t\t\tis IAnnotationBinding -> EclipseJavaAnnotationAsAnnotationArgument(value, name)\n\t\t\t\tis IVariableBinding -> EclipseJavaReferenceAnnotationArgument(value)\n\t\t\t\tis Array<*> -> EclipseJavaArrayAnnotationArgument(value, name, javaProject)\n\t\t\t\tis Class<*> -> EclipseJavaClassObjectAnnotationArgument(value, name, javaProject)\n\t\t\t\tis ITypeBinding -> EclipseJavaTypeAsAnnotationArgument(value, name)\n\t\t\t\tis String, is Boolean, is Int, is Short, is Long, is Byte, is Float, is Double, is Char ->\n\t\t\t\t    EclipseJavaLiteralAnnotationArgument(value, name)\n\t\t\t\telse -> throw IllegalArgumentException(\"Wrong annotation argument: $value\")\n\t\t\t}\n\t\t}\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaAnnotationAsAnnotationArgument.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.IAnnotationBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationAsAnnotationArgument\nimport org.jetbrains.kotlin.name.Name\n\npublic class EclipseJavaAnnotationAsAnnotationArgument(\n\t\tprivate val annotation: IAnnotationBinding, \n\t\toverride val name: Name?) : JavaAnnotationAsAnnotationArgument {\n\toverride public fun getAnnotation(): JavaAnnotation = EclipseJavaAnnotation(annotation)\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaArrayAnnotationArgument.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument\nimport org.jetbrains.kotlin.load.java.structure.JavaArrayAnnotationArgument\nimport org.jetbrains.kotlin.name.Name\n\npublic class EclipseJavaArrayAnnotationArgument(\n\t\tprivate val arguments: Array<*>, \n\t\toverride val name: Name, \n\t\tprivate val javaProject: IJavaProject) : JavaArrayAnnotationArgument {\n\toverride public fun getElements(): List<JavaAnnotationArgument> {\n\t\treturn arguments.map { EclipseJavaAnnotationArgument.create(it!!, name, javaProject) }\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaArrayType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.load.java.structure.JavaArrayType;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\n\npublic class EclipseJavaArrayType extends EclipseJavaType<ITypeBinding> implements JavaArrayType {\n\n    public EclipseJavaArrayType(@NotNull ITypeBinding typeBinding) {\n        super(typeBinding);\n    }\n\n    @Override\n    @NotNull\n    public JavaType getComponentType() {\n        return EclipseJavaType.create(getBinding().getComponentType());\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaClass.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.ITypeBinding\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.classifierTypes\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.typeParameters\nimport org.jetbrains.kotlin.descriptors.Visibility\nimport org.jetbrains.kotlin.load.java.structure.*\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.name.SpecialNames\nimport java.lang.reflect.Modifier\n\npublic class EclipseJavaClass(javaElement: ITypeBinding) : EclipseJavaClassifier<ITypeBinding>(javaElement), JavaClass {\n    override val name: Name = SpecialNames.safeIdentifier(binding.getName())\n\n    override val isAbstract: Boolean = Modifier.isAbstract(binding.getModifiers())\n\n    override val isStatic: Boolean = Modifier.isStatic(binding.getModifiers())\n\n    override val isFinal: Boolean = Modifier.isFinal(binding.getModifiers())\n\n    override val visibility: Visibility = EclipseJavaElementUtil.getVisibility(binding)\n\n    override val typeParameters: List<JavaTypeParameter>\n        get() = typeParameters(binding.getTypeParameters())\n\n    override val innerClassNames: Collection<Name>\n        get() = binding.declaredTypes.mapNotNull { it.name?.takeIf(Name::isValidIdentifier)?.let(Name::identifier) }\n\n    override fun findInnerClass(name: Name): JavaClass? {\n        return binding.declaredTypes.find { it.name == name.asString() }?.let(::EclipseJavaClass)\n    }\n\n    override val fqName: FqName? = binding.getQualifiedName()?.let { FqName(it) }\n\n    override val isInterface: Boolean = binding.isInterface()\n    override val isRecord: Boolean\n        get() = false //TODO\n    override val isSealed: Boolean\n        get() = false //TODO\n\n    override val isAnnotationType: Boolean = binding.isAnnotation()\n\n    override val isEnum: Boolean = binding.isEnum()\n\n    override val outerClass: JavaClass?\n        get() = binding.getDeclaringClass()?.let { EclipseJavaClass(it) }\n    override val permittedTypes: Collection<JavaClassifierType>\n        get() = emptyList() //TODO\n    override val recordComponents: Collection<JavaRecordComponent>\n        get() = emptyList() // TODO\n\n    override val supertypes: Collection<JavaClassifierType>\n        get() = classifierTypes(EclipseJavaElementUtil.getSuperTypesWithObject(binding))\n\n    override val methods: Collection<JavaMethod>\n        get() = binding.declaredMethods.filterNot { it.isConstructor() }.map(::EclipseJavaMethod)\n\n    override val fields: Collection<JavaField>\n        get() = binding.getDeclaredFields()\n                .filter {\n                    val name = it.getName()\n                    name != null && Name.isValidIdentifier(name)\n                }\n                .map { EclipseJavaField(it) }\n\n    override val constructors: Collection<JavaConstructor>\n        get() = binding.declaredMethods.filter { it.isConstructor() }.map(::EclipseJavaConstructor)\n\n    override val isDeprecatedInJavaDoc: Boolean = binding.isDeprecated\n\n    override val annotations: Collection<JavaAnnotation>\n        get() = binding.annotations.map(::EclipseJavaAnnotation)\n\n    override val lightClassOriginKind: LightClassOriginKind?\n        get() = binding.javaElement.let {\n            if (EclipseJavaElementUtil.isKotlinLightClass(it))\n                LightClassOriginKind.SOURCE\n            else\n                null\n        }\n\n    override fun hasDefaultConstructor() = !isInterface && constructors.isEmpty()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaClassObjectAnnotationArgument.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaClassObjectAnnotationArgument;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder;\n\npublic class EclipseJavaClassObjectAnnotationArgument implements JavaClassObjectAnnotationArgument {\n\n    private final Class<?> javaClass;\n    private final IJavaProject javaProject;\n    private final Name name;\n    \n    protected EclipseJavaClassObjectAnnotationArgument(Class<?> javaClass, @NotNull Name name, @NotNull IJavaProject javaProject) {\n        this.javaClass = javaClass;\n        this.name = name;\n        this.javaProject = javaProject;\n    }\n\n    @Override\n    @NotNull\n    public JavaType getReferencedType() {\n        ITypeBinding typeBinding = EclipseJavaClassFinder.findType(new FqName(javaClass.getCanonicalName()), javaProject);\n        assert typeBinding != null;\n        return EclipseJavaType.create(typeBinding);\n    }\n\n    @Override\n    @Nullable\n    public Name getName() {\n        return name;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaClassifier.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.ITypeBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaClassifier\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation\nimport org.jetbrains.kotlin.name.FqName\n\npublic abstract class EclipseJavaClassifier<T : ITypeBinding>(javaType: T) : \n        EclipseJavaElement<T>(javaType), JavaClassifier, JavaAnnotationOwner {\n    companion object {\n        @JvmStatic\n        fun create(element: ITypeBinding): JavaClassifier {\n            return when {\n                element.isTypeVariable() -> EclipseJavaTypeParameter(element)\n                \n                element.isClass() || element.isParameterizedType() || \n                    element.isInterface() || element.isEnum() -> EclipseJavaClass(element)\n                \n                else -> throw IllegalArgumentException(\"Element: ${element.getName()} is not JavaClassifier\")\n            }\n        }\n    }\n    \n    override val annotations: Collection<JavaAnnotation>\n        get() = binding.getAnnotations().map(::EclipseJavaAnnotation)\n    \n    override fun findAnnotation(fqName: FqName): JavaAnnotation? {\n        return EclipseJavaElementUtil.findAnnotation(binding.getAnnotations(), fqName)\n    }\n    \n    override val isDeprecatedInJavaDoc: Boolean = binding.isDeprecated()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaClassifierType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport static org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.types;\n\nimport java.util.List;\n\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaClassifier;\nimport org.jetbrains.kotlin.load.java.structure.JavaClassifierType;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\n\npublic class EclipseJavaClassifierType extends EclipseJavaType<ITypeBinding> implements JavaClassifierType {\n\n    public EclipseJavaClassifierType(ITypeBinding typeBinding) {\n        super(typeBinding);\n    }\n\n    @Override\n    @Nullable\n    public JavaClassifier getClassifier() {\n        return EclipseJavaClassifier.Companion.create(getBinding().getTypeDeclaration());\n    }\n    \n    @Override\n    @NotNull\n    public String getPresentableText() {\n        return getBinding().getQualifiedName();\n    }\n\n    @Override\n    public boolean isRaw() {\n        return getBinding().isRawType();\n    }\n\n    @Override\n    @NotNull\n    public List<JavaType> getTypeArguments() {\n        return types(getBinding().getTypeArguments());\n    }\n\n    @Override\n    @NotNull\n    public String getClassifierQualifiedName() {\n        return getBinding().getName();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaConstructor.java",
    "content": "package org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport static org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.typeParameters;\n\nimport java.util.List;\n\nimport org.eclipse.jdt.core.dom.IMethodBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.load.java.structure.JavaClass;\nimport org.jetbrains.kotlin.load.java.structure.JavaConstructor;\nimport org.jetbrains.kotlin.load.java.structure.JavaTypeParameter;\nimport org.jetbrains.kotlin.load.java.structure.JavaValueParameter;\n\npublic class EclipseJavaConstructor extends EclipseJavaMember<IMethodBinding> implements JavaConstructor {\n    \n    public EclipseJavaConstructor(@NotNull IMethodBinding methodBinding) {\n        super(methodBinding);\n        assert methodBinding.isConstructor() :\n            \"Method binding which is not a constructor should not be wrapped in EclipseJavaConstructor: \" + methodBinding.getName();\n    }\n    \n    @Override\n    @NotNull\n    public JavaClass getContainingClass() {\n        return new EclipseJavaClass(getBinding().getDeclaringClass());\n    }\n    \n    @Override\n    @NotNull\n    public List<JavaTypeParameter> getTypeParameters() {\n        return typeParameters(getBinding().getTypeParameters());\n    }\n    \n    @Override\n    @NotNull\n    public List<JavaValueParameter> getValueParameters() {\n        return EclipseJavaElementUtil.getValueParameters(getBinding());\n    }\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaElement.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.IBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaElement\n\nabstract class EclipseJavaElement<T : IBinding> protected constructor(val binding: T) : JavaElement {\n    override fun hashCode(): Int = binding.hashCode()\n    override fun equals(other: Any?): Boolean = other is EclipseJavaElement<*> && binding == other.binding\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaElementFactory.java",
    "content": "/*******************************************************************************\n * Copyright 2010-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.jdt.core.dom.IAnnotationBinding;\nimport org.eclipse.jdt.core.dom.IMethodBinding;\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.eclipse.jdt.core.dom.IVariableBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaClassifierType;\nimport org.jetbrains.kotlin.load.java.structure.JavaField;\nimport org.jetbrains.kotlin.load.java.structure.JavaMethod;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\nimport org.jetbrains.kotlin.load.java.structure.JavaTypeParameter;\n\npublic class EclipseJavaElementFactory {\n    private EclipseJavaElementFactory() {\n    }\n    \n    private interface Factory<Binding, Java> {\n        @NotNull\n        Java create(@NotNull Binding binding);\n    }\n    \n    private static class Factories {\n        private static final Factory<IAnnotationBinding, JavaAnnotation> ANNOTATIONS = new Factory<IAnnotationBinding, JavaAnnotation>() {\n            @Override\n            @NotNull\n            public JavaAnnotation create(@NotNull IAnnotationBinding annotationBinding) {\n                return new EclipseJavaAnnotation(annotationBinding);\n            }\n        };\n        \n        private static final Factory<ITypeBinding, JavaClassifierType> CLASSIFIER_TYPES = new Factory<ITypeBinding, JavaClassifierType>() {\n            @Override\n            @NotNull\n            public JavaClassifierType create(@NotNull ITypeBinding typeBinding) {\n                return new EclipseJavaClassifierType(typeBinding);\n            }\n        };\n        \n        private static final Factory<ITypeBinding, JavaType> TYPES = new Factory<ITypeBinding, JavaType>() {\n            @Override\n            @NotNull\n            public JavaType create(@NotNull ITypeBinding typeBinding) {\n                return EclipseJavaType.create(typeBinding);\n            }\n        };\n        \n        private static final Factory<IMethodBinding, JavaMethod> METHODS = new Factory<IMethodBinding, JavaMethod>() {\n            @Override\n            @NotNull\n            public JavaMethod create(@NotNull IMethodBinding methodBinding) {\n                return new EclipseJavaMethod(methodBinding);\n            }\n        };\n        \n        private static final Factory<IVariableBinding, JavaField> FIELDS = new Factory<IVariableBinding, JavaField>() {\n            @Override\n            @NotNull\n            public JavaField create(@NotNull IVariableBinding variableBinding) {\n                return new EclipseJavaField(variableBinding);\n            }\n        };\n        \n        private static final Factory<ITypeBinding, JavaTypeParameter> TYPE_PARAMETERS = new Factory<ITypeBinding, JavaTypeParameter>() {\n            @Override\n            @NotNull\n            public JavaTypeParameter create(@NotNull ITypeBinding typeParameterBinding) {\n                return new EclipseJavaTypeParameter(typeParameterBinding);\n            }\n        };\n    }\n    \n    @NotNull\n    private static <Binding, Java> List<Java> convert(@NotNull Binding[] elements, @NotNull Factory<Binding, Java> factory) {\n        if (elements.length == 0) return Collections.emptyList();\n        List<Java> result = new ArrayList<Java>();\n        for (Binding element : elements) {\n            result.add(factory.create(element));\n        }\n        return result;\n    }\n    \n    @NotNull\n    public static List<JavaAnnotation> annotations(@NotNull IAnnotationBinding[] annotations) {\n        return convert(annotations, Factories.ANNOTATIONS);\n    }\n    \n    @NotNull\n    public static List<JavaClassifierType> classifierTypes(@NotNull ITypeBinding[] classTypes) {\n        return convert(classTypes, Factories.CLASSIFIER_TYPES);\n    }\n    \n    @NotNull\n    public static List<JavaMethod> methods(@NotNull IMethodBinding[] methods) {\n        return convert(methods, Factories.METHODS);\n    }\n    \n    @NotNull\n    public static List<JavaField> fields(@NotNull IVariableBinding[] variables) {\n        return convert(variables, Factories.FIELDS);\n    }\n    \n    @NotNull\n    public static List<JavaType> types(@NotNull ITypeBinding[] types) {\n        return convert(types, Factories.TYPES);\n    }\n    \n    @NotNull\n    public static List<JavaTypeParameter> typeParameters(@NotNull ITypeBinding[] typeParameters) {\n        return convert(typeParameters, Factories.TYPE_PARAMETERS);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaElementUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.eclipse.core.resources.IContainer;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.core.dom.IAnnotationBinding;\nimport org.eclipse.jdt.core.dom.IBinding;\nimport org.eclipse.jdt.core.dom.IMethodBinding;\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;\nimport org.eclipse.jdt.internal.core.BinaryMethod;\nimport org.eclipse.jdt.internal.core.BinaryType;\nimport org.eclipse.jdt.internal.core.ClassFile;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.filesystem.KotlinFileSystem;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\nimport org.jetbrains.kotlin.descriptors.Visibilities;\nimport org.jetbrains.kotlin.descriptors.Visibility;\nimport org.jetbrains.kotlin.descriptors.java.JavaVisibilities;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaValueParameter;\nimport org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache;\nimport org.jetbrains.kotlin.load.kotlin.KotlinClassFinder;\nimport org.jetbrains.kotlin.name.ClassId;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\nimport org.eclipse.jdt.core.dom.Modifier;\nimport org.eclipse.jdt.core.Flags;\n\nimport com.intellij.openapi.application.ApplicationManager;\nimport com.intellij.openapi.util.io.FileUtil;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.openapi.vfs.VirtualFileManager;\nimport com.intellij.psi.CommonClassNames;\n\npublic class EclipseJavaElementUtil {\n\n    @NotNull\n    static Visibility getVisibility(@NotNull IBinding member) {\n        int flags = member.getModifiers();\n        if (Modifier.isPublic(flags)) {\n            return Visibilities.Public.INSTANCE;\n        } else if (Modifier.isPrivate(flags)) {\n            return Visibilities.Private.INSTANCE;\n        } else if (Modifier.isProtected(flags)) {\n            return Flags.isStatic(flags) ? JavaVisibilities.ProtectedAndPackage.INSTANCE : JavaVisibilities.ProtectedAndPackage.INSTANCE;\n        }\n\n        return JavaVisibilities.PackageVisibility.INSTANCE;\n    }\n\n    private static List<ITypeBinding> getSuperTypes(@NotNull ITypeBinding typeBinding) {\n        List<ITypeBinding> superTypes = new ArrayList<>();\n        for (ITypeBinding superInterface : typeBinding.getInterfaces()) {\n            superTypes.add(superInterface);\n        }\n\n        ITypeBinding superClass = typeBinding.getSuperclass();\n        if (superClass != null) {\n            superTypes.add(superClass);\n        }\n\n        return superTypes;\n    }\n\n    static ITypeBinding[] getSuperTypesWithObject(@NotNull ITypeBinding typeBinding) {\n        List<ITypeBinding> allSuperTypes = new ArrayList<>();\n\n        boolean javaLangObjectInSuperTypes = false;\n        for (ITypeBinding superType : getSuperTypes(typeBinding)) {\n            if (superType.getQualifiedName().equals(CommonClassNames.JAVA_LANG_OBJECT)) {\n                javaLangObjectInSuperTypes = true;\n            }\n            allSuperTypes.add(superType);\n        }\n\n        if (!javaLangObjectInSuperTypes && !typeBinding.getQualifiedName().equals(CommonClassNames.JAVA_LANG_OBJECT)) {\n            allSuperTypes.add(getJavaLangObjectBinding(typeBinding.getJavaElement().getJavaProject()));\n        }\n\n        return allSuperTypes.toArray(new ITypeBinding[allSuperTypes.size()]);\n    }\n\n    @NotNull\n    private static ITypeBinding getJavaLangObjectBinding(@NotNull IJavaProject javaProject) {\n        try {\n            IType javaType = javaProject.findType(CommonClassNames.JAVA_LANG_OBJECT);\n            if(javaType == null) {\n            \treturn null; // this happens if the project was modified while analyzing in progress.\n            }\n            return EclipseJavaClassFinder.createTypeBinding(javaType);\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n            throw new IllegalStateException(e);\n        }\n    }\n\n    @NotNull\n    static List<JavaValueParameter> getValueParameters(@NotNull IMethodBinding method) {\n        List<JavaValueParameter> parameters = new ArrayList<JavaValueParameter>();\n        ITypeBinding[] parameterTypes = method.getParameterTypes();\n\n        String[] parameterNames = getParameterNames(method);\n        int parameterTypesCount = parameterTypes.length;\n        for (int i = 0; i < parameterTypesCount; ++i) {\n            boolean isLastParameter = i == parameterTypesCount - 1;\n            parameters.add(new EclipseJavaValueParameter(\n                    parameterTypes[i],\n                    method.getParameterAnnotations(i),\n                    parameterNames[i],\n                    isLastParameter ? method.isVarargs() : false));\n        }\n\n        return parameters;\n    }\n\n    @NotNull\n    private static String[] getParameterNames(@NotNull IMethodBinding methodBinding) {\n        try {\n            IMethod methodElement = (IMethod) methodBinding.getJavaElement();\n            String[] parameterNames;\n            if (methodElement != null && methodElement.exists()) {\n                parameterNames = methodElement.getParameterNames();\n            } else {\n                int parametersCount = methodBinding.getParameterTypes().length;\n                parameterNames = new String[parametersCount];\n                for (int i = 0; i < parametersCount; ++i) {\n                    parameterNames[i] = \"arg\" + i;\n                }\n            }\n\n            return parameterNames;\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n\n        throw new RuntimeException();\n    }\n\n    public static JavaAnnotation findAnnotation(@NotNull IAnnotationBinding[] annotationBindings, @NotNull FqName fqName) {\n        for (IAnnotationBinding annotation : annotationBindings) {\n            String annotationFQName = annotation.getAnnotationType().getQualifiedName();\n            if (fqName.asString().equals(annotationFQName)) {\n                return new EclipseJavaAnnotation(annotation);\n            }\n        }\n\n        return null;\n    }\n\n    @Nullable\n    public static ClassId computeClassId(@NotNull ITypeBinding classBinding) {\n        ITypeBinding container = classBinding.getDeclaringClass();\n        if (container != null) {\n            ClassId parentClassId = computeClassId(container);\n            return parentClassId == null ? null : parentClassId.createNestedClassId(Name.identifier(classBinding.getName()));\n        }\n\n        String fqName = classBinding.getQualifiedName();\n        return fqName == null ? null : ClassId.topLevel(new FqName(fqName));\n    }\n\n    public static boolean isKotlinLightClass(@NotNull IJavaElement element) {\n        IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(element.getPath());\n        if (resource == null) {\n            return false;\n        }\n\n        return isFromKotlinBinFolder(resource);\n    }\n\n    public static boolean isFromKotlinBinFolder(@NotNull IResource resource) {\n        IContainer parent = resource.getParent();\n        while (parent != null) {\n            if (KotlinFileSystem.SCHEME.equals(parent.getLocationURI().getScheme())) {\n                return true;\n            }\n            parent = parent.getParent();\n        }\n\n        return false;\n    }\n\n    public static boolean isFromKotlinBinFolder(@NotNull IJavaElement element) {\n        IClassFile classFile;\n        if (element instanceof IClassFile) {\n            classFile = (IClassFile) element;\n        } else if (element instanceof BinaryType) {\n            classFile = ((BinaryType) element).getClassFile();\n        } else if(element instanceof BinaryMethod) {\n            classFile = ((BinaryMethod) element).getClassFile();\n        } else {\n            return false;\n        }\n        return classFile.getResource() == null || isFromKotlinBinFolder(classFile.getResource());\n    }\n\n    public static boolean isKotlinBinaryElement(@NotNull IJavaElement element) {\n        IClassFile classFile;\n        if (element instanceof IClassFile) {\n            classFile = (IClassFile) element;\n        } else if (element instanceof BinaryType) {\n            classFile = ((BinaryType) element).getClassFile();\n        } else {\n            return false;\n        }\n        return isKotlinClassFile(classFile);\n    }\n\n    private static boolean isKotlinClassFile(IClassFile classFile) {\n        IPath classFilePath = ProjectUtils.convertToGlobalPath(classFile.getPath());\n        if (classFilePath == null) {\n            return false;\n        }\n        VirtualFile virtualFile = jarFileOrDirectoryToVirtualFile(classFilePath.toFile());\n        if (virtualFile == null) return false;\n\n        String relativePath = classFile.getType().getFullyQualifiedName().replace('.', '/') + \".class\";\n        VirtualFile archiveRelativeFile = virtualFile.findFileByRelativePath(relativePath);\n        if (archiveRelativeFile == null) {\n            return false;\n        }\n        KotlinClassFinder.Result binaryClass = KotlinBinaryClassCache.Companion.getKotlinBinaryClassOrClassFileContent(archiveRelativeFile, null);\n        if (binaryClass == null) {\n            return false;\n        }\n        if (classFile instanceof ClassFile) {\n            try {\n                IBinaryAnnotation[] annotations = ((ClassFile) classFile).getBinaryTypeInfo().getAnnotations();\n                if (annotations != null) {\n                    for (IBinaryAnnotation info : annotations) {\n                        if (Arrays.equals(info.getTypeName(), \"Lkotlin/Metadata;\".toCharArray())) return true;\n                    }\n                }\n            } catch (JavaModelException ignored) { }\n        }\n        return false;\n    }\n\n    @Nullable\n    private static VirtualFile jarFileOrDirectoryToVirtualFile(@NotNull File file) {\n        if (ApplicationManager.getApplication() == null) return null;\n        if (file.exists()) {\n            if (file.isDirectory()) {\n                return VirtualFileManager.getInstance()\n                        .findFileByUrl(\"file://\" + FileUtil.toSystemIndependentName(file.getAbsolutePath()));\n            } else {\n                return VirtualFileManager.getInstance().findFileByUrl(\"jar://\" + FileUtil.toSystemIndependentName(file.getAbsolutePath()) + \"!/\");\n            }\n        } else {\n            throw new IllegalStateException(\"Path \" + file + \" does not exist.\");\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaField.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.IVariableBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaClass\nimport org.jetbrains.kotlin.load.java.structure.JavaField\nimport org.jetbrains.kotlin.load.java.structure.JavaType\n\npublic class EclipseJavaField(private val javaField: IVariableBinding) : EclipseJavaMember<IVariableBinding>(javaField), JavaField {\n    override val hasConstantNotNullInitializer: Boolean\n        get() = false\n    \n    override val initializerValue: Any? = binding.constantValue\n\n    override val isEnumEntry: Boolean = binding.isEnumConstant()\n    \n    override val type: JavaType\n        get() = EclipseJavaType.create(binding.getType())\n    \n    override val containingClass: JavaClass\n        get() = EclipseJavaClass(binding.getDeclaringClass())\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaLiteralAnnotationArgument.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaLiteralAnnotationArgument;\nimport org.jetbrains.kotlin.name.Name;\n\npublic class EclipseJavaLiteralAnnotationArgument implements JavaLiteralAnnotationArgument {\n\n    private final Object value;\n    private final Name name;\n\n    public EclipseJavaLiteralAnnotationArgument(@NotNull Object value, @NotNull Name name) {\n        this.value = value;\n        this.name = name;\n    }\n\n    @Override\n    @Nullable\n    public Name getName() {\n        return name;\n    }\n\n    @Override\n    @Nullable\n    public Object getValue() {\n        return value;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaMember.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport static org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.annotations;\n\nimport java.lang.reflect.Modifier;\nimport java.util.Collection;\n\nimport org.eclipse.jdt.core.dom.IBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.descriptors.Visibility;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaMember;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\n\npublic abstract class EclipseJavaMember<T extends IBinding> extends EclipseJavaElement<T> implements JavaMember {\n\n    protected EclipseJavaMember(@NotNull T javaElement) {\n        super(javaElement);\n    }\n    \n    @Override\n    @NotNull\n    public Collection<JavaAnnotation> getAnnotations() {\n        return annotations(getBinding().getAnnotations());\n    }\n\n    @Override\n    @Nullable\n    public JavaAnnotation findAnnotation(@NotNull FqName fqName) {\n        return EclipseJavaElementUtil.findAnnotation(getBinding().getAnnotations(), fqName);\n    }\n\n    @Override\n    public boolean isAbstract() {\n        return Modifier.isAbstract(getBinding().getModifiers());\n    }\n\n    @Override\n    public boolean isStatic() {\n        return Modifier.isStatic(getBinding().getModifiers());\n    }\n\n    @Override\n    public boolean isFinal() {\n        return Modifier.isFinal(getBinding().getModifiers());\n    }\n\n    @Override\n    @NotNull\n    public Visibility getVisibility() {\n        return EclipseJavaElementUtil.getVisibility(getBinding());\n    }\n\n    @Override\n    @NotNull\n    public Name getName() {\n        return Name.identifier(getBinding().getName());\n    }\n    \n    @Override\n    public boolean isDeprecatedInJavaDoc() {\n         return getBinding().isDeprecated();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaMethod.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.typeParameters\n\nimport org.eclipse.jdt.core.dom.IMethodBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument\nimport org.jetbrains.kotlin.load.java.structure.JavaClass\nimport org.jetbrains.kotlin.load.java.structure.JavaMethod\nimport org.jetbrains.kotlin.load.java.structure.JavaType\nimport org.jetbrains.kotlin.load.java.structure.JavaTypeParameter\nimport org.jetbrains.kotlin.load.java.structure.JavaValueParameter\nimport org.jetbrains.kotlin.name.Name\n\nclass EclipseJavaMethod(method: IMethodBinding) : EclipseJavaMember<IMethodBinding>(method), JavaMethod {\n\n    override val typeParameters: List<JavaTypeParameter>\n        get() = typeParameters(binding.typeParameters)\n\n    override val valueParameters: List<JavaValueParameter>\n        get() = EclipseJavaElementUtil.getValueParameters(binding)\n\n    override val annotationParameterDefaultValue: JavaAnnotationArgument?\n        get() = with(binding) {\n            defaultValue?.let {\n                EclipseJavaAnnotationArgument.create(defaultValue, Name.identifier(name), javaElement.javaProject)\n            }\n        }\n\n    override val returnType: JavaType\n        get() = EclipseJavaType.create(binding.returnType)\n\n    override val containingClass: JavaClass\n        get() = EclipseJavaClass(binding.declaringClass)\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaPackage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaClass;\nimport org.jetbrains.kotlin.load.java.structure.JavaElement;\nimport org.jetbrains.kotlin.load.java.structure.JavaPackage;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\n\nimport kotlin.jvm.functions.Function1;\n\npublic class EclipseJavaPackage implements JavaElement, JavaPackage {\n    \n    private final List<IPackageFragment> packages = new ArrayList<>();\n    private final IJavaProject javaProject;\n\n    public EclipseJavaPackage(List<IPackageFragment> packages) {\n        this.packages.addAll(packages);\n        this.javaProject = packages.get(0).getJavaProject();\n    }\n    \n    public EclipseJavaPackage(IPackageFragment pckg) {\n        this(Collections.singletonList(pckg));\n    }\n    \n    @Override\n    @NotNull\n    public Collection<JavaClass> getClasses(@NotNull Function1<? super Name, Boolean> nameFilter) {\n        List<JavaClass> javaClasses = new ArrayList<>();\n        for (IPackageFragment pckg : packages) {\n            javaClasses.addAll(getClassesInPackage(pckg, nameFilter));\n        }\n        \n        return javaClasses;\n    }\n    \n    @Override\n    @NotNull\n    public Collection<JavaPackage> getSubPackages() {\n        String thisPackageName = getFqName().asString();\n        String pattern = thisPackageName.isEmpty() ? \"*\" : thisPackageName + \".\";\n        \n        IPackageFragment[] packageFragments = EclipseJavaClassFinder.findPackageFragments(\n                javaProject, pattern, true, true);\n\n        int thisNestedLevel = thisPackageName.split(\"\\\\.\").length;\n        List<JavaPackage> javaPackages = new ArrayList<>();\n        if (packageFragments != null && packageFragments.length > 0) {\n            for (IPackageFragment packageFragment : packageFragments) {\n                int subNestedLevel = packageFragment.getElementName().split(\"\\\\.\").length;\n                boolean applicableForRootPackage = thisNestedLevel == 1 && thisNestedLevel == subNestedLevel;\n                if (!packageFragment.getElementName().isEmpty() && \n                   (applicableForRootPackage || (thisNestedLevel + 1 == subNestedLevel))) {\n                    javaPackages.add(new EclipseJavaPackage(packageFragment));\n                }\n            }\n        }\n        \n        return javaPackages;\n    }\n\n    @Override\n    @NotNull\n    public FqName getFqName() {\n        return new FqName(packages.get(0).getElementName()); // They all should have same names\n    }\n    \n    private List<JavaClass> getClassesInPackage(IPackageFragment javaPackage, Function1<? super Name, ? extends Boolean> nameFilter) {\n        try {\n            List<JavaClass> javaClasses = new ArrayList<>();\n            for (IClassFile classFile : javaPackage.getClassFiles()) {\n                IType type = classFile.getType();\n                if (isOuterClass(classFile)) {\n                    String elementName = type.getElementName();\n                    if (Name.isValidIdentifier(elementName) && nameFilter.invoke(Name.identifier(elementName))) {\n                        javaClasses.add(new EclipseOptimizedJavaClass(type));\n                    }\n                }\n            }\n            \n            for (ICompilationUnit cu : javaPackage.getCompilationUnits()) {\n                for (IType javaClass : cu.getAllTypes()) {\n                    String elementName = javaClass.getElementName();\n                    if (Name.isValidIdentifier(elementName) && nameFilter.invoke(Name.identifier(elementName))) {\n                        javaClasses.add(new EclipseOptimizedJavaClass(javaClass));\n                    }\n                }\n            }\n            \n            return javaClasses;\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n            throw new IllegalStateException(e);\n        }\n    }\n\n    // TODO: Add correct resolve binding for all class files with $\n    private boolean isOuterClass(IClassFile classFile) {\n        return !classFile.getElementName().contains(\"$\");\n    }\n\n    @Override\n    @Nullable\n    public JavaAnnotation findAnnotation(@NotNull FqName arg0) {\n        return null;\n    }\n\n    @Override\n    @NotNull\n    public Collection<JavaAnnotation> getAnnotations() {\n        return Collections.emptyList();\n    }\n\n    @Override\n    public boolean isDeprecatedInJavaDoc() {\n        return false;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaPrimitiveType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.builtins.PrimitiveType;\nimport org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType;\nimport org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;\n\npublic class EclipseJavaPrimitiveType extends EclipseJavaType<ITypeBinding> implements JavaPrimitiveType {\n\n    public EclipseJavaPrimitiveType(ITypeBinding typeBinding) {\n        super(typeBinding);\n    }\n\n    @Override\n    @Nullable\n    public PrimitiveType getType() {\n        String text = getBinding().getName();\n        return \"void\".equals(text) ? null : JvmPrimitiveType.get(text).getPrimitiveType();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaPropertyInitializerEvaluator.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.descriptors.PropertyDescriptor;\nimport org.jetbrains.kotlin.load.java.components.JavaPropertyInitializerEvaluator;\nimport org.jetbrains.kotlin.load.java.structure.JavaField;\nimport org.jetbrains.kotlin.resolve.constants.ConstantValue;\nimport org.jetbrains.kotlin.resolve.constants.ConstantValueFactory;\n\npublic class EclipseJavaPropertyInitializerEvaluator implements JavaPropertyInitializerEvaluator {\n    @Override\n    @Nullable\n    public ConstantValue<?> getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) {\n        Object evaluated = field.getInitializerValue();\n        if (evaluated == null)\n            return null;\n        // Note: evaluated expression may be of class that does not match field type in\n        // some cases\n        // tested for Int, left other checks just in case\n        if (evaluated instanceof Byte || evaluated instanceof Short || evaluated instanceof Integer\n                || evaluated instanceof Long)\n            return ConstantValueFactory.INSTANCE.createIntegerConstantValue(((Number) evaluated).longValue(),\n                    descriptor.getType(),\n                    false);\n        else\n            return ConstantValueFactory.INSTANCE.createConstantValue(evaluated);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaReferenceAnnotationArgument.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.eclipse.jdt.core.dom.IVariableBinding;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaEnumValueAnnotationArgument;\nimport org.jetbrains.kotlin.load.java.structure.JavaField;\nimport org.jetbrains.kotlin.name.ClassId;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\n\npublic class EclipseJavaReferenceAnnotationArgument extends EclipseJavaAnnotationArgument<IVariableBinding>\n        implements JavaEnumValueAnnotationArgument {\n\n    protected EclipseJavaReferenceAnnotationArgument(IVariableBinding javaElement) {\n        super(javaElement);\n    }\n\n    @Nullable\n    public JavaField resolve() {\n        return new EclipseJavaField(getBinding());\n    }\n\n    @Override\n    @Nullable\n    public Name getEntryName() {\n        return Name.identifier(getBinding().getName());\n    }\n\n    @Override\n    @Nullable\n    public ClassId getEnumClassId() {\n        String className = getBinding().getType().getQualifiedName();\n        return ClassId.topLevel(new FqName(className));\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport static org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.annotations;\n\nimport java.util.Collection;\n\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\nimport org.jetbrains.kotlin.name.FqName;\n\npublic class EclipseJavaType<T extends ITypeBinding> implements JavaType, JavaAnnotationOwner {\n\n    private final T binding;\n    \n    public EclipseJavaType(@NotNull T binding) {\n        this.binding = binding;\n    }\n    \n    public static EclipseJavaType<?> create(@NotNull ITypeBinding typeBinding) {\n        if (typeBinding.isPrimitive()) {\n            return new EclipseJavaPrimitiveType(typeBinding); \n        } else if (typeBinding.isArray()) {\n            return new EclipseJavaArrayType(typeBinding);\n        } else if (typeBinding.isClass() || typeBinding.isTypeVariable() || \n                typeBinding.isInterface() || typeBinding.isParameterizedType() || \n                typeBinding.isEnum()) {\n            return new EclipseJavaClassifierType(typeBinding);\n        } else if (typeBinding.isWildcardType()) {\n            return new EclipseJavaWildcardType(typeBinding);\n        } else {\n            throw new UnsupportedOperationException(\"Unsupported EclipseType: \" + typeBinding);\n        }\n    }\n    \n    @NotNull\n    public T getBinding() {\n        return binding;\n    }\n    \n    @Override\n    public int hashCode() {\n        return getBinding().hashCode();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        return obj instanceof EclipseJavaType && getBinding().equals(((EclipseJavaType<?>) obj).getBinding());\n    }\n    \n    @Override\n    @NotNull\n    public Collection<JavaAnnotation> getAnnotations() {\n        return annotations(getBinding().getAnnotations());\n    }\n\n    @Override\n    @Nullable\n    public JavaAnnotation findAnnotation(@NotNull FqName fqName) {\n        return EclipseJavaElementUtil.findAnnotation(getBinding().getAnnotations(), fqName);\n    }\n\n    @Override\n    public boolean isDeprecatedInJavaDoc() {\n        return binding.isDeprecated();\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaTypeAsAnnotationArgument.kt",
    "content": "package org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.ITypeBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaClassObjectAnnotationArgument\nimport org.jetbrains.kotlin.load.java.structure.JavaType\nimport org.jetbrains.kotlin.name.Name\n\npublic class EclipseJavaTypeAsAnnotationArgument(binding: ITypeBinding, override val name: Name?)\n\t: EclipseJavaAnnotationArgument<ITypeBinding>(binding), JavaClassObjectAnnotationArgument {\n\n\toverride fun getReferencedType(): JavaType {\n\t\treturn EclipseJavaType(binding)\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaTypeParameter.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.dom.IMethodBinding\nimport org.eclipse.jdt.core.dom.ITypeBinding\nimport org.jetbrains.kotlin.load.java.structure.JavaClassifierType\nimport org.jetbrains.kotlin.load.java.structure.JavaType\nimport org.jetbrains.kotlin.load.java.structure.JavaTypeParameter\nimport org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.name.SpecialNames\n\npublic class EclipseJavaTypeParameter(binding: ITypeBinding) : EclipseJavaClassifier<ITypeBinding>(binding), JavaTypeParameter {\n    override val name: Name = SpecialNames.safeIdentifier(binding.getName())\n    \n    override val upperBounds: Collection<JavaClassifierType>\n        get() = binding.getTypeBounds().map(::EclipseJavaClassifierType)\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaValueParameter.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport static org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementFactory.annotations;\n\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport org.eclipse.jdt.core.dom.IAnnotationBinding;\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaAnnotation;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\nimport org.jetbrains.kotlin.load.java.structure.JavaValueParameter;\nimport org.jetbrains.kotlin.name.FqName;\nimport org.jetbrains.kotlin.name.Name;\n\npublic class EclipseJavaValueParameter extends EclipseJavaElement<ITypeBinding> implements JavaValueParameter {\n\n    private final String name;\n    private final boolean isVararg;\n    private final IAnnotationBinding[] annotationBindings;\n    \n    public EclipseJavaValueParameter(ITypeBinding type, IAnnotationBinding annotationBindings[], \n            String name, boolean isVararg) {\n        super(type);\n        this.name = name;\n        this.isVararg = isVararg;\n        this.annotationBindings = Arrays.copyOf(annotationBindings, annotationBindings.length);\n    }\n\n    @Override\n    @NotNull\n    public Collection<JavaAnnotation> getAnnotations() {\n        return annotations(annotationBindings);\n    }\n\n    @Override\n    @Nullable\n    public JavaAnnotation findAnnotation(@NotNull FqName fqName) {\n        return EclipseJavaElementUtil.findAnnotation(annotationBindings, fqName);\n    }\n\n    @Override\n    @Nullable\n    public Name getName() {\n        return Name.identifier(name);\n    }\n\n    @Override\n    @NotNull\n    public JavaType getType() {\n        return EclipseJavaType.create(getBinding());\n    }\n\n    @Override\n    public boolean isVararg() {\n        return isVararg;\n    }\n\n    @Override\n    public boolean isDeprecatedInJavaDoc() {\n        return getBinding().isDeprecated();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseJavaWildcardType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *  \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n *  You may obtain a copy of the License at\n *  \n * http://www.apache.org/licenses/LICENSE-2.0\n *   \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.java.structure;\n\nimport org.eclipse.jdt.core.dom.ITypeBinding;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.load.java.structure.JavaType;\nimport org.jetbrains.kotlin.load.java.structure.JavaWildcardType;\n\npublic class EclipseJavaWildcardType extends EclipseJavaType<ITypeBinding> implements JavaWildcardType {\n\n    public EclipseJavaWildcardType(@NotNull ITypeBinding typeBinding) {\n        super(typeBinding);\n    }\n\n    @Override\n    @Nullable\n    public JavaType getBound() {\n        ITypeBinding bound = getBinding().getBound();\n        return bound != null ? EclipseJavaType.create(bound) : null;\n    }\n\n    @Override\n    public boolean isExtends() {\n        return getBinding().isUpperbound();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/java/structure/EclipseOptimizedJavaClass.kt",
    "content": "package org.jetbrains.kotlin.core.resolve.lang.java.structure\n\nimport org.eclipse.jdt.core.IType\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.name.SpecialNames\nimport org.jetbrains.kotlin.descriptors.Visibility\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder\nimport org.jetbrains.kotlin.load.java.structure.*\n\nclass EclipseOptimizedJavaClass(val eclipseClass: IType) : JavaClass {\n    override val name: Name\n        get() = SpecialNames.safeIdentifier(eclipseClass.getElementName())\n    \n    override val constructors: Collection<JavaConstructor>\n        get() = throw UnsupportedOperationException()\n    \n    override val fields: Collection<JavaField>\n        get() = throw UnsupportedOperationException()\n    \n    override val fqName: FqName?\n        get() = throw UnsupportedOperationException()\n    \n    override val innerClassNames: Collection<Name>\n        get() = throw UnsupportedOperationException()\n    \n    override fun findInnerClass(name: Name): JavaClass? {\n        throw UnsupportedOperationException()\n    }\n    \n    override val isAnnotationType: Boolean\n        get() = throw UnsupportedOperationException()\n    \n    override val isEnum: Boolean\n        get() = throw UnsupportedOperationException()\n    \n    override val isInterface: Boolean\n        get() = throw UnsupportedOperationException()\n\n    override val isRecord: Boolean\n        get() = throw UnsupportedOperationException()\n\n    override val isSealed: Boolean\n        get() = throw UnsupportedOperationException()\n\n    override val lightClassOriginKind: LightClassOriginKind?\n        get() = if (EclipseJavaElementUtil.isKotlinLightClass(eclipseClass)) LightClassOriginKind.SOURCE else null\n    \n    override val methods: Collection<JavaMethod>\n        get() = throw UnsupportedOperationException()\n    \n    override val outerClass: JavaClass?\n        get() = throw UnsupportedOperationException()\n\n    override val permittedTypes: Collection<JavaClassifierType>\n        get() = throw UnsupportedOperationException()\n\n    override val recordComponents: Collection<JavaRecordComponent>\n        get() = throw UnsupportedOperationException()\n\n    override val supertypes: Collection<JavaClassifierType>\n        get() = throw UnsupportedOperationException()\n    \n    override val annotations: Collection<JavaAnnotation>\n        get() = throw UnsupportedOperationException()\n    \n    override val isDeprecatedInJavaDoc: Boolean\n        get() = throw UnsupportedOperationException()\n\n    override fun findAnnotation(fqName: FqName): JavaAnnotation? {\n        throw UnsupportedOperationException()\n    }\n\n    override val typeParameters: List<JavaTypeParameter>\n        get() = throw UnsupportedOperationException()\n    \n    override val isAbstract: Boolean\n        get() = throw UnsupportedOperationException()\n    \n    override val isFinal: Boolean\n        get() = throw UnsupportedOperationException()\n    \n    override val isStatic: Boolean\n        get() = throw UnsupportedOperationException()\n    \n    override val visibility: Visibility\n        get() = throw UnsupportedOperationException()\n\n    override fun hasDefaultConstructor() = throw UnsupportedOperationException()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/lang/kotlin/EclipseVirtualFileFinder.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.lang.kotlin\n\nimport com.intellij.openapi.vfs.VirtualFile\nimport com.intellij.psi.search.GlobalSearchScope\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.jdt.internal.compiler.util.Util.isClassFileName\nimport org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol\nimport org.jetbrains.kotlin.cli.jvm.index.JavaRoot\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.resolve.lang.java.EclipseJavaClassFinder\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaClassifier\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil\nimport org.jetbrains.kotlin.load.java.structure.JavaClass\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragment\nimport java.io.InputStream\nimport org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndex\nimport org.jetbrains.kotlin.load.kotlin.*\nimport com.intellij.openapi.project.Project\nimport org.jetbrains.kotlin.descriptors.ModuleDescriptor\n\nclass EclipseVirtualFileFinder(\n        private val javaProject: IJavaProject,\n        private val scope: GlobalSearchScope) : VirtualFileFinder() {\n    \n    private val index: JvmDependenciesIndex\n        get() = KotlinEnvironment.getEnvironment(javaProject.project).index\n    \n    override fun findMetadata(classId: ClassId): InputStream? {\n        assert(!classId.isNestedClass) { \"Nested classes are not supported here: $classId\" }\n\n        return findBinaryClass(\n                classId,\n                classId.shortClassName.asString() + MetadataPackageFragment.DOT_METADATA_FILE_EXTENSION)?.inputStream\n    }\n\n    override fun findSourceOrBinaryVirtualFile(classId: ClassId): VirtualFile? = findVirtualFileWithHeader(classId)\n\n    override fun hasMetadataPackage(fqName: FqName): Boolean {\n        var found = false\n        \n        val index = KotlinEnvironment.getEnvironment(javaProject.project).index\n        \n        index.traverseDirectoriesInPackage(fqName, continueSearch = { dir, _ ->\n            found = found or dir.children.any { it.extension == MetadataPackageFragment.METADATA_FILE_EXTENSION }\n            !found\n        })\n        return found\n    }\n\n    override fun findBuiltInsData(packageFqName: FqName): InputStream? {\n        val fileName = BuiltInSerializerProtocol.getBuiltInsFileName(packageFqName)\n\n        // \"<builtins-metadata>\" is just a made-up name\n        // JvmDependenciesIndex requires the ClassId of the class which we're searching for, to cache the last request+result\n        val classId = ClassId(packageFqName, Name.special(\"<builtins-metadata>\"))\n        \n        return index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, _ ->\n            dir.findChild(fileName)?.check(VirtualFile::isValid)\n        }?.check { it in scope && it.isValid }?.inputStream\n    }\n\n    override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? {\n        val type = javaProject.findType(classId.packageFqName.asString(), classId.relativeClassName.asString())\n        if (type == null || !isBinaryKotlinClass(type)) return null\n\n        val resource = type.resource // if resource != null then it exists in the workspace and then get absolute path\n        val path = if (resource != null) resource.location else type.path\n\n        val eclipseProject = javaProject.project\n//        In the classpath we can have either path to jar file ot to the class folder\n//        Therefore in path might be location to the jar file or to the class file\n        return when {\n            isClassFileName(path.toOSString()) -> KotlinEnvironment.getEnvironment(eclipseProject).getVirtualFile(path)\n\n            KotlinEnvironment.getEnvironment(eclipseProject).isJarFile(path) -> {\n\t            val relativePath = \"${type.fullyQualifiedName.replace('.', '/')}.class\"\n\t            KotlinEnvironment.getEnvironment(eclipseProject).getVirtualFileInJar(path, relativePath)\n            }\n\n            else -> throw IllegalArgumentException(\"Virtual file not found for $path\")\n        }\n    }\n    \n    private fun isBinaryKotlinClass(type: IType): Boolean = type.isBinary && !EclipseJavaClassFinder.isInKotlinBinFolder(type)\n\n    private fun classFileName(jClass:JavaClass): String {\n        val outerClass = jClass.outerClass\n        if (outerClass == null) return jClass.name.asString()\n        return classFileName(outerClass) + \"$\" + jClass.name.asString()\n    }\n    \n    private fun findBinaryClass(classId: ClassId, fileName: String): VirtualFile? =\n            index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, rootType ->\n                dir.findChild(fileName)?.check(VirtualFile::isValid)\n            }?.check { it in scope }\n\n    override fun findKotlinClassOrContent(javaClass: JavaClass): KotlinClassFinder.Result? {\n        val fqName = javaClass.fqName ?: return null\n        if (fqName == null) return null\n\n        val classId = EclipseJavaElementUtil.computeClassId((javaClass as EclipseJavaClassifier<*>).binding) ?: return null\n        if (classId == null) return null\n\n        var file = findVirtualFileWithHeader(classId)\n        if (file == null) return null\n\n        if (javaClass.outerClass != null) {\n            // For nested classes we get a file of the containing class, to get the actual class file for A.B.C,\n            // we take the file for A, take its parent directory, then in this directory we look for A$B$C.class\n            file = file.getParent().findChild(\"${classFileName(javaClass)}.class\")\n            if (file != null) throw IllegalStateException(\"Virtual file not found for $javaClass\")\n        }\n\n        return KotlinBinaryClassCache.getKotlinBinaryClassOrClassFileContent(file!!)\n    }\n}\n\nclass EclipseVirtualFileFinderFactory(private val project: IJavaProject) : VirtualFileFinderFactory {\n\n\toverride fun create(_project: Project, module: ModuleDescriptor) =\n\t\t\tEclipseVirtualFileFinder(project, GlobalSearchScope.allScope(_project))\n\n    override fun create(scope: GlobalSearchScope): VirtualFileFinder = EclipseVirtualFileFinder(project, scope)\n}\n\nfun <T: Any> T.check(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/sources/LibrarySourcesIndex.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.resolve.sources\n\nimport java.util.HashMap\nimport org.eclipse.jdt.core.IPackageFragmentRoot\nimport java.util.zip.ZipFile\nimport org.eclipse.core.runtime.Path\nimport java.util.ArrayList\nimport org.eclipse.jdt.core.IPackageFragment\nimport java.util.zip.ZipEntry\nimport java.io.BufferedInputStream\nimport java.io.InputStreamReader\nimport java.io.BufferedReader\nimport org.jetbrains.kotlin.core.resolve.KotlinSourceIndex\nimport kotlin.io.use\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.eclipse.core.runtime.IPath\nimport java.io.File\n\nfun getSourcePath(root: IPackageFragmentRoot): IPath? {\n    return ProjectUtils.convertToGlobalPath(root.resolvedClasspathEntry?.sourceAttachmentPath)\n}\n\nclass LibrarySourcesIndex(private val jarWithSources: File) {\n    \n    private val index = hashMapOf<String, ArrayList<SourceFile>>()\n    private val PACKAGE_LINE_PREFIX = \"package \"\n\n    init {\n        if (!jarWithSources.exists()) {\n            throw IllegalArgumentException(\"File with sources ($jarWithSources) should exist\")\n        }\n        \n        val sourceArchive = ZipFile(jarWithSources)\n\n        sourceArchive.entries().toList()\n                .map { it.getName() }\n                .filter { KotlinSourceIndex.isKotlinSource(it) }\n                .forEach {\n                    val shortName = Path(it).lastSegment()\n                    index.getOrPut(shortName) { ArrayList() }.add(SourceFile(it))\n                }\n    }\n    \n    fun resolve(shortName: String, packageFolder: IPath): String? {\n        val packageFqName = packageFolder.segments().joinToString(\".\")\n        return resolve(shortName, packageFqName)\n    }\n\n    fun resolve(shortName: String, packageFqName: String): String? {\n        val sourcesList = index[shortName] ?: return null\n        if (sourcesList.size == 1) {\n            return sourcesList.first().path\n        }\n        \n        val sourceArchive = ZipFile(jarWithSources)\n        \n        for (it in sourcesList) {\n            if (it.effectivePackage == null) {\n                it.effectivePackage = getPackageName(sourceArchive, sourceArchive.getEntry(it.path))\n            }\n        }\n        \n        return sourcesList\n                .filter { packageFqName == it.effectivePackage }\n                .singleOrNull()\n                ?.path\n    }\n\n    private fun getPackageName(zipFile: ZipFile, entry: ZipEntry): String? {\n        val istream = zipFile.getInputStream(entry)\n        val reader = BufferedReader(InputStreamReader(istream))\n        return reader.use {\n            it.lineSequence()\n                    .firstOrNull { it.startsWith(PACKAGE_LINE_PREFIX) }\n                    ?.removePrefix(PACKAGE_LINE_PREFIX)\n                    ?.trim()\n        }\n    }\n}\n\nprivate class SourceFile(val path: String, var effectivePackage: String? = null)"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/script/EnvironmentProjectsManager.kt",
    "content": "package org.jetbrains.kotlin.core.script\n\nimport org.eclipse.core.internal.resources.ProjectDescription\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.jetbrains.kotlin.core.utils.withResourceLock\nimport org.jetbrains.kotlin.psi.KtFile\nimport java.net.URI\nimport java.util.concurrent.ConcurrentHashMap\nimport java.util.concurrent.ConcurrentMap\n\nobject EnvironmentProjectsManager {\n    private val projectCache: ConcurrentMap<String, IJavaProject> = ConcurrentHashMap()\n\n    private val createdProjects = mutableSetOf<String>()\n\n    operator fun get(scriptFile: KtFile) = projectCache.getOrPut(scriptFile.virtualFilePath) {\n        withResourceLock(ResourcesPlugin.getWorkspace().root) { root ->\n            nameCandidates(scriptFile).map { root.getProject(it) }\n                .first { !it.exists() }\n                .run {\n                    createdProjects += name\n\n                    val description = ProjectDescription().apply {\n                        name = this@run.name\n                        locationURI = URI.create(\"org.jetbrains.kotlin.script:/environments/${this@run.name}\")\n                        natureIds = arrayOf(JavaCore.NATURE_ID)\n                    }\n\n                    create(description, null)\n                    open(null)\n                    KotlinNature.addNature(this)\n                    isHidden = true\n                    JavaCore.create(this)\n                }\n        }\n    }\n\n    fun wasCreated(name: String) = name in createdProjects\n\n    private fun nameCandidates(scriptFile: KtFile): Sequence<String> = generateSequence(1) { it + 1 }\n        .map { n ->\n            listOfNotNull(\n                scriptFile.packageFqName.takeUnless { it.isRoot },\n                scriptFile.name,\n                n.takeIf { it > 1 }?.toString()\n            ).joinToString(\"-\")\n        }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/script/ScriptTemplateContribution.kt",
    "content": "package org.jetbrains.kotlin.core.script\n\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport java.io.File\nimport kotlin.reflect.KClass\nimport kotlin.script.experimental.api.ScriptCompilationConfiguration\n\nabstract class ScriptTemplateContribution {\n    open val priority = 0\n\n    protected abstract fun loadTemplate(): KClass<*>\n\n    open fun createClasspath(environment: KotlinScriptEnvironment): Array<IClasspathEntry> = environment.javaProject.rawClasspath\n\n    val template by lazy { loadTemplate() }\n\n    open fun isNullable(propName: String, compilationConfig: ScriptCompilationConfiguration): Boolean = true\n\n    open fun scriptEnvironment(script: File): Map<String, Any?> = emptyMap()\n}\n\nabstract class JavaScriptTemplateContribution : ScriptTemplateContribution() {\n\n    abstract val javaClass: Class<*>\n\n    override fun loadTemplate(): KClass<*> = javaClass.kotlin\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/script/template/ProjectFilesResolver.kt",
    "content": "package org.jetbrains.kotlin.core.script.template\n\nimport java.io.File\nimport kotlin.script.dependencies.Environment\nimport kotlin.script.dependencies.ScriptContents\nimport kotlin.script.experimental.dependencies.DependenciesResolver\nimport kotlin.script.experimental.dependencies.ScriptDependencies\nimport kotlin.script.experimental.dependencies.asSuccess\n\nclass ProjectFilesResolver : DependenciesResolver {\n    override fun resolve(scriptContents: ScriptContents, environment: Environment): DependenciesResolver.ResolveResult {\n        val classpath = (environment[\"eclipseProjectClasspath\"] as? String)\n            ?.split(\":\")\n            ?.map { File(it) }\n            .orEmpty()\n\n        return ScriptDependencies(classpath = classpath).asSuccess()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/script/template/ProjectScriptTemplate.kt",
    "content": "package org.jetbrains.kotlin.core.script.template\n\nimport kotlin.script.templates.ScriptTemplateDefinition\n\n\n@ScriptTemplateDefinition(resolver = ProjectFilesResolver::class)\nabstract class ProjectScriptTemplate(val args: Array<String>)"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/script/template/ProjectScriptTemplateContribution.kt",
    "content": "/*\n * Copyright 2019 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.jetbrains.kotlin.core.script.template\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.core.script.ScriptTemplateContribution\nimport org.jetbrains.kotlin.core.utils.*\nimport java.io.File\n\nclass ProjectScriptTemplateContribution : ScriptTemplateContribution() {\n\n    override val priority: Int get() = Int.MAX_VALUE\n\n    override fun loadTemplate() = ProjectScriptTemplate::class\n\n    override fun scriptEnvironment(script: File): Map<String, Any?> {\n        val file = script.asResource\n\n        val definitionClasspath = file?.let { KotlinScriptEnvironment.getEnvironment(file) }\n            ?.definitionClasspath.orEmpty()\n\n        val projectClasspath = projectClasspathForScript(file)\n        val allClasspath = (projectClasspath + definitionClasspath)\n            .joinToString(separator = \":\") { it.absolutePath }\n\n        return mapOf(\"eclipseProjectClasspath\" to allClasspath)\n    }\n\n    private fun projectClasspathForScript(file: IFile?): List<File> {\n        if (file == null) return emptyList()\n        val javaProject = file.javaProject ?: return emptyList()\n        if (!file.isInClasspath) return emptyList()\n\n        val projectClasspath = try {\n            ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, false)\n        } catch (e: DependencyResolverException) {\n            e.resolvedFiles\n        }\n        val outputFolders = ProjectUtils.getAllOutputFolders(javaProject).map { it.location.toFile() }\n        return projectClasspath + outputFolders\n    }\n\n    override fun createClasspath(environment: KotlinScriptEnvironment): Array<IClasspathEntry> =\n        (environment.javaProject.rawClasspath + environment.definitionClasspath.map {\n            JavaCore.newLibraryEntry(Path(it.absolutePath), null, null)\n        }).distinctBy { it.path }.toTypedArray()\n}"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/DebugUtils.java",
    "content": "package org.jetbrains.kotlin.core.utils;\n\nimport java.util.Optional;\n\nimport org.eclipse.debug.core.DebugException;\nimport org.eclipse.debug.core.model.IStackFrame;\nimport org.eclipse.debug.core.model.IVariable;\nimport org.eclipse.jdt.debug.core.IJavaStackFrame;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\n\npublic class DebugUtils {\n    public static Boolean isVisible(IVariable variable) {\n        try {\n            return !variable.getName().startsWith(\"$i$\");\n        } catch (Exception e) {\n            KotlinLogger.logError(e);\n            return false;\n        }\n    }\n\n    public static Boolean hasKotlinSource(IStackFrame frame) throws DebugException {\n        if (frame instanceof IJavaStackFrame) {\n            IJavaStackFrame javaFrame = (IJavaStackFrame) frame;\n            return Optional.ofNullable(javaFrame.getSourceName()).map(s -> s.endsWith(\".kt\")).orElse(false);\n        } else {\n            return false;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/DependencyResolverException.kt",
    "content": "package org.jetbrains.kotlin.core.utils\n\nimport java.io.File\n\nclass DependencyResolverException(val resolvedFiles: List<File>) : RuntimeException()"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/ProjectUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.core.utils\n\nimport org.eclipse.core.resources.*\nimport org.eclipse.core.runtime.*\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.core.JavaModelException\nimport org.eclipse.jdt.launching.JavaRuntime\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.jetbrains.kotlin.psi.KtFile\nimport java.io.File\n\nobject ProjectUtils {\n\n    private const val LIB_FOLDER = \"lib\"\n    private const val LIB_EXTENSION = \"jar\"\n\n    private const val MAVEN_NATURE_ID = \"org.eclipse.m2e.core.maven2Nature\"\n    private const val GRADLE_NATURE_ID = \"org.eclipse.buildship.core.gradleprojectnature\"\n\n    val accessibleKotlinProjects: List<IProject>\n        get() = ResourcesPlugin.getWorkspace().root.projects.filter { project -> isAccessibleKotlinProject(project) }\n\n    @JvmStatic\n    val ktHome: String by lazy {\n        val compilerBundle = Platform.getBundle(\"org.jetbrains.kotlin.bundled-compiler\")\n        FileLocator.toFileURL(compilerBundle.getEntry(\"/\")).file\n    }\n\n    fun getJavaProjectFromCollection(files: Collection<IFile>): IJavaProject? =\n        files.firstOrNull()\n            ?.let { JavaCore.create(it.project) }\n\n    fun getPackageByFile(file: IFile): String? = KotlinPsiManager.getParsedFile(file).packageFqName.asString()\n\n    @JvmStatic\n    @JvmOverloads\n    fun cleanFolder(container: IContainer?, predicate: (IResource) -> Boolean = { true }) {\n        try {\n            if (container == null) {\n                return\n            }\n            if (container.exists()) {\n                for (member in container.members()) {\n                    if (member is IContainer) {\n                        cleanFolder(member, predicate)\n                    }\n                    if (predicate(member)) {\n                        if (member.exists()) {\n                            member.delete(true, null)\n                        }\n                    }\n                }\n            }\n        } catch (e: CoreException) {\n            KotlinLogger.logError(\"Error while cleaning folder\", e)\n        }\n\n    }\n\n    @JvmStatic\n    fun getDefaultOutputFolder(javaProject: IJavaProject): IFolder? =\n        ResourcesPlugin.getWorkspace().root.findMember(javaProject.outputLocation) as? IFolder\n\n    @JvmStatic\n    fun getAllOutputFolders(javaProject: IJavaProject): List<IFolder> =\n        javaProject.getResolvedClasspath(true)\n            .asSequence()\n            .filter { it.entryKind == IClasspathEntry.CPE_SOURCE }\n            .map { it.outputLocation }\n            .let { it + javaProject.outputLocation }\n            .filterNotNull()\n            .distinct()\n            .mapNotNull { ResourcesPlugin.getWorkspace().root.findMember(it) as? IFolder }\n            .filter { it.exists() }\n            .toList()\n\n    fun getSourceFiles(project: IProject): List<KtFile> {\n        var tempFiles = KotlinPsiManager.getFilesByProject(project)\n        if (tempFiles.any { !it.asFile.exists() }) {\n            project.refreshLocal(IResource.DEPTH_INFINITE, NullProgressMonitor())\n        }\n        tempFiles = KotlinPsiManager.getFilesByProject(project)\n        return tempFiles\n            .map { KotlinPsiManager.getParsedFile(it) }\n    }\n\n    fun getSourceFilesWithDependencies(javaProject: IJavaProject): List<KtFile> =\n        (listOf(javaProject).getDependencyProjects() + javaProject.project)\n            .flatMap { getSourceFiles(it) }\n\n    fun getDependencyProjects(javaProject: IJavaProject) = listOf(javaProject).getDependencyProjects()\n\n    tailrec fun Collection<IJavaProject>.getDependencyProjects(result: MutableSet<IProject> = hashSetOf()): Set<IProject> {\n        if (isEmpty()) return result\n        return flatMap { it.getResolvedClasspath(true).toList() }\n            .asSequence()\n            .filter { it.entryKind == IClasspathEntry.CPE_PROJECT }\n            .map { ResourcesPlugin.getWorkspace().root.getProject(it.path.toPortableString()) }\n            .filter { it.isAccessible }\n            .filter { result.add(it) }\n            .map { JavaCore.create(it) }\n            .toList()\n            .getDependencyProjects(result)\n    }\n\n    fun collectClasspathWithDependenciesForBuild(javaProject: IJavaProject): List<File> {\n        return expandClasspath(javaProject, true, false) { true }\n    }\n\n    @JvmStatic\n    fun collectClasspathWithDependenciesForLaunch(javaProject: IJavaProject, includeJRE: Boolean): List<File> {\n        val jreEntries = getJREClasspathElements(javaProject)\n        return expandClasspath(javaProject, true, true) { entry ->\n            entry.entryKind == IClasspathEntry.CPE_LIBRARY && (includeJRE || jreEntries.none { it.path == entry.path })\n        }\n    }\n\n    private fun getJREClasspathElements(javaProject: IJavaProject): List<IClasspathEntry> =\n        JavaRuntime.resolveRuntimeClasspathEntry(JavaRuntime.computeJREEntry(javaProject), javaProject)\n            .map { it.classpathEntry }\n\n    private fun expandClasspath(\n        javaProject: IJavaProject, includeDependencies: Boolean,\n        includeBinFolders: Boolean, entryPredicate: Function1<IClasspathEntry, Boolean>\n    ): List<File> {\n        val orderedFiles = LinkedHashSet<File>()\n        var wasError = false\n\n        for (classpathEntry in javaProject.getResolvedClasspath(true)) {\n            if (classpathEntry.entryKind == IClasspathEntry.CPE_PROJECT && includeDependencies) {\n                try {\n                    orderedFiles.addAll(\n                        expandDependentProjectClasspath(\n                            classpathEntry,\n                            includeBinFolders,\n                            entryPredicate\n                        )\n                    )\n                } catch (e: DependencyResolverException) {\n                    wasError = true\n                    orderedFiles.addAll(e.resolvedFiles)\n                }\n            } else { // Source folder or library\n                if (entryPredicate.invoke(classpathEntry)) {\n                    orderedFiles.addAll(getFileByEntry(classpathEntry, javaProject))\n                }\n            }\n        }\n\n        if(wasError) {\n            throw DependencyResolverException(orderedFiles.toList())\n        }\n\n        return orderedFiles.toList()\n    }\n\n    fun getFileByEntry(entry: IClasspathEntry, javaProject: IJavaProject): List<File> =\n        javaProject.findPackageFragmentRoots(entry)\n            .takeIf { it.isNotEmpty() }\n            ?.map { it.resource?.location?.toFile() ?: it.path.toFile() }\n            ?: entry.path.toFile()\n                .takeIf { it.exists() }\n                ?.let { listOf(it) }\n            ?: emptyList()\n\n    private fun expandDependentProjectClasspath(\n        projectEntry: IClasspathEntry,\n        includeBinFolders: Boolean, entryPredicate: Function1<IClasspathEntry, Boolean>\n    ): List<File> {\n        val projectPath = projectEntry.path\n        val dependentProject = ResourcesPlugin.getWorkspace().root.getProject(projectPath.toString())\n        val javaProject = JavaCore.create(dependentProject)\n\n        val orderedFiles = LinkedHashSet<File>()\n        var wasError = false\n\n        try {\n            for (classpathEntry in javaProject.getResolvedClasspath(true)) {\n                if (!(classpathEntry.isExported || classpathEntry.entryKind == IClasspathEntry.CPE_SOURCE)) {\n                    continue\n                }\n\n                if (classpathEntry.entryKind == IClasspathEntry.CPE_PROJECT) {\n                    try {\n                        orderedFiles.addAll(\n                            expandDependentProjectClasspath(\n                                classpathEntry,\n                                includeBinFolders,\n                                entryPredicate\n                            )\n                        )\n                    } catch (e: DependencyResolverException) {\n                        wasError = true\n                        orderedFiles.addAll(e.resolvedFiles)\n                    }\n                } else {\n                    if (entryPredicate.invoke(classpathEntry)) {\n                        orderedFiles.addAll(getFileByEntry(classpathEntry, javaProject))\n                    }\n                }\n            }\n\n\n            if (includeBinFolders) {\n                getAllOutputFolders(javaProject)\n                    .map { it.location.toFile() }\n                    .toCollection(orderedFiles)\n            }\n        } catch (e: JavaModelException) {\n            throw DependencyResolverException(emptyList())\n        }\n\n        if(wasError) {\n            throw DependencyResolverException(orderedFiles.toList())\n        }\n\n        return orderedFiles.toList()\n    }\n\n    @JvmStatic\n    fun getSrcOutDirectories(javaProject: IJavaProject): List<Pair<File, File>> {\n        val projectOutput = javaProject.outputLocation\n        val root = ResourcesPlugin.getWorkspace().root\n\n        return javaProject.getResolvedClasspath(true)\n            .filter { it.entryKind == IClasspathEntry.CPE_SOURCE }\n            .filter { root.findMember(it.path)?.takeIf(IResource::exists) != null }\n            .mapNotNull { cpe ->\n                (cpe.outputLocation ?: projectOutput)\n                    ?.let { root.findMember(it) }\n                    ?.takeIf { it.exists() }\n                    ?.let { root.findMember(cpe.path).location.toFile() to it.location.toFile() }\n                    .also {\n                        if (it == null)\n                            KotlinLogger.logError(\n                                \"There is no output folder for sources: ${cpe.path.toOSString()}\",\n                                null\n                            )\n                    }\n            }\n    }\n\n    fun addToClasspath(javaProject: IJavaProject, vararg newEntries: IClasspathEntry) {\n        javaProject.setRawClasspath(javaProject.rawClasspath + newEntries, null)\n    }\n\n    @JvmStatic\n    fun addContainerEntryToClasspath(javaProject: IJavaProject, newEntry: IClasspathEntry) {\n        if (!classpathContainsContainerEntry(javaProject.rawClasspath, newEntry)) {\n            addToClasspath(javaProject, newEntry)\n        }\n    }\n\n    fun equalsEntriesPaths(entry: IClasspathEntry, otherEntry: IClasspathEntry): Boolean {\n        return entry.path == otherEntry.path\n    }\n\n    private fun classpathContainsContainerEntry(\n        entries: Array<IClasspathEntry>,\n        entry: IClasspathEntry\n    ): Boolean {\n        return entries.any { classpathEntry -> equalsEntriesPaths(classpathEntry, entry) }\n    }\n\n    fun hasKotlinRuntime(project: IProject): Boolean {\n        return classpathContainsContainerEntry(\n            JavaCore.create(project).rawClasspath,\n            KotlinClasspathContainer.CONTAINER_ENTRY\n        )\n    }\n\n    @JvmStatic\n    fun addKotlinRuntime(project: IProject) {\n        addKotlinRuntime(JavaCore.create(project))\n    }\n\n    @JvmStatic\n    fun addKotlinRuntime(javaProject: IJavaProject) {\n        addContainerEntryToClasspath(javaProject, KotlinClasspathContainer.CONTAINER_ENTRY)\n    }\n\n    @JvmStatic\n    fun convertToGlobalPath(path: IPath?): IPath? {\n        if (path == null) {\n            return null\n        }\n        if (path.toFile().exists()) {\n            return path.makeAbsolute()\n        } else {\n            val file = ResourcesPlugin.getWorkspace().root.getFile(path)\n            if (file.exists()) {\n                return file.rawLocation\n            }\n        }\n        return null\n\n    }\n\n    fun isMavenProject(project: IProject): Boolean = project.hasNature(MAVEN_NATURE_ID)\n\n\n    fun isGradleProject(project: IProject): Boolean = project.hasNature(GRADLE_NATURE_ID)\n\n\n    @JvmStatic\n    fun buildLibPath(libName: String): String = ktHome + buildLibName(libName)\n\n    fun isAccessibleKotlinProject(project: IProject): Boolean =\n        project.isAccessible && KotlinNature.hasKotlinNature(project)\n\n    private fun buildLibName(libName: String): String = \"$LIB_FOLDER/$libName.$LIB_EXTENSION\"\n\n    fun newExportedLibraryEntry(path: IPath): IClasspathEntry =\n        JavaCore.newLibraryEntry(path, null, null, true)\n\n}\n\nfun String.buildLibPath(): Path =\n    Path(ProjectUtils.buildLibPath(this))"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/analyzeUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n\npackage org.jetbrains.kotlin.core.utils\n\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.descriptors.ModuleDescriptor\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.resolve.BindingContext\n\nfun KtElement.getBindingContext(): BindingContext =\n    containingKtFile.getBindingContext()\n\nfun KtFile.getBindingContext(): BindingContext =\n    KotlinAnalyzer.analyzeFile(this).analysisResult.bindingContext\n\nfun getModuleDescriptor(ktFile: KtFile): ModuleDescriptor =\n    KotlinAnalyzer.analyzeFile(ktFile).analysisResult.moduleDescriptor"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/genericUtils.kt",
    "content": "package org.jetbrains.kotlin.core.utils\n\nfun <T, S> pairOfNotNulls(first: T?, second: S?): Pair<T, S>? = second?.let { first?.to(it) }"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/importsUtils.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.utils\n\nimport com.intellij.psi.PsiClass\nimport org.jetbrains.kotlin.config.ApiVersion\nimport org.jetbrains.kotlin.config.LanguageFeature.DefaultImportOfPackageKotlinComparisons\nimport org.jetbrains.kotlin.config.LanguageVersion\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.idea.util.ActionRunningMode\nimport org.jetbrains.kotlin.idea.util.ImportDescriptorResult\nimport org.jetbrains.kotlin.idea.util.ImportInsertHelper\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.resolve.ImportPath\nimport org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices\n\nclass KotlinImportInserterHelper : ImportInsertHelper() {\n    private val importSortComparator: Comparator<ImportPath> = Comparator { _, _ -> 0 }\n\n    override fun getImportSortComparator(contextFile: KtFile): Comparator<ImportPath> {\n        return importSortComparator\n    }\n\n    override fun importDescriptor(\n        element: KtElement,\n        descriptor: DeclarationDescriptor,\n        actionRunningMode: ActionRunningMode,\n        forceAllUnderImport: Boolean\n    ): ImportDescriptorResult {\n        throw UnsupportedOperationException()\n    }\n\n    override fun importPsiClass(\n        element: KtElement,\n        psiClass: PsiClass,\n        actionRunningMode: ActionRunningMode\n    ): ImportDescriptorResult {\n        throw UnsupportedOperationException()\n    }\n\n    override fun isImportedWithDefault(importPath: ImportPath, contextFile: KtFile): Boolean {\n        val defaultImports = JvmPlatformAnalyzerServices.getDefaultImports(\n            if (LanguageVersionSettingsImpl.DEFAULT.supportsFeature(DefaultImportOfPackageKotlinComparisons)) LanguageVersionSettingsImpl.DEFAULT\n            else LanguageVersionSettingsImpl(LanguageVersion.KOTLIN_1_0, ApiVersion.KOTLIN_1_0),\n            true\n        )\n        return importPath.isImported(defaultImports)\n    }\n\n    override fun mayImportOnShortenReferences(descriptor: DeclarationDescriptor, contextFile: KtFile): Boolean {\n        return false\n    }\n\n    override fun isImportedWithLowPriorityDefaultImport(importPath: ImportPath, contextFile: KtFile): Boolean =\n        isImportedWithDefault(importPath, contextFile)\n}\n\n\n// TODO: obtain these functions from fqNameUtil.kt (org.jetbrains.kotlin.idea.refactoring.fqName)\nfun FqName.isImported(importPath: ImportPath, skipAliasedImports: Boolean = true): Boolean {\n    return when {\n        skipAliasedImports && importPath.hasAlias() -> false\n        importPath.isAllUnder && !isRoot -> importPath.fqName == this.parent()\n        else -> importPath.fqName == this\n    }\n}\n\nfun ImportPath.isImported(alreadyImported: ImportPath): Boolean {\n    return if (isAllUnder || hasAlias()) this == alreadyImported else fqName.isImported(alreadyImported)\n}\n\nfun ImportPath.isImported(imports: Iterable<ImportPath>): Boolean = imports.any { isImported(it) }"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/jobUtils.kt",
    "content": "package org.jetbrains.kotlin.core.utils\n\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.jobs.Job\n\nfun <R: IResource, T> withResourceLock(resource: R, monitor: IProgressMonitor? = null, block: (R) -> T): T =\n    try {\n        Job.getJobManager().beginRule(resource, monitor)\n        block(resource)\n    } finally {\n        Job.getJobManager().endRule(resource)\n    }"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/kotlinFilesCollectorUtils.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.utils\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IFolder\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.IResourceDelta\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.eclipse.jdt.core.IPackageFragmentRoot\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.model.setKotlinBuilderBeforeJavaBuilder\n\nval IJavaProject.sourceFolders: List<IPackageFragmentRoot>\n    get() = packageFragmentRoots.filter { it.kind == IPackageFragmentRoot.K_SOURCE }"
  },
  {
    "path": "kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/projectFilesUtils.kt",
    "content": "package org.jetbrains.kotlin.core.utils\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.IClasspathEntry\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.internal.core.JavaProject\nimport java.io.File\n\nval IFile.isInClasspath: Boolean\n    get() {\n        val project = JavaCore.create(project) as JavaProject\n        val packageRoots = project.getResolvedClasspath(true)\n                .asSequence()\n                .filter { it.entryKind == IClasspathEntry.CPE_SOURCE }\n                .flatMap { project.computePackageFragmentRoots(it).asSequence() }\n                .map { it.resource }\n                .toSet()\n\n        return generateSequence<IResource>(this) { it.parent }\n                .any { it in packageRoots }\n    }\n\nval File.asResource: IFile?\n    get() = ResourcesPlugin.getWorkspace().root\n            .getFileForLocation(Path.fromOSString(absolutePath))\n\nval IFile.asFile: File\n\tget() = File(locationURI)\n\nval IFile.javaProject: IJavaProject?\n    get() = project?.let { JavaCore.create(it) }\n"
  },
  {
    "path": "kotlin-eclipse-feature/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nbin.includes = feature.xml\n"
  },
  {
    "path": "kotlin-eclipse-feature/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n      id=\"org.jetbrains.kotlin.feature\"\n      label=\"Kotlin\"\n      version=\"0.8.24.qualifier\"\n      provider-name=\"JetBrains\">\n\n   <description url=\"http://kotlinlang.org/\">\n      Kotlin language support for Kotlin 1.6.21\n   </description>\n\n   <copyright url=\"http://www.jetbrains.com/\">\n      Copyright 2010-2016 JetBrains s.r.o.\n   </copyright>\n\n   <license url=\"\">\n      Copyright 2010-2016 JetBrains s.r.o.\n\nLicensed under the Apache License, Version 2.0 (the &quot;License&quot;);\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an &quot;AS IS&quot; BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n   </license>\n\n   <includes\n         id=\"org.jetbrains.kotlin.policy\"\n         version=\"0.0.0\"/>\n\n   <includes\n         id=\"org.jetbrains.kotlin.weaving.feature\"\n         version=\"0.0.0\"\n         optional=\"true\"/>\n\n   <plugin\n         id=\"org.jetbrains.kotlin.bundled-compiler\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"/>\n\n   <plugin\n         id=\"org.jetbrains.kotlin.core\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"/>\n\n   <plugin\n         id=\"org.jetbrains.kotlin.ui\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"/>\n\n   <plugin\n         id=\"org.jetbrains.kotlin.aspects\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.jetbrains.kotlin.maven\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n</feature>\n"
  },
  {
    "path": "kotlin-eclipse-feature/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.feature</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>eclipse-feature</packaging>\n\n</project>"
  },
  {
    "path": "kotlin-eclipse-gradle/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-gradle\nBundle-SymbolicName: org.jetbrains.kotlin.gradle;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.gradle.Activator\nBundle-Vendor: JetBrains\nRequire-Bundle: org.jetbrains.kotlin.core,\n org.jetbrains.kotlin.bundled-compiler,\n org.eclipse.buildship.core;bundle-version=\"3.0.0\",\n org.eclipse.core.runtime,\n org.jetbrains.kotlin.gradle.model\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ActivationPolicy: lazy\nImport-Package: org.eclipse.core.resources,\n org.eclipse.jdt.core\nExport-Package: org.jetbrains.kotlin.gradle.initialization,\n org.jetbrains.kotlin.gradle.configurator\n"
  },
  {
    "path": "kotlin-eclipse-gradle/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               scripts/\n\n"
  },
  {
    "path": "kotlin-eclipse-gradle/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.buildship.core.projectconfigurators\">\n      <configurator\n            class=\"org.jetbrains.kotlin.gradle.configurator.KotlinProjectConfigurator\"\n            id=\"kotlin-eclipse-gradle.configurator\"\n            runsAfter=\"org.eclipse.buildship.configurators.base\">\n      </configurator>\n   </extension>\n   <extension\n         point=\"org.eclipse.buildship.core.invocationcustomizers\">\n      <customizer\n            class=\"org.jetbrains.kotlin.gradle.initialization.ModelInjector\">\n      </customizer>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "kotlin-eclipse-gradle/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.gradle</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-gradle/scripts/init.gradle.kts",
    "content": "import javax.inject.Inject\nimport org.gradle.api.Plugin\nimport org.gradle.api.Project\nimport org.gradle.tooling.provider.model.ToolingModelBuilder\nimport org.gradle.tooling.provider.model.ToolingModelBuilderRegistry\nimport org.jetbrains.kotlin.gradle.model.GradleProjectForEclipse\nimport org.jetbrains.kotlin.gradle.model.KotlinGradleProject\nimport org.jetbrains.kotlin.gradle.model.GradleMultiProjectForEclipse\nimport org.jetbrains.kotlin.gradle.model.GradleMultiProjectForEclipseImpl\nimport org.jetbrains.kotlin.gradle.model.NonKotlinProject\nimport org.jetbrains.kotlin.gradle.model.CompilerPluginConfig\nimport org.jetbrains.kotlin.gradle.model.AllOpen\nimport org.jetbrains.kotlin.gradle.model.NoArg\nimport org.jetbrains.kotlin.gradle.model.SAMWithReceiver\n\ninitscript {\n    dependencies {\n        classpath(files(System.getProperty(\"org.jetbrains.kotlin.eclipse.gradle.model.path\")))\n    }\n}\n\nallprojects {\n    buildscript {\n        dependencies {\n            classpath(files(System.getProperty(\"org.jetbrains.kotlin.eclipse.gradle.model.path\")))\n        }\n    }\n\n    apply<GradleProjectForEclipseInstaller>()\n}\n\nclass GradleProjectForEclipseInstaller @Inject constructor(val registry: ToolingModelBuilderRegistry) :\n    Plugin<Project> {\n    override fun apply(project: Project) {\n        registry.register(GradleProjectForEclipseBuilder())\n    }\n}\n\nclass GradleProjectForEclipseBuilder() : ToolingModelBuilder {\n\n    override fun canBuild(modelName: String) = (modelName == GradleMultiProjectForEclipse::class.qualifiedName)\n\n    override fun buildAll(modelName: String, project: Project): GradleMultiProjectForEclipse =\n        GradleMultiProjectForEclipseImpl(process(project).toMap())\n\n    private fun process(project: Project): List<Pair<String, GradleProjectForEclipse>> =\n        project.childProjects.values.flatMap(::process) +\n                (project.name to buildForSubproject(project))\n\n    private fun buildForSubproject(project: Project): GradleProjectForEclipse =\n        project.tasks.findByName(\"compileKotlin\")\n            ?.dynamicCall(\"kotlinOptions\")\n            ?.run {\n                KotlinGradleProject(\n                    project.findProperty(\"kotlin.code.style\") as? String,\n                    property(\"apiVersion\"),\n                    property(\"languageVersion\"),\n                    property(\"jvmTarget\"),\n                    collectPlugins(project)\n                )\n            } ?: NonKotlinProject\n\n    private fun collectPlugins(project: Project): List<CompilerPluginConfig> {\n        val result = arrayListOf<CompilerPluginConfig>()\n\n        project.extensions.findByName(\"allOpen\")?.let {\n            AllOpen(\n                it.dynamicCall(\"myAnnotations\") as List<String>,\n                it.dynamicCall(\"myPresets\") as List<String>\n            )\n        }?.also { result += it }\n\n        project.extensions.findByName(\"noArg\")?.let {\n            NoArg(\n                it.dynamicCall(\"myAnnotations\") as List<String>,\n                it.dynamicCall(\"myPresets\") as List<String>,\n                it.dynamicCall(\"invokeInitializers\") as Boolean\n            )\n        }?.also { result += it }\n\n        project.extensions.findByName(\"samWithReceiver\")?.let {\n            SAMWithReceiver(\n                it.dynamicCall(\"myAnnotations\") as List<String>,\n                it.dynamicCall(\"myPresets\") as List<String>\n            )\n        }?.also { result += it }\n\n        return result\n    }\n\n    // We need this method, because there is no way for us to get here classes that are added to classpath alongside\n// the kotlin gradle plugin. Even if we add them to the classpath of this initscript, they will have different\n// classloader.\n    fun Any.dynamicCall(name: String, vararg args: Any?): Any? =\n        this::class.members.first { it.name == name && it.parameters.size == args.size + 1 }\n            .call(this, *args)\n\n    fun Any.property(name: String): String? = dynamicCall(name) as? String\n}"
  },
  {
    "path": "kotlin-eclipse-gradle/src/org/jetbrains/kotlin/gradle/Activator.kt",
    "content": "package org.jetbrains.kotlin.gradle\n\nimport org.osgi.framework.BundleActivator\nimport org.osgi.framework.BundleContext\n\nclass Activator: BundleActivator {\n    override fun start(context: BundleContext?) {\n        Activator.context = context\n    }\n\n    override fun stop(context: BundleContext?) {\n        Activator.context = null\n    }\n    \n    companion object {\n        const val PLUGIN_ID = \"org.jetbrains.kotlin.gradle\"\n        \n        var context: BundleContext? = null\n            private set\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-gradle/src/org/jetbrains/kotlin/gradle/configurator/KotlinProjectConfigurator.kt",
    "content": "package org.jetbrains.kotlin.gradle.configurator\n\nimport org.eclipse.buildship.core.InitializationContext\nimport org.eclipse.buildship.core.ProjectConfigurator\nimport org.eclipse.buildship.core.ProjectContext\nimport org.eclipse.core.resources.ProjectScope\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.jetbrains.kotlin.config.ApiVersion\nimport org.jetbrains.kotlin.config.JvmTarget\nimport org.jetbrains.kotlin.config.LanguageVersion\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.gradle.model.GradleProjectForEclipse\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.gradle.model.GradleMultiProjectForEclipse\n\nclass KotlinProjectConfigurator : ProjectConfigurator {\n\n    lateinit var multiModel: GradleMultiProjectForEclipse\n\n    override fun init(context: InitializationContext, monitor: IProgressMonitor) {\n        context.gradleBuild.withConnection({\n            multiModel = it.getModel(GradleMultiProjectForEclipse::class.java)\n        }, monitor)\n    }\n\n    override fun configure(context: ProjectContext, monitor: IProgressMonitor) {\n        val project = context.project\n        KotlinEnvironment.removeEnvironment(project)\n        \n        if (!::multiModel.isInitialized) return\n        val model = multiModel[project.name]\n        if (model == null || !model.isKotlinProject) {\n            // Kotlin nature may left in .project file after editing out kotlin plugin from gradle buildfile.\n            // This leads to nasty bugs so we have to unconfigure project.\n            unconfigure(context, monitor)\n            return\n        }\n\n        KotlinNature.addNature(project)\n        if (!ProjectUtils.hasKotlinRuntime(project)) {\n            ProjectUtils.addKotlinRuntime(project)\n        }\n\n        val compilerProperties = KotlinEnvironment.getEnvironment(project).projectCompilerProperties\n        compilerProperties.loadDefaults()\n        var configurationChanged = false\n\n        fun String?.configure(action: KotlinProperties.(String) -> Unit) {\n            this?.let {\n                compilerProperties.action(it)\n                configurationChanged = true\n            }\n        }\n\n        model.jvmTarget.configure { jvmTarget = JvmTarget.fromString(it) ?: JvmTarget.DEFAULT }\n        model.languageVersion.configure {\n            languageVersion = LanguageVersion.fromVersionString(it) ?: LanguageVersion.LATEST_STABLE\n        }\n        model.apiVersion.configure {\n            apiVersion = ApiVersion.parse(it) ?: ApiVersion.createByLanguageVersion(languageVersion)\n        }\n\n        configurationChanged = configurationChanged || model.compilerPlugins.any()\n        model.compilerPlugins.forEach {\n            compilerProperties.compilerPlugins[it.pluginName].apply {\n                active = true\n                args += it.options\n            }\n        }\n\n        if (configurationChanged) {\n            compilerProperties.globalsOverridden = true\n            compilerProperties.saveChanges()\n        }\n\n        model.codestyle\n            ?.let { KotlinCodeStyleManager.buildsystemAliases[it] }\n            ?.also {\n                with(KotlinCodeStyleProperties(ProjectScope(project))) {\n                    codeStyleId = it\n                    globalsOverridden = true\n                    saveChanges()\n                }\n            }\n    }\n\n    override fun unconfigure(context: ProjectContext, monitor: IProgressMonitor) {\n        KotlinNature.removeNature(context.project)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-gradle/src/org/jetbrains/kotlin/gradle/initialization/ModelInjector.kt",
    "content": "package org.jetbrains.kotlin.gradle.initialization\n\nimport org.eclipse.buildship.core.invocation.InvocationCustomizer\nimport org.eclipse.core.runtime.Platform\nimport org.jetbrains.kotlin.gradle.Activator\nimport org.eclipse.core.runtime.FileLocator\nimport java.io.File\nimport java.lang.management.ManagementFactory\nimport org.jetbrains.kotlin.core.log.KotlinLogger\n\nclass ModelInjector : InvocationCustomizer {\n    override fun getExtraArguments() = listOf(\"--init-script\", initializerPath)\n        .also { System.setProperty(MODEL_PATH_PROPERTY, modelLibPath) }\n\n    companion object {\n        private const val MODEL_PATH_PROPERTY = \"org.jetbrains.kotlin.eclipse.gradle.model.path\"\n\n        private val initializerPath by lazy {\n            Platform.getBundle(Activator.PLUGIN_ID)\n                .getEntry(\"scripts/init.gradle.kts\")\n                .let(FileLocator::toFileURL)\n                .path\n        }\n\n        private val modelLibPath by lazy<String> {\n            Platform.getBundle(\"org.jetbrains.kotlin.gradle.model\")\n                .getEntry(\"lib/kotlin-eclipse-gradle-model.jar\")\n                .let(FileLocator::toFileURL)\n                .path\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-gradle-feature/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nbin.includes = feature.xml\n"
  },
  {
    "path": "kotlin-eclipse-gradle-feature/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n      id=\"org.jetbrains.kotlin.gradle.feature\"\n      label=\"Kotlin-gradle\"\n      version=\"0.8.24.qualifier\"\n      provider-name=\"JetBrains\">\n\n   <description url=\"http://kotlinlang.org/\">\n      Integration of Kotlin language plugin and gradle\n   </description>\n\n   <copyright url=\"http://www.jetbrains.com/\">\n      Copyright 2010-2016 JetBrains s.r.o.\n   </copyright>\n\n   <license url=\"\">\n      Copyright 2010-2016 JetBrains s.r.o.\n\nLicensed under the Apache License, Version 2.0 (the &quot;License&quot;);\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an &quot;AS IS&quot; BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n   </license>\n\n</feature>\n"
  },
  {
    "path": "kotlin-eclipse-gradle-feature/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.gradle.feature</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>eclipse-feature</packaging>\n\n</project>"
  },
  {
    "path": "kotlin-eclipse-gradle-model/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-gradle-model\nBundle-SymbolicName: org.jetbrains.kotlin.gradle.model;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Vendor: JetBrains\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ActivationPolicy: lazy\nExport-Package: org.jetbrains.kotlin.gradle.model\nImport-Package: kotlin\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/build.gradle",
    "content": "plugins {\n    id 'org.jetbrains.kotlin.jvm' version '1.6.0'\n}\n\ngroup 'kotlin-eclipse-plugin'\nversion '0.8.20-SNAPSHOT'\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    compile \"org.jetbrains.kotlin:kotlin-stdlib-jdk8\"\n}\n\nsourceSets {\n    main.kotlin.srcDirs += 'src'\n}\n\ncompileKotlin {\n    kotlinOptions.jvmTarget = \"17\"\n}\ncompileTestKotlin {\n    kotlinOptions.jvmTarget = \"17\"\n}\n\njar {\n    version = null\n    destinationDir = file('lib')\n}\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               scripts/,\\\n               lib/\n\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.0-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/gradlew",
    "content": "#!/usr/bin/env sh\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\"-Xmx64m\"\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windows variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.gradle.model</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-gradle-model/settings.gradle",
    "content": "pluginManagement {\n    repositories {\n        mavenCentral()\n\n        maven {\n            url 'https://plugins.gradle.org/m2/'\n        }\n    }\n}\nrootProject.name = 'kotlin-eclipse-gradle-model'\n\n"
  },
  {
    "path": "kotlin-eclipse-gradle-model/src/org/jetbrains/kotlin/gradle/model/GradleMultiProjectForEclipse.kt",
    "content": "package org.jetbrains.kotlin.gradle.model\n\nimport java.io.Serializable\n\ninterface GradleMultiProjectForEclipse : Serializable {\n    operator fun get(name: String): GradleProjectForEclipse?\n}\n\nclass GradleMultiProjectForEclipseImpl(\n    private val subprojects: Map<String, GradleProjectForEclipse>\n) : GradleMultiProjectForEclipse {\n    override fun get(name: String) = subprojects[name]\n}"
  },
  {
    "path": "kotlin-eclipse-gradle-model/src/org/jetbrains/kotlin/gradle/model/GradleProjectForEclipse.kt",
    "content": "package org.jetbrains.kotlin.gradle.model\n\nimport java.io.Serializable\n\n// This interface is used to communicate with gradle deamon via proxy, so it has to have all methods that are expected\n// in its subclasses.\ninterface GradleProjectForEclipse : Serializable {\n    val isKotlinProject: Boolean\n\n    val codestyle: String?\n        get() = null\n\n    val apiVersion: String?\n        get() = null\n\n    val languageVersion: String?\n        get() = null\n\n    val jvmTarget: String?\n        get() = null\n    \n    val compilerPlugins: List<CompilerPluginConfig>\n    \tget() = emptyList()\n}\n\ndata class KotlinGradleProject(\n    override val codestyle: String?,\n    override val apiVersion: String?,\n    override val languageVersion: String?,\n    override val jvmTarget: String?,\n    override val compilerPlugins: List<CompilerPluginConfig>\n) : GradleProjectForEclipse {\n    override val isKotlinProject: Boolean = true\n}\n\nobject NonKotlinProject : GradleProjectForEclipse {\n    override val isKotlinProject: Boolean = false\n}"
  },
  {
    "path": "kotlin-eclipse-gradle-model/src/org/jetbrains/kotlin/gradle/model/plugins.kt",
    "content": "package org.jetbrains.kotlin.gradle.model\n\nimport java.io.Serializable\n\ninterface CompilerPluginConfig: Serializable {\n    val pluginName: String\n    val options: List<String>\n}\n\nsealed class CompilerPluginConfigImpl(\n    shortName: String,\n    fqName: String,\n    knownPresets: Collection<String>,\n    declaredAnnotations: Collection<String>,\n    declaredPresets: Collection<String>,\n    otherOptions: List<String> = emptyList()\n) : CompilerPluginConfig {\n    final override val pluginName: String = knownPresets.find { it in declaredPresets } ?: shortName\n\n    override val options: List<String> =\n        (declaredPresets - pluginName).map { \"$fqName:preset=$it\" } +\n                declaredAnnotations.map { \"$fqName:annotation=$it\" } +\n                otherOptions\n}\n\nclass AllOpen(\n    annotations: Collection<String>,\n    presets: Collection<String>\n) : CompilerPluginConfigImpl(\n    shortName = \"all-open\",\n    fqName = \"org.jetbrains.kotlin.allopen\",\n    knownPresets = listOf(\"spring\"),\n    declaredAnnotations = annotations,\n    declaredPresets = presets\n)\n\nclass NoArg(\n    annotations: Collection<String>,\n    presets: Collection<String>,\n    invokeInitializers: Boolean?\n) : CompilerPluginConfigImpl(\n    shortName = \"no-arg\",\n    fqName = \"org.jetbrains.kotlin.noarg\",\n    knownPresets = listOf(\"jpa\"),\n    declaredAnnotations = annotations,\n    declaredPresets = presets,\n    otherOptions = invokeInitializers?.let { listOf(\"org.jetbrains.kotlin.noarg:invokeInitializers=$it\") }.orEmpty()\n)\n\nclass SAMWithReceiver(\n    annotations: Collection<String>,\n    presets: Collection<String>\n) : CompilerPluginConfigImpl(\n    shortName = \"sam-with-receiver\",\n    fqName = \"org.jetbrains.kotlin.samWithReceiver\",\n    knownPresets = emptyList(),\n    declaredAnnotations = annotations,\n    declaredPresets = presets\n)\n"
  },
  {
    "path": "kotlin-eclipse-maven/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-maven\nBundle-SymbolicName: org.jetbrains.kotlin.maven;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.maven.Activator\nBundle-Vendor: JetBrains\nRequire-Bundle: org.eclipse.core.runtime,\n org.eclipse.m2e.core,\n org.eclipse.m2e.jdt,\n org.eclipse.m2e.maven.runtime,\n org.jetbrains.kotlin.core,\n org.jetbrains.kotlin.bundled-compiler\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ActivationPolicy: lazy\nImport-Package: org.eclipse.core.resources,\n org.eclipse.jdt.core,\n org.eclipse.m2e.core.project.configurator\n"
  },
  {
    "path": "kotlin-eclipse-maven/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               lifecycle-mapping-metadata.xml\n"
  },
  {
    "path": "kotlin-eclipse-maven/lifecycle-mapping-metadata.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<lifecycleMappingMetadata>\n  <pluginExecutions>\n     <pluginExecution>\n       <pluginExecutionFilter>\n        <groupId>org.jetbrains.kotlin</groupId>\n        <artifactId>kotlin-maven-plugin</artifactId>\n        <versionRange>[0.0,)</versionRange>\n        <goals>\n          <goal>compile</goal>\n          <goal>test-compile</goal>\n        </goals>\n      </pluginExecutionFilter>\n      <action>\n        <configurator>\n          <id>org.jetbrains.kotlin.maven.projectConfigurator</id>\n        </configurator>\n      </action>\n    </pluginExecution>    \n  </pluginExecutions>\n</lifecycleMappingMetadata>"
  },
  {
    "path": "kotlin-eclipse-maven/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.m2e.core.projectConfigurators\">\n      <configurator\n            class=\"org.jetbrains.kotlin.maven.configuration.KotlinMavenProjectConfigurator\"\n            id=\"org.jetbrains.kotlin.maven.projectConfigurator\">\n      </configurator>\n   </extension>\n   <extension\n         point=\"org.eclipse.m2e.core.lifecycleMappingMetadataSource\">\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "kotlin-eclipse-maven/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.maven</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-maven/src/org/jetbrains/kotlin/maven/Activator.java",
    "content": "package org.jetbrains.kotlin.maven;\n\nimport org.osgi.framework.BundleActivator;\nimport org.osgi.framework.BundleContext;\n\npublic class Activator implements BundleActivator {\n\n\tprivate static BundleContext context;\n\n\tstatic BundleContext getContext() {\n\t\treturn context;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext bundleContext) throws Exception {\n\t\tActivator.context = bundleContext;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext bundleContext) throws Exception {\n\t\tActivator.context = null;\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-maven/src/org/jetbrains/kotlin/maven/configuration/KotlinMavenProjectConfigurator.kt",
    "content": "package org.jetbrains.kotlin.maven.configuration\r\n\r\nimport org.apache.maven.model.Plugin\r\nimport org.apache.maven.project.MavenProject\r\nimport org.codehaus.plexus.util.xml.Xpp3Dom\r\nimport org.eclipse.core.resources.ProjectScope\r\nimport org.eclipse.core.runtime.IProgressMonitor\r\nimport org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator\r\nimport org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest\r\nimport org.eclipse.m2e.jdt.AbstractSourcesGenerationProjectConfigurator\r\nimport org.eclipse.m2e.jdt.IClasspathDescriptor\r\nimport org.jetbrains.kotlin.config.ApiVersion\r\nimport org.jetbrains.kotlin.config.JvmTarget\r\nimport org.jetbrains.kotlin.config.LanguageVersion\r\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\r\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager\r\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\r\nimport org.jetbrains.kotlin.core.model.KotlinNature\r\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\r\n\r\nprivate const val GROUP_ID = \"org.jetbrains.kotlin\"\r\nprivate const val MAVEN_PLUGIN_ID = \"kotlin-maven-plugin\"\r\n\r\nclass KotlinMavenProjectConfigurator : AbstractSourcesGenerationProjectConfigurator() {\r\n\r\n    override fun configure(request: ProjectConfigurationRequest, monitor: IProgressMonitor) {\r\n        val mavenProject = request.mavenProject\r\n        val plugin: Plugin = mavenProject.buildPlugins\r\n            .find { checkCoordinates(it, GROUP_ID, MAVEN_PLUGIN_ID) } ?: return\r\n\r\n        val compilerProperties = KotlinEnvironment.getEnvironment(request.mavenProjectFacade.project).projectCompilerProperties\r\n        var configurationChanged = false\r\n\r\n        fun configureProperty(\r\n            attributeName: String? = null,\r\n            propertyPath: String? = null,\r\n            isChangingConfiguration: Boolean = true,\r\n            callback: (String) -> Unit\r\n        ) {\r\n            MavenAttributeAccessor(attributeName, propertyPath)\r\n                .getFrom(mavenProject, plugin)\r\n                ?.also(callback)\r\n                ?.also { configurationChanged = configurationChanged || isChangingConfiguration }\r\n        }\r\n\r\n\r\n        configureProperty(\"languageVersion\", \"kotlin.compiler.languageVersion\") {\r\n            compilerProperties.languageVersion = LanguageVersion.fromVersionString(it) ?: LanguageVersion.LATEST_STABLE\r\n        }\r\n\r\n        configureProperty(\"apiVersion\", \"kotlin.compiler.apiVersion\") {\r\n            compilerProperties.apiVersion = ApiVersion.parse(it)\r\n                    ?: ApiVersion.createByLanguageVersion(compilerProperties.languageVersion)\r\n        }\r\n\r\n        configureProperty(\"jvmTarget\", \"kotlin.compiler.jvmTarget\") {\r\n            compilerProperties.jvmTarget = JvmTarget.fromString(it) ?: JvmTarget.DEFAULT\r\n        }\r\n\r\n        getCompilerFlags(plugin.configuration)?.also {\r\n            compilerProperties.compilerFlags = it\r\n            configurationChanged = true\r\n        }\r\n\r\n        configureProperty(propertyPath = \"kotlin.code.style\", isChangingConfiguration = false) { alias ->\r\n            KotlinCodeStyleManager.buildsystemAliases[alias]?.let {\r\n                with(KotlinCodeStyleProperties(ProjectScope(request.mavenProjectFacade.project))) {\r\n                    codeStyleId = it\r\n                    globalsOverridden = true\r\n                    saveChanges()\r\n                }\r\n            }\r\n        }\r\n\r\n        if (configurationChanged) {\r\n            compilerProperties.globalsOverridden = true\r\n            compilerProperties.saveChanges()\r\n        }\r\n    }\r\n\r\n    override fun configureRawClasspath(\r\n        request: ProjectConfigurationRequest, classpath: IClasspathDescriptor,\r\n        monitor: IProgressMonitor\r\n    ) {\r\n        if (hasKotlinMavenPlugin(request.mavenProject)) {\r\n            classpath.addEntry(KotlinClasspathContainer.CONTAINER_ENTRY)\r\n            AbstractProjectConfigurator.addNature(request.mavenProjectFacade.project, KotlinNature.KOTLIN_NATURE, monitor)\r\n        }\r\n    }\r\n\r\n    private fun getCompilerFlags(configuration: Any?): String? =\r\n        (configuration as? Xpp3Dom)\r\n            ?.getChild(\"args\")\r\n            ?.children\r\n            ?.filter { it.name == \"arg\" }\r\n            ?.map { it.value }\r\n            ?.takeIf { it.isNotEmpty() }\r\n            ?.joinToString(separator = \" \")\r\n\r\n    private fun hasKotlinMavenPlugin(mavenProject: MavenProject): Boolean =\r\n        mavenProject.buildPlugins.any { checkCoordinates(it, GROUP_ID, MAVEN_PLUGIN_ID) }\r\n\r\n    private fun checkCoordinates(buildPlugin: Plugin, groupId: String, artifactId: String): Boolean =\r\n        groupId == buildPlugin.groupId && artifactId == buildPlugin.artifactId\r\n}"
  },
  {
    "path": "kotlin-eclipse-maven/src/org/jetbrains/kotlin/maven/configuration/MavenAttributeAccessor.kt",
    "content": "package org.jetbrains.kotlin.maven.configuration\n\nimport org.apache.maven.model.Plugin\nimport org.apache.maven.project.MavenProject\nimport org.codehaus.plexus.util.xml.Xpp3Dom\nimport java.util.*\n\nclass MavenAttributeAccessor(private val attributeName: String? = null, private val propertyPath: String? = null) {\n    fun getFrom(project: MavenProject, plugin: Plugin): String? =\n        getFromConfiguration(plugin.configuration) ?: getFromProperties(project.properties)\n\n    private fun getFromConfiguration(configuration: Any?): String? =\n        (configuration as? Xpp3Dom)\n            ?.getChild(attributeName)\n            ?.value\n\n    private fun getFromProperties(properties: Properties): String? =\n            propertyPath?.let { properties[it] as? String }\n}"
  },
  {
    "path": "kotlin-eclipse-p2updatesite/category.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<site>\n   <feature url=\"features/org.jetbrains.kotlin.feature_0.8.24.qualifier.jar\" id=\"org.jetbrains.kotlin.feature\" version=\"0.8.24.qualifier\">\n      <category name=\"org.jetbrains.kotlin.category\"/>\n   </feature>\n   <feature url=\"features/org.jetbrains.kotlin.feature_0.8.24.qualifier.jar\" id=\"org.jetbrains.kotlin.gradle.feature\" version=\"0.8.24.qualifier\">\n      <category name=\"org.jetbrains.kotlin.category\"/>\n   </feature>\n   <category-def name=\"org.jetbrains.kotlin.category\" label=\"Kotlin Development Tools\"/>\n</site>\n"
  },
  {
    "path": "kotlin-eclipse-p2updatesite/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.p2updatesite</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>eclipse-repository</packaging>\n\n</project>"
  },
  {
    "path": "kotlin-eclipse-policy/build.properties",
    "content": "bin.includes = feature.xml\n"
  },
  {
    "path": "kotlin-eclipse-policy/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n      id=\"org.jetbrains.kotlin.policy\"\n      label=\"kotlin-eclipse-policy\"\n      version=\"0.8.24.qualifier\"\n      provider-name=\"JetBrains\">\n\n   <copyright url=\"http://www.jetbrains.com/\">\n      Copyright 2010-2016 JetBrains s.r.o.\n   </copyright>\n\n   <license url=\"https://www.jetbrains.com/company/privacy.html\">\n      JetBrains Privacy Policy\n\nThis software is governed by JetBrains Privacy Policy.\nhttps://www.jetbrains.com/company/privacy.html\n   </license>\n\n</feature>\n"
  },
  {
    "path": "kotlin-eclipse-policy/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.policy</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>eclipse-feature</packaging>\n\n</project>"
  },
  {
    "path": "kotlin-eclipse-test-framework/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-testframework\nBundle-SymbolicName: org.jetbrains.kotlin.testframework\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.testframework.Activator\nRequire-Bundle: org.jetbrains.kotlin.core,\n org.jetbrains.kotlin.ui,\n org.eclipse.ui,\n org.eclipse.core.runtime,\n org.eclipse.ui.editors;bundle-version=\"3.8.0\",\n org.eclipse.jface.text;bundle-version=\"3.8.1\",\n org.jetbrains.kotlin.bundled-compiler,\n org.eclipse.jdt.ui\nBundle-ActivationPolicy: lazy\nBundle-RequiredExecutionEnvironment: JavaSE-17\nImport-Package: junit.framework;version=\"4.10.0\",\n org.eclipse.core.resources,\n org.eclipse.jdt.core,\n org.eclipse.jdt.launching,\n org.eclipse.jface.text,\n org.eclipse.ui.part,\n org.junit;version=\"4.10.0\",\n org.junit.rules;version=\"4.10.0\"\nExport-Package: org.jetbrains.kotlin.testframework.editor,\n org.jetbrains.kotlin.testframework.utils\nBundle-Vendor: JetBrains\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nsource.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.testframework</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\t\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>3.10.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<release>17</release>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/Activator.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n    // The plug-in ID\n    public static final String PLUGIN_ID = \"org.jetbrains.kotlin.testframework\"; //$NON-NLS-1$\n    \n    // The shared instance\n    private static Activator plugin;\n    \n    /**\n     * The constructor\n     */\n    public Activator() {\n    }\n    \n    /*\n     * (non-Javadoc)\n     * \n     * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.\n     * BundleContext)\n     */\n    @Override\n    public void start(BundleContext context) throws Exception {\n        super.start(context);\n        plugin = this;\n    }\n    \n    /*\n     * (non-Javadoc)\n     * \n     * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.\n     * BundleContext)\n     */\n    @Override\n    public void stop(BundleContext context) throws Exception {\n        plugin = null;\n        super.stop(context);\n    }\n    \n    /**\n     * Returns the shared instance\n     *\n     * @return the shared instance\n     */\n    public static Activator getDefault() {\n        return plugin;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/KotlinEditorAutoTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.editor;\n\nimport java.io.File;\n\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.SourceFileData;\nimport org.junit.Rule;\nimport org.junit.rules.TestName;\n\npublic abstract class KotlinEditorAutoTestCase extends KotlinProjectTestCase {\n    \n    protected abstract static class EditorSourceFileData extends SourceFileData {\n        public EditorSourceFileData(File file) {\n            super(file.getName(), KotlinTestUtils.getText(file.getAbsolutePath()));\n        }\n    }\n    \n    @Rule\n    public TestName name = new TestName();\n    \n    private static final String TEST_DATA_PATH = \"testData\";\n    \n    private static String fileExtension;\n    \n    private static final String KT_FILE_EXTENSION = \".kt\";\n    private static final String KT_SCRIPT_FILE_EXTENSION = \".kts\";\n    protected static final String AFTER_FILE_EXTENSION = \".after\";\n    protected static final String BEFORE_FILE_EXTENSION = \".before\";\n    \n    protected static final String FILE_DEPENDENCY_SUFFIX = \".dependency\";\n    \n    protected final void doAutoTest() {\n        String testPath = TEST_DATA_PATH + \"/\" + getTestDataRelativePath() + \"/\" + name.getMethodName();\n        File testFolder = new File(testPath);\n        \n        File testFile = new File(testPath + KT_FILE_EXTENSION);\n        File scriptTestFile = new File(testPath + KT_SCRIPT_FILE_EXTENSION);\n        if (testFile.exists()) {\n            fileExtension = KT_FILE_EXTENSION;\n        } else {\n            testFile = scriptTestFile;\n            fileExtension = KT_SCRIPT_FILE_EXTENSION;\n        }\n        \n        File dependencyFile = new File(testPath + FILE_DEPENDENCY_SUFFIX + getExtension());\n        \n        if (testFolder.exists() && testFolder.isDirectory()) {\n            doMultiFileAutoTest(testFolder);\n        } else if (testFile.exists() && testFile.isFile() && dependencyFile.exists()) {\n            doAutoTestWithDependencyFile(testPath + getExtension(), dependencyFile);\n        } else if (testFile.exists() && testFile.isFile() && !dependencyFile.exists()) {\n            doSingleFileAutoTest(testPath + getExtension());\n        } else {\n            throw new RuntimeException(String.format(\"Neither file \\'%s\\' nor directory \\'%s\\' was found\", testFile.getAbsolutePath(), testFolder.getAbsolutePath()));\n        }\n    }\n    \n    protected abstract void doSingleFileAutoTest(String testPath);\n    \n    protected abstract void doMultiFileAutoTest(File testFolder);\n    \n    protected void doAutoTestWithDependencyFile(String mainTestPath, File dependencyFile) {\n        throw new UnsupportedOperationException(\"Auto test with dependency file is not supported\");\n    }\n    \n    protected abstract String getTestDataRelativePath();\n    \n    protected String getExtension() {\n        return fileExtension;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/KotlinEditorSequentialAutoTestCase.java",
    "content": "package org.jetbrains.kotlin.testframework.editor;\n\nimport java.io.File;\nimport java.util.ArrayList;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.ui.PlatformUI;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\n\npublic abstract class KotlinEditorSequentialAutoTestCase extends KotlinEditorAutoTestCase {\n    \n    @Override\n    protected void doSingleFileAutoTest(String testPath) {\n        throw new UnsupportedOperationException(\"Single-file tests are not supported for this case\");\n    }\n    \n    abstract protected void performSingleOperation();\n    \n    abstract protected String getInitialFileName();\n    \n    private TextEditorTest testEditor;\n    \n    protected TextEditorTest getTestEditor() {\n        return testEditor;\n    }\n    \n    @Override\n    protected void doMultiFileAutoTest(File testFolder) {\n        testEditor = configureEditor(getInitialFileName(), getInitialFileContent(testFolder));\n        \n        ArrayList<String> afterFilesPaths = getAfterFilesPaths(testFolder);\n        \n        JavaEditor activeEditor = (JavaEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\n        \n        for (String afterFilePath : afterFilesPaths) {\n            String afterFileContent = getAfterFileContent(afterFilePath);\n            performSingleOperation();\n            String errorMessage = String.format(\"Comparison error: %s\", afterFilePath);\n            EditorTestUtils.assertByEditorWithErrorMessage(activeEditor, afterFileContent, errorMessage);\n        }\n    }\n    \n    protected String getInitialFileContent(File testFolder) {\n        return KotlinTestUtils.getText(testFolder.getAbsolutePath() + File.separator + getInitialFileName());\n    }\n    \n    abstract protected ArrayList<String> getAfterFilesPaths(File testFolder);\n    \n    abstract protected String getAfterFileContent(String afterFilePath);\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/KotlinEditorTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.editor;\n\nimport java.io.File;\nimport java.io.IOException;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.NullProgressMonitor;\nimport org.eclipse.core.runtime.OperationCanceledException;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.core.runtime.jobs.Job;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\nimport org.jetbrains.kotlin.testframework.utils.WorkspaceUtil;\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.rules.TestName;\n\nimport com.intellij.openapi.util.io.FileUtil;\n\npublic abstract class KotlinEditorTestCase {\n    \n    public enum Separator {\n        TAB, SPACE;\n    }\n    \n    public static final String CARET_TAG = \"<caret>\";\n    public static final String SELECTION_TAG_OPEN = \"<selection>\";\n    public static final String SELECTION_TAG_CLOSE = \"</selection>\";\n    public static final String ERROR_TAG_OPEN = \"<error>\";\n    public static final String ERROR_TAG_CLOSE = \"</error>\";\n    public static final String WARNING_TAG_OPEN = \"<warning>\";\n    public static final String WARNING_TAG_CLOSE = \"</warning>\";\n    public static final String BREAK_TAG = \"<br>\";\n    public static final String REFERENCE_TAG = \"<ref>\";\n    \n    @Rule\n    public TestName name = new TestName();\n    protected TextEditorTest testEditor;\n    private Separator initialSeparator;\n    private int initialSpacesCount;\n    \n    @After\n    public void afterTest() {\n        deleteProjectAndCloseEditors();\n        \n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS,\n                (Separator.SPACE == initialSeparator));\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH,\n                initialSpacesCount);\n    }\n    \n    @Before\n    public void beforeTest() {\n        refreshWorkspace();\n        \n        initialSeparator = EditorsUI.getPreferenceStore().getBoolean(\n                AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS) ? Separator.SPACE\n                        : Separator.TAB;\n        initialSpacesCount = EditorsUI.getPreferenceStore().getInt(\n                AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);\n    }\n    \n    protected KotlinFileEditor getEditor() {\n        return (KotlinFileEditor) testEditor.getEditor();\n    }\n    \n    protected int getCaret() {\n        return getEditor().getViewer().getTextWidget().getCaretOffset();\n    }\n    \n    public IFile createSourceFile(String pkg, String fileName, String content) {\n        content = removeTags(content);\n        try {\n            if (testEditor == null) {\n                testEditor = new TextEditorTest(TextEditorTest.TEST_PROJECT_NAME);\n            }\n            return testEditor.getTestJavaProject().createSourceFile(pkg, fileName, content);\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n    }\n    \n    public IFile createSourceFile(String fileName, String content) {\n        return createSourceFile(TextEditorTest.TEST_PACKAGE_NAME, fileName, content);\n    }\n    \n    protected static TextEditorTest configureEditor(String fileName, String content) {\n        return configureEditor(fileName, content, TextEditorTest.TEST_PACKAGE_NAME);\n    }\n    \n    protected static TextEditorTest configureEditor(String fileName, String content, String packageName) {\n        return configureEditor(fileName, content, TextEditorTest.TEST_PROJECT_NAME, packageName);\n    }\n    \n    protected static TextEditorTest configureEditor(String fileName, String content, String projectName,\n            String packageName) {\n        TextEditorTest testEditor = new TextEditorTest(projectName);\n        testEditor.createEditor(fileName, resolveTestTags(content), packageName);\n        \n        return testEditor;\n    }\n    \n    private void deleteProjectAndCloseEditors() {\n        try {\n            joinBuildThread();\n            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);\n            \n            if (testEditor != null) {\n                TestJavaProject testJavaProject = testEditor.getTestJavaProject();\n                if (testJavaProject != null) {\n                    testJavaProject.clean();\n                }\n            }\n            \n            IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();\n            for (IProject project : projects) {\n                project.delete(true, true, null);\n            }\n        } catch (CoreException e) {\n            e.printStackTrace();\n        }\n        \n    }\n    \n    public static void refreshWorkspace() {\n        WorkspaceUtil.refreshWorkspace();\n        try {\n            Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, new NullProgressMonitor());\n        } catch (OperationCanceledException | InterruptedException e) {\n            e.printStackTrace();\n        }\n    }\n    \n    public static String getText(String testPath) {\n        return getText(new File(testPath));\n    }\n    \n    public static String getText(File file) {\n        try {\n            return String.valueOf(FileUtil.loadFile(file));\n        } catch (IOException e) {\n            throw new RuntimeException(e);\n        }\n    }\n    \n    public static void joinBuildThread() {\n        while (true) {\n            try {\n                Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);\n                break;\n            } catch (OperationCanceledException | InterruptedException e) {\n            }\n        }\n    }\n    \n    public static String resolveTestTags(String text) {\n        return text\n                .replaceAll(ERROR_TAG_OPEN, \"\")\n                .replaceAll(ERROR_TAG_CLOSE, \"\")\n                .replaceAll(WARNING_TAG_OPEN, \"\")\n                .replaceAll(WARNING_TAG_CLOSE, \"\")\n                .replaceAll(BREAK_TAG, System.lineSeparator());\n    }\n    \n    public static String removeTags(String text) {\n        return resolveTestTags(text)\n                .replaceAll(CARET_TAG, \"\")\n                .replaceAll(SELECTION_TAG_OPEN, \"\")\n                .replaceAll(SELECTION_TAG_CLOSE, \"\")\n                .replaceAll(REFERENCE_TAG, \"\");\n    }\n    \n    public static String getNameByPath(String testPath) {\n        return new Path(testPath).lastSegment();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/KotlinEditorWithAfterFileTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.editor;\n\nimport com.intellij.openapi.util.Condition;\nimport com.intellij.util.containers.ContainerUtil;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.SourceFileData;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic abstract class KotlinEditorWithAfterFileTestCase extends KotlinEditorAutoTestCase {\n\n    public enum AfterSuffixPosition {\n        BEFORE_DOT, AFTER_NAME\n    }\n\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.AFTER_NAME;\n    }\n\n    private static class WithAfterSourceFileData extends EditorSourceFileData {\n\n        private static final Condition<WithAfterSourceFileData> TARGET_PREDICATE = new Condition<WithAfterSourceFileData>() {\n            @Override\n            public boolean value(WithAfterSourceFileData data) {\n                return data.contentAfter != null;\n            }\n        };\n\n        private static final String NO_TARGET_FILE_FOUND_ERROR_MESSAGE = \"No target file found\";\n        private static final String NO_TARGET_FILE_FOUND_FOR_AFTER_FILE_ERROR_MESSAGE_FORMAT = \"No target file found for \\'%s\\' file\";\n\n        private String contentAfter = null;\n\n        public WithAfterSourceFileData(File file) {\n            super(file);\n        }\n\n        public String getContentAfter() {\n            return contentAfter;\n        }\n\n        public static Collection<WithAfterSourceFileData> getTestFiles(File testFolder) {\n            Map<String, WithAfterSourceFileData> result = new HashMap<String, WithAfterSourceFileData>();\n\n            File targetAfterFile = null;\n            for (File file : testFolder.listFiles()) {\n                String fileName = file.getName();\n\n                if (!fileName.endsWith(AFTER_FILE_EXTENSION)) {\n                    result.put(fileName, new WithAfterSourceFileData(file));\n                } else {\n                    targetAfterFile = file;\n                }\n            }\n\n            if (targetAfterFile == null) {\n                throw new RuntimeException(NO_TARGET_FILE_FOUND_ERROR_MESSAGE);\n            }\n\n            WithAfterSourceFileData target = result.get(targetAfterFile.getName().replace(AFTER_FILE_EXTENSION, \"\"));\n            if (target == null) {\n                throw new RuntimeException(String.format(NO_TARGET_FILE_FOUND_FOR_AFTER_FILE_ERROR_MESSAGE_FORMAT, targetAfterFile.getAbsolutePath()));\n            }\n\n            target.contentAfter = KotlinTestUtils.getText(targetAfterFile.getAbsolutePath());\n\n            return result.values();\n        }\n\n        public static WithAfterSourceFileData getTargetFile(Iterable<WithAfterSourceFileData> files) {\n            return ContainerUtil.find(files, TARGET_PREDICATE);\n        }\n    }\n\n    private TextEditorTest testEditor;\n\n    protected abstract void performTest(String fileText, String expectedFileText);\n\n    protected TextEditorTest getTestEditor() {\n        return testEditor;\n    }\n\n    protected boolean loadFilesBeforeOpeningEditor() {\n        return false;\n    }\n\n    @Override\n    protected void doSingleFileAutoTest(String testPath) {\n        String fileText = loadEditor(testPath);\n\n        String afterTestPath;\n        AfterSuffixPosition afterPosition = getAfterPosition();\n        if (afterPosition == AfterSuffixPosition.AFTER_NAME) {\n            afterTestPath = testPath + AFTER_FILE_EXTENSION;\n        } else {\n            afterTestPath = testPath.substring(0, testPath.length() - getExtension().length()) + AFTER_FILE_EXTENSION + getExtension();\n        }\n\n        performTest(fileText, KotlinTestUtils.getText(afterTestPath));\n    }\n\n    @Override\n    protected void doMultiFileAutoTest(File testFolder) {\n        Collection<WithAfterSourceFileData> files = WithAfterSourceFileData.getTestFiles(testFolder);\n\n        WithAfterSourceFileData target = WithAfterSourceFileData.getTargetFile(files);\n\n        if (loadFilesBeforeOpeningEditor()) {\n            loadFiles(files, target);\n            testEditor = configureEditor(target.getFileName(), target.getContent(), target.getPackageName());\n        } else {\n            testEditor = configureEditor(target.getFileName(), target.getContent(), target.getPackageName());\n            loadFiles(files, target);\n        }\n\n        performTest(target.getContent(), target.getContentAfter());\n    }\n\n    private void loadFiles(Collection<WithAfterSourceFileData> files, WithAfterSourceFileData target) {\n        for (WithAfterSourceFileData file : files) {\n            if (file != target) {\n                createSourceFile(file.getPackageName(), file.getFileName(), file.getContent());\n            }\n        }\n    }\n\n    @Override\n    protected void doAutoTestWithDependencyFile(String mainTestPath, File dependencyFile) {\n        String fileText;\n\n        if (loadFilesBeforeOpeningEditor()) {\n            loadDependencyFile(dependencyFile);\n            fileText = loadEditor(mainTestPath);\n        } else {\n            fileText = loadEditor(mainTestPath);\n            loadDependencyFile(dependencyFile);\n        }\n\n        performTest(fileText, KotlinTestUtils.getText(mainTestPath + AFTER_FILE_EXTENSION));\n    }\n\n    private String loadEditor(String mainTestPath) {\n        String fileText = KotlinTestUtils.getText(mainTestPath);\n        testEditor = configureEditor(KotlinTestUtils.getNameByPath(mainTestPath), fileText,\n                WithAfterSourceFileData.getPackageFromContent(fileText));\n        return fileText;\n    }\n\n    private void loadDependencyFile(File dependencyFile) {\n        try {\n            SourceFileData dependencySourceFile = new SourceFileData(dependencyFile);\n            String fileName = dependencySourceFile.getFileName();\n            String dependencyFileName = fileName.substring(0, fileName.indexOf(FILE_DEPENDENCY_SUFFIX)) +\n                    \"_dependency\" + getExtension();\n            createSourceFile(dependencySourceFile.getPackageName(), dependencyFileName,\n                    dependencySourceFile.getContent());\n        } catch (IOException e) {\n            throw new RuntimeException(e);\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/KotlinProjectTestCase.java",
    "content": "package org.jetbrains.kotlin.testframework.editor;\r\n\r\nimport org.eclipse.core.resources.IFile;\r\nimport org.eclipse.core.resources.IProject;\r\nimport org.eclipse.core.resources.ResourcesPlugin;\r\nimport org.eclipse.core.runtime.CoreException;\r\nimport org.eclipse.core.runtime.OperationCanceledException;\r\nimport org.eclipse.ui.PlatformUI;\r\nimport org.eclipse.ui.editors.text.EditorsUI;\r\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\r\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase.Separator;\r\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\r\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\r\nimport org.junit.After;\r\nimport org.junit.AfterClass;\r\nimport org.junit.Before;\r\n\r\npublic class KotlinProjectTestCase {\r\n    \r\n    private static TestJavaProject testJavaProject;\r\n    private int initialSpacesCount;\r\n    private Separator initialSeparator;\r\n    \r\n    @Before\r\n    public void beforeTest() {\r\n        KotlinTestUtils.refreshWorkspace();\r\n        \r\n        initialSeparator = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS) ? Separator.SPACE : Separator.TAB;\r\n        initialSpacesCount = EditorsUI.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);\r\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);\r\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);\r\n    }\r\n    \r\n    @After\r\n    public void afterTest() {\r\n        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);\r\n        \r\n        if (testJavaProject != null) {\r\n            testJavaProject.clean();\r\n        }\r\n        \r\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, (Separator.SPACE == initialSeparator));\r\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, initialSpacesCount);\r\n    }\r\n    \r\n    @AfterClass\r\n    public static void afterAllTests() {\r\n        if (testJavaProject != null) {\r\n            testJavaProject.clean();\r\n            testJavaProject.setDefaultSettings();\r\n        }\r\n        \r\n        try {\r\n            IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();\r\n            for (IProject project : projects) {\r\n                project.delete(true, true, null);\r\n            }\r\n        } catch (CoreException e) {\r\n            throw new RuntimeException(e);\r\n        }\r\n    }\r\n    \r\n    protected void configureProject() {\r\n        configureProject(TextEditorTest.TEST_PROJECT_NAME);\r\n    }\r\n    \r\n    protected void configureProject(String projectName) {\r\n        configureProject(projectName, null);\r\n    }\r\n    \r\n    protected void configureProject(String projectName, String location) {\r\n        testJavaProject = new TestJavaProject(projectName, location);\r\n    }\r\n    \r\n    protected void configureProjectWithStdLib() {\r\n        configureProjectWithStdLib(TextEditorTest.TEST_PROJECT_NAME);\r\n    }\r\n    \r\n    protected void configureProjectWithStdLib(String projectName) {\r\n        configureProjectWithStdLib(projectName, null);\r\n    }\r\n    \r\n    protected void configureProjectWithStdLib(String projectName, String location) {\r\n        configureProject(projectName, location);\r\n        \r\n        try {\r\n            testJavaProject.addKotlinRuntime();\r\n        } catch (CoreException e) {\r\n            throw new RuntimeException(e);\r\n        }\r\n    }\r\n    \r\n    public IFile createSourceFile(String pkg, String fileName, String content) {\r\n        try {\r\n            return testJavaProject.createSourceFile(pkg, fileName, KotlinEditorTestCase.removeTags(content));\r\n        } catch (CoreException e) {\r\n            throw new RuntimeException(e);\r\n        }\r\n    }\r\n    \r\n    public IFile createSourceFile(String fileName, String content) {\r\n        return createSourceFile(\"\", fileName, content);\r\n    }\r\n    \r\n    protected TextEditorTest configureEditor(String fileName, String content) {\r\n        return configureEditor(fileName, content, \"\");\r\n    }\r\n    \r\n    protected TextEditorTest configureEditor(String fileName, String content, String pkg) {\r\n        TextEditorTest testEditor = new TextEditorTest(testJavaProject);\r\n        testEditor.createEditor(fileName, content, pkg);\r\n        \r\n        return testEditor;\r\n    }\r\n    \r\n    protected TestJavaProject getTestProject() {\r\n        return testJavaProject;\r\n    }\r\n\r\n    protected void waitForEditorInitialization(TextEditorTest testEditor) {\r\n        // TODO\r\n    }\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/editor/TextEditorTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.editor;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Event;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.KotlinFormatAction;\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction;\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectEnclosingAction;\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectNextAction;\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectPreviousAction;\n\npublic class TextEditorTest {\n    \n    public static final String TEST_PROJECT_NAME = \"test_project\";\n    public static final String TEST_PACKAGE_NAME = \"testing\";\n    private TestJavaProject testProject;\n    private JavaEditor editor = null;\n    \n    public TextEditorTest() {\n        this(TEST_PROJECT_NAME);\n    }\n    \n    public TextEditorTest(String projectName) {\n        testProject = new TestJavaProject(projectName);\n    }\n    \n    public TextEditorTest(TestJavaProject testProject) {\n        this.testProject = testProject;\n    }\n    \n    public TestJavaProject getTestJavaProject() {\n        return testProject;\n    }\n    \n    public IProject getEclipseProject() {\n        return testProject.getJavaProject().getProject();\n    }\n    \n    public JavaEditor createEditor(String name, String content) {\n        return createEditor(name, content, TEST_PACKAGE_NAME);\n    }\n    \n    public JavaEditor createEditor(String name, String content, String packageName) {\n        if (editor == null) {\n            try {\n                int cursor = content.indexOf(KotlinEditorTestCase.CARET_TAG);\n                content = content.replaceAll(KotlinEditorTestCase.CARET_TAG, \"\");\n                \n                int selectionStart = content.indexOf(KotlinEditorTestCase.SELECTION_TAG_OPEN);\n                content = content.replaceAll(KotlinEditorTestCase.SELECTION_TAG_OPEN, \"\");\n                \n                int selectionEnd = content.indexOf(KotlinEditorTestCase.SELECTION_TAG_CLOSE);\n                content = content.replaceAll(KotlinEditorTestCase.SELECTION_TAG_CLOSE, \"\");               \n                \n                IFile file = testProject.createSourceFile(packageName, name, content);\n                editor = (JavaEditor) EditorTestUtils.openInEditor(file);\n                setCaret(cursor);\n                setSelection(selectionStart, selectionEnd - selectionStart);\n            } catch (Exception e) {\n                throw new RuntimeException(e);\n            }\n        }\n        \n        return editor;\n    }    \n\n\tpublic void type(char c) {\n        Event e = new Event();\n        e.character = c;\n        e.widget = editor.getViewer().getTextWidget();\n        e.widget.notifyListeners(SWT.KeyDown, e);\n    }\n    \n    public void runOpenDeclarationAction() {\n        ((KotlinEditor) editor).getJavaEditor().getAction(KotlinOpenDeclarationAction.OPEN_EDITOR_TEXT).run();\n    }\n    \n    public void runFormatAction() {\n        ((KotlinEditor) editor).getJavaEditor().getAction(KotlinFormatAction.Companion.getFORMAT_ACTION_TEXT()).run();\n    }\n    \n    public void runSelectEnclosingAction() {\n        ((KotlinEditor) editor).getJavaEditor().getAction(KotlinSelectEnclosingAction.SELECT_ENCLOSING_TEXT).run();\n    }\n    \n    public void runSelectPreviousAction() {\n        ((KotlinEditor) editor).getJavaEditor().getAction(KotlinSelectPreviousAction.SELECT_PREVIOUS_TEXT).run();\n    }\n    \n    public void runSelectNextAction() {\n        ((KotlinEditor) editor).getJavaEditor().getAction(KotlinSelectNextAction.SELECT_NEXT_TEXT).run();\n    }\n    \n    public int getCaretOffset() {\n    \treturn ((ITextSelection) editor.getViewer().getSelectionProvider().getSelection()).getOffset();\n    }\n    \n    public void setCaret(int offset) {\n        if (offset > -1) {\n            editor.setHighlightRange(offset, 0, true);\n            editor.setFocus();\n        }\n    }\n    \n    public void setSelection(int selectionStart, int selectionLength) {\n\t\tif (selectionStart >= 0 && selectionLength >= 0) {\n\t\t\teditor.selectAndReveal(selectionStart, selectionLength);\n\t\t}\n    }\n    \n    public void typeEnter() {\n        type('\\n');\n    }\n    \n    public void save() {\n        editor.doSave(null);\n    }\n    \n    public void close() {\n        editor.close(false);\n    }\n    \n    public IFile getEditingFile() {\n        return EditorUtil.getFile(editor);\n    }\n    \n    public String getEditorInput() {\n        return EditorUtil.getDocument(editor).get();\n    }\n    \n    public void deleteEditingFile() {\n        IFile editingFile = getEditingFile();\n        close();\n        try {\n            editingFile.delete(true, null);\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n    }\n    \n    public JavaEditor getEditor() {\n        return editor;\n    }\n    \n    public IDocument getDocument() {\n    \treturn editor.getDocumentProvider().getDocument(editor.getEditorInput());\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/CodeStyleConfigurator.kt",
    "content": "package org.jetbrains.kotlin.testframework.utils\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.ProjectScope\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.idea.KotlinLanguage\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings\nimport java.util.*\nimport kotlin.reflect.KFunction\nimport kotlin.reflect.KMutableProperty\n\nobject CodeStyleConfigurator {\n    fun configure(project: IProject, fileText: String) {\n        val generatedId = UUID.randomUUID().toString()\n\n        KotlinCodeStyleProperties(ProjectScope(project)).apply {\n            codeStyleId = generatedId\n            globalsOverridden = true\n            saveChanges()\n        }\n\n        KotlinCodeStyleManager.getOrCreate(generatedId) {\n            val kotlinSettings = getCustomSettings(KotlinCodeStyleSettings::class.java)\n            val commonSettings = getCommonSettings(KotlinLanguage.INSTANCE)\n\n            fun setDynamic(prop: String, value: Any) {\n                kotlinSettings.setDynamic(prop, value) or commonSettings.setDynamic(prop, value)\n            }\n\n            InTextDirectivesUtils.findListWithPrefixes(fileText, \"SET_TRUE:\")\n                    .forEach { setDynamic(it, true) }\n\n            InTextDirectivesUtils.findListWithPrefixes(fileText, \"SET_FALSE:\")\n                    .forEach { setDynamic(it, false) }\n\n            InTextDirectivesUtils.findListWithPrefixes(fileText, \"SET_INT:\")\n                    .map { it.split(\"=\", limit = 2) }\n                    .forEach { (prop, value) -> setDynamic(prop, value.trim().toInt()) }\n\n            InTextDirectivesUtils.findStringWithPrefixes(fileText, \"RIGHT_MARGIN: \")\n                    ?.also { commonSettings.RIGHT_MARGIN = it.trim().toInt() }\n        }\n    }\n\n    fun deconfigure(project: IProject) {\n        KotlinCodeStyleProperties(ProjectScope(project)).apply {\n            globalsOverridden = false\n            codeStyleId?.also { KotlinCodeStyleManager.invalidate(it) }\n            saveChanges()\n        }\n    }\n\n    private fun Any.setDynamic(name: String, value: Any): Boolean =\n            this::class.members.singleOrNull { it.name in setOf(name) }\n                    ?.let {\n                        when (it) {\n                            is KMutableProperty -> it.setter\n                            is KFunction -> it\n                            else -> null\n                        }\n                    }\n                    ?.call(this, value)\n                    ?.let { true }\n                    ?: false\n\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/EditorTestUtils.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.utils;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.ui.IEditorDescriptor;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.part.FileEditorInput;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.junit.Assert;\nimport org.junit.ComparisonFailure;\n\npublic class EditorTestUtils {\n    \n    public static IEditorPart openInEditor(IFile file) throws PartInitException {\n        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n        IWorkbenchPage page = window.getActivePage();\n        \n        FileEditorInput fileEditorInput = new FileEditorInput(file);\n        IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(\n                file.getName());\n        \n        return page.openEditor(fileEditorInput, defaultEditor.getId());\n    }\n    \n    public static void assertByEditorWithErrorMessage(JavaEditor activeEditor, String expected, String message) {\n        StyledText editorTextWidget = activeEditor.getViewer().getTextWidget();\n        assertByStringWithEditorWidgetAndErrorMessage(EditorUtil.getSourceCode(activeEditor), expected,\n                editorTextWidget, message);\n    }\n    \n    public static void assertByEditor(JavaEditor activeEditor, String expected) {\n        assertByEditorWithErrorMessage(activeEditor, expected, \"\");\n    }\n    \n    private static void assertByStringWithEditorWidgetAndErrorMessage(String actual, String expected,\n            StyledText editorTextWidget, String errorMessage) {\n        int caretOffset = editorTextWidget.getCaretOffset();\n        Point selection = editorTextWidget.getSelection();\n        expected = expected.replaceAll(KotlinEditorTestCase.BREAK_TAG, System.lineSeparator());\n        int selectionStartOffset = selection.x;\n        int selectionEndOffset = selection.y;\n        if (expected.contains(KotlinEditorTestCase.CARET_TAG) && caretOffset != -1) {\n            actual = actual.substring(0, caretOffset) + KotlinEditorTestCase.CARET_TAG + actual.substring(caretOffset);\n            int caretTagLength = KotlinEditorTestCase.CARET_TAG.length();\n            if (selectionStartOffset > caretOffset) {\n                selectionStartOffset += caretTagLength;\n            }\n            if (selectionEndOffset >= caretOffset) {\n                selectionEndOffset += caretTagLength;\n            }\n        }\n        // caret tag is expected to be absent if selection is present or to be\n        // within selection\n        if (expected.contains(KotlinEditorTestCase.SELECTION_TAG_OPEN) && selection.x != selection.y) {\n            StringBuilder taggedBuilder = new StringBuilder(actual);\n            // insert closing tag first, because then there's no need to recalc\n            // end offset\n            taggedBuilder.insert(selectionEndOffset, KotlinEditorTestCase.SELECTION_TAG_CLOSE);\n            taggedBuilder.insert(selectionStartOffset, KotlinEditorTestCase.SELECTION_TAG_OPEN);\n            actual = taggedBuilder.toString();\n        }\n        \n        try {\n            Assert.assertEquals(LineEndUtil.removeAllCarriageReturns(expected).trim(),\n                    LineEndUtil.removeAllCarriageReturns(actual).trim());\n        } catch (ComparisonFailure e) {\n            throw new ComparisonFailure(errorMessage, e.getExpected(), e.getActual());\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/ExpectedCompletionUtils.java",
    "content": "package org.jetbrains.kotlin.testframework.utils;\n\nimport static org.jetbrains.kotlin.testframework.utils.InTextDirectivesUtils.getItems;\n\nimport java.util.List;\n\npublic class ExpectedCompletionUtils {\n    \n    private static final String EXIST_LINE_PREFIX = \"EXIST:\";\n    private static final String ABSENT_LINE_PREFIX = \"ABSENT:\";\n    private static final String NUMBER_LINE_PREFIX = \"NUMBER:\";\n    private static final String EXIST_JAVA_ONLY_LINE_PREFIX = \"EXIST_JAVA_ONLY:\";\n    private static final String ELEMENT_PREFIX = \"ELEMENT:\";\n    private static final String COMPLETION_CHAR_PREFIX = \"COMPLETION_CHAR:\";\n    private static final String INVOCATION_COUNT_PREFIX = \"INVOCATION_COUNT:\";\n    private static final String NOTHING_ELSE_PREFIX = \"NOTHING_ELSE\";\n    \n    public static List<String> itemsShouldAbsent(String fileText) {\n        return getItems(fileText, ABSENT_LINE_PREFIX);\n    }\n    \n    public static List<String> itemsShouldExist(String fileText) {\n        return getItems(fileText, EXIST_LINE_PREFIX);\n    }\n    \n    public static boolean isNothingElseExpected(String fileText) {\n        return !InTextDirectivesUtils.findListWithPrefixes(fileText, NOTHING_ELSE_PREFIX).isEmpty();\n    }\n    \n    public static String itemToComplete(String fileText) {\n        List<String> items = getItems(fileText, ELEMENT_PREFIX);\n        if (!items.isEmpty()) {\n            assert items.size() == 1 : \"There should be only one item to complete\";\n            return items.get(0);\n        }\n        \n        return null;\n    }\n    \n    public static Character getCompletionChar(String fileText) {\n        List<String> items = getItems(fileText, COMPLETION_CHAR_PREFIX);\n        return !items.isEmpty() ? items.get(0).charAt(0) : null;\n    }\n    \n    public static List<String> itemsJavaOnlyShouldExists(String fileText) {\n        return getItems(fileText, EXIST_JAVA_ONLY_LINE_PREFIX);\n    }\n    \n    public static Integer numberOfItemsShouldPresent(String fileText) {\n        List<String> numbers = getItems(fileText, NUMBER_LINE_PREFIX);\n        \n        if (numbers.isEmpty()) {\n            return null;\n        }\n        \n        return new Integer(numbers.get(0));\n    }\n    \n    public static Boolean shouldHideNonVisibleMembers(String fileText) {\n        List<String> counts = getItems(fileText, INVOCATION_COUNT_PREFIX);\n        \n        if (counts.isEmpty()) {\n            return true;\n        }\n        \n        return new Integer(counts.get(0)) == 1;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/InTextDirectivesUtils.java",
    "content": "package org.jetbrains.kotlin.testframework.utils;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.StringReader;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.intellij.openapi.util.text.StringUtil;\nimport kotlin.text.StringsKt;\n\n//\tSource code is taken from org.jetbrains.kotlin.InTextDirectivesUtils\npublic class InTextDirectivesUtils {\n    \n    public static String findStringWithPrefixes(String fileText, String... prefixes) {\n        List<String> strings = findListWithPrefixes(fileText, prefixes);\n        if (strings.isEmpty()) {\n            return null;\n        }\n        \n        if (strings.size() != 1) {\n            throw new IllegalStateException(\n                    \"There is more than one string with given prefixes \" + Arrays.toString(prefixes) + \":\\n\"\n                            + StringUtil.join(strings, \"\\n\") + \"\\n\" + \"Use findListWithPrefixes() instead.\");\n        }\n        \n        return strings.get(0);\n    }\n    \n    public static List<String> findListWithPrefixes(String fileText, String... prefixes) {\n        List<String> result = new ArrayList<String>();\n        \n        for (String line : findLinesWithPrefixesRemoved(fileText, prefixes)) {\n            String[] variants = line.split(\",\");\n            \n            for (String variant : variants) {\n                result.add(StringUtil.unquoteString(variant.trim()));\n            }\n        }\n        \n        return result;\n    }\n    \n    private static List<String> findLinesWithPrefixesRemoved(String fileText, String... prefixes) {\n        List<String> result = new ArrayList<String>();\n        List<String> cleanedPrefixes = cleanDirectivesFromComments(Arrays.asList(prefixes));\n        \n        for (String line : fileNonEmptyCommentedLines(fileText)) {\n            for (String prefix : cleanedPrefixes) {\n                if (!line.startsWith(prefix))\n                    continue;\n                \n                String noPrefixLine = line.substring(prefix.length());\n                \n                if (noPrefixLine.isEmpty() || Character.isWhitespace(noPrefixLine.charAt(0))\n                        || Character.isWhitespace(prefix.charAt(prefix.length() - 1))) {\n                    result.add(noPrefixLine.trim());\n                    \n                    break;\n                }\n            }\n        }\n        \n        return result;\n    }\n    \n    private static List<String> cleanDirectivesFromComments(Collection<String> prefixes) {\n        List<String> resultPrefixes = new ArrayList<String>();\n        \n        for (String prefix : prefixes) {\n            if (prefix.startsWith(\"//\")) {\n                resultPrefixes.add(StringsKt.removePrefix(prefix, prefix.substring(0, 2)).trim());\n            } else {\n                resultPrefixes.add(prefix.trim());\n            }\n        }\n        \n        return resultPrefixes;\n    }\n    \n    private static List<String> fileNonEmptyCommentedLines(String fileText) {\n        List<String> result = new ArrayList<String>();\n        \n        try {\n            BufferedReader reader = new BufferedReader(new StringReader(fileText));\n            try {\n                String line;\n                \n                while ((line = reader.readLine()) != null) {\n                    line = line.trim();\n                    if (line.startsWith(\"//\")) {\n                        String uncommentedLine = line.substring(2).trim();\n                        if (!uncommentedLine.isEmpty()) {\n                            result.add(StringUtil.trim(uncommentedLine));\n                        }\n                    }\n                }\n            } finally {\n                reader.close();\n            }\n        } catch (IOException e) {\n            throw new AssertionError(e);\n        }\n        \n        return result;\n    }\n    \n    // TODO: Parse JSon string from tests\n    static List<String> getItems(String fileText, String prefix) {\n        List<String> items = new ArrayList<String>();\n        for (String itemStr : findLinesWithPrefixesRemoved(fileText, prefix)) {\n            if (itemStr.startsWith(\"{\"))\n                continue;\n            \n            for (String item : itemStr.split(\",\")) {\n                items.add(item.trim());\n            }\n        }\n        \n        return items;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/KotlinTestUtils.java",
    "content": "package org.jetbrains.kotlin.testframework.utils;\r\n\r\nimport java.io.File;\r\nimport java.io.IOException;\r\n\r\nimport org.eclipse.core.resources.ResourcesPlugin;\r\nimport org.eclipse.core.runtime.NullProgressMonitor;\r\nimport org.eclipse.core.runtime.OperationCanceledException;\r\nimport org.eclipse.core.runtime.Path;\r\nimport org.eclipse.core.runtime.jobs.Job;\r\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\r\n\r\nimport com.intellij.openapi.util.io.FileUtil;\r\n\r\npublic class KotlinTestUtils {\r\n    public enum Separator {\r\n        TAB, SPACE;\r\n    }\r\n    \r\n    public static final String ERROR_TAG_OPEN = \"<error>\";\r\n    public static final String ERROR_TAG_CLOSE = \"</error>\";\r\n    public static final String BR = \"<br>\";\r\n    \r\n    public static String getText(String testPath) {\r\n        try {\r\n            File file = new File(testPath);\r\n            return String.valueOf(FileUtil.loadFile(file));\r\n        } catch (IOException e) {\r\n            throw new RuntimeException(e);\r\n        }\r\n    }\r\n    \r\n    public static String getNameByPath(String testPath) {\r\n        return new Path(testPath).lastSegment();\r\n    }\r\n    \r\n    public static void joinBuildThread() {\r\n        while (true) {\r\n            try {\r\n                Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);\r\n                break;\r\n            } catch (OperationCanceledException | InterruptedException e) {\r\n            }\r\n        }\r\n    }\r\n    \r\n    public static void refreshWorkspace() {\r\n        WorkspaceUtil.refreshWorkspace();\r\n        try {\r\n            Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, new NullProgressMonitor());\r\n        } catch (OperationCanceledException | InterruptedException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n    \r\n    public static int getCaret(JavaEditor javaEditor) {\r\n        return javaEditor.getViewer().getTextWidget().getCaretOffset();\r\n    }\r\n    \r\n    public static String resolveTestTags(String text) {\r\n        return text.replaceAll(ERROR_TAG_OPEN, \"\").replaceAll(ERROR_TAG_CLOSE, \"\").replaceAll(BR,\r\n                System.lineSeparator());\r\n    }\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/SourceFileData.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.utils;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport com.intellij.openapi.util.io.FileUtil;\n\npublic class SourceFileData {\n    \n    private final static String DEFAULT_PACKAGE_NAME = \"\";\n    private final static String JAVA_IDENTIFIER_REGEXP = \"[_a-zA-Z]\\\\w*\";\n    private final static String PACKAGE_REGEXP = \"package\\\\s((\" + JAVA_IDENTIFIER_REGEXP + \")(\\\\.\"\n            + JAVA_IDENTIFIER_REGEXP + \")*)\";\n    private final static Pattern PATTERN = Pattern.compile(PACKAGE_REGEXP);\n    \n    private final String fileName;\n    private final String packageName;\n    private final String content;\n    \n    public SourceFileData(String fileName, String content) {\n        this.fileName = fileName;\n        this.content = content;\n        this.packageName = getPackageFromContent(content);\n    }\n    \n    public SourceFileData(File file) throws IOException {\n        this(file.getName(), FileUtil.loadFile(file));\n    }\n    \n    public String getFileName() {\n        return fileName;\n    }\n    \n    public String getPackageName() {\n        return packageName;\n    }\n    \n    public String getContent() {\n        return content;\n    }\n    \n    public static String getPackageFromContent(String content) {\n        Matcher matcher = PATTERN.matcher(content);\n        return matcher.find() ? matcher.group(1) : DEFAULT_PACKAGE_NAME;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/TestJavaProject.java",
    "content": "/*******************************************************************************\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.utils;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.InputStream;\nimport java.nio.charset.Charset;\nimport java.nio.charset.StandardCharsets;\n\nimport org.eclipse.core.resources.IContainer;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IFolder;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.IProjectDescription;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.resources.IWorkspaceRoot;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.jdt.core.IClasspathEntry;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.launching.JavaRuntime;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager;\nimport org.jetbrains.kotlin.core.model.KotlinNature;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\n\nimport com.intellij.lang.java.JavaLanguage;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.io.FileUtilRt;\nimport com.intellij.psi.PsiClass;\nimport com.intellij.psi.PsiFileFactory;\nimport com.intellij.psi.PsiJavaFile;\n\npublic class TestJavaProject {\n\n    public final static String SRC_FOLDER = \"src\";\n\n    private IProject project;\n    private IJavaProject javaProject;\n\n    private IPackageFragmentRoot sourceFolder;\n\n    public TestJavaProject(String projectName) {\n        this(projectName, null);\n    }\n\n    public TestJavaProject(String projectName, String location) {\n        project = createProject(projectName, location);\n    }\n\n    private IProject createProject(String projectName, String location) {\n        IWorkspace workspace = ResourcesPlugin.getWorkspace();\n        IWorkspaceRoot workspaceRoot = workspace.getRoot();\n        IProjectDescription projectDescription = workspace.newProjectDescription(projectName);\n        if (location != null) {\n            IPath rootPath = workspaceRoot.getLocation();\n            IPath locationPath = rootPath.append(location);\n            projectDescription.setLocation(locationPath);\n        }\n\n        project = workspaceRoot.getProject(projectName);\n        try {\n            boolean projectExists = project.exists();\n            if (!projectExists) {\n                project.create(projectDescription, null);\n            }\n            project.open(null);\n\n            javaProject = JavaCore.create(project);\n\n            if (!projectExists) {\n                setNatureSpecificProperties();\n                setDefaultSettings();\n\n                IFolder outputFolder = createFolderIfNotExist(\"bin\");\n                createOutputFolder(outputFolder);\n            }\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n\n        return project;\n    }\n\n    public void setDefaultSettings() {\n        try {\n            javaProject.setRawClasspath(new IClasspathEntry[0], null);\n            addSystemLibraries();\n            sourceFolder = createSourceFolder(SRC_FOLDER);\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    private void setNatureSpecificProperties() throws CoreException {\n        IProjectDescription description = project.getDescription();\n        description.setNatureIds(new String[] { JavaCore.NATURE_ID });\n        project.setDescription(description, null);\n\n        KotlinNature.Companion.addNature(project);\n    }\n\n    private IFile createFile(IContainer folder, String name, InputStream content) {\n        IFile file = folder.getFile(new Path(name));\n        try {\n            if (file.exists()) {\n                file.delete(true, null);\n            }\n            file.create(content, true, null);\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n\n        return file;\n    }\n\n    public IFile createSourceFile(String pkg, String fileName, String content) throws CoreException {\n        return createSourceFile(pkg, fileName, content, null);\n    }\n\n    public IFile createSourceFile(String pkg, String fileName, String content, Charset charset) throws CoreException {\n        String ext = FileUtilRt.getExtension(fileName);\n        String refinedFileName;\n        if (\"java\".equals(ext)) {\n            refinedFileName = getJavaClassName(content);\n            if (refinedFileName != null) {\n                refinedFileName += \".java\";\n            } else {\n                refinedFileName = fileName;\n            }\n            pkg = SourceFileData.getPackageFromContent(content);\n        } else {\n            refinedFileName = fileName;\n        }\n\n        Charset effectiveCharset = (charset == null) ? StandardCharsets.UTF_8 : charset;\n\n        IPackageFragment fragment = createPackage(pkg);\n        IFile file = createFile((IFolder) fragment.getResource(), refinedFileName,\n                new ByteArrayInputStream(content.getBytes(effectiveCharset)));\n\n        if (charset != null) {\n            file.setCharset(charset.name(), null);\n        }\n\n        return file;\n    }\n\n    public IPackageFragment createPackage(String name) throws CoreException {\n        if (sourceFolder == null) {\n            sourceFolder = createSourceFolder(SRC_FOLDER);\n        }\n        return sourceFolder.createPackageFragment(name, true, null);\n    }\n\n    private void createOutputFolder(IFolder outputFolder) throws JavaModelException {\n        IPath outputLocation = outputFolder.getFullPath();\n        javaProject.setOutputLocation(outputLocation, null);\n    }\n\n    public IPackageFragmentRoot createSourceFolder(String srcFolderName) throws CoreException {\n        IFolder folder = createFolderIfNotExist(srcFolderName);\n        IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);\n        for (IClasspathEntry entry : javaProject.getResolvedClasspath(false)) {\n            if (folder.getFullPath().equals(entry.getPath())) {\n                return root;\n            }\n        }\n\n        IClasspathEntry[] oldEntries = javaProject.getRawClasspath();\n        IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];\n        System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);\n        newEntries[oldEntries.length] = JavaCore.newSourceEntry(root.getPath());\n        javaProject.setRawClasspath(newEntries, null);\n\n        return root;\n    }\n\n    public IFolder createFolderIfNotExist(String name) throws CoreException {\n        IFolder folder = project.getFolder(name);\n        if (!folder.exists()) {\n            folder.create(false, true, null);\n        }\n\n        return folder;\n    }\n\n    public KotlinEnvironment getKotlinEnvironment() {\n        return KotlinEnvironment.Companion.getEnvironment(javaProject.getProject());\n    }\n\n    public IJavaProject getJavaProject() {\n        return javaProject;\n    }\n\n    public IProject getProject() {\n        return project;\n    }\n\n    public void addKotlinRuntime() throws CoreException {\n        ProjectUtils.addKotlinRuntime(javaProject);\n    }\n\n    public void addLibrary(IPath libraryPath, IPath sourcePath) throws JavaModelException {\n        IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libraryPath, sourcePath, null);\n        ProjectUtils.addContainerEntryToClasspath(javaProject, libraryEntry);\n    }\n\n    private void addSystemLibraries() throws JavaModelException {\n        ProjectUtils.addContainerEntryToClasspath(javaProject, JavaRuntime.getDefaultJREContainerEntry());\n    }\n\n    public void clean() {\n        try {\n            cleanSourceFolder();\n\n            IFolder outputFolder = ProjectUtils.getDefaultOutputFolder(getJavaProject());\n            ProjectUtils.cleanFolder(outputFolder);\n            ProjectUtils.cleanFolder(KotlinJavaManager.INSTANCE.getKotlinBinFolderFor(project));\n        } catch (JavaModelException e) {\n            throw new RuntimeException(e);\n        } catch (CoreException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    private String getJavaClassName(String content) {\n        PsiJavaFile javaPsiFile = createJavaPsiFile(content, getKotlinEnvironment().getProject());\n        PsiClass[] classes = javaPsiFile.getClasses();\n        return classes.length > 0 ? classes[0].getName() : null;\n    }\n\n    private PsiJavaFile createJavaPsiFile(String text, Project ideaProject) {\n        return (PsiJavaFile) PsiFileFactory.getInstance(ideaProject).createFileFromText(\"test.java\",\n                JavaLanguage.INSTANCE, text);\n    }\n\n    private void cleanSourceFolder() throws CoreException {\n        for (IClasspathEntry resolvedCP : javaProject.getResolvedClasspath(true)) {\n            if (resolvedCP.getEntryKind() == IClasspathEntry.CPE_SOURCE) {\n                IResource sourceFolder = findResourceInProject(resolvedCP.getPath());\n                ProjectUtils.cleanFolder((IContainer) sourceFolder);\n            }\n        }\n    }\n\n    private IResource findResourceInProject(IPath path) {\n        return ResourcesPlugin.getWorkspace().getRoot().findMember(path);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/TypingUtils.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.utils;\n\nimport static org.jetbrains.kotlin.testframework.utils.InTextDirectivesUtils.getItems;\n\nimport java.util.List;\n\npublic class TypingUtils {\n    \n    private static final String TYPE_PREFIX = \"TYPE: \";\n    \n    public static Character typedCharacter(String fileText) {\n        List<String> items = getItems(fileText, TYPE_PREFIX);\n        \n        return !items.isEmpty() ? items.get(0).charAt(0) : null;\n    }\n    \n    public static String typedText(String fileText) {\n        return getItems(fileText, TYPE_PREFIX).get(0);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-test-framework/src/org/jetbrains/kotlin/testframework/utils/WorkspaceUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.testframework.utils;\n\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.NullProgressMonitor;\n\npublic class WorkspaceUtil {\n    \n    public static void refreshWorkspace() {\n        try {\n            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();\n            for (IProject project : projects) {\n                project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());\n            }\n        } catch (CoreException e) {\n            e.printStackTrace();\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-ui\nBundle-SymbolicName: org.jetbrains.kotlin.ui;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Activator: org.jetbrains.kotlin.ui.Activator\nBundle-Vendor: JetBrains\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime,\n org.jetbrains.kotlin.core,\n org.eclipse.jface.text,\n org.eclipse.ui.editors;visibility:=reexport,\n org.jetbrains.kotlin.bundled-compiler,\n org.eclipse.debug.ui,\n org.eclipse.jdt.debug.ui,\n org.eclipse.jdt.ui,\n org.eclipse.jdt.junit,\n org.eclipse.jdt.debug,\n org.eclipse.compare,\n org.eclipse.search,\n org.eclipse.jdt.core.manipulation,\n org.eclipse.ltk.core.refactoring,\n org.eclipse.ltk.ui.refactoring,\n org.eclipse.equinox.p2.operations,\n org.eclipse.equinox.p2.core,\n org.eclipse.equinox.p2.metadata,\n org.eclipse.equinox.p2.engine,\n org.eclipse.equinox.p2.director,\n org.eclipse.core.variables\nBundle-ActivationPolicy: lazy\nImport-Package: com.google.common.collect,\n org.jetbrains.kotlin.nj2k,\n org.jetbrains.kotlin.idea.j2k,\n org.jetbrains.kotlin.nj2k.postProcessing,\n org.eclipse.core.expressions,\n org.eclipse.core.resources,\n org.eclipse.jdt.core,\n org.eclipse.jdt.core.compiler,\n org.eclipse.jdt.core.dom,\n org.eclipse.jdt.core.search,\n org.eclipse.jdt.debug.ui.launchConfigurations,\n org.eclipse.jdt.internal.compiler.classfmt,\n org.eclipse.jdt.internal.compiler.env,\n org.eclipse.jdt.internal.core,\n org.eclipse.jdt.junit.launcher,\n org.eclipse.jdt.launching,\n org.eclipse.jdt.ui,\n org.eclipse.swt.graphics,\n org.eclipse.ui,\n org.eclipse.ui.console,\n org.eclipse.ui.dialogs,\n org.eclipse.ui.ide,\n org.eclipse.ui.ide.undo,\n org.eclipse.ui.internal.texteditor.quickdiff,\n org.eclipse.ui.part,\n org.eclipse.ui.texteditor.link,\n org.eclipse.ui.texteditor.templates,\n org.eclipse.ui.views.contentoutline,\n org.eclipse.ui.wizards.newresource,\n org.jetbrains.kotlin.idea.util\nBundle-RequiredExecutionEnvironment: JavaSE-17\nExport-Package: org.jetbrains.kotlin.eclipse.ui.utils,\n org.jetbrains.kotlin.ui,\n org.jetbrains.kotlin.ui.builder,\n org.jetbrains.kotlin.ui.commands.findReferences,\n org.jetbrains.kotlin.ui.commands.j2k,\n org.jetbrains.kotlin.ui.editors,\n org.jetbrains.kotlin.ui.editors.annotations,\n org.jetbrains.kotlin.ui.editors.codeassist,\n org.jetbrains.kotlin.ui.editors.highlighting,\n org.jetbrains.kotlin.ui.editors.navigation,\n org.jetbrains.kotlin.ui.editors.organizeImports,\n org.jetbrains.kotlin.ui.editors.quickassist,\n org.jetbrains.kotlin.ui.editors.quickfix,\n org.jetbrains.kotlin.ui.editors.selection,\n org.jetbrains.kotlin.ui.formatter,\n org.jetbrains.kotlin.ui.launch,\n org.jetbrains.kotlin.ui.launch.junit,\n org.jetbrains.kotlin.ui.navigation,\n org.jetbrains.kotlin.ui.overrideImplement,\n org.jetbrains.kotlin.ui.refactorings.extract,\n org.jetbrains.kotlin.ui.refactorings.rename,\n org.jetbrains.kotlin.ui.search,\n org.jetbrains.kotlin.ui.editors.hover\n"
  },
  {
    "path": "kotlin-eclipse-ui/Run Kotlin Plugin with Equinox Weaving.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.scala-ide.ew.launcher.RuntimeWorkbench\">\n<booleanAttribute key=\"append.args\" value=\"true\"/>\n<booleanAttribute key=\"askclear\" value=\"true\"/>\n<booleanAttribute key=\"automaticAdd\" value=\"true\"/>\n<booleanAttribute key=\"automaticValidate\" value=\"false\"/>\n<stringAttribute key=\"bootstrap\" value=\"\"/>\n<stringAttribute key=\"checked\" value=\"[NONE]\"/>\n<booleanAttribute key=\"clearConfig\" value=\"false\"/>\n<booleanAttribute key=\"clearws\" value=\"false\"/>\n<booleanAttribute key=\"clearwslog\" value=\"false\"/>\n<stringAttribute key=\"configLocation\" value=\"${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Run Kotlin Plugin with Equinox Weaving\"/>\n<booleanAttribute key=\"default\" value=\"true\"/>\n<booleanAttribute key=\"generateProfile\" value=\"true\"/>\n<booleanAttribute key=\"includeOptional\" value=\"true\"/>\n<stringAttribute key=\"location\" value=\"${workspace_loc}/../sampleWorkspace2\"/>\n<stringAttribute key=\"org.eclipse.debug.core.source_locator_id\" value=\"org.eclipse.pde.ui.launcher.PDESourceLookupDirector\"/>\n<stringAttribute key=\"org.eclipse.debug.core.source_locator_memento\" value=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-bundled-compiler&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-stdlib.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-ide-common.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-converter.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-formatter.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/openapi-shrinked.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/util-shrinked.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-aspects&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-core&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-test-framework&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-ui&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-ui-test&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;folder nest=&amp;quot;false&amp;quot; path=&amp;quot;/kotlin-eclipse-core/src&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.folder&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;\"/>\n<booleanAttribute key=\"org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD\" value=\"true\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.JRE_CONTAINER\" value=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.PROGRAM_ARGUMENTS\" value=\"-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -nosplash\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER\" value=\"org.eclipse.pde.ui.workbenchClasspathProvider\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-Dosgi.requiredJavaVersion=1.7 -Xms40m -Xmx512m -XX:MaxPermSize=356m -ea\"/>\n<booleanAttribute key=\"pde.generated.config\" value=\"false\"/>\n<stringAttribute key=\"pde.version\" value=\"3.3\"/>\n<stringAttribute key=\"product\" value=\"org.eclipse.platform.ide\"/>\n<booleanAttribute key=\"show_selected_only\" value=\"false\"/>\n<booleanAttribute key=\"tracing\" value=\"false\"/>\n<booleanAttribute key=\"useCustomFeatures\" value=\"false\"/>\n<booleanAttribute key=\"useDefaultConfig\" value=\"true\"/>\n<booleanAttribute key=\"useDefaultConfigArea\" value=\"true\"/>\n<booleanAttribute key=\"useProduct\" value=\"true\"/>\n<booleanAttribute key=\"usefeatures\" value=\"false\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "kotlin-eclipse-ui/Run with open port.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.scala-ide.ew.launcher.RuntimeWorkbench\">\n<booleanAttribute key=\"append.args\" value=\"true\"/>\n<booleanAttribute key=\"askclear\" value=\"true\"/>\n<booleanAttribute key=\"automaticAdd\" value=\"true\"/>\n<booleanAttribute key=\"automaticValidate\" value=\"false\"/>\n<stringAttribute key=\"bootstrap\" value=\"\"/>\n<stringAttribute key=\"checked\" value=\"[NONE]\"/>\n<booleanAttribute key=\"clearConfig\" value=\"false\"/>\n<booleanAttribute key=\"clearws\" value=\"false\"/>\n<booleanAttribute key=\"clearwslog\" value=\"false\"/>\n<stringAttribute key=\"configLocation\" value=\"${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Run with open port\"/>\n<booleanAttribute key=\"default\" value=\"true\"/>\n<booleanAttribute key=\"generateProfile\" value=\"true\"/>\n<booleanAttribute key=\"includeOptional\" value=\"true\"/>\n<stringAttribute key=\"location\" value=\"${workspace_loc}/../runtime-EclipseApplicationwithEquinoxWeaving\"/>\n<stringAttribute key=\"org.eclipse.debug.core.source_locator_id\" value=\"org.eclipse.pde.ui.launcher.PDESourceLookupDirector\"/>\n<stringAttribute key=\"org.eclipse.debug.core.source_locator_memento\" value=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-bundled-compiler&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-stdlib.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-ide-common.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-converter.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/kotlin-formatter.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/openapi-shrinked.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;packageFragmentRoot handle=&amp;quot;=kotlin-bundled-compiler/lib\\/util-shrinked.jar&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.packageFragmentRoot&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-aspects&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-core&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-test-framework&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-ui&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;kotlin-eclipse-ui-test&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;folder nest=&amp;quot;false&amp;quot; path=&amp;quot;/kotlin-eclipse-core/src&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.folder&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;\"/>\n<listAttribute key=\"org.eclipse.debug.ui.favoriteGroups\">\n<listEntry value=\"org.eclipse.debug.ui.launchGroup.run\"/>\n</listAttribute>\n<booleanAttribute key=\"org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD\" value=\"true\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.JRE_CONTAINER\" value=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.PROGRAM_ARGUMENTS\" value=\"-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -nosplash\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER\" value=\"org.eclipse.pde.ui.workbenchClasspathProvider\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-Dosgi.requiredJavaVersion=1.7 -Xms40m -Xmx512m -XX:MaxPermSize=356m -ea -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005\"/>\n<booleanAttribute key=\"pde.generated.config\" value=\"false\"/>\n<stringAttribute key=\"pde.version\" value=\"3.3\"/>\n<stringAttribute key=\"product\" value=\"org.eclipse.platform.ide\"/>\n<booleanAttribute key=\"show_selected_only\" value=\"false\"/>\n<booleanAttribute key=\"tracing\" value=\"false\"/>\n<booleanAttribute key=\"useCustomFeatures\" value=\"false\"/>\n<booleanAttribute key=\"useDefaultConfig\" value=\"true\"/>\n<booleanAttribute key=\"useDefaultConfigArea\" value=\"true\"/>\n<booleanAttribute key=\"useProduct\" value=\"true\"/>\n<booleanAttribute key=\"usefeatures\" value=\"false\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "kotlin-eclipse-ui/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nsource.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/,\\\n               templates/,\\\n               schema/\nsrc.includes = icons/,\\\n               templates/,\\\n"
  },
  {
    "path": "kotlin-eclipse-ui/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension-point id=\"org.jetbrains.kotlin.ui.editor.textHover\" name=\"Kotlin Text Hover\" schema=\"schema/org.jetbrains.kotlin.ui.editor.textHover.exsd\"/>\n   <extension\n         point=\"org.eclipse.ui.newWizards\">\n      <category\n            id=\"org.jetbrains.kotlin.wizards\"\n            name=\"Kotlin\">\n      </category>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewProjectWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            icon=\"icons/newprj_kotlin_wiz.gif\"\n            id=\"org.jetbrains.kotlin.projectWizard\"\n            name=\"Kotlin Project\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective,org.eclipse.jdt.ui.JavaPerspective\"\n            project=\"true\">\n         <description>\n            Create a new Kotlin project\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewUnitWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newfile_wiz.gif\"\n            id=\"org.jetbrains.kotlin.wizard\"\n            name=\"Kotlin File\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective,org.eclipse.jdt.ui.JavaPerspective\"\n            project=\"false\">\n           <description>\n              Create a new Kotlin file\n           </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewClassWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newclass_wiz.gif\"\n            id=\"org.jetbrains.kotlin.classWizard\"\n            name=\"Kotlin Class\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin class\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewSealedClassWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newclass_wiz.gif\"\n            id=\"org.jetbrains.kotlin.classWizard\"\n            name=\"Kotlin sealed Class\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin sealed class\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewInterfaceWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newint_wiz.gif\"\n            id=\"org.jetbrains.kotlin.traitWizard\"\n            name=\"Kotlin Interface\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin interface\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewSealedInterfaceWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newint_wiz.gif\"\n            id=\"org.jetbrains.kotlin.traitWizard\"\n            name=\"Kotlin sealed Interface\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin sealed interface\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewObjectWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newobj_wiz.gif\"\n            id=\"org.jetbrains.kotlin.objectWizard\"\n            name=\"Kotlin Object\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin object\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewEnumWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newenum_wiz.gif\"\n            id=\"org.jetbrains.kotlin.enumWizard\"\n            name=\"Kotlin Enum\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin enum\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewDataClassWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newclass_wiz.gif\"\n            id=\"org.jetbrains.kotlin.enumWizard\"\n            name=\"Kotlin Data Class\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin data class\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewAnnotationWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newclass_wiz.gif\"\n            id=\"org.jetbrains.kotlin.enumWizard\"\n            name=\"Kotlin Annotation Class\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n         <description>\n            Create a new Kotlin annotation\n         </description>\n      </wizard>\n      <wizard\n            category=\"org.jetbrains.kotlin.wizards\"\n            class=\"org.jetbrains.kotlin.wizards.NewScriptWizard\"\n            finalPerspective=\"org.jetbrains.kotlin.perspective\"\n            hasPages=\"true\"\n            icon=\"icons/newfile_wiz.gif\"\n            id=\"org.jetbrains.kotlin.scriptWizard\"\n            name=\"Kotlin Script\"\n            preferredPerspectives=\"org.jetbrains.kotlin.perspective\"\n            project=\"false\">\n      </wizard>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editorActions\">\n      <editorContribution\n            id=\"org.jetbrains.kotlin.ui.debug.KotlinFileEditor.BreakpointRulerActions\"\n            targetID=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\">\n         <action\n               actionID=\"RulerDoubleClick\"\n               class=\"org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate\"\n               id=\"org.jetbrains.kotlin.ui.debug.actions.ManageBreakpointRulerAction\"\n               label=\"Toggle &amp;Breakpoint\">\n         </action>\n      </editorContribution>\n      <editorContribution\n            id=\"org.jetbrains.kotlin.ui.debug.KotlinClassFileEditor.BreakpointRulerActions\"\n            targetID=\"org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\">\n         <action\n               actionID=\"RulerDoubleClick\"\n               class=\"org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate\"\n               id=\"org.jetbrains.kotlin.ui.debug.actions.ManageBreakpointRulerAction\"\n               label=\"Toggle &amp;Breakpoint\">\n         </action>\n      </editorContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectiveExtensions\">\n      <perspectiveExtension\n            targetID=\"org.eclipse.jdt.ui.JavaPerspective\">\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.wizard\">\n         </newWizardShortcut>\n      </perspectiveExtension>\n      <perspectiveExtension\n            targetID=\"org.jetbrains.kotlin.perspective\">\n         <view\n               id=\"org.eclipse.jdt.ui.PackageExplorer\"\n               minimized=\"false\"\n               ratio=\"0.3\"\n               relationship=\"left\"\n               relative=\"org.eclipse.ui.editorss\"\n               visible=\"true\">\n         </view>\n         <view\n               id=\"org.eclipse.ui.views.ProblemView\"\n               minimized=\"false\"\n               relationship=\"bottom\"\n               relative=\"org.eclipse.ui.editorss\"\n               visible=\"true\">\n         </view>\n         <view\n               id=\"org.eclipse.ui.console.ConsoleView\"\n               minimized=\"false\"\n               relationship=\"stack\"\n               relative=\"org.eclipse.ui.views.ProblemView\"\n               visible=\"true\">\n         </view>\n         <view\n               id=\"org.eclipse.ui.views.ContentOutline\"\n               minimized=\"false\"\n               relationship=\"right\"\n               relative=\"org.eclipse.ui.editorss\"\n               visible=\"true\">\n         </view>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.wizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.classWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.traitWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.objectWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.enumWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.jdt.ui.wizards.NewPackageCreationWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.jdt.ui.wizards.NewClassCreationWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.ui.wizards.new.folder\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.eclipse.ui.wizards.new.file\">\n         </newWizardShortcut>\n         <newWizardShortcut\n               id=\"org.jetbrains.kotlin.projectWizard\">\n         </newWizardShortcut>\n      </perspectiveExtension>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.preferencePages\">\n      <page\n            class=\"org.jetbrains.kotlin.preferences.KotlinPreferencePage\"\n            id=\"kotlin-eclipse-ui.preferences\"\n            name=\"Kotlin\">\n      </page>\n      <page\n            category=\"kotlin-eclipse-ui.preferences\"\n            class=\"org.jetbrains.kotlin.preferences.style.WorkspaceCodeStylePropertyPage\"\n            id=\"kotlin-eclipse-ui.preferences.style\"\n            name=\"Code style\">\n      </page>\n      <page\n            category=\"kotlin-eclipse-ui.preferences\"\n            class=\"org.jetbrains.kotlin.preferences.compiler.WorkspaceCompilerPropertyPage\"\n            id=\"kotlin-eclipse-ui.preferences.compiler\"\n            name=\"Compiler\">\n      </page>\n      <page\n            category=\"kotlin-eclipse-ui.preferences\"\n            class=\"org.jetbrains.kotlin.preferences.building.WorkspaceBuildingPropertyPage\"\n            id=\"kotlin-eclipse-ui.preferences.compiler\"\n            name=\"Building\">\n      </page>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors\">\n      <editor\n            class=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\"\n            contributorClass=\"org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor\"\n            extensions=\"kt\"\n            icon=\"icons/kotlin-file.gif\"\n            symbolicFontName=\"org.eclipse.jdt.ui.editors.textfont\"\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\"\n            name=\"Kotlin Editor\">\n      </editor>\n      <editor\n            class=\"org.jetbrains.kotlin.ui.editors.KotlinScriptEditor\"\n            contributorClass=\"org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor\"\n            default=\"false\"\n            extensions=\"kts\"\n            icon=\"icons/kotlin-file.gif\"\n            symbolicFontName=\"org.eclipse.jdt.ui.editors.textfont\"\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinScriptEditor\"\n            name=\"Kotlin Script Editor\">\n      </editor>\n      <editor\n            class=\"org.jetbrains.kotlin.ui.editors.KotlinExternalReadOnlyEditor\"\n            contributorClass=\"org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor\"\n            default=\"false\"\n            extensions=\"kt\"\n            icon=\"icons/kotlin-file.gif\"\n            symbolicFontName=\"org.eclipse.jdt.ui.editors.textfont\"\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinExternalReadOnlyEditor\"\n            name=\"Kotlin External Editor\">\n      </editor>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors\">\n      <editor\n            class=\"org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\"\n            extensions=\"class\"\n            icon=\"icons/kotlin-file.gif\"\n            symbolicFontName=\"org.eclipse.jdt.ui.editors.textfont\"\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\"\n            name=\"Kotlin Class File Editor\">\n      </editor>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.psiVisualization.PsiVisualization\"\n            id=\"org.jetbrains.kotlin.psi.visualization\"\n            name=\"Psi Visualization\">\n      </command>\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.j2k.JavaToKotlinActionHandler\"\n            id=\"org.jetbrains.kotlin.ui.commands.j2k\"\n            name=\"Convert Java to Kotlin\">\n      </command>\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.DeconfigureKotlinActionHandler\"\n            id=\"org.jetbrains.kotlin.ui.commands.deconfiguration\"\n            name=\"Deconfigure Kotlin\">\n      </command>\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.ConfigureKotlinActionHandler\"\n            id=\"org.jetbrains.kotlin.ui.commands.configuration\"\n            name=\"Configure Kotlin\">\n      </command>\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.AddCoroutinesActionHandler\"\n            id=\"org.jetbrains.kotlin.ui.commands.configuration.coroutines\"\n            name=\"Add Coroutines Library\">\n      </command>\n      <command\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindReferencesInProjectHandler\"\n            id=\"org.jetbrains.kotlin.ui.commands.findReferences.findReferencesInProject\"\n            name=\"Find References In Project\">\n      </command>\n      <command\n            categoryId=\"org.eclipse.search.ui.category.search\"\n            defaultHandler=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindReferencesInWorkspaceHandler\"\n            description=\"Find References In Workspace\"\n            id=\"org.jetbrains.kotlin.ui.commands.findReferences.findReferencesInWorkspace\"\n            name=\"Find References In Workspace\">\n      </command>\n      <command\n              defaultHandler=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInWorkspaceHandler\"\n              id=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInWorkspaceHandler\"\n              name=\"Find Implementations in Workspace\">\n      </command>\n      <command\n              defaultHandler=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectHandler\"\n              id=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectHandler\"\n              name=\"Find Implementations in Project\">\n      </command>\n       <command defaultHandler=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenSuperImplementationActionHandler\"\n                id=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenSuperImplementationActionHandler\"\n                name=\"Super Implementations\"/>\n       <command defaultHandler=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenAllSuperImplementationActionHandler\"\n                id=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenAllSuperImplementationActionHandler\"\n                name=\"All Super Implementations\"/>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"popup:org.jetbrains.kotlin.ui.editors.KotlinFileEditor.EditorContext\">\n         <command\n               commandId=\"org.jetbrains.kotlin.psi.visualization\"\n               label=\"View Psi Structure of current file\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"popup:org.jetbrains.kotlin.ui.editors.KotlinFileEditor.EditorContext\">\n         <menu\n               label=\"References\">\n            <command\n                  commandId=\"org.jetbrains.kotlin.ui.commands.findReferences.findReferencesInProject\"\n                  label=\"References in Project\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.jetbrains.kotlin.ui.commands.findReferences.findReferencesInWorkspace\"\n                  label=\"References in Workspace\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInWorkspaceHandler\"\n                  label=\"Implementations in Workspace\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectHandler\"\n                  label=\"Implementations in Project\"\n                  style=\"push\">\n            </command>\n             <command commandId=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenSuperImplementationActionHandler\"\n                      label=\"Super Implementations\" style=\"push\"/>\n             <command\n                     commandId=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenAllSuperImplementationActionHandler\"\n                     label=\"All Super Implementations\" style=\"push\"/>\n         </menu>\n      </menuContribution>\n   </extension>\n   <extension\n         id=\"org.jetbrains.kotlin.ui.marker\"\n         point=\"org.eclipse.core.resources.markers\">\n      <super\n            type=\"org.eclipse.core.resources.marker\">\n      </super>\n      <super\n            type=\"org.eclipse.core.resources.textmarker\">\n      </super>\n      <persistent\n            value=\"true\">\n      </persistent>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors.markerAnnotationSpecification\">\n      <specification\n            annotationImageProvider=\"org.jetbrains.kotlin.ui.editors.annotations.KotlinAnnotationImageProvider\"\n            annotationType=\"org.jetbrains.kotlin.ui.annotation.error\"\n            colorPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.color\"\n            colorPreferenceValue=\"255,0,128\"\n            highlightPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.highlight\"\n            label=\"Kotlin Compilation Error\"\n            overviewRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.overview\"\n            overviewRulerPreferenceValue=\"true\"\n            symbolicIcon=\"error\"\n            textPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.text\"\n            textPreferenceValue=\"true\"\n            textStylePreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.textstyle\"\n            textStylePreferenceValue=\"PROBLEM_UNDERLINE\"\n            verticalRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.error.ruler\"\n            verticalRulerPreferenceValue=\"true\">\n      </specification>\n      <specification\n            annotationImageProvider=\"org.jetbrains.kotlin.ui.editors.annotations.KotlinAnnotationImageProvider\"\n            annotationType=\"org.jetbrains.kotlin.ui.annotation.warning\"\n            colorPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.color\"\n            colorPreferenceValue=\"244,200,45\"\n            highlightPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.highlight\"\n            label=\"Kotlin Compilation Warning\"\n            overviewRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.overview\"\n            overviewRulerPreferenceValue=\"true\"\n            symbolicIcon=\"warning\"\n            textPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.text\"\n            textPreferenceValue=\"true\"\n            textStylePreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.textstyle\"\n            textStylePreferenceValue=\"PROBLEM_UNDERLINE\"\n            verticalRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.warning.ruler\"\n            verticalRulerPreferenceValue=\"true\">\n      </specification>\n      <specification\n            annotationType=\"org.jetbrains.kotlin.ui.annotation.smartCast\"\n            colorPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.smartCast.color\"\n            colorPreferenceValue=\"219,255,219\"\n            highlightPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.smartCast.highlight\"\n            highlightPreferenceValue=\"true\"\n            label=\"Kotlin Smart Cast\"\n            overviewRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.smartCast.overview\"\n            overviewRulerPreferenceValue=\"true\"\n            textPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.smartCast.text\"\n            textPreferenceValue=\"true\"\n            textStylePreferenceValue=\"NONE\"\n            verticalRulerPreferenceKey=\"org.jetbrains.kotlin.ui.annotation.smartCast.ruler\"\n            verticalRulerPreferenceValue=\"false\">\n      </specification>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors.annotationTypes\">\n      <type\n            markerSeverity=\"1\"\n            markerType=\"org.jetbrains.kotlin.ui.marker\"\n            name=\"org.jetbrains.kotlin.ui.annotation.error\"\n            super=\"org.eclipse.ui.workbench.texteditor.error\">\n      </type>\n      <type\n            markerSeverity=\"2\"\n            markerType=\"org.jetbrains.kotlin.ui.marker\"\n            name=\"org.jetbrains.kotlin.ui.annotation.warning\"\n            super=\"org.eclipse.ui.workbench.texteditor.warning\">\n      </type>\n      <type\n            name=\"org.jetbrains.kotlin.ui.annotation.smartCast\">\n      </type>\n   </extension>\n   <extension\n         point=\"org.eclipse.debug.ui.launchShortcuts\">\n      <shortcut\n            class=\"org.jetbrains.kotlin.ui.launch.KotlinLaunchShortcut\"\n            icon=\"icons/kotlin-file.gif\"\n            id=\"org.jetbrains.kotlin.ui.launch.launchShortcut\"\n            label=\"Kotlin Application\"\n            modes=\"run,debug\">\n         <contextualLaunch>\n            <enablement>\n               <with\n                     variable=\"selection\">\n                  <count\n                        value=\"1\">\n                  </count>\n                  <iterate\n                        operator=\"and\">\n                     <test\n                           property=\"org.jetbrains.kotlin.ui.launching.canLaunchAsApplication\">\n                     </test>\n                  </iterate>\n               </with>\n            </enablement>\n         </contextualLaunch>\n      </shortcut>\n      <shortcut\n            class=\"org.jetbrains.kotlin.ui.launch.junit.KotlinJUnitLaunchShortcut\"\n            icon=\"icons/julaunch.gif\"\n            id=\"org.jetbrains.kotlin.ui.launch.junit\"\n            label=\"Kotlin JUnit Test\"\n            modes=\"run,debug\">\n         <contextualLaunch>\n            <enablement>\n               <with\n                     variable=\"selection\">\n                  <count\n                        value=\"1\">\n                  </count>\n                  <iterate\n                        operator=\"and\">\n                     <test\n                           property=\"org.jetbrains.kotlin.ui.launching.canLaunchAsJUnit\">\n                     </test>\n                  </iterate>\n               </with>\n            </enablement>\n         </contextualLaunch>\n      </shortcut>\n      <shortcut\n            class=\"org.jetbrains.kotlin.ui.launch.KotlinScriptLaunchShortcut\"\n            icon=\"icons/kotlin-file.gif\"\n            id=\"org.jetbrains.kotlin.ui.launch.scriptLaunchShortcut\"\n            label=\"Kotlin Script\"\n            modes=\"run\">\n         <contextualLaunch>\n            <enablement>\n               <with\n                     variable=\"selection\">\n                  <count\n                        value=\"1\">\n                  </count>\n                  <iterate\n                        operator=\"and\">\n                     <test\n                           property=\"org.jetbrains.kotlin.ui.launching.canLaunchAsScript\">\n                     </test>\n                  </iterate>\n               </with>\n            </enablement>\n         </contextualLaunch>\n      </shortcut>\n   </extension>\n   <extension\n         point=\"org.eclipse.debug.core.statusHandlers\">\n      <statusHandler\n            class=\"org.jetbrains.kotlin.ui.launch.CompilerStatusHandler\"\n            code=\"1\"\n            id=\"org.jetbrains.kotlin.ui.statusHandler\"\n            plugin=\"org.jetbrains.kotlin.core\">\n      </statusHandler>\n   </extension>\n   <extension\n         id=\"org.jetbrains.kotlin.ui.kotlinBuilder\"\n         name=\"KotlinBuilder\"\n         point=\"org.eclipse.core.resources.builders\">\n      <builder callOnEmptyDelta=\"true\">\n         <run\n               class=\"org.jetbrains.kotlin.ui.builder.KotlinBuilder\">\n         </run>\n      </builder>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors.templates\">\n      <include\n            file=\"templates/default-templates.xml\"\n            translations=\"templates/default-templates.xml\">\n      </include>\n      <contextType\n            class=\"org.jetbrains.kotlin.ui.editors.templates.KotlinTemplateContextType\"\n            id=\"kotlin-top-level-declarations\"\n            name=\"Kotlin Top Level Declarations\"\n            registryId=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\">\n      </contextType>\n      <contextTypeRegistry\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\">\n      </contextTypeRegistry>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectives\">\n      <perspective\n            class=\"org.jetbrains.kotlin.perspective.KotlinPerspectiveFactory\"\n            icon=\"icons/kotlin.png\"\n            id=\"org.jetbrains.kotlin.perspective\"\n            name=\"Kotlin\">\n         <description>\n            Open Kotlin pespective\n         </description>\n      </perspective>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets\">\n      <target\n            id=\"org.jetbrains.kotlin.ui.editors.kotlinCode\"\n            name=\"Kotlin Editor\">\n         <context\n               type=\"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\">\n         </context>\n      </target>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.workbench.texteditor.hyperlinkDetectors\">\n      <hyperlinkDetector\n            activate=\"true\"\n            class=\"org.jetbrains.kotlin.ui.editors.KotlinElementHyperlinkDetector\"\n            id=\"org.jetbrains.kotlin.ui.editors.KotlinElementHyperlinkDetector\"\n            name=\"KotlinElementHyperlinkDetector\"\n            targetId=\"org.jetbrains.kotlin.ui.editors.kotlinCode\"/>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.startup\">\n      <startup\n            class=\"org.jetbrains.kotlin.ui.KotlinUiStartupClass\">\n      </startup>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.expressions.propertyTesters\">\n      <propertyTester\n            class=\"org.jetbrains.kotlin.ui.launch.junit.KotlinJUnitLaunchableTester\"\n            id=\"org.jetbrains.kotlin.ui.junitLaunchableTester\"\n            namespace=\"org.jetbrains.kotlin.ui.launching\"\n            properties=\"canLaunchAsJUnit\"\n            type=\"org.eclipse.core.runtime.IAdaptable\">\n      </propertyTester>\n      <propertyTester\n            class=\"org.jetbrains.kotlin.ui.launch.KotlinLaunchableTester\"\n            id=\"org.jetbrains.kotlin.ui.launchableTester\"\n            namespace=\"org.jetbrains.kotlin.ui.launching\"\n            properties=\"canLaunchAsApplication\"\n            type=\"org.eclipse.core.runtime.IAdaptable\">\n      </propertyTester>\n      <propertyTester\n            class=\"org.jetbrains.kotlin.ui.launch.KotlinScriptLaunchableTester\"\n            id=\"org.jetbrains.kotlin.ui.scriptLaunchableTester\"\n            namespace=\"org.jetbrains.kotlin.ui.launching\"\n            properties=\"canLaunchAsScript\"\n            type=\"org.eclipse.core.runtime.IAdaptable\">\n      </propertyTester>\n   </extension>\n   <extension\n         point=\"org.eclipse.compare.contentMergeViewers\">\n      <viewer\n            class=\"org.jetbrains.kotlin.ui.editors.highlighting.KotlinViewerCreator\"\n            extensions=\"kt\"\n            id=\"org.jetbrains.kotlin.eclipse.ui.kotlinMergeViewer\">\n      </viewer>\n   </extension>\n   <extension\n         point=\"org.eclipse.jdt.ui.queryParticipants\">\n      <queryParticipant\n            class=\"org.jetbrains.kotlin.ui.search.KotlinQueryParticipant\"\n            id=\"org.jetbrains.kotlin.ui.search.queryParticipant\"\n            name=\"Kotlin Query Participant\"\n            nature=\"org.jetbrains.kotlin.core.kotlinNature\">\n      </queryParticipant>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.contexts\">\n      <context\n            description=\"Kotlin Editor Scope\"\n            id=\"org.jetbrains.kotlin.eclipse.ui.kotlinEditorScope\"\n            name=\"Editing Kotlin Source\"\n            parentId=\"org.eclipse.ui.textEditorScope\">\n      </context>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"org.jetbrains.kotlin.ui.debug.commands.KotlinStepIntoSelectionHandler\"\n            commandId=\"org.eclipse.jdt.debug.ui.commands.StepIntoSelection\">\n         <activeWhen>\n            <with\n                  variable=\"activeEditor\">\n               <instanceof\n                     value=\"org.jetbrains.kotlin.ui.editors.KotlinEditor\">\n               </instanceof>\n            </with>\n         </activeWhen>\n      </handler>\n   </extension>\n   <extension\n         point=\"org.eclipse.ltk.core.refactoring.renameParticipants\">\n      <renameParticipant\n            class=\"org.jetbrains.kotlin.ui.refactorings.rename.KotlinTypeRenameParticipant\"\n            id=\"org.jetbrains.kotlin.ui.refacotrings.renameType\"\n            name=\"Kotlin Type Rename Participant\">\n         <enablement>\n            <with\n                  variable=\"affectedNatures\">\n               <iterate\n                     ifEmpty=\"false\"\n                     operator=\"or\">\n                  <equals\n                        value=\"org.jetbrains.kotlin.core.kotlinNature\">\n                  </equals>\n               </iterate>\n            </with>\n            <with\n                  variable=\"element\">\n               <instanceof\n                     value=\"org.eclipse.jdt.core.IType\">\n               </instanceof>\n            </with>\n         </enablement>\n      </renameParticipant>\n      <renameParticipant\n            class=\"org.jetbrains.kotlin.ui.refactorings.rename.KotlinFunctionRenameParticipant\"\n            id=\"org.jetbrains.kotlin.ui.refacotrings.renameFunction\"\n            name=\"Kotlin Function Rename Participant\">\n         <enablement>\n            <with\n                  variable=\"affectedNatures\">\n               <iterate\n                     ifEmpty=\"false\"\n                     operator=\"or\">\n                  <equals\n                        value=\"org.jetbrains.kotlin.core.kotlinNature\">\n                  </equals>\n               </iterate>\n            </with>\n            <with\n                  variable=\"element\">\n               <instanceof\n                     value=\"org.eclipse.jdt.core.IMethod\">\n               </instanceof>\n            </with>\n         </enablement>\n      </renameParticipant>\n      <renameParticipant\n            class=\"org.jetbrains.kotlin.ui.refactorings.rename.KotlinLocalRenameParticipant\"\n            id=\"org.jetbrains.kotlin.ui.refacotrings.renameLocalElement\"\n            name=\"Kotlin Local Rename Participant\">\n         <enablement>\n            <with\n                  variable=\"affectedNatures\">\n               <iterate\n                     operator=\"or\">\n                  <equals\n                        value=\"org.jetbrains.kotlin.core.kotlinNature\">\n                  </equals>\n               </iterate>\n            </with>\n            <with\n                  variable=\"element\">\n               <instanceof\n                     value=\"org.jetbrains.kotlin.psi.KtElement\">\n               </instanceof>\n            </with>\n         </enablement>\n      </renameParticipant>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.runtime.preferences\">\n      <initializer\n            class=\"org.jetbrains.kotlin.preferences.KotlinPreferenceInitializer\">\n      </initializer>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.console.consolePatternMatchListeners\">\n      <consolePatternMatchListener\n            class=\"org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenEditorFromConsole\"\n            id=\"org.jetbrains.kotlin.eclipse.ui.consoleListener\"\n            regex=\"at .+\\(.+\\.kt\\:\\d+\\)\">\n         <enablement>\n            <or>\n               <test\n                     property=\"org.eclipse.ui.console.consoleTypeTest\"\n                     value=\"org.eclipse.debug.ui.ProcessConsoleType\">\n               </test>\n               <test\n                     property=\"org.eclipse.ui.console.consoleTypeTest\"\n                     value=\"javaStackTraceConsole\">\n               </test>\n            </or></enablement>\n      </consolePatternMatchListener>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.ide.markerResolution\">\n      <markerResolutionGenerator\n            class=\"org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolutionGenerator\"\n            markerType=\"org.eclipse.jdt.core.problem\">\n      </markerResolutionGenerator>\n   </extension>\n   <extension\n         point=\"org.eclipse.debug.core.launchConfigurationTypes\">\n      <launchConfigurationType\n            delegate=\"org.jetbrains.kotlin.ui.launch.KotlinScriptLaunchConfigurationDelegate\"\n            delegateDescription=\"The Kotlin Script Launcher supports running local Kotlin scripts\"\n            id=\"org.jetbrains.kotlin.ui.scriptLaunchConfiguration\"\n            modes=\"run\"\n            name=\"Kotlin Script Launch Configuration\">\n      </launchConfigurationType>\n   </extension>\n   <extension\n         point=\"org.eclipse.debug.ui.launchConfigurationTabGroups\">\n      <launchConfigurationTabGroup\n            class=\"org.jetbrains.kotlin.ui.launch.KotlinScriptLaunchConfigurationTabGroup\"\n            id=\"org.jetbrains.kotlin.ui.scriptLaunchConfigurationTabGroup\"\n            type=\"org.jetbrains.kotlin.ui.scriptLaunchConfiguration\">\n      </launchConfigurationTabGroup>\n   </extension>\n   <extension\n         point=\"org.jetbrains.kotlin.ui.editor.textHover\">\n      <hover\n            class=\"org.jetbrains.kotlin.ui.editors.hover.KotlinJavadocTextHover\"\n            name=\"Hover showing details of Kotlin element\">\n      </hover>\n      <hover\n            class=\"org.jetbrains.kotlin.ui.editors.hover.KotlinProblemTextHover\"\n            name=\"Hover showing problem annotation details\">\n      </hover>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"menu:org.eclipse.ui.main.menu?after=edit\">\n         <menu\n               label=\"Source\">\n            <separator\n                  name=\"commentGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.toggle.comment\"\n                  label=\"Toggle Comment\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.add.block.comment\"\n                  label=\"Add Block Comment\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.remove.block.comment\"\n                  label=\"Remove Block Comment\"\n                  style=\"push\">\n            </command>\n            <separator\n                  name=\"editGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.indent\"\n                  label=\"Correct Indentation\"\n                  style=\"push\">\n            </command>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.format\"\n                  label=\"Format\"\n                  style=\"push\">\n            </command>\n            <separator\n                  name=\"importGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.organize.imports\"\n                  label=\"Organize Imports\"\n                  style=\"push\">\n            </command>\n            <separator\n                  name=\"generateGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.override.methods\"\n                  label=\"Override/Implement members...\"\n                  style=\"push\">\n            </command>\n            <visibleWhen\n                  checkEnabled=\"false\">\n               <with\n                     variable=\"activeEditor\">\n                  <instanceof\n                        value=\"org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\">\n                  </instanceof>\n               </with>\n            </visibleWhen>\n         </menu>\n         <menu\n               label=\"Refactor\">\n            <separator\n                  name=\"reorgGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.rename.element\"\n                  label=\"Rename...\"\n                  style=\"push\">\n            </command>\n            <separator\n                  name=\"codingGroup\"\n                  visible=\"true\">\n            </separator>\n            <command\n                  commandId=\"org.eclipse.jdt.ui.edit.text.java.extract.local.variable\"\n                  label=\"Extract Local Variable\"\n                  style=\"push\">\n            </command>\n            <visibleWhen\n                  checkEnabled=\"false\">\n               <with\n                     variable=\"activeEditor\">\n                  <instanceof\n                        value=\"org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\">\n                  </instanceof>\n               </with>\n            </visibleWhen>\n         </menu>\n      </menuContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.propertyPages\">\n      <page\n            class=\"org.jetbrains.kotlin.preferences.compiler.ProjectCompilerPropertyPage\"\n            id=\"org.jetbrains.kotlin.ui.project-properties\"\n            name=\"Kotlin Compiler\">\n         <enabledWhen>\n            <reference\n                  definitionId=\"org.jetbrains.kotlin.core.hasNature\">\n            </reference>\n         </enabledWhen>\n      </page>\n       <page\n               class=\"org.jetbrains.kotlin.preferences.style.ProjectCodeStylePropertyPage\"\n               id=\"org.jetbrains.kotlin.ui.project-properties-codestyle\"\n               name=\"Kotlin Code Style\">\n           <enabledWhen>\n               <reference\n                       definitionId=\"org.jetbrains.kotlin.core.hasNature\">\n               </reference>\n           </enabledWhen>\n       </page>\n      <page\n            class=\"org.jetbrains.kotlin.preferences.building.ProjectBuildingPropertyPage\"\n            id=\"org.jetbrains.kotlin.ui.project-properties\"\n            name=\"Kotlin Building\">\n         <enabledWhen>\n            <reference\n                  definitionId=\"org.jetbrains.kotlin.core.hasNature\">\n            </reference>\n         </enabledWhen>\n      </page>\n   </extension>\n   <extension\n         point=\"org.eclipse.jdt.ui.javaElementFilters\">\n      <filter\n            class=\"org.jetbrains.kotlin.ui.ScriptEnvironmentsFilter\"\n            enabled=\"true\"\n            id=\"org.jetbrains.kotlin.ui.scriptEnvironmentsFilter\"\n            name=\"Kotlin script environments\">\n      </filter>\n   </extension>\n   <extension\n       \tpoint=\"org.eclipse.ui.actionSets\">\n       <actionSet\n       \tid=\"kotlin-eclipse-ui.compilation\"\n       \tvisible=\"true\"\n       \tlabel=\"compilation\">\n         \t<action\n         \t\tclass=\"org.jetbrains.kotlin.ui.builder.CompileKotlinClassesAction\"\n         \t\tid=\"kotlin-eclipse-ui.compile\"\n         \t\tlabel=\"Compile Kotlin classes\"\n         \t\tmenubarPath=\"project/additions\">\n         </action>\n       </actionSet>\n   </extension>\n   <extension\n         id=\"org.jetbrains.kotlin.project.menus\"\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"popup:org.eclipse.ui.projectConfigure\">\n         <command\n               commandId=\"org.jetbrains.kotlin.ui.commands.configuration\"\n               label=\"Add Kotlin Nature\"\n               style=\"push\">\n            <visibleWhen\n                  checkEnabled=\"true\">\n            </visibleWhen>\n         </command>\n         <command\n               commandId=\"org.jetbrains.kotlin.ui.commands.deconfiguration\"\n               label=\"Remove Kotlin Nature\"\n               style=\"push\">\n            <visibleWhen checkEnabled=\"true\">\n            </visibleWhen>\n         </command>\n         <command\n               commandId=\"org.jetbrains.kotlin.ui.commands.configuration.coroutines\"\n               label=\"Add Coroutines Library\"\n               style=\"push\">\n            <visibleWhen checkEnabled=\"true\">\n            </visibleWhen>\n         </command>\n      </menuContribution>\n   </extension>\n</plugin>\n"
  },
  {
    "path": "kotlin-eclipse-ui/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.ui</artifactId>\n\t<packaging>eclipse-plugin</packaging>\n\t\n\t<build>\n\t\t<sourceDirectory>src</sourceDirectory>\n\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>3.10.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<release>17</release>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>"
  },
  {
    "path": "kotlin-eclipse-ui/schema/org.jetbrains.kotlin.ui.editor.textHover.exsd",
    "content": "<?xml version='1.0' encoding='UTF-8'?>\n<!-- Schema file written by PDE -->\n<schema targetNamespace=\"org.jetbrains.kotlin.ui\" xmlns=\"http://www.w3.org/2001/XMLSchema\">\n<annotation>\n      <appinfo>\n         <meta.schema plugin=\"org.jetbrains.kotlin.ui\" id=\"org.jetbrains.kotlin.ui.editor.textHover\" name=\"Kotlin Text Hover\"/>\n      </appinfo>\n      <documentation>\n         [Enter description of this extension point.]\n      </documentation>\n   </annotation>\n\n   <element name=\"extension\">\n      <annotation>\n         <appinfo>\n            <meta.element />\n         </appinfo>\n      </annotation>\n      <complexType>\n         <choice minOccurs=\"1\" maxOccurs=\"unbounded\">\n            <element ref=\"hover\"/>\n         </choice>\n         <attribute name=\"point\" type=\"string\" use=\"required\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"id\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"name\" type=\"string\">\n            <annotation>\n               <documentation>\n                  \n               </documentation>\n               <appinfo>\n                  <meta.attribute translatable=\"true\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <element name=\"hover\">\n      <complexType>\n         <attribute name=\"name\" type=\"string\">\n            <annotation>\n               <documentation>\n                  A human readable name of this provider\n               </documentation>\n            </annotation>\n         </attribute>\n         <attribute name=\"class\" type=\"string\" use=\"required\">\n            <annotation>\n               <documentation>\n                  The name of a class that implements interface org.jetbrains.kotlin.ui.editors.hover.KotlinEditorTextHover\n               </documentation>\n               <appinfo>\n                  <meta.attribute kind=\"java\" basedOn=\":org.jetbrains.kotlin.ui.editors.hover.KotlinEditorTextHover\"/>\n               </appinfo>\n            </annotation>\n         </attribute>\n      </complexType>\n   </element>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"since\"/>\n      </appinfo>\n      <documentation>\n         [Enter the first release in which this extension point appears.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"examples\"/>\n      </appinfo>\n      <documentation>\n         [Enter extension point usage example here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"apiinfo\"/>\n      </appinfo>\n      <documentation>\n         [Enter API information here.]\n      </documentation>\n   </annotation>\n\n   <annotation>\n      <appinfo>\n         <meta.section type=\"implementation\"/>\n      </appinfo>\n      <documentation>\n         [Enter information about supplied implementation of this extension point.]\n      </documentation>\n   </annotation>\n\n\n</schema>\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/EditorUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.editors.text.TextFileDocumentProvider;\nimport org.eclipse.ui.texteditor.AbstractTextEditor;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.references.ReferenceUtilsKt;\nimport org.jetbrains.kotlin.psi.KtElement;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtReferenceExpression;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.util.PsiTreeUtil;\n\npublic class EditorUtil {\n    \n    @Nullable\n    public static IFile getFile(@NotNull IEditorPart editor) {\n        return editor.getEditorInput().getAdapter(IFile.class);\n    }\n    \n    @NotNull\n    public static String getSourceCode(@NotNull KotlinEditor editor) {\n        return editor.getDocument().get();\n    }\n    \n    @NotNull\n    public static String getSourceCode(@NotNull AbstractTextEditor editor) {\n        return getDocument(editor).get();\n    }\n    \n    @NotNull\n    public static IDocument getDocument(@NotNull AbstractTextEditor editor) {\n        return editor.getDocumentProvider().getDocument(editor.getEditorInput());\n    }\n    \n    @NotNull\n    public static IDocument getDocument(@NotNull IFile file) {\n        TextFileDocumentProvider provider = new TextFileDocumentProvider();\n        try {\n            provider.connect(file);\n            return provider.getDocument(file);\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        } finally {\n            provider.disconnect(file);\n        }\n        \n        throw new RuntimeException();\n    }\n    \n    public static String getDocumentLineDelimiter(@NotNull KotlinEditor editor) {\n        return TextUtilities.getDefaultLineDelimiter(editor.getDocument());\n    }\n    \n    @Nullable\n    public static PsiElement getPsiElement(@NotNull KotlinEditor editor, int offset) {\n        KtFile jetFile = editor.getParsedFile();\n        if (jetFile != null) {\n            int caretOffset = LineEndUtil.convertCrToDocumentOffset(editor.getDocument(), offset);\n            return jetFile.findElementAt(caretOffset);\n        } else {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null);\n        }\n\n        return null;\n    }\n    \n    @Nullable\n    public static KtElement getJetElement(@NotNull KotlinEditor editor, int offset) {\n        PsiElement psiElement = getPsiElement(editor, offset);\n        return psiElement != null ? PsiTreeUtil.getNonStrictParentOfType(psiElement, KtElement.class) : null;\n    }\n    \n    @Nullable\n    public static KtReferenceExpression getReferenceExpression(@NotNull KotlinEditor editor, int offset) {\n        KtFile ktFile = editor.getParsedFile();\n        if (ktFile == null) return null;\n        \n        int documentOffset = LineEndUtil.convertCrToDocumentOffset(editor.getDocument(), offset);\n        PsiElement psiExpression = ktFile.findElementAt(documentOffset);\n        if (psiExpression == null) return null;\n        \n        return ReferenceUtilsKt.getReferenceExpression(psiExpression);\n    }\n    \n    @Nullable\n    public static KtFile updatePsiFile(@NotNull KotlinEditor editor) {\n        IFile file = editor.getEclipseFile();\n        return file != null ? KotlinPsiManager.getKotlinFileIfExist(file, editor.getDocument().get()) : null;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/IndenterUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils;\n\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.lexer.KtTokens;\n\nimport com.intellij.psi.impl.source.tree.LeafPsiElement;\n\npublic class IndenterUtil {\n    \n    public static final char SPACE_CHAR = ' ';\n    public static final String SPACE_STRING = Character.toString(SPACE_CHAR);\n    public static final char TAB_CHAR = '\\t';\n    public static final String TAB_STRING = Character.toString(TAB_CHAR);\n    \n    public static String createWhiteSpace(int curIndent, int countBreakLines, String lineSeparator) {\n        StringBuilder stringBuilder = new StringBuilder();\n        for (int i = 0; i < countBreakLines; i++) {\n            stringBuilder.append(lineSeparator);\n        }\n        \n        String whiteSpace = getIndentString();\n        for (int i = 0; i < curIndent; i++) {\n            stringBuilder.append(whiteSpace);\n        }\n        \n        return stringBuilder.toString();\n    }\n    \n    public static String createWhiteSpaceByRawIndent(int rawIndent, int countBreakLines, String lineSeparator) {\n        StringBuilder stringBuilder = new StringBuilder();\n        for (int i = 0; i < countBreakLines; i++) {\n            stringBuilder.append(lineSeparator);\n        }\n        \n        for (int i = 0; i < rawIndent; i++) {\n            stringBuilder.append(SPACE_CHAR);\n        }\n        \n        return stringBuilder.toString();\n    }\n    \n    public static String getIndentString() {\n        if (isSpacesForTabs()) {\n            StringBuilder result = new StringBuilder();\n            for (int i = 0; i < getDefaultIndent(); i++) {\n               result.append(SPACE_CHAR);\n            }\n            return result.toString();\n        } else {\n            return new Character(TAB_CHAR).toString();\n        }\n    }\n    \n    public static int getLineSeparatorsOccurences(String text) {\n        int result = 0;\n        \n        for (char c : text.toCharArray()) {\n            if (c == LineEndUtil.NEW_LINE_CHAR) {\n                result++;\n            }\n        }\n        \n        return result;\n    }\n    \n    public static boolean isNewLine(LeafPsiElement psiElement) {\n        return psiElement.getElementType() == KtTokens.WHITE_SPACE && psiElement.getText().contains(LineEndUtil.NEW_LINE_STRING);\n    }\n    \n    public static int getDefaultIndent() {\n        return EditorsUI.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);\n    }\n    \n    public static int getDefaultIndentSize() {\n        if (isSpacesForTabs()) {\n            return getDefaultIndent();\n        } else {\n            return 1;\n        }\n    }\n    \n    public static boolean isSpacesForTabs() {\n        return EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);\n    }\n    \n    public static boolean isWhiteSpaceChar(char c) {\n        return c == SPACE_CHAR || c == TAB_CHAR;\n    }\n    \n    public static boolean isWhiteSpaceOrNewLine(char c) {\n        return c == SPACE_CHAR || c == TAB_CHAR || c == LineEndUtil.NEW_LINE_CHAR;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/KotlinEclipseScope.kt",
    "content": "package org.jetbrains.kotlin.eclipse.ui.utils\n\nimport kotlinx.coroutines.CoroutineScope\nimport kotlinx.coroutines.Dispatchers\nimport kotlinx.coroutines.SupervisorJob\n\nobject KotlinEclipseScope : CoroutineScope by CoroutineScope(SupervisorJob() + Dispatchers.IO)\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/KotlinImageProvider.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils\n\nimport org.eclipse.jdt.ui.ISharedImages\nimport org.eclipse.jdt.ui.JavaUI\nimport org.eclipse.swt.graphics.Image\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFunction\nimport org.jetbrains.kotlin.psi.KtVariableDeclaration\n\nobject KotlinImageProvider {\n    fun getImage(descriptor: DeclarationDescriptor): Image? {\n        return when(descriptor) {\n            is ClassDescriptor, is TypeParameterDescriptor, is TypeAliasDescriptor ->\n                getImageFromJavaUI(ISharedImages.IMG_OBJS_CLASS)\n            is FunctionDescriptor -> getImageFromJavaUI(ISharedImages.IMG_OBJS_PUBLIC)\n            is VariableDescriptor -> getImageFromJavaUI(ISharedImages.IMG_FIELD_PUBLIC)\n            is PackageViewDescriptor -> getImageFromJavaUI(ISharedImages.IMG_OBJS_PACKAGE)\n            else -> null\n        }\n    }\n    \n    fun getImage(element: KtElement): Image? {\n        return when(element) {\n            is KtClassOrObject -> getImageFromJavaUI(ISharedImages.IMG_OBJS_CLASS)\n            is KtFunction -> getImageFromJavaUI(ISharedImages.IMG_OBJS_PUBLIC)\n            is KtVariableDeclaration -> getImageFromJavaUI(ISharedImages.IMG_FIELD_PUBLIC)\n            else -> null\n        }\n    }\n    \n    private fun getImageFromJavaUI(imageName: String): Image = JavaUI.getSharedImages().getImage(imageName)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/LineEndUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils;\n\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.jetbrains.annotations.NotNull;\n\nimport com.intellij.openapi.util.TextRange;\n\npublic class LineEndUtil {\n    \n    public static final char CARRIAGE_RETURN_CHAR = '\\r';\n    public static final String CARRIAGE_RETURN_STRING = Character.toString(CARRIAGE_RETURN_CHAR);\n    public static final char NEW_LINE_CHAR = '\\n';\n    public static final String NEW_LINE_STRING = Character.toString(NEW_LINE_CHAR);\n    \n    public static int convertLfToDocumentOffset(@NotNull String lfText, int lfOffset, @NotNull IDocument document) {\n        String documentLineDelimiter = TextUtilities.getDefaultLineDelimiter(document);\n        if (documentLineDelimiter.length() == 1) {\n            return lfOffset;\n        }\n        \n        assertLineSeparator(documentLineDelimiter);\n        \n        // In CrLf move to new line takes 2 char instead of 1 in Lf\n        return lfOffset + offsetToLineNumber(lfText, lfOffset);\n    }\n\n    private static int offsetToLineNumber(String lfText, int offset) {\n        int line = 0;\n        int curOffset = 0;\n        \n        while (curOffset < offset) {\n            if (curOffset == lfText.length()) {\n                break;\n            }\n            \n            char c = lfText.charAt(curOffset);\n            if (c == NEW_LINE_CHAR) {\n                line++;\n            } else if (c == CARRIAGE_RETURN_CHAR) {\n                throw new IllegalArgumentException(\"Given text shouldn't contain \\\\r char\");\n            }\n            \n            curOffset++;\n        }\n        \n        return line;\n    }\n    \n    public static int convertCrToDocumentOffset(@NotNull IDocument document, int crOffset) {\n        return convertCrToDocumentOffset(document.get(), crOffset, document);\n    }\n    \n    public static int convertCrToDocumentOffset(@NotNull String crText, int crOffset, @NotNull IDocument document) {\n        String defaultLineDelimiter = TextUtilities.getDefaultLineDelimiter(document);\n        if (defaultLineDelimiter.length() == 1) {\n            return crOffset;\n        }\n        \n        assertLineSeparator(defaultLineDelimiter);\n        \n        return crOffset - countCrToLineNumber(crText, crOffset);\n    }\n    \n    private static int countCrToLineNumber(String lfText, int offset) {\n        int countCR = 0;\n        int curOffset = 0;\n        \n        while (curOffset < offset) {\n            if (curOffset == lfText.length()) {\n                break;\n            }\n            \n            char c = lfText.charAt(curOffset);\n            if (c == CARRIAGE_RETURN_CHAR) {\n                countCR++;\n            } \n            \n            curOffset++;\n        }\n        \n        return countCR;  \n    }\n    \n    private static void assertLineSeparator(String osLineSeparator) {\n        assert osLineSeparator.equals(CARRIAGE_RETURN_STRING + NEW_LINE_STRING) : \"Only \\r\\n is expected as multi char line separator\";\n    }\n    \n    public static String removeAllCarriageReturns(String s) {\n        return s.replaceAll(CARRIAGE_RETURN_STRING, \"\");\n    }\n    \n    @NotNull\n    public static TextRange lfRangeFromCrRange(@NotNull TextRange crRange, @NotNull IDocument document) {\n        int startOffset = LineEndUtil.convertCrToDocumentOffset(document, crRange.getStartOffset());\n        int endOffset = LineEndUtil.convertCrToDocumentOffset(document, crRange.getEndOffset());\n        return new TextRange(startOffset, endOffset);\n    }\n    \n    @NotNull\n    public static TextRange crRangeFromLfRange(@NotNull String lfText, @NotNull TextRange lfRange,\n            @NotNull IDocument document) {\n        int startOffset = LineEndUtil.convertLfToDocumentOffset(lfText, lfRange.getStartOffset(), document);\n        int endOffset = LineEndUtil.convertLfToDocumentOffset(lfText, lfRange.getEndOffset(), document);\n        return new TextRange(startOffset, endOffset);\n    }\n\n    public static int convertLfOffsetForMixedDocument(@NotNull IDocument document, int lfOffset) {\n        int countCRs = 0;\n        int current = 0;\n        String text = document.get();\n\n\n        while (current - countCRs < lfOffset) {\n            if (text.charAt(current) == CARRIAGE_RETURN_CHAR) {\n                countCRs++;\n            }\n            current++;\n        }\n\n        return current;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/ProjectScopedPreferenceUtils.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils;\n\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.ProjectScope;\nimport org.eclipse.core.runtime.preferences.IEclipsePreferences;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.ui.Activator;\nimport org.osgi.service.prefs.BackingStoreException;\n\npublic class ProjectScopedPreferenceUtils {\n    \n    @NotNull\n    private static IEclipsePreferences getPreferences(@NotNull final IProject project) {\n        return new ProjectScope(project).getNode(Activator.Companion.getPLUGIN_ID());        \n    }\n    \n    public static boolean getBooleanPreference(@NotNull final IProject project, @NotNull final String key, final boolean defaultValue) {\n        return getPreferences(project).getBoolean(key, defaultValue);\n    }\n    \n    public static void putBooleanPreference(@NotNull final IProject project, @NotNull final String key, final boolean value) throws BackingStoreException {\n        IEclipsePreferences preferences = getPreferences(project);\n        preferences.putBoolean(key, value);\n        \n        preferences.flush();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/analyzeUtils.kt",
    "content": "package org.jetbrains.kotlin.eclipse.ui.utils\n\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.core.utils.getBindingContext\n\nfun KotlinEditor.getBindingContext(): BindingContext? =\n    parsedFile?.getBindingContext()"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/eclipse/ui/utils/offsetUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.eclipse.ui.utils\n\nimport com.intellij.psi.PsiElement\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.psi.KtFile\n\nfun PsiElement.getEndLfOffset(document: IDocument): Int {\n\treturn LineEndUtil.convertLfToDocumentOffset(this.getContainingFile().getText(), this.getTextRange().getEndOffset(), document)\n}\n\nfun PsiElement.getTextDocumentOffset(document: IDocument): Int {\n    return getOffsetByDocument(document, getTextOffset())\n}\n\nfun PsiElement.getOffsetByDocument(document: IDocument, psiOffset: Int): Int {\n    return LineEndUtil.convertLfToDocumentOffset(this.getContainingFile().getText(), psiOffset, document)\n}\n\nfun KtFile.findElementByDocumentOffset(offset: Int, document: IDocument): PsiElement? {\n    val offsetWithoutCr = LineEndUtil.convertCrToDocumentOffset(document, offset);\n    return this.findElementAt(offsetWithoutCr)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/perspective/KotlinPerspectiveFactory.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.perspective;\n\nimport org.eclipse.debug.ui.IDebugUIConstants;\nimport org.eclipse.jdt.ui.JavaUI;\nimport org.eclipse.ui.IPageLayout;\nimport org.eclipse.ui.IPerspectiveFactory;\n\npublic class KotlinPerspectiveFactory implements IPerspectiveFactory {\n\n    @Override\n    public void createInitialLayout(IPageLayout layout) {\n        layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);\n        layout.addActionSet(JavaUI.ID_ACTION_SET);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/BasePropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences\n\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.layout.GridLayout\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.dialogs.PropertyPage\nimport org.jetbrains.kotlin.core.preferences.Preferences\nimport org.jetbrains.kotlin.swt.builders.asView\nimport org.jetbrains.kotlin.swt.builders.layout\n\nabstract class BasePropertyPage : PropertyPage() {\n    protected abstract val properties: Preferences\n\n    private lateinit var rootView: Composite\n\n    protected abstract fun createUI(parent: Composite): Control\n\n    protected open fun afterOk() {}\n\n    final override fun createContents(parent: Composite): Control {\n        rootView = Composite(parent, SWT.NONE).apply {\n            layout = GridLayout().apply {\n                marginWidth = 0\n                marginHeight = 0\n            }\n        }\n\n        createUI(rootView).asView\n                .layout(horizontalGrab = true, verticalGrab = true)\n\n        return rootView\n    }\n\n    final override fun performOk(): Boolean {\n        properties.saveChanges()\n        afterOk()\n        return super.performOk()\n    }\n\n    final override fun performCancel(): Boolean {\n        properties.cancelChanges()\n        return super.performCancel()\n    }\n\n    final override fun performDefaults() {\n        properties.loadDefaults()\n\n        // Recreate view\n        rootView.children.forEach { it.dispose() }\n        createUI(rootView).asView\n                .layout(horizontalGrab = true, verticalGrab = true)\n        rootView.layout()\n\n        super.performDefaults()\n    }\n\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/EditorPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.preferences;\n\nimport org.eclipse.jface.preference.PreferencePage;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\npublic class EditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {\n\n    public EditorPreferencePage() {\n    }\n\n    public EditorPreferencePage(String title) {\n        super(title);\n    }\n\n    public EditorPreferencePage(String title, ImageDescriptor image) {\n        super(title, image);\n    }\n\n    @Override\n    public void init(IWorkbench workbench) {\n    }\n\n    @Override\n    protected Control createContents(Composite parent) {\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/KotlinPreferenceInitializer.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.preferences\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer\nimport org.jetbrains.kotlin.ui.Activator\nimport org.jetbrains.kotlin.ui.KotlinPluginUpdater\nimport java.util.Random\nimport org.jetbrains.kotlin.core.preferences.CompilerPlugin\nimport org.eclipse.jface.preference.IPreferenceStore\n\nclass KotlinPreferenceInitializer : AbstractPreferenceInitializer() {\n    override fun initializeDefaultPreferences() {\n        val kotlinStore = Activator.getDefault().preferenceStore\n        with(kotlinStore) {\n            setDefault(KotlinPluginUpdater.LAST_UPDATE_CHECK, 0L)\n            setDefault(KotlinPluginUpdater.USER_ID, 0L)\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/KotlinPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.preferences;\n\nimport org.eclipse.jface.preference.PreferencePage;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\npublic class KotlinPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {\n\n    public KotlinPreferencePage() {\n    }\n\n    public KotlinPreferencePage(String title) {\n        super(title);\n    }\n\n    public KotlinPreferencePage(String title, ImageDescriptor image) {\n        super(title, image);\n    }\n\n    @Override\n    public void init(IWorkbench workbench) {\n\n    }\n\n    @Override\n    protected Control createContents(Composite parent) {\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/KotlinTemplatePreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.preferences;\n\nimport org.eclipse.ui.texteditor.templates.TemplatePreferencePage;\nimport org.jetbrains.kotlin.ui.Activator;\nimport org.jetbrains.kotlin.ui.editors.templates.KotlinTemplateManager;\n\npublic class KotlinTemplatePreferencePage extends TemplatePreferencePage {\n    \n    public KotlinTemplatePreferencePage() {\n        setPreferenceStore(Activator.Companion.getDefault().getPreferenceStore());\n        setTemplateStore(KotlinTemplateManager.INSTANCE.getTemplateStore());\n        \n        setContextTypeRegistry(KotlinTemplateManager.INSTANCE.getContextTypeRegistry());\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/building/ProjectBuildingPropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.building\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.ProjectScope\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbenchPropertyPage\nimport org.jetbrains.kotlin.core.preferences.KotlinBuildingProperties\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.buildingPropertiesView\nimport org.jetbrains.kotlin.swt.builders.View\nimport org.jetbrains.kotlin.swt.builders.asView\nimport org.jetbrains.kotlin.swt.builders.checkbox\nimport org.jetbrains.kotlin.swt.builders.enabled\nimport org.jetbrains.kotlin.swt.builders.layout\nimport org.jetbrains.kotlin.swt.builders.separator\nimport org.jetbrains.kotlin.utils.LazyObservable\n\nclass ProjectBuildingPropertyPage : BasePropertyPage(), IWorkbenchPropertyPage {\n    // project must be lazy initialized, because getElement() called during construction of page object returns null\n    val project: IProject by lazy { element.getAdapter(IProject::class.java) }\n\n    private var overrideFlag by LazyObservable({ properties.globalsOverridden }) { _, _, v ->\n        properties.globalsOverridden = v\n        settingsView.enabled = v\n    }\n\n    private lateinit var settingsView: View<Composite>\n\n    override val properties by lazy { KotlinBuildingProperties(ProjectScope(project)) }\n\n    override fun createUI(parent: Composite): Control =\n        parent.asView.apply {\n            checkbox(::overrideFlag, \"Enable project speciffic settings\")\n            separator { layout(horizontalGrab = true) }\n            settingsView = buildingPropertiesView(properties) {\n                enabled = properties.globalsOverridden\n            }\n        }.control\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/building/WorkspaceBuildingPropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.building\n\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbench\nimport org.eclipse.ui.IWorkbenchPreferencePage\nimport org.jetbrains.kotlin.core.preferences.KotlinBuildingProperties\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.buildingPropertiesView\nimport org.jetbrains.kotlin.swt.builders.asView\n\nclass WorkspaceBuildingPropertyPage : BasePropertyPage(), IWorkbenchPreferencePage {\n\n    override val properties = KotlinBuildingProperties.workspaceInstance\n\n    override fun init(workbench: IWorkbench?) {\n    }\n\n    override fun createUI(parent: Composite): Control =\n        parent.asView\n            .buildingPropertiesView(properties) {\n                onIsValidChanged = { setValid(it) }\n            }\n            .control\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/compiler/CompilerPluginDialog.kt",
    "content": "package org.jetbrains.kotlin.preferences.compiler\n\nimport org.eclipse.jface.dialogs.IDialogConstants\nimport org.eclipse.jface.dialogs.MessageDialog\nimport org.eclipse.jface.dialogs.TrayDialog\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.layout.GridLayout\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.swt.widgets.Shell\nimport org.jetbrains.kotlin.core.preferences.CompilerPlugin\nimport org.jetbrains.kotlin.core.preferences.PreferencesCollection\nimport org.jetbrains.kotlin.swt.builders.*\n\nclass CompilerPluginDialog(\n        shell: Shell,\n        private val allPlugins: PreferencesCollection<CompilerPlugin>,\n        private val plugin: CompilerPlugin?\n) : TrayDialog(shell) {\n    private var keyField = plugin?.key\n\n    private var pathField = plugin?.jarPath\n    \n    private var argsField = plugin?.args?.joinToString(separator = \"\\n\")\n    \n    private val newKey: String\n        get() = keyField?.trim() ?: \"\"\n\n\n    override fun createDialogArea(parent: Composite): Control =\n            parent.asView.gridContainer(cols = 2) {\n                (control.layout as GridLayout).marginTop = 10\n                label(\"Plugin name:\")\n                textField(::keyField, style = SWT.BORDER) {\n                    layout(horizontalGrab = true)\n                }\n                label(\"Path to jar:\")\n                textField(::pathField, style = SWT.BORDER) {\n                    layout(horizontalGrab = true)\n                }\n                group(\"Plugin options:\") {\n                    layout(horizontalSpan = 2, horizontalGrab = true, verticalGrab = true)\n                    textField(::argsField, style = SWT.BORDER or SWT.MULTI or SWT.V_SCROLL) {\n                        layout(suggestedHeight = 200, suggestedWidth = 450)\n                    }\n                    label(\"Note: plugin options should match the <plugin id>:<key>=<value> pattern\")\n                }\n            }.control\n\n    override fun configureShell(newShell: Shell) {\n        super.configureShell(newShell)\n        newShell.text = if (plugin == null) \"New compiler plugin\" else \"Edit compiler plugin\"\n    }\n\n    override fun isHelpAvailable() = false\n\n    override fun buttonPressed(buttonId: Int) {\n        val successful = try {\n            when {\n                buttonId != IDialogConstants.OK_ID -> true\n\n                keyField.isNullOrBlank() -> throw ValidationException(\"Plugin name cannot be blank\")\n\n                plugin != null && newKey == plugin.key -> {\n                    with(plugin) {\n                        jarPath = pathField?.trim()\n                        args = processArgs()\n                    }\n                    true\n                }\n\n                newKey in allPlugins -> throw ValidationException(\"Plugin with chosen name already exists\")\n\n                else -> {\n                    plugin?.delete()\n                    with(allPlugins[newKey]) {\n                        jarPath = pathField?.trim()\n                        active = plugin?.active ?: true\n                        args = processArgs()\n                    }\n                    true\n                }\n            }\n        } catch (e: ValidationException) {\n            MessageDialog.openError(shell, \"Validation error\", e.message)\n            false\n        }\n\n\n        if (successful) {\n            super.buttonPressed(buttonId)\n        }\n    }\n    \n    private fun processArgs() : List<String> {\n        val processedArgs = argsField.orEmpty()\n                .lineSequence()\n                .map(String::trim)\n                .filterNot(String::isEmpty)\n                .toList()\n\n        processedArgs.find { \"\"\".+:.+=.+\"\"\".toRegex().matchEntire(it) == null }?.also {\n            throw ValidationException(\"$it does not match the <plugin id>:<key>=<value> pattern.\")\n        }\n\n        val pluginPrefixes = processedArgs.map { \"\"\"^.+:\"\"\".toRegex().find(it)?.value }\n                .toSet()\n        if (pluginPrefixes.size > 1) {\n            throw ValidationException(\"Plugin arguments have different prefixes\")\n        }\n\n        return processedArgs\n    }\n\n    override fun createButtonsForButtonBar(parent: Composite) {\n        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true)\n        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false)\n    }\n}\n\nprivate class ValidationException(message: String): Exception(message)"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/compiler/ProjectCompilerPropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.compiler\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IncrementalProjectBuilder\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbenchPropertyPage\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.projectCompilerPropertiesView\nimport org.jetbrains.kotlin.swt.builders.asView\n\nclass ProjectCompilerPropertyPage : BasePropertyPage(), IWorkbenchPropertyPage {\n    // project must be lazy initialized, because getElement() called during construction of page object returns null\n    val project: IProject by lazy { element.getAdapter(IProject::class.java) }\n\n    override val properties by lazy { KotlinEnvironment.getEnvironment(project).projectCompilerProperties }\n\n    override fun createUI(parent: Composite): Control =\n            parent.asView\n                    .projectCompilerPropertiesView(properties) {\n                        onIsValidChanged = { setValid(it) }\n                    }\n                    .control\n\n    override fun afterOk() {\n        RebuildJob { monitor ->\n            KotlinEnvironment.removeEnvironment(project)\n            project.build(IncrementalProjectBuilder.FULL_BUILD, monitor)\n        }.schedule()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/compiler/RebuildJob.kt",
    "content": "package org.jetbrains.kotlin.preferences.compiler\n\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.jetbrains.kotlin.core.Activator\n\nclass RebuildJob(private val rebuildTask: (IProgressMonitor?) -> Unit) : Job(\"Rebuilding workspace\") {\n\n    init {\n        priority = BUILD\n    }\n\n    override fun run(monitor: IProgressMonitor?): IStatus = try {\n        rebuildTask(monitor)\n        Status.OK_STATUS\n    } catch (e: CoreException) {\n        Status(Status.ERROR, Activator.PLUGIN_ID, \"Error during build of the project\", e)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/compiler/WorkspaceCompilerPropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.compiler\n\nimport org.eclipse.core.resources.IncrementalProjectBuilder.FULL_BUILD\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbench\nimport org.eclipse.ui.IWorkbenchPreferencePage\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.compilerPropertiesView\nimport org.jetbrains.kotlin.swt.builders.asView\n\nclass WorkspaceCompilerPropertyPage : BasePropertyPage(), IWorkbenchPreferencePage {\n\n    override val properties = KotlinProperties.workspaceInstance\n\n    override fun init(workbench: IWorkbench?) {\n    }\n\n    override fun createUI(parent: Composite): Control =\n            parent.asView\n                    .compilerPropertiesView(properties) {\n                        onIsValidChanged = { setValid(it) }\n                    }\n                    .control\n\n    override fun afterOk() {\n        RebuildJob { monitor ->\n            KotlinEnvironment.removeAllEnvironments()\n            ResourcesPlugin.getWorkspace().build(FULL_BUILD, monitor)\n        }.schedule()\n    }\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/style/ProjectCodeStylePropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.style\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.ProjectScope\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbenchPropertyPage\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.codeStylePropertiesView\nimport org.jetbrains.kotlin.swt.builders.*\nimport org.jetbrains.kotlin.utils.LazyObservable\nimport kotlin.properties.Delegates\n\nclass ProjectCodeStylePropertyPage : BasePropertyPage(), IWorkbenchPropertyPage {\n    // project must be lazy initialized, because getElement() called during construction of page object returns null\n    val project: IProject by lazy { element.getAdapter(IProject::class.java) }\n\n    private var overrideFlag by LazyObservable({ properties.globalsOverridden }) { _, _, v ->\n        properties.globalsOverridden = v\n        settingsView.enabled = v\n    }\n\n    private lateinit var settingsView: View<Composite>\n\n    override val properties by lazy { KotlinCodeStyleProperties(ProjectScope(project)) }\n\n    override fun createUI(parent: Composite): Control =\n            parent.asView.apply {\n                checkbox(::overrideFlag, \"Enable project speciffic settings\")\n                separator { layout(horizontalGrab = true) }\n                settingsView = codeStylePropertiesView(properties) {\n                    enabled = properties.globalsOverridden\n                }\n            }.control\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/style/WorkspaceCodeStylePropertyPage.kt",
    "content": "package org.jetbrains.kotlin.preferences.style\n\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Control\nimport org.eclipse.ui.IWorkbench\nimport org.eclipse.ui.IWorkbenchPreferencePage\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.preferences.BasePropertyPage\nimport org.jetbrains.kotlin.preferences.views.codeStylePropertiesView\nimport org.jetbrains.kotlin.swt.builders.*\n\nclass WorkspaceCodeStylePropertyPage : BasePropertyPage(), IWorkbenchPreferencePage {\n\n    override val properties = KotlinCodeStyleProperties.workspaceInstance\n\n    override fun init(workbench: IWorkbench?) {\n    }\n\n    override fun createUI(parent: Composite): Control =\n            parent.asView.apply {\n                codeStylePropertiesView(properties)\n            }.control\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/views/BuildingPropertiesView.kt",
    "content": "package org.jetbrains.kotlin.preferences.views\n\nimport org.eclipse.swt.widgets.Composite\nimport org.jetbrains.kotlin.core.preferences.KotlinBuildingProperties\nimport org.jetbrains.kotlin.swt.builders.View\nimport org.jetbrains.kotlin.swt.builders.checkbox\nimport org.jetbrains.kotlin.swt.builders.gridContainer\nimport kotlin.properties.Delegates\n\nfun View<Composite>.buildingPropertiesView(\n    kotlinBuildingProperties: KotlinBuildingProperties,\n    operations: BuildingPropertiesView.() -> Unit = {}\n) =\n    BuildingPropertiesView(this, kotlinBuildingProperties)\n        .apply(operations)\n\nclass BuildingPropertiesView(\n    parent: View<Composite>,\n    kotlinBuildingProperties: KotlinBuildingProperties\n) : View<Composite>, Validable {\n\n    override val control: Composite\n\n    override var isValid: Boolean = true\n        private set(value) {\n            field = value\n            onIsValidChanged(value)\n        }\n\n    override var onIsValidChanged: (Boolean) -> Unit = {}\n\n    private var useIncremental by Delegates.observable(kotlinBuildingProperties.useIncremental) { _, _, value ->\n        kotlinBuildingProperties.useIncremental = value\n    }\n\n    init {\n        control = parent.gridContainer {\n            checkbox(::useIncremental, \"Use incremental compiler (experimental)\")\n        }.control\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/views/CompilerPropertiesView.kt",
    "content": "package org.jetbrains.kotlin.preferences.views\n\nimport org.eclipse.jface.resource.FontDescriptor\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.layout.GridLayout\nimport org.eclipse.swt.widgets.*\nimport org.jetbrains.kotlin.config.ApiVersion\nimport org.jetbrains.kotlin.config.JvmTarget\nimport org.jetbrains.kotlin.config.LanguageVersion\nimport org.jetbrains.kotlin.core.preferences.CompilerPlugin\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties\nimport org.jetbrains.kotlin.preferences.compiler.CompilerPluginDialog\nimport org.jetbrains.kotlin.swt.builders.*\nimport org.jetbrains.kotlin.utils.LazyObservable\nimport kotlin.properties.Delegates\n\nfun View<Composite>.compilerPropertiesView(\n        kotlinProperties: KotlinProperties,\n        operations: CompilerPropertiesView.() -> Unit = {}\n) =\n        CompilerPropertiesView(this, kotlinProperties)\n                .apply(operations)\n\nclass CompilerPropertiesView(\n        parent: View<Composite>,\n        private val kotlinProperties: KotlinProperties\n) : View<Composite>, Validable {\n\n    override val control: Composite\n\n    override var isValid: Boolean = true\n        private set(value) {\n            field = value\n            onIsValidChanged(value)\n        }\n\n    override var onIsValidChanged: (Boolean) -> Unit = {}\n\n    private var languageVersionProxy: LanguageVersion by LazyObservable(\n            initialValueProvider = { kotlinProperties.languageVersion },\n            onChange = { _, _, value ->\n                kotlinProperties.languageVersion = value\n                checkApiVersionCorrectness()\n            }\n    )\n\n    private var apiVersionProxy: ApiVersion by LazyObservable(\n            initialValueProvider = { kotlinProperties.apiVersion },\n            onChange = { _, _, value ->\n                kotlinProperties.apiVersion = value\n                checkApiVersionCorrectness()\n            }\n    )\n\n    private var jdkHomeProxy: String? by LazyObservable(\n            initialValueProvider = { kotlinProperties.jdkHome },\n            onChange = { _, oldValue, value ->\n                if (oldValue != value) {\n                    kotlinProperties.jdkHome = value\n                    jdkHomeTextField.update(value.orEmpty())\n                }\n            }\n    )\n\n    private lateinit var apiVersionErrorLabel: Label\n\n    private lateinit var jdkHomeTextField: View<Text>\n\n    private var selectedPlugin by Delegates.observable<CompilerPlugin?>(null) { _, _, value ->\n        val source = value?.source\n\n        editButton.enabled = source != null\n        removeButton.enabled = source != null && source != CompilerPluginSource.Inherited\n        removeButton.label =\n                if (source == CompilerPluginSource.InheritedOverridden) \"Restore\"\n                else \"Remove\"\n    }\n\n    private lateinit var editButton: View<Button>\n\n    private lateinit var removeButton: View<Button>\n\n    init {\n        control = parent.gridContainer(cols = 2) {\n            label(\"JVM target version: \")\n            singleOptionPreference(kotlinProperties::jvmTarget,\n                    allowedValues = enumValues<JvmTarget>().asList(),\n                    nameProvider = JvmTarget::description) {\n                layout(horizontalGrab = true)\n            }\n            label(\"Language version: \")\n            singleOptionPreference(::languageVersionProxy,\n                    allowedValues = enumValues<LanguageVersion>().asList(),\n                    nameProvider = LanguageVersion::description) {\n                layout(horizontalGrab = true)\n            }\n            label(\"API version: \")\n            singleOptionPreference(::apiVersionProxy,\n                    allowedValues = enumValues<LanguageVersion>().map { ApiVersion.createByLanguageVersion(it) },\n                    nameProvider = ApiVersion::description) {\n                layout(horizontalGrab = true)\n            }\n            label(\"JDK Home: \")\n            gridContainer(cols = 2) {\n                with(control.layout as GridLayout) {\n                    marginWidth = 0\n                    marginHeight = 0\n                }\n                jdkHomeTextField = textField(::jdkHomeProxy, style = SWT.SINGLE or SWT.BORDER) {\n                    layout(\n                        horizontalGrab = true, verticalAlignment = SWT.CENTER\n                    )\n                }\n                button(label = \"Browse\") {\n                    layout(verticalAlignment = SWT.CENTER)\n                    onClick {\n                        DirectoryDialog(control.shell).open()?.let { jdkHomeProxy = it }\n                    }\n                }\n            }\n            label(\"\")\n            apiVersionErrorLabel = label(\"API version must be lower or equal to language version\")\n                    .control\n                    .apply {\n                        font = FontDescriptor.createFrom(control.font)\n                                .increaseHeight(-1)\n                                .createFont(Display.getCurrent())\n                        foreground = Display.getCurrent().getSystemColor(SWT.COLOR_RED)\n                        visible = false\n                    }\n            group(\"Compiler plugins:\", cols = 2) {\n                layout(horizontalSpan = 2, verticalGrab = true)\n                val list = checkList({ kotlinProperties.compilerPlugins.entries.sortedBy { it.key } },\n                        selectionDelegate = ::selectedPlugin,\n                        style = SWT.BORDER) {\n                    layout(horizontalGrab = true, verticalGrab = true, verticalSpan = 4)\n                    nameProvider = { it.description }\n                    checkDelegate = CompilerPlugin::active\n                }\n                button(\"Add\") {\n                    onClick {\n                        CompilerPluginDialog(control.shell, kotlinProperties.compilerPlugins, null).open()\n                        list.refresh()\n                    }\n                }\n                editButton = button(\"Edit\") {\n                    enabled = false\n                    onClick {\n                        selectedPlugin?.also { CompilerPluginDialog(control.shell, kotlinProperties.compilerPlugins, it).open() }\n                        list.refresh()\n                    }\n                }\n                removeButton = button(\"Remove\") {\n                    enabled = false\n                    onClick {\n                        selectedPlugin?.delete()\n                        list.refresh()\n                    }\n                }\n            }\n            group(\"Additional compiler flags\") {\n                layout(horizontalSpan = 2, verticalGrab = true)\n                textField(kotlinProperties::compilerFlags, style = SWT.MULTI) { layout(horizontalGrab = true, verticalGrab = true) }\n            }\n        }.control\n    }\n\n    private fun checkApiVersionCorrectness() {\n        val correct = apiVersionProxy <= ApiVersion.createByLanguageVersion(languageVersionProxy)\n        apiVersionErrorLabel.visible = !correct\n        isValid = correct\n    }\n\n    private val CompilerPlugin.source: CompilerPluginSource\n        get() = when {\n            this.keysInParentScopes.isEmpty() ->\n                CompilerPluginSource.Own\n            (this.keysInOwnScope - CompilerPlugin::active.name).isEmpty() ->\n                CompilerPluginSource.Inherited\n            else ->\n                CompilerPluginSource.InheritedOverridden\n        }\n\n    private val CompilerPlugin.description: String\n        get() =\n            this.key + when (this.source) {\n                CompilerPluginSource.Own -> \"\"\n                CompilerPluginSource.Inherited -> \" (inherited)\"\n                CompilerPluginSource.InheritedOverridden -> \" (inherited, overridden)\"\n            }\n\n    private enum class CompilerPluginSource {\n        Own,\n        Inherited,\n        InheritedOverridden\n    }\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/views/ProjectCompilerPropertiesView.kt",
    "content": "package org.jetbrains.kotlin.preferences.views\n\nimport org.eclipse.swt.widgets.Composite\nimport org.jetbrains.kotlin.core.preferences.KotlinProperties\nimport org.jetbrains.kotlin.swt.builders.*\nimport kotlin.properties.Delegates\n\nfun View<Composite>.projectCompilerPropertiesView(\n        kotlinProperties: KotlinProperties,\n        operations: ProjectCompilerPropertiesView.() -> Unit = {}\n) =\n        ProjectCompilerPropertiesView(this, kotlinProperties)\n                .apply(operations)\n\nclass ProjectCompilerPropertiesView(\n        parent: View<Composite>,\n        private val kotlinProperties: KotlinProperties\n) : View<Composite>, Validable {\n\n    override val control: Composite\n\n    override val isValid get() = innerView.isValid\n\n    override var onIsValidChanged\n        get() = innerView.onIsValidChanged\n        set(value) {\n            innerView.onIsValidChanged = value\n        }\n\n    private lateinit var innerView: CompilerPropertiesView\n\n    private var overrideFlag by Delegates.observable(kotlinProperties.globalsOverridden) { _, _, value ->\n        kotlinProperties.globalsOverridden = value\n        innerView.enabled = value\n    }\n\n    init {\n        control = parent.gridContainer {\n            checkbox(::overrideFlag, \"Enable project specific settings\")\n            separator()\n            innerView = compilerPropertiesView(kotlinProperties) {\n                enabled = kotlinProperties.globalsOverridden\n                layout(horizontalGrab = true, verticalGrab = true)\n            }\n        }.control\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/views/Validable.kt",
    "content": "package org.jetbrains.kotlin.preferences.views\n\ninterface Validable {\n    val isValid: Boolean\n    var onIsValidChanged: (Boolean) -> Unit\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/preferences/views/codeStylePropertiesView.kt",
    "content": "package org.jetbrains.kotlin.preferences.views\n\nimport org.eclipse.swt.widgets.Composite\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager\nimport org.jetbrains.kotlin.core.preferences.KotlinCodeStyleProperties\nimport org.jetbrains.kotlin.swt.builders.*\n\nfun View<Composite>.codeStylePropertiesView(\n        properties: KotlinCodeStyleProperties,\n        operations: View<Composite>.() -> Unit = {}\n) =\n        gridContainer(cols = 2) {\n            label(\"Code style:\")\n            singleOptionPreference(\n                    properties::codeStyleId,\n                    KotlinCodeStyleManager.styles,\n                    KotlinCodeStyleManager::getStyleLabel\n            ) { layout(horizontalGrab = true) }\n            operations()\n        }\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/swt/builders/ChecklistView.kt",
    "content": "package org.jetbrains.kotlin.swt.builders\n\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.events.SelectionAdapter\nimport org.eclipse.swt.events.SelectionEvent\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.widgets.Table\nimport org.eclipse.swt.widgets.TableItem\nimport kotlin.reflect.KMutableProperty1\nimport kotlin.reflect.KMutableProperty0\n\nclass ChecklistView<T>(override val control: Table, val model: () -> Iterable<T>) : View<Table> {\n    var nameProvider: (T) -> String = { it.toString() }\n\n    var checkDelegate: KMutableProperty1<T, Boolean>? = null\n\n    var selected: T? = null\n        private set\n\n    @PublishedApi\n    internal fun setSelection(element: T) {\n        selected = element\n    }\n    \n    fun refresh() {\n        control.removeAll()\n        model().forEach {\n                TableItem(control, SWT.NONE).apply {\n                    checked = checkDelegate?.invoke(it) ?: false\n                    text = nameProvider(it)\n                    data = it\n                }\n            } \n    }\n}\n\ninline fun <reified T> View<Composite>.checkList(\n        noinline model: () -> Iterable<T>,\n        selectionDelegate: KMutableProperty0<T?>? = null,\n        style: Int = SWT.NONE,\n        operations: ChecklistView<T>.() -> Unit = {}\n) =\n        ChecklistView(Table(control, style or SWT.CHECK or SWT.SINGLE), model).apply {\n            operations()\n            refresh()\n            control.addSelectionListener(object : SelectionAdapter() {\n                override fun widgetSelected(e: SelectionEvent): Unit = with(e.item as TableItem) {\n                    if (e.detail and SWT.CHECK != 0) {\n                        checkDelegate?.set(this.data as T, checked)\n                    } else {\n                        setSelection(this.data as T)\n                        selectionDelegate?.also { it.set(this.data as T) }\n                    }\n                }\n            })\n        }.applyDefaultLayoutIfNeeded()"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/swt/builders/controls.kt",
    "content": "package org.jetbrains.kotlin.swt.builders\n\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.events.SelectionAdapter\nimport org.eclipse.swt.events.SelectionEvent\nimport org.eclipse.swt.layout.GridData\nimport org.eclipse.swt.layout.GridLayout\nimport org.eclipse.swt.widgets.*\nimport kotlin.reflect.KMutableProperty0\n\ninterface View<out T : Control> {\n    val control: T\n}\n\nval <T : Control> T.asView: View<T>\n    get() = object : View<T> {\n        override val control: T = this@asView\n    }\n\ninline fun View<Composite>.label(\n        text: String = \"\",\n        style: Int = SWT.NONE,\n        operations: View<Label>.() -> Unit = {}) =\n        Label(control, style).asView.apply {\n            control.text = text\n            operations()\n        }\n\ninline fun View<Composite>.separator(style: Int = SWT.NONE, operations: View<Label>.() -> Unit = {}) =\n        Label(control, SWT.HORIZONTAL or SWT.SEPARATOR or style).asView\n                .apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\ninline fun <T> View<Composite>.singleOptionPreference(\n        delegate: KMutableProperty0<T>,\n        allowedValues: List<T>,\n        nameProvider: (T) -> String = { it.toString() },\n        style: Int = SWT.NONE,\n        operations: View<Combo>.() -> Unit = {}\n) =\n        Combo(control, style or SWT.READ_ONLY).apply {\n            val valuesMapping = allowedValues.associateByTo(LinkedHashMap(), nameProvider)\n            valuesMapping.keys.forEach { this.add(it) }\n\n            delegate.get()\n                    .let(nameProvider)\n                    .let(valuesMapping.keys::indexOf)\n                    .also { select(it) }\n\n            addSelectionListener(object : SelectionAdapter() {\n                override fun widgetSelected(event: SelectionEvent) {\n                    delegate.set(valuesMapping[(event.widget as Combo).text]!!)\n                }\n            })\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\ninline fun View<Composite>.button(label: String = \"\", style: Int = SWT.NONE, operations: View<Button>.() -> Unit = {}) =\n        Button(control, style).apply {\n            text = label\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\ninline fun View<Composite>.checkbox(\n        delegate: KMutableProperty0<Boolean>,\n        label: String = \"\",\n        style: Int = SWT.NONE,\n        operations: View<Button>.() -> Unit = {}\n) =\n        Button(control, SWT.CHECK or style).apply {\n            text = label\n            selection = delegate.get()\n            addSelectionListener(object : SelectionAdapter() {\n                override fun widgetSelected(e: SelectionEvent) {\n                    delegate.set(selection)\n                }\n            })\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\n\nfun View<Button>.onClick(callback: () -> Unit) {\n    control.addSelectionListener(object : SelectionAdapter() {\n        override fun widgetSelected(e: SelectionEvent?) {\n            callback()\n        }\n    })\n}\n\nval View<Button>.selected: Boolean\n    get() = control.selection\n\ninline fun View<Composite>.textField(\n        delegate: KMutableProperty0<String?>,\n        style: Int = SWT.NONE,\n        operations: View<Text>.() -> Unit = {}\n) =\n        Text(control, style).apply {\n            text = delegate.get().orEmpty()\n            addModifyListener {\n                delegate.set(text)\n            }\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\nvar View<Text>.text: String\n    get() = control.text\n    set(value) {\n        control.text = value\n    }\n\nfun View<Text>.update(value: String) = with(control) {\n    if (text != value) {\n        text = value\n    }\n}\n\ninline fun View<Composite>.gridContainer(cols: Int = 1, style: Int = SWT.NONE, operations: View<Composite>.() -> Unit = {}) =\n        Composite(control, style).apply {\n            layout = GridLayout(cols, false)\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\ninline fun View<Composite>.group(title: String? = null, cols: Int = 1, style: Int = SWT.NONE, operations: View<Group>.() -> Unit = {}) =\n        Group(control, style).apply {\n            title?.also { text = it }\n            layoutData = GridData(SWT.FILL, SWT.FILL, true, true)\n            layout = GridLayout(cols, false)\n        }.asView.apply(operations)\n                .applyDefaultLayoutIfNeeded()\n\nvar Control.recursiveEnabled: Boolean\n    get() = enabled\n    set(value) {\n        enabled = value\n        if (this is Composite) {\n            this.children.forEach { it.recursiveEnabled = value }\n        }\n    }\n\nvar View<Control>.enabled: Boolean\n    get() = control.enabled\n    set(value) {\n        control.recursiveEnabled = value\n    }\n\nvar View<Button>.label: String\n    get() = control.text\n    set(value) {\n        control.text = value\n    }\n\nfun View<Control>.layout(\n        horizontalSpan: Int = 1,\n        verticalSpan: Int = 1,\n        horizontalAlignment: Int = SWT.FILL,\n        verticalAlignment: Int = SWT.FILL,\n        horizontalGrab: Boolean = false,\n        verticalGrab: Boolean = false,\n        suggestedWidth: Int = SWT.DEFAULT,\n        suggestedHeight: Int = SWT.DEFAULT\n) {\n    control.layoutData = GridData(horizontalAlignment, verticalAlignment, horizontalGrab, verticalGrab, horizontalSpan, verticalSpan).apply {\n        widthHint = suggestedWidth\n        heightHint = suggestedHeight\n    }\n}\n\nfun <T : View<Control>> T.applyDefaultLayoutIfNeeded() = apply {\n    if (control.layoutData == null) {\n        layout()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/Activator.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui\n\nimport org.eclipse.core.resources.IResourceChangeEvent\nimport org.eclipse.core.resources.IResourceChangeListener\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jdt.core.IElementChangedListener\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.ui.plugin.AbstractUIPlugin\nimport org.jetbrains.kotlin.ui.builder.KotlinClassPathListener\nimport org.jetbrains.kotlin.ui.builder.KotlinJavaDeclarationsListener\nimport org.jetbrains.kotlin.ui.builder.ResourceChangeListener\nimport org.osgi.framework.BundleContext\n\n/**\n * The activator class controls the plug-in life cycle\n */\nclass Activator : AbstractUIPlugin() {\n\tprivate val resourceChangeListener by lazy { ResourceChangeListener() }\n\tprivate val scriptClasspathUpdater by lazy { ScriptClasspathUpdater() }\n\tprivate val kotlinClassPathChangedListener by lazy { KotlinClassPathListener() }\n\tprivate val kotlinJavaDeclarationsListener by lazy { KotlinJavaDeclarationsListener() }\n\n\t@Override\n\toverride fun start(context: BundleContext): Unit {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\n\t\tResourcesPlugin.getWorkspace().addResourceChangeListener(\n\t\t\t\tresourceChangeListener,\n\t\t\t\tIResourceChangeEvent.POST_CHANGE.or(IResourceChangeEvent.PRE_CLOSE).or(IResourceChangeEvent.PRE_DELETE))\n\t\tResourcesPlugin.getWorkspace().addResourceChangeListener(scriptClasspathUpdater, IResourceChangeEvent.POST_CHANGE)\n\t\tJavaCore.addElementChangedListener(kotlinClassPathChangedListener)\n\t\tJavaCore.addElementChangedListener(kotlinJavaDeclarationsListener)\n\t}\n\n\t@Override\n\toverride fun stop(context: BundleContext): Unit {\n\t\tResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener)\n\t\tResourcesPlugin.getWorkspace().removeResourceChangeListener(scriptClasspathUpdater)\n\t\tJavaCore.removeElementChangedListener(kotlinClassPathChangedListener)\n\t\tJavaCore.removeElementChangedListener(kotlinJavaDeclarationsListener)\n\n\t\tplugin = null\n\t\tsuper.stop(context)\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t */\n\tcompanion object {\n\t\t// The plug-in ID\n\t\tval PLUGIN_ID = \"org.jetbrains.kotlin.ui\" //$NON-NLS-1$\n\t\t// The shared instance\n\t\tprivate var plugin: Activator? = null\n\n\t\tfun getDefault(): Activator {\n\t\t\treturn plugin as Activator\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/KotlinAwarePackageExplorerLabelProvider.kt",
    "content": "package org.jetbrains.kotlin.ui\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.core.IPackageFragment\nimport org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider\nimport org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider\nimport org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider\nimport org.eclipse.swt.graphics.Image\nimport org.jetbrains.kotlin.core.model.EclipseScriptDefinitionProvider\nimport org.jetbrains.kotlin.core.utils.asFile\nimport kotlin.script.experimental.host.FileScriptSource\n\n/**\n * Modified version of [PackageExplorerLabelProvider] that returns correct images for packages\n * that contains only Kotlin source files.\n *\n * Original [PackageExplorerLabelProvider] treats Kotlin source files as non-Java resources\n * and returns \"empty\" package icon.\n *\n * Injected by [org.jetbrains.kotlin.aspects.ui.PackageExplorerLabelProviderAspect]\n */\nclass KotlinAwarePackageExplorerLabelProvider(cp: PackageExplorerContentProvider) : PackageExplorerLabelProvider(cp) {\n\n    override fun getImage(element: Any?): Image? {\n        // Replace instances of IPackageFragment with instances of KotlinAwarePackageFragment\n        return super.getImage(when (element) {\n            is IPackageFragment -> KotlinAwarePackageFragment(element)\n            else -> element\n        })\n    }\n\n    class KotlinAwarePackageFragment(private val base: IPackageFragment) : IPackageFragment by base {\n        /**\n         * Returns true also when a package contains any Kotlin source file.\n         *\n         * Used by [JavaElementImageProvider.getPackageFragmentIcon]\n         */\n        override fun hasChildren(): Boolean {\n            return base.hasChildren() ||\n                    base.nonJavaResources.any { obj ->\n                        obj is IFile && (obj.name.endsWith(\".kt\") || EclipseScriptDefinitionProvider.isScript(FileScriptSource(obj.asFile)))\n                    }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/KotlinPluginUpdater.kt",
    "content": "/*******************************************************************************\r\n * Copyright 2000-2016 JetBrains s.r.o.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n *\r\n *******************************************************************************/\r\npackage org.jetbrains.kotlin.ui\r\n\r\nimport java.util.concurrent.TimeUnit\r\nimport org.eclipse.core.runtime.IProgressMonitor\r\nimport org.eclipse.equinox.p2.metadata.IInstallableUnit\r\nimport org.eclipse.equinox.p2.operations.OperationFactory\r\nimport org.eclipse.core.runtime.NullProgressMonitor\r\nimport java.net.URI\r\nimport org.eclipse.jface.dialogs.MessageDialog\r\nimport org.eclipse.swt.widgets.Display\r\nimport org.eclipse.equinox.p2.operations.ProfileModificationJob\r\nimport org.eclipse.equinox.p2.operations.ProvisioningJob\r\nimport org.eclipse.swt.widgets.Composite\r\nimport org.eclipse.swt.layout.GridLayout\r\nimport org.eclipse.swt.widgets.Label\r\nimport org.eclipse.swt.SWT\r\nimport org.eclipse.swt.layout.GridData\r\nimport org.eclipse.swt.widgets.Link\r\nimport org.eclipse.swt.widgets.Shell\r\nimport org.eclipse.swt.events.SelectionAdapter\r\nimport org.eclipse.swt.events.SelectionEvent\r\nimport org.eclipse.equinox.p2.operations.UpdateOperation\r\nimport java.net.URL\r\nimport java.net.URLConnection\r\nimport java.net.HttpURLConnection\r\nimport org.jetbrains.kotlin.core.log.KotlinLogger\r\nimport com.intellij.openapi.util.SystemInfo\r\nimport java.net.URLEncoder\r\nimport org.eclipse.jface.preference.IPreferenceStore\r\nimport org.eclipse.equinox.p2.metadata.Version\r\nimport java.util.Random\r\nimport org.jetbrains.kotlin.core.model.runJob\r\nimport org.eclipse.core.runtime.IStatus\r\nimport org.eclipse.core.runtime.Status\r\nimport java.io.IOException\r\nimport org.eclipse.core.runtime.jobs.JobChangeAdapter\r\nimport org.eclipse.core.runtime.jobs.IJobChangeEvent\r\nimport org.eclipse.ui.PlatformUI\r\n\r\nprivate sealed class PluginUpdateStatus() {\r\n    object Update : PluginUpdateStatus()\r\n    \r\n    object CheckUpdateSiteFailed : PluginUpdateStatus()\r\n    \r\n    class UpdateFailed(val message: String) : PluginUpdateStatus()\r\n}\r\n\r\npublic object KotlinPluginUpdater {\r\n    val LAST_UPDATE_CHECK = \"kotlin.lastUpdateCheck\"\r\n    val USER_ID = \"kotlin.userId\"\r\n    \r\n    private val KOTLIN_GROUP_ID = \"org.jetbrains.kotlin.feature.feature.group\"\r\n    private val ECLIPSE_PLATFORM_ID = \"org.eclipse.platform\"\r\n    \r\n    private val MAIN_DELAY: Long = TimeUnit.DAYS.toMillis(1)\r\n    private val retryState = RetryState(TimeUnit.HOURS.toMillis(3))\r\n    \r\n    fun kotlinFileEdited() {\r\n        val kotlinStore = Activator.getDefault().preferenceStore\r\n        \r\n        val updateStatus: PluginUpdateStatus\r\n        if (retryState.retryToUpdate()) {\r\n            updateStatus = tryToUpdate(kotlinStore)\r\n        } else {\r\n            val lastUpdateTime = kotlinStore.getLong(LAST_UPDATE_CHECK)\r\n            if (lastUpdateTime == 0L || checkTimeIsUp(lastUpdateTime, MAIN_DELAY)) {\r\n                updateStatus = tryToUpdate(kotlinStore)\r\n            } else {\r\n                return\r\n            }\r\n        }\r\n        \r\n        processResults(updateStatus, kotlinStore)\r\n    }\r\n    \r\n    private fun getKotlinInstallationUnit(monitor: IProgressMonitor): IInstallableUnit? {\r\n        return OperationFactory().listInstalledElements(true, monitor).find { it.id == KOTLIN_GROUP_ID }\r\n    }\r\n    \r\n    private fun checkTimeIsUp(lastTry: Long, delay: Long): Boolean = System.currentTimeMillis() - lastTry > delay\r\n    \r\n    private fun processResults(updateStatus: PluginUpdateStatus, kotlinStore: IPreferenceStore) {\r\n        when (updateStatus) {\r\n            is PluginUpdateStatus.Update -> {\r\n                kotlinStore.setValue(LAST_UPDATE_CHECK, System.currentTimeMillis())\r\n                retryState.disableRetry()\r\n            }\r\n            \r\n            is PluginUpdateStatus.CheckUpdateSiteFailed -> retryState.setUpForRetry()\r\n            \r\n            is PluginUpdateStatus.UpdateFailed -> {\r\n                KotlinLogger.logWarning(\"Could not check for update (${updateStatus.message})\")\r\n                retryState.setUpForRetry()\r\n            }\r\n        }\r\n    }\r\n    \r\n    private fun tryToUpdate(store: IPreferenceStore): PluginUpdateStatus {\r\n        val monitor = NullProgressMonitor()\r\n        val kotlinUnit = getKotlinInstallationUnit(monitor)\r\n        if (kotlinUnit == null) {\r\n            return PluginUpdateStatus.UpdateFailed(\"There is no kotlin feature group with id: $KOTLIN_GROUP_ID\")\r\n        }\r\n        \r\n        val os = URLEncoder.encode(SystemInfo.OS_NAME + \" \" + SystemInfo.OS_VERSION, \"UTF-8\")\r\n        val pluginVersion = kotlinUnit.version\r\n        val uid = getOrSetUID(store)\r\n        val eclipseVersion = getEclipsePlatformVersion(monitor)\r\n        if (eclipseVersion == null) {\r\n            KotlinLogger.logWarning(\"There is no eclipse platform group with id: $ECLIPSE_PLATFORM_ID\")\r\n        }\r\n\r\n        val params = \"build=$eclipseVersion&pluginVersion=$pluginVersion&os=$os&uuid=$uid\"\r\n        val updateSiteStatus = obtainUpdateSite(\"https://plugins.jetbrains.com/eclipse-plugins/kotlin/update?$params\")\r\n        \r\n        return when (updateSiteStatus) {\r\n            is UpdateSiteStatus.UpdateSite -> {\r\n                val resolvedUpdateSite = updateSiteStatus.updateSite.removeSuffix(\"compositeArtifacts.xml\")\r\n                proposeToUpdate(kotlinUnit, resolvedUpdateSite, monitor)\r\n            }\r\n            \r\n            is UpdateSiteStatus.UpdateSiteNotFound -> PluginUpdateStatus.CheckUpdateSiteFailed\r\n            \r\n            is UpdateSiteStatus.Failed -> PluginUpdateStatus.UpdateFailed(\"Could not obtain update site\")\r\n        }\r\n    }\r\n    \r\n    private fun proposeToUpdate(kotlinUnit: IInstallableUnit, updateSite: String, monitor: IProgressMonitor): PluginUpdateStatus {\r\n        val uri = URI(updateSite)\r\n        val updateOperation = OperationFactory().createUpdateOperation(listOf(kotlinUnit), listOf(uri), monitor)\r\n        val result = updateOperation.resolveModal(monitor)\r\n        if (result.isOK) {\r\n            Display.getDefault().asyncExec { \r\n                MessageDialog.openInformation(Shell(Display.getDefault()), \"Kotlin Plugin\",\r\n                    \"A new version \" + updateOperation.getProfileChangeRequest().getAdditions().first().getVersion() + \" of the Kotlin plugin is available.\")\r\n            }\r\n        }\r\n        \r\n        return PluginUpdateStatus.Update\r\n    }\r\n    \r\n    private fun getOrSetUID(store: IPreferenceStore): Long {\r\n        val userId = store.getLong(USER_ID)\r\n        if (userId == 0L) {\r\n            val generatedId = Random().nextLong()\r\n            store.setValue(USER_ID, generatedId)\r\n            return generatedId\r\n        }\r\n        \r\n        return userId\r\n    }\r\n    \r\n    private fun getEclipsePlatformVersion(monitor: IProgressMonitor): Version? {\r\n        return OperationFactory().listInstalledElements(false, monitor)\r\n                .find { it.id == ECLIPSE_PLATFORM_ID }\r\n                ?.version\r\n    }\r\n    \r\n    private fun obtainUpdateSite(urlString: String): UpdateSiteStatus {\r\n        val url = URL(urlString)\r\n        val connection = url.openConnection()\r\n        if (connection is HttpURLConnection) {\r\n            try {\r\n                connection.setInstanceFollowRedirects(false)\r\n                connection.connect()\r\n                \r\n                if (connection.getResponseCode() == 302) {\r\n                    val redirect = connection.getHeaderField(\"Location\")\r\n                    return if (redirect != null) UpdateSiteStatus.UpdateSite(redirect) else UpdateSiteStatus.Failed\r\n                }\r\n            }  catch (e: IOException) {\r\n                return UpdateSiteStatus.UpdateSiteNotFound\r\n            } finally {\r\n                connection.disconnect()\r\n            }\r\n        }\r\n        \r\n        return UpdateSiteStatus.Failed\r\n    }\r\n    \r\n    private sealed class UpdateSiteStatus {\r\n        object UpdateSiteNotFound : UpdateSiteStatus()\r\n        \r\n        object Failed : UpdateSiteStatus()\r\n        \r\n        class UpdateSite(val updateSite: String) : UpdateSiteStatus()\r\n    }\r\n    \r\n    private class RetryState(private val retryDelay: Long) {\r\n        @Volatile private var lastRetryTime: Long = 0\r\n        @Volatile private var isActive: Boolean = false\r\n        \r\n        @Synchronized fun setUpForRetry() {\r\n            isActive = true\r\n            lastRetryTime = System.currentTimeMillis()\r\n        }\r\n        \r\n        fun disableRetry() {\r\n            isActive = false\r\n        }\r\n        \r\n        fun retryToUpdate(): Boolean {\r\n            return isActive && checkTimeIsUp(lastRetryTime, retryDelay)\r\n        }\r\n    }\r\n}\r\n\r\nfun gridData(\r\n            horizontalAlignment: Int = SWT.BEGINNING,\r\n            verticalAlignment: Int = SWT.CENTER,\r\n            grabExcessHorizontalSpace: Boolean = false,\r\n            grabExcessVerticalSpace: Boolean = false,\r\n            horizontalSpan: Int = 1,\r\n            verticalSpan: Int = 1): GridData {\r\n    return GridData(horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace, grabExcessVerticalSpace, horizontalSpan, verticalSpan)\r\n}\r\n\r\nprivate class RestartJobAdapter(val display: Display) : JobChangeAdapter() {\r\n    override fun done(event: IJobChangeEvent) {\r\n        val result = event.result\r\n        if (result.isOK) {\r\n            display.syncExec { \r\n                val restart = MessageDialog.openQuestion(\r\n                        null,\r\n                        \"Updates installed, restart?\",\r\n                        \"Updates have been installed successfully, do you want to restart?\");\r\n                if (restart) {\r\n                    PlatformUI.getWorkbench().restart()\r\n                }\r\n            }\r\n        } else if (!result.matches(IStatus.CANCEL)) {\r\n            display.syncExec { \r\n                MessageDialog.openError(null, \"Error\", event.result.message)\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/KotlinUiStartupClass.java",
    "content": "package org.jetbrains.kotlin.ui;\n\nimport org.eclipse.ui.IStartup;\n\npublic class KotlinUiStartupClass implements IStartup {\n    \n    @Override\n    public void earlyStartup() {\n        // activating Kotlin UI plugin on workbench startup\n\n        new RemoveRemnantProjectsJob().schedule(3 * 1000);\n    }\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/RemoveRemnantProjectsJob.kt",
    "content": "package org.jetbrains.kotlin.ui\n\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.resources.WorkspaceJob\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.jetbrains.kotlin.core.filesystem.EnvironmentRemnantNature\n\nclass RemoveRemnantProjectsJob: WorkspaceJob(\"Removing outdated script environments\") {\n\n    init {\n        isSystem = true\n        priority = Job.DECORATE\n        rule = ResourcesPlugin.getWorkspace().root\n    }\n\n    override fun runInWorkspace(monitor: IProgressMonitor): IStatus {\n        ResourcesPlugin.getWorkspace().root.projects\n            .asSequence()\n            .filter { it.isOpen }\n            .filter { it.hasNature(EnvironmentRemnantNature.NATURE_ID) }\n            .forEach { it.delete(false, false, null) }\n\n        return Status.OK_STATUS\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/ScriptClasspathUpdater.kt",
    "content": "package org.jetbrains.kotlin.ui\n\nimport com.intellij.openapi.components.ServiceManager\nimport org.eclipse.core.resources.*\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.core.model.*\nimport org.jetbrains.kotlin.core.utils.asFile\nimport org.jetbrains.kotlin.scripting.resolve.ScriptContentLoader\nimport org.jetbrains.kotlin.ui.editors.KotlinScriptEditor\nimport kotlin.script.experimental.dependencies.DependenciesResolver\nimport kotlin.script.experimental.dependencies.ScriptDependencies\n\n\nclass ScriptClasspathUpdater : IResourceChangeListener {\n    override fun resourceChanged(event: IResourceChangeEvent) {\n        val delta = event.delta ?: return\n        delta.accept(object : IResourceDeltaVisitor {\n            override fun visit(delta: IResourceDelta?): Boolean {\n                val resource = delta?.resource ?: return false\n                if (resource is IFile) {\n                    tryUpdateScriptClasspath(resource)\n                    return false\n                }\n\n                return true\n            }\n        })\n    }\n}\n\ninternal fun tryUpdateScriptClasspath(file: IFile) {\n    if (findEditor(file) == null) return\n\n    val environment = getEnvironment(file) as? KotlinScriptEnvironment ?: return\n\n    val dependenciesProvider: DependenciesResolver? = ServiceManager.getService(environment.project, DependenciesResolver::class.java)\n\n    runJob(\"Check script dependencies\", Job.DECORATE, null, {\n        var newDependencies: DependenciesResolver.ResolveResult? = null\n        if(dependenciesProvider != null) {\n            val contents = ScriptContentLoader(environment.project).getScriptContents(\n                    environment.definition?.legacyDefinition!!,\n                    environment.getVirtualFile(file.location)!!\n            )\n\n            val scriptEnvironment = EclipseScriptDefinitionProvider.getEnvironment(file.asFile).orEmpty()\n            newDependencies = dependenciesProvider.resolve(contents, scriptEnvironment)\n        }\n        StatusWithDependencies(Status.OK_STATUS, newDependencies?.dependencies)\n    }) { event ->\n        val editor = findEditor(file)\n        val statusWithDependencies = event.result\n        val newDependencies = (statusWithDependencies as? StatusWithDependencies)?.dependencies\n        if (file.isAccessible && editor != null) {\n            editor.reconcile {\n                val tempEnv = KotlinScriptEnvironment.getEnvironment(file)\n                if(tempEnv.dependencies != newDependencies) {\n                    KotlinScriptEnvironment.updateDependencies(file, newDependencies)\n                    KotlinAnalysisFileCache.resetCache()\n                }\n            }\n        }\n    }\n}\n\nprivate data class StatusWithDependencies(val status: IStatus, val dependencies: ScriptDependencies?) :\n    IStatus by status\n\nprivate fun findEditor(scriptFile: IFile): KotlinScriptEditor? {\n    for (window in PlatformUI.getWorkbench().getWorkbenchWindows()) {\n        for (page in window.getPages()) {\n            for (editorReference in page.getEditorReferences()) {\n                val editor = editorReference.getEditor(false)\n                if (editor !is KotlinScriptEditor) continue\n\n                if (editor.eclipseFile == scriptFile) return editor\n            }\n        }\n    }\n\n    return null\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/ScriptEnvironmentsFilter.kt",
    "content": "package org.jetbrains.kotlin.ui\n\nimport org.eclipse.jdt.internal.core.JavaProject\nimport org.eclipse.jface.viewers.Viewer\nimport org.eclipse.jface.viewers.ViewerFilter\nimport org.jetbrains.kotlin.core.filesystem.EnvironmentRemnantNature\nimport org.jetbrains.kotlin.core.script.EnvironmentProjectsManager\n\nclass ScriptEnvironmentsFilter : ViewerFilter() {\n    override fun select(viewer: Viewer, parentElement: Any, element: Any): Boolean {\n        val project = (element as? JavaProject)?.project ?: return true\n        if (!project.isOpen) return true\n        return !project.hasNature(EnvironmentRemnantNature.NATURE_ID)\n                && !EnvironmentProjectsManager.wasCreated(project.name)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/AspectsUtils.java",
    "content": "package org.jetbrains.kotlin.ui.builder;\n\nimport org.eclipse.core.resources.IFile;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment;\n\npublic class AspectsUtils {\n    public static boolean isKotlinFile(IFile file) {\n        return KotlinPsiManager.isKotlinFile(file);\n    }\n    \n    public static boolean existsSourceFile(IFile file) {\n        return KotlinPsiManager.INSTANCE.existsSourceFile(file);\n    }\n    \n    public static boolean isScript(IFile file) {\n        return KotlinScriptEnvironment.Companion.isScript(file);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/BaseKotlinBuilderElement.kt",
    "content": "package org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResourceDelta\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.core.model.runJob\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.resolve.diagnostics.Diagnostics\nimport org.jetbrains.kotlin.ui.KotlinPluginUpdater\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotation\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotationUtil\nimport org.jetbrains.kotlin.ui.editors.quickfix.removeMarkers\n\nabstract class BaseKotlinBuilderElement {\n\n    private val fileFilters = listOf(ScriptFileFilter, FileFromOutputFolderFilter, FileFromKotlinBinFolderFilter)\n\n    abstract fun build(project: IProject, delta: IResourceDelta?, kind: Int): Array<IProject>?\n\n    protected fun isAllFilesApplicableForFilters(files: Set<IFile>, javaProject: IJavaProject): Boolean {\n        return files.all { file ->\n            fileFilters.any { filter ->\n                filter.isApplicable(file, javaProject)\n            }\n        }\n    }\n\n    protected fun makeClean(javaProject: IJavaProject) {\n        val kotlinFiles = KotlinPsiManager.getFilesByProject(javaProject.project)\n        val existingFiles = kotlinFiles.filter { it.exists() }\n\n        commitFiles(existingFiles)\n\n        clearProblemAnnotationsFromOpenEditorsExcept(emptyList())\n        clearMarkersFromFiles(existingFiles)\n\n        runCancellableAnalysisFor(javaProject) { analysisResult ->\n            updateLineMarkers(analysisResult.bindingContext.diagnostics, existingFiles)\n            KotlinLightClassGeneration.updateLightClasses(javaProject.project, kotlinFiles)\n        }\n    }\n\n    protected fun commitFiles(files: Collection<IFile>) {\n        files.forEach { KotlinPsiManager.commitFile(it, EditorUtil.getDocument(it)) }\n    }\n\n    protected fun getAllAffectedFiles(resourceDelta: IResourceDelta): Set<IFile> {\n        val affectedFiles = hashSetOf<IFile>()\n        resourceDelta.accept { delta ->\n            if (delta.kind == IResourceDelta.NO_CHANGE) return@accept false\n\n            val resource = delta.resource\n            if (resource is IFile) {\n                affectedFiles.add(resource)\n            } else {\n                return@accept true\n            }\n\n            false\n        }\n\n        return affectedFiles\n    }\n\n    protected fun updateLineMarkers(diagnostics: Diagnostics, affectedFiles: List<IFile>) {\n        clearMarkersFromFiles(affectedFiles)\n        addMarkersToProject(DiagnosticAnnotationUtil.INSTANCE.handleDiagnostics(diagnostics), affectedFiles)\n    }\n\n    protected fun postBuild(delta: IResourceDelta?, javaProject: IJavaProject) {\n        val allAffectedFiles = if (delta != null) getAllAffectedFiles(delta) else emptySet()\n\n        if (allAffectedFiles.isNotEmpty()) {\n            if (isAllFilesApplicableForFilters(allAffectedFiles, javaProject)) {\n                return\n            }\n        }\n\n        val kotlinAffectedFiles =\n                allAffectedFiles\n                        .filterTo(hashSetOf()) { KotlinPsiManager.isKotlinSourceFile(it, javaProject) }\n\n        val existingAffectedFiles = kotlinAffectedFiles.filter { it.exists() }\n\n        commitFiles(existingAffectedFiles)\n\n        KotlinLightClassGeneration.updateLightClasses(javaProject.project, kotlinAffectedFiles)\n        if (kotlinAffectedFiles.isNotEmpty()) {\n\n            runJob(\"Checking for update\", Job.DECORATE) {\n                KotlinPluginUpdater.kotlinFileEdited()\n                Status.OK_STATUS\n            }\n        }\n\n        val ktFiles = existingAffectedFiles.map { KotlinPsiManager.getParsedFile(it) }\n\n        val analysisResultWithProvider = if (ktFiles.isEmpty())\n            KotlinAnalyzer.analyzeProject(javaProject.project)\n        else\n            KotlinAnalyzer.analyzeFiles(ktFiles)\n\n        clearProblemAnnotationsFromOpenEditorsExcept(existingAffectedFiles)\n        updateLineMarkers(analysisResultWithProvider.analysisResult.bindingContext.diagnostics, existingAffectedFiles)\n\n        runCancellableAnalysisFor(javaProject) { analysisResult ->\n            val projectFiles = KotlinPsiManager.getFilesByProject(javaProject.project)\n            updateLineMarkers(\n                    analysisResult.bindingContext.diagnostics,\n                    (projectFiles - existingAffectedFiles.toSet()).toList()\n            )\n        }\n    }\n}\n\nprivate fun clearMarkersFromFiles(files: List<IFile>) {\n    files.forEach { it.removeMarkers() }\n}\n\nfun clearProblemAnnotationsFromOpenEditorsExcept(affectedFiles: List<IFile>) {\n    for (window in PlatformUI.getWorkbench().getWorkbenchWindows()) {\n        for (page in window.pages) {\n            page.editorReferences\n                .map { it.getEditor(false) }\n                .filterIsInstance(KotlinFileEditor::class.java)\n                .filterNot { it.eclipseFile in affectedFiles }\n                .forEach {\n                    AnnotationManager.removeAnnotations(it, AnnotationManager.ANNOTATION_ERROR_TYPE)\n                    AnnotationManager.removeAnnotations(it, AnnotationManager.ANNOTATION_WARNING_TYPE)\n                }\n        }\n    }\n}\n\nprivate fun addMarkersToProject(annotations: Map<IFile, List<DiagnosticAnnotation>>, affectedFiles: List<IFile>) {\n    for (file in affectedFiles) {\n        DiagnosticAnnotationUtil.INSTANCE.addParsingDiagnosticAnnotations(file, annotations)\n        annotations[file]?.forEach { AnnotationManager.addProblemMarker(it, file) }\n    }\n}\n\ninterface KotlinFileFilterForBuild {\n    fun isApplicable(file: IFile, javaProject: IJavaProject): Boolean\n}\n\nobject ScriptFileFilter : KotlinFileFilterForBuild {\n    override fun isApplicable(file: IFile, javaProject: IJavaProject): Boolean {\n        return KotlinScriptEnvironment.isScript(file)\n    }\n}\n\nobject FileFromOutputFolderFilter : KotlinFileFilterForBuild {\n    override fun isApplicable(file: IFile, javaProject: IJavaProject): Boolean {\n        val workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getFullPath()\n        val outputLocation = javaProject.outputLocation\n\n        val filePathLocation = file.fullPath.makeRelativeTo(workspaceLocation)\n        return outputLocation.isPrefixOf(filePathLocation)\n    }\n}\n\nobject FileFromKotlinBinFolderFilter : KotlinFileFilterForBuild {\n    override fun isApplicable(file: IFile, javaProject: IJavaProject): Boolean {\n        return EclipseJavaElementUtil.isFromKotlinBinFolder(file)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/CompileKotlinClassesAction.kt",
    "content": "package org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.IncrementalProjectBuilder.INCREMENTAL_BUILD\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jface.action.IAction\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.ui.IWorkbenchWindow\nimport org.eclipse.ui.IWorkbenchWindowActionDelegate\nimport org.jetbrains.kotlin.preferences.compiler.RebuildJob\n\nclass CompileKotlinClassesAction : IWorkbenchWindowActionDelegate {\n\n    override fun run(action: IAction?) {\n        RebuildJob { monitor ->\n            ResourcesPlugin.getWorkspace().build(INCREMENTAL_BUILD, monitor)\n        }.schedule()\n    }\n\n    override fun selectionChanged(action: IAction?, selection: ISelection?) {\n    }\n\n    override fun init(window: IWorkbenchWindow?) {\n    }\n\n    override fun dispose() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/IncrementalKotlinBuilderElement.kt",
    "content": "package org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResourceDelta\nimport org.eclipse.core.resources.IncrementalProjectBuilder\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.compiler.KotlinCompilerResult\nimport org.jetbrains.kotlin.core.compiler.KotlinCompilerUtils\nimport org.jetbrains.kotlin.core.model.runJob\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.ui.KotlinPluginUpdater\nimport org.jetbrains.kotlin.ui.launch.removeKotlinConsoles\n\nclass IncrementalKotlinBuilderElement : BaseKotlinBuilderElement() {\n\n    override fun build(project: IProject, delta: IResourceDelta?, kind: Int): Array<IProject>? {\n        val javaProject = JavaCore.create(project)\n\n        if (kind == IncrementalProjectBuilder.FULL_BUILD) {\n            makeClean(javaProject)\n            return null\n        }\n\n        removeKotlinConsoles(javaProject)\n        compileKotlinFilesIncrementally(javaProject)\n\n        postBuild(delta, javaProject)\n\n        return null\n    }\n\n    private fun compileKotlinFilesIncrementally(javaProject: IJavaProject) {\n        val compilerResult: KotlinCompilerResult = KotlinCompilerUtils.compileProjectIncrementally(javaProject)\n        if (!compilerResult.compiledCorrectly()) {\n            KotlinCompilerUtils.handleCompilerOutput(KotlinCompilerUtils.CompilerOutputWithProject(compilerResult.compilerOutput, javaProject))\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/KotlinAnalysisJob.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.IJobChangeEvent\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.core.runtime.jobs.JobChangeAdapter\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\nimport org.jetbrains.kotlin.progress.CompilationCanceledException\nimport org.jetbrains.kotlin.progress.CompilationCanceledStatus\nimport org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus\nimport org.eclipse.core.resources.ResourcesPlugin\n\npublic class KotlinAnalysisJob(private val javaProject: IJavaProject) : Job(\"Kotlin Analysis\") {\n    init {\n        setPriority(DECORATE)\n        setSystem(true)\n    }\n    \n    val familyIndicator = constructFamilyIndicator(javaProject)\n    \n    @Volatile var canceled = false\n    \n    override fun run(monitor: IProgressMonitor): IStatus {\n        try {\n            canceled = false\n            \n            ProgressIndicatorAndCompilationCanceledStatus.setCompilationCanceledStatus(object : CompilationCanceledStatus {\n                override fun checkCanceled() {\n                    if (canceled) throw CompilationCanceledException()\n                }\n            })\n            \n            if (!javaProject.isOpen) {\n                return Status.OK_STATUS\n            }\n            \n            val analysisResult = KotlinAnalysisProjectCache.getAnalysisResult(javaProject)\n            \n            return AnalysisResultStatus(Status.OK_STATUS, analysisResult)\n        } catch (e: CompilationCanceledException) {\n            return AnalysisResultStatus(Status.CANCEL_STATUS, AnalysisResult.EMPTY)\n        } finally {\n            ProgressIndicatorAndCompilationCanceledStatus.setCompilationCanceledStatus(null)\n        }\n    }\n    \n    override fun belongsTo(family: Any): Boolean = family == familyIndicator\n    \n    override fun canceling() {\n        super.canceling()\n        canceled = true\n    }\n    \n    class AnalysisResultStatus(val status: IStatus, val analysisResult: AnalysisResult): IStatus by status\n}\n\nprivate fun constructFamilyIndicator(javaProject: IJavaProject): String {\n    return javaProject.getProject().getName() + \"_kotlinAnalysisFamily\"\n}\n\nfun runCancellableAnalysisFor(javaProject: IJavaProject, postAnalysisTask: (AnalysisResult) -> Unit = {}) {\n    val family = constructFamilyIndicator(javaProject)\n    Job.getJobManager().cancel(family)\n    Job.getJobManager().join(family, NullProgressMonitor()) // It should be fast enough\n    \n    KotlinAnalysisProjectCache.resetCache(javaProject.project)\n    \n    val analysisJob = KotlinAnalysisJob(javaProject)\n    analysisJob.setRule(ResourcesPlugin.getWorkspace().getRoot());\n    \n    analysisJob.addJobChangeListener(object : JobChangeAdapter() {\n        override fun done(event: IJobChangeEvent) {\n            val result = event.result\n            if (result is KotlinAnalysisJob.AnalysisResultStatus && result.isOK) {\n                postAnalysisTask(result.analysisResult)\n            }\n        }\n    })\n    \n    analysisJob.schedule()\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/KotlinBuilder.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IncrementalProjectBuilder\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\n\nclass KotlinBuilder : IncrementalProjectBuilder() {\n\n    companion object {\n        private val RESOURCE_COPY_EXCLUSION_FILTER_VALUE_PATTERN = Regex(\"^(?:.*,)?\\\\*\\\\.kt(?:,.*)?$\")\n        private const val RESOURCE_COPY_EXCLUSION_FILTER_NAME =\n            \"org.eclipse.jdt.core.builder.resourceCopyExclusionFilter\"\n        private const val RESOURCE_COPY_EXCLUSION_FILTER_VALUE = \"*.kt\"\n    }\n\n    private val oldBuilderElement: KotlinBuilderElement by lazy { KotlinBuilderElement() }\n\n    private val incrementalBuilder: IncrementalKotlinBuilderElement by lazy { IncrementalKotlinBuilderElement() }\n\n    override fun build(kind: Int, args: Map<String, String>?, monitor: IProgressMonitor?): Array<IProject>? {\n        val javaProject = JavaCore.create(project)\n        val delta = getDelta(project)\n        return if (KotlinEnvironment.getEnvironment(javaProject.project).buildingProperties.useIncremental) {\n            incrementalBuilder\n        } else {\n            oldBuilderElement\n        }.build(project, delta, kind)\n    }\n\n    override fun startupOnInitialize() {\n        super.startupOnInitialize()\n        with(JavaCore.create(project)) {\n            (getOption(RESOURCE_COPY_EXCLUSION_FILTER_NAME, false) ?: \"\").let { value ->\n                if (!RESOURCE_COPY_EXCLUSION_FILTER_VALUE_PATTERN.matches(value))\n                    setOption(\n                        RESOURCE_COPY_EXCLUSION_FILTER_NAME,\n                        \"${if (value.isNotBlank()) \"$value,\" else \"\"}$RESOURCE_COPY_EXCLUSION_FILTER_VALUE\"\n                    )\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/KotlinBuilderElement.kt",
    "content": "package org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResourceDelta\nimport org.eclipse.core.resources.IncrementalProjectBuilder.FULL_BUILD\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.debug.core.model.LaunchConfigurationDelegate\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.compiler.KotlinCompilerResult\nimport org.jetbrains.kotlin.core.compiler.KotlinCompilerUtils\nimport org.jetbrains.kotlin.core.model.runJob\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.ui.KotlinPluginUpdater\nimport org.jetbrains.kotlin.ui.launch.removeKotlinConsoles\n\nclass KotlinBuilderElement : BaseKotlinBuilderElement() {\n\n    override fun build(project: IProject, delta: IResourceDelta?, kind: Int): Array<IProject>? {\n        val javaProject = JavaCore.create(project)\n        if (isBuildingForLaunch()) {\n            removeKotlinConsoles(javaProject)\n            compileKotlinFiles(javaProject)\n            return null\n        }\n\n        if (kind == FULL_BUILD) {\n            makeClean(javaProject)\n            return null\n        }\n\n        postBuild(delta, javaProject)\n\n        return null\n    }\n\n    private fun isBuildingForLaunch(): Boolean {\n        val launchDelegateFQName = LaunchConfigurationDelegate::class.java.canonicalName\n        return Thread.currentThread().stackTrace.find {\n            it.className == launchDelegateFQName\n        } != null\n    }\n\n    private fun compileKotlinFiles(javaProject: IJavaProject) {\n        val compilerResult: KotlinCompilerResult = KotlinCompilerUtils.compileWholeProject(javaProject)\n        if (!compilerResult.compiledCorrectly()) {\n            KotlinCompilerUtils.handleCompilerOutput(KotlinCompilerUtils.CompilerOutputWithProject(compilerResult.compilerOutput, javaProject))\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/ResourceChangeListener.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.core.resources.*\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.*\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asFile\nimport kotlin.script.experimental.host.FileScriptSource\n\nclass ResourceChangeListener : IResourceChangeListener {\n    override fun resourceChanged(event: IResourceChangeEvent) {\n        val eventResource = event.resource\n        if (eventResource != null) {\n            val type = event.type\n            if (type == IResourceChangeEvent.PRE_CLOSE || type == IResourceChangeEvent.PRE_DELETE) {\n                updateManager(eventResource, IResourceDelta.REMOVED)\n            }\n\n            return\n        }\n\n        event.delta?.accept(ProjectChangeListener())\n    }\n}\n\nclass ProjectChangeListener : IResourceDeltaVisitor {\n    override fun visit(delta: IResourceDelta): Boolean {\n        val resource = delta.resource\n        if ((delta.flags and IResourceDelta.OPEN) != 0) {\n            if (resource is IProject && resource.isOpen) {\n                return updateManager(resource, IResourceDelta.ADDED)\n            }\n        }\n\n        if (delta.kind == IResourceDelta.CHANGED) {\n            return true\n        }\n\n        return updateManager(resource, delta.kind)\n    }\n}\n\nprivate fun updateManager(resource: IResource, deltaKind: Int): Boolean {\n    return when (resource) {\n        is IFile -> {\n            //IF we got a source file we update the psi!\n            if (KotlinPsiManager.isKotlinSourceFile(resource)) {\n                KotlinPsiManager.updateProjectPsiSources(resource, deltaKind)\n            }\n\n            //If we got a script file and it was deleted we remove the environment.\n            if(EclipseScriptDefinitionProvider.isScript(FileScriptSource(resource.asFile))) {\n                if(deltaKind == IResourceDelta.REMOVED) {\n                    KotlinScriptEnvironment.removeKotlinEnvironment(resource)\n                }\n            }\n            false\n        }\n\n        is IProject -> {\n            //If we got a project removed we need to remove all environments that represent\n            //this project or dependet on that project. For simplicity we remove all environments for now.\n            if (deltaKind == IResourceDelta.REMOVED) {\n                KotlinPsiManager.removeProjectFromManager(resource)\n                KotlinEnvironment.removeEnvironmentIf { it: KotlinCommonEnvironment ->\n                    val tempDepPrjs = ProjectUtils.getDependencyProjects(it.javaProject)\n                    resource in tempDepPrjs\n                }\n                KotlinScriptEnvironment.removeEnvironmentIf { it: KotlinCommonEnvironment ->\n                    val tempDepPrjs = ProjectUtils.getDependencyProjects(it.javaProject)\n                    resource in tempDepPrjs\n                }\n            }\n\n            //If a project was added we need to make sure the kotlin builder is invoked before the java builder.\n            //Also we need to refresh all environments that had errors before, as they could be resolved by the new project.\n            if (deltaKind == IResourceDelta.ADDED) {\n                if(KotlinNature.hasKotlinBuilder(resource)) {\n                    setKotlinBuilderBeforeJavaBuilder(resource)\n                }\n                KotlinEnvironment.removeEnvironmentIf { it.hasError }\n                KotlinScriptEnvironment.removeEnvironmentIf { it.hasError }\n            }\n\n            false\n        }\n\n        else -> true // folder\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/kotlinJavaElementsListeners.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.builder\n\nimport org.eclipse.jdt.core.ElementChangedEvent\nimport org.eclipse.jdt.core.IElementChangedListener\nimport org.eclipse.jdt.core.IJavaElementDelta\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.eclipse.jdt.core.IAnnotation\nimport org.eclipse.jdt.core.IMember\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.jdt.core.ICompilationUnit\nimport org.eclipse.jdt.core.IJavaElement\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\nimport org.eclipse.jdt.core.IJavaModel\nimport org.eclipse.jdt.core.ITypeParameter\nimport org.eclipse.jdt.internal.core.ImportContainer\nimport org.eclipse.jdt.core.IPackageFragment\nimport org.eclipse.jdt.core.IPackageDeclaration\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\n\npublic class KotlinClassPathListener : IElementChangedListener {\n    override public fun elementChanged(event: ElementChangedEvent) {\n        updateEnvironmentIfClasspathChanged(event.getDelta())\n    }\n    \n    private fun updateEnvironmentIfClasspathChanged(delta: IJavaElementDelta) {\n        delta.getAffectedChildren().forEach { updateEnvironmentIfClasspathChanged(it) }\n        \n        val element = delta.getElement()\n        if (element is IJavaProject && element.exists() && KotlinNature.hasKotlinNature(element.getProject())) {\n            val flags = delta.getFlags()\n            if ((flags and IJavaElementDelta.F_CLASSPATH_CHANGED) != 0 || \n                (flags and IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0) {\n                KotlinEnvironment.removeEnvironment(element.project)\n            }\n        }\n    }\n}\n\npublic class KotlinJavaDeclarationsListener : IElementChangedListener {\n    override fun elementChanged(event: ElementChangedEvent) {\n        resetCacheIfJavaElementDeclarationChanged(event.getDelta())\n    }\n    \n    private fun resetCacheIfJavaElementDeclarationChanged(delta: IJavaElementDelta) {\n        delta.getAffectedChildren().forEach { resetCacheIfJavaElementDeclarationChanged(it) }\n        \n        val element = delta.getElement()\n        when (element) {\n            is IType,\n            is IMember,\n            is ITypeParameter,\n            is ImportContainer,\n            is IPackageDeclaration -> {\n                val javaProject = element.getJavaProject()\n                if (javaProject != null) {\n                    KotlinAnalysisProjectCache.resetCache(javaProject.project)\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/AddCoroutinesActionHandler.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands\n\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.eclipse.ui.ISources\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.jetbrains.kotlin.core.model.isConfigurationMissing\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.buildLibPath\nimport org.eclipse.jdt.core.JavaCore\n\npublic class AddCoroutinesActionHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val selection = HandlerUtil.getActiveMenuSelection(event)\n        val project = getFirstOrNullProject(selection as IStructuredSelection)!!\n\n        ProjectUtils.addToClasspath(\n            JavaCore.create(project),\n            ProjectUtils.newExportedLibraryEntry(\"kotlinx-coroutines-core\".buildLibPath()),\n            ProjectUtils.newExportedLibraryEntry(\"kotlinx-coroutines-jdk8\".buildLibPath())\n        )\n\n        return null\n    }\n\n    override fun setEnabled(evaluationContext: Any) {\n        val selection = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME)\n        val newEnabled = (selection as? IStructuredSelection)\n            ?.let { getFirstOrNullProject(it) }\n        \t?.let { if (it.hasNature(JavaCore.NATURE_ID)) JavaCore.create(it) else null }\n            ?.let { needsCoroutinesLibrary(it) }\n            ?: false\n\n        setBaseEnabled(newEnabled)\n    }\n\n    private fun needsCoroutinesLibrary(javaProject: IJavaProject): Boolean =\n        javaProject.findType(\"kotlinx.coroutines.CoroutineScope\") == null\n                && !ProjectUtils.isGradleProject(javaProject.project)\n                && !ProjectUtils.isMavenProject(javaProject.project) && !isConfigurationMissing(javaProject.project)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/ConfigureKotlinActionHandler.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands\n\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.eclipse.ui.ISources\nimport org.jetbrains.kotlin.core.model.isConfigurationMissing\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.jetbrains.kotlin.wizards.NewUnitWizard\nimport org.jetbrains.kotlin.ui.launch.KotlinRuntimeConfigurator\nimport org.jetbrains.kotlin.core.model.KotlinNature\n\npublic class ConfigureKotlinActionHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val selection = HandlerUtil.getActiveMenuSelection(event)\n        val project = getFirstOrNullProject(selection as IStructuredSelection)!!\n        \n        KotlinNature.addNature(project)\n        KotlinRuntimeConfigurator.suggestForProject(project);\n        \n        return null\n    }\n    \n    override fun setEnabled(evaluationContext: Any) {\n        val selection = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME)\n        if (selection is IStructuredSelection) {\n            val project = getFirstOrNullProject(selection)\n            if (project != null) {\n                setBaseEnabled(isConfigurationMissing(project))\n                return\n            }\n        }\n        \n        setBaseEnabled(false)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/DeconfigureKotlinActionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.commands\n\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.jetbrains.kotlin.core.model.unconfigureKotlinProject\nimport org.jetbrains.kotlin.core.model.canBeDeconfigured\nimport org.eclipse.ui.ISources\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.eclipse.jdt.core.JavaCore\n\npublic class DeconfigureKotlinActionHandler : AbstractHandler() {\n\toverride fun execute(event: ExecutionEvent): Any? {\n\t\tval selection = HandlerUtil.getActiveMenuSelection(event)\n\t\tval project = getFirstOrNullProject(selection as IStructuredSelection)\n\t\tunconfigureKotlinProject(JavaCore.create(project!!))\n\t\t\n\t\treturn null\n\t}\n\t\n\toverride fun setEnabled(evaluationContext: Any) {\n\t\tval selection = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME)\n\t\tif (selection is IStructuredSelection) {\n\t\t\tval project = getFirstOrNullProject(selection)\n\t\t\tif (project != null) {\n\t\t\t\tsetBaseEnabled(canBeDeconfigured(project))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\t \n\t\tsetBaseEnabled(false)\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/commandsUtils.kt",
    "content": "package org.jetbrains.kotlin.ui.commands\n\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.core.CompilationUnit\nimport org.eclipse.ui.ide.undo.DeleteResourcesOperation\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.ide.IDE\nimport org.eclipse.jdt.core.JavaCore\n\ndata class ConvertedKotlinData(val file: IFile, val kotlinFileData: String)\n\nfun getFirstOrNullProject(selection: IStructuredSelection): IProject? {\n\treturn selection.toArray().firstOrNull().let { if( it is IJavaProject) it.getProject() else it as? IProject }\n}\n\nfun getDeleteOperation(compilationUnits: Set<CompilationUnit>): DeleteResourcesOperation {\n\tval resources = compilationUnits.map { it.getResource() }\n\treturn DeleteResourcesOperation(resources.toTypedArray(), \"Deleting files\", true)\n}\n\nfun getCorrespondingProjects(compilationUnits: Set<CompilationUnit>): Set<IProject> {\n\treturn compilationUnits.map { \n\t\tit.getJavaProject().getProject() \n\t}.toSet() \n}\n\nfun openEditor(file: IFile) {\n\tIDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/findReferences/KotlinFindReferencesAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands.findReferences\n\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.core.search.IJavaSearchScope\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.jdt.internal.ui.JavaPluginImages\nimport org.eclipse.jdt.internal.ui.search.JavaSearchQuery\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.eclipse.jdt.internal.ui.search.SearchMessages\nimport org.eclipse.jdt.internal.ui.search.SearchUtil\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport kotlin.properties.Delegates\n\nabstract class KotlinFindReferencesHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val editor = HandlerUtil.getActiveEditor(event)\n        if (editor !is KotlinCommonEditor) return null\n\n        getAction(editor).run(editor.viewer.selectionProvider.selection as ITextSelection)\n\n        return null\n    }\n\n    abstract fun getAction(editor: KotlinCommonEditor): KotlinFindReferencesAction\n\n}\n\nclass KotlinFindReferencesInProjectHandler : KotlinFindReferencesHandler() {\n    override fun getAction(editor: KotlinCommonEditor): KotlinFindReferencesAction {\n        return KotlinFindReferencesInProjectAction(editor)\n    }\n\n}\n\nclass KotlinFindReferencesInWorkspaceHandler : KotlinFindReferencesHandler() {\n    override fun getAction(editor: KotlinCommonEditor): KotlinFindReferencesAction {\n        return KotlinFindReferencesInWorkspaceAction(editor)\n    }\n}\n\nclass KotlinFindImplementationsInWorkspaceHandler : KotlinFindReferencesHandler() {\n\n    override fun getAction(editor: KotlinCommonEditor): KotlinFindReferencesAction {\n        return KotlinFindImplementationsInWorkspaceAction(editor)\n    }\n}\n\nclass KotlinFindImplementationsInProjectHandler : KotlinFindReferencesHandler() {\n\n    override fun getAction(editor: KotlinCommonEditor): KotlinFindReferencesAction {\n        return KotlinFindImplementationsInProjectAction(editor)\n    }\n}\n\nclass KotlinFindImplementationsInProjectAction(editor: KotlinCommonEditor) : KotlinFindReferencesAction(editor) {\n\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENTORS_IN_WORKSPACE\n        text = SearchMessages.Search_FindImplementorsAction_label\n        toolTipText = SearchMessages.Search_FindImplementorsAction_tooltip\n        imageDescriptor = JavaPluginImages.DESC_OBJS_SEARCH_REF\n        PlatformUI.getWorkbench().helpSystem.setHelp(this, IJavaHelpContextIds.FIND_IMPLEMENTORS_IN_WORKSPACE_ACTION)\n    }\n\n    override fun createScopeQuerySpecification(jetElement: KtElement): QuerySpecification {\n        val factory = JavaSearchScopeFactory.getInstance()\n        return createQuerySpecification(\n            jetElement,\n            factory.createJavaProjectSearchScope(javaProject, false),\n            factory.getProjectScopeDescription(javaProject, false),\n            IMPLEMENTORS_LIMIT_TO\n        )\n    }\n\n    companion object {\n        const val IMPLEMENTORS_LIMIT_TO = 48\n    }\n}\n\nclass KotlinFindImplementationsInWorkspaceAction(editor: KotlinCommonEditor) : KotlinFindReferencesAction(editor) {\n\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENTORS_IN_WORKSPACE\n        text = SearchMessages.Search_FindImplementorsAction_label\n        toolTipText = SearchMessages.Search_FindImplementorsAction_tooltip\n        imageDescriptor = JavaPluginImages.DESC_OBJS_SEARCH_REF\n        PlatformUI.getWorkbench().helpSystem.setHelp(this, IJavaHelpContextIds.FIND_IMPLEMENTORS_IN_WORKSPACE_ACTION)\n    }\n\n    override fun createScopeQuerySpecification(jetElement: KtElement): QuerySpecification {\n        val factory = JavaSearchScopeFactory.getInstance()\n        return createQuerySpecification(\n            jetElement,\n            factory.createWorkspaceScope(false),\n            factory.getWorkspaceScopeDescription(false),\n            KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO\n        )\n    }\n}\n\nclass KotlinFindReferencesInProjectAction(editor: KotlinCommonEditor) : KotlinFindReferencesAction(editor) {\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT\n        text = SearchMessages.Search_FindReferencesInProjectAction_label\n        toolTipText = SearchMessages.Search_FindReferencesInProjectAction_tooltip\n        imageDescriptor = JavaPluginImages.DESC_OBJS_SEARCH_REF\n        PlatformUI.getWorkbench().helpSystem.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_PROJECT_ACTION)\n    }\n\n    companion object {\n        const val ACTION_ID = \"SearchReferencesInProject\"\n    }\n\n    override fun createScopeQuerySpecification(jetElement: KtElement): QuerySpecification {\n        val factory = JavaSearchScopeFactory.getInstance()\n        return createQuerySpecification(\n            jetElement,\n            factory.createJavaProjectSearchScope(javaProject, false),\n            factory.getProjectScopeDescription(javaProject, false)\n        )\n    }\n}\n\nclass KotlinFindReferencesInWorkspaceAction(editor: KotlinCommonEditor) : KotlinFindReferencesAction(editor) {\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE\n        text = SearchMessages.Search_FindReferencesAction_label\n        toolTipText = SearchMessages.Search_FindReferencesAction_tooltip\n        imageDescriptor = JavaPluginImages.DESC_OBJS_SEARCH_REF\n        PlatformUI.getWorkbench().helpSystem.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION)\n    }\n\n    companion object {\n        const val ACTION_ID = \"SearchReferencesInWorkspace\"\n    }\n\n    override fun createScopeQuerySpecification(jetElement: KtElement): QuerySpecification {\n        val factory = JavaSearchScopeFactory.getInstance()\n        return createQuerySpecification(\n            jetElement,\n            factory.createWorkspaceScope(false),\n            factory.getWorkspaceScopeDescription(false)\n        )\n    }\n}\n\nabstract class KotlinFindReferencesAction(val editor: KotlinCommonEditor) : SelectionDispatchAction(editor.site) {\n    var javaProject: IJavaProject by Delegates.notNull()\n\n    override fun run(selection: ITextSelection) {\n        val file = editor.eclipseFile ?: return\n\n        javaProject = JavaCore.create(file.project)\n\n        val jetElement = EditorUtil.getJetElement(editor, selection.offset) ?: return\n\n        val querySpecification = createScopeQuerySpecification(jetElement)\n        val query = JavaSearchQuery(querySpecification)\n\n        SearchUtil.runQueryInBackground(query)\n    }\n\n    abstract fun createScopeQuerySpecification(jetElement: KtElement): QuerySpecification\n}\n\nfun createQuerySpecification(jetElement: KtElement, scope: IJavaSearchScope, description: String, limitTo: Int = IJavaSearchConstants.REFERENCES): QuerySpecification {\n    val sourceElements = jetElement.resolveToSourceDeclaration()\n    return KotlinJavaQuerySpecification(sourceElements, limitTo, scope, description)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/findReferences/querySpecifications.kt",
    "content": "package org.jetbrains.kotlin.ui.commands.findReferences\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.core.search.IJavaSearchScope\nimport org.eclipse.jdt.ui.search.PatternQuerySpecification\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.psi.KtElement\n\ninterface KotlinAndJavaSearchable {\n    val sourceElements: List<SourceElement>\n}\n\ninterface KotlinScoped {\n    val searchScope: List<IFile>\n}\n\nclass KotlinJavaQuerySpecification(\n        override val sourceElements: List<SourceElement>,\n        limitTo: Int,\n        searchScope: IJavaSearchScope,\n        description: String) : KotlinDummyQuerySpecification(searchScope, description, limitTo), KotlinAndJavaSearchable\n\nclass KotlinScopedQuerySpecification(\n        override val sourceElements: List<SourceElement>,\n        override val searchScope: List<IFile>,\n        limitTo: Int,\n        description: String) : KotlinDummyQuerySpecification(EmptyJavaSearchScope, description, limitTo),\n            KotlinAndJavaSearchable, KotlinScoped\n\nclass KotlinOnlyQuerySpecification(\n        val kotlinElement: KtElement,\n        override val searchScope: List<IFile>,\n        limitTo: Int,\n        description: String) : KotlinDummyQuerySpecification(EmptyJavaSearchScope, description, limitTo), KotlinScoped\n\n// After passing this query specification to java, it will try to find some usages and to ensure that nothing will found\n// before KotlinQueryParticipant here is using dummy element '------------'\nabstract class KotlinDummyQuerySpecification(\n    searchScope: IJavaSearchScope,\n    description: String,\n    limitTo: Int = IJavaSearchConstants.REFERENCES\n) : PatternQuerySpecification(\n    \"Kotlin Find ${if (limitTo == IJavaSearchConstants.REFERENCES) \"References\" else if (limitTo == KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO) \"Implementations\" else \"???\"}\",\n    IJavaSearchConstants.CLASS,\n    true,\n    limitTo,\n    searchScope,\n    description\n)\n\nobject EmptyJavaSearchScope : IJavaSearchScope {\n    override fun setIncludesClasspaths(includesClasspaths: Boolean) {\n    }\n\n    override fun setIncludesBinaries(includesBinaries: Boolean) {\n    }\n\n    override fun enclosingProjectsAndJars(): Array<out IPath> {\n        val base = ResourcesPlugin.getWorkspace().getRoot().getLocation()\n        return ResourcesPlugin.getWorkspace().getRoot().getProjects()\n                .map { it.getLocation().makeRelativeTo(base) }\n                .toTypedArray()\n    }\n\n    override fun includesBinaries(): Boolean = false\n\n    override fun includesClasspaths(): Boolean = false\n\n    override fun encloses(resourcePath: String?): Boolean = false\n\n    override fun encloses(element: IJavaElement?): Boolean = false\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/j2k/CompositeUndoableOperation.java",
    "content": "package org.jetbrains.kotlin.ui.commands.j2k;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.operations.AbstractOperation;\nimport org.eclipse.core.commands.operations.ICompositeOperation;\nimport org.eclipse.core.commands.operations.IUndoableOperation;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.IAdaptable;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.IStatus;\nimport org.eclipse.core.runtime.Status;\nimport org.eclipse.ui.ide.undo.WorkspaceUndoUtil;\n\npublic class CompositeUndoableOperation extends AbstractOperation implements ICompositeOperation {\n\n    private final List<IUndoableOperation> operations = new ArrayList<>();\n    \n    public CompositeUndoableOperation(String name) {\n        super(name);\n        this.addContext(WorkspaceUndoUtil.getWorkspaceUndoContext());\n    }\n\n    \n    @Override\n    public void add(IUndoableOperation operation) {\n        operations.add(operation);\n    }\n\n    @Override\n    public void remove(IUndoableOperation operation) {\n        operations.remove(operation);\n    }\n\n    @Override\n    public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        IStatus status = Status.OK_STATUS;\n        for (IUndoableOperation operation : operations) {\n            IStatus executionStatus = operation.execute(monitor, info);\n            if (!executionStatus.isOK()) {\n                status = executionStatus;\n            }\n        }\n        \n        return status;\n    }\n    \n    protected IWorkspace getWorkspace() {\n        return ResourcesPlugin.getWorkspace();\n    }\n\n    @Override\n    public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        for (IUndoableOperation operation : operations) {\n            if (operation.canRedo()) {\n                IStatus redoStatus = operation.redo(monitor, info);\n                if (!redoStatus.isOK()) {\n                    return redoStatus;\n                }\n            }\n        }\n        \n        return Status.OK_STATUS;\n    }\n\n    @Override\n    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        for (IUndoableOperation operation : operations) {\n            if (operation.canUndo()) {\n                IStatus undoStatus = operation.undo(monitor, info);\n                if (!undoStatus.isOK()) {\n                    return undoStatus;\n                }\n            }\n        }\n        \n        return Status.OK_STATUS;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/j2k/JavaToKotlinActionHandler.java",
    "content": "package org.jetbrains.kotlin.ui.commands.j2k;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.Pair;\nimport com.intellij.openapi.util.io.FileUtil;\nimport com.intellij.openapi.util.text.StringUtil;\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.runtime.IStatus;\nimport org.eclipse.core.runtime.Status;\nimport org.eclipse.jdt.core.*;\nimport org.eclipse.jdt.internal.core.CompilationUnit;\nimport org.eclipse.jdt.internal.core.DocumentAdapter;\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IEditorReference;\nimport org.eclipse.ui.ISources;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.handlers.HandlerUtil;\nimport org.eclipse.ui.ide.undo.CreateFileOperation;\nimport org.eclipse.ui.ide.undo.DeleteResourcesOperation;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManagerKt;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.model.KotlinNature;\nimport org.jetbrains.kotlin.j2k.JavaToKotlinTranslatorKt;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtPsiFactory;\nimport org.jetbrains.kotlin.psi.KtPsiFactoryKt;\nimport org.jetbrains.kotlin.ui.Activator;\nimport org.jetbrains.kotlin.ui.commands.CommandsUtilsKt;\nimport org.jetbrains.kotlin.ui.commands.ConvertedKotlinData;\nimport org.jetbrains.kotlin.ui.formatter.KotlinFormatterKt;\nimport org.jetbrains.kotlin.ui.launch.KotlinRuntimeConfigurator;\nimport org.jetbrains.kotlin.wizards.FileCreationOp;\n\nimport java.io.ByteArrayInputStream;\nimport java.nio.charset.StandardCharsets;\nimport java.util.*;\n\nimport static org.eclipse.ui.ide.undo.WorkspaceUndoUtil.getUIInfoAdapter;\n\npublic class JavaToKotlinActionHandler extends AbstractHandler {\n    \n    @Override\n    public Object execute(ExecutionEvent event) throws ExecutionException {\n        ISelection selection = HandlerUtil.getActiveMenuSelection(event);\n        if (selection instanceof IStructuredSelection) {\n            Object[] elements = ((IStructuredSelection) selection).toArray();\n            Set<CompilationUnit> elementsToKotlin = collectCompilationUnits(elements);\n            Set<IProject> projects = CommandsUtilsKt.getCorrespondingProjects(elementsToKotlin);\n            \n            Pair<IStatus, List<IFile>> result = convertToKotlin(elementsToKotlin, HandlerUtil.getActiveShell(event));\n            if (result.getFirst().isOK()) {\n                configureProjectsWithKotlin(projects);\n                \n                List<IFile> convertedFiles = result.getSecond();\n                if (!convertedFiles.isEmpty()) {\n                    CommandsUtilsKt.openEditor(convertedFiles.get(0));\n                }\n            } else {\n                MessageDialog.openError(HandlerUtil.getActiveShell(event), \"Conversion error\", result.getFirst().getMessage());\n            }\n        }\n        \n        return null;\n    }\n    \n    @Override\n    public void setEnabled(Object evaluationContext) {\n        Object selection = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME);\n        if (selection instanceof IStructuredSelection) {\n            Object[] elements = ((IStructuredSelection) selection).toArray();\n            Set<CompilationUnit> elementsToKotlin = collectCompilationUnits(elements);\n            super.setBaseEnabled(!elementsToKotlin.isEmpty());\n        } else {\n            super.setBaseEnabled(false);\n        }\n    }\n    \n    private void closeEditors(@NotNull Set<CompilationUnit> units) {\n        IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow()\n                .getActivePage().getEditorReferences();\n        for (IEditorReference editorReference : editorReferences) {\n            IEditorPart editor = editorReference.getEditor(true);\n            \n            ITypeRoot root = EditorUtility.getEditorInputJavaElement(editor, true);\n            if (root instanceof CompilationUnit) {\n                if (units.contains(root)) {\n                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, true);\n                }\n            }\n        }\n    }\n\n    private void configureProjectsWithKotlin(@NotNull Set<IProject> projects) {\n        for (IProject project : projects) {\n            KotlinNature.Companion.addNature(project);\n            KotlinRuntimeConfigurator.Companion.suggestForProject(project);\n        }\n    }\n    \n    private Set<CompilationUnit> collectCompilationUnits(@NotNull Object[] selectedElements) {\n        Set<CompilationUnit> elementsToKotlin = new LinkedHashSet<>();\n        for (Object element : selectedElements) {\n            if (element instanceof CompilationUnit) {\n                CompilationUnit unit = (CompilationUnit) element;\n                if (JavaCore.isJavaLikeFileName(unit.getElementName())) {\n                    elementsToKotlin.add(unit);\n                }\n            } else if (element instanceof IPackageFragment) {\n                elementsToKotlin.addAll(collectCompilationUnits((IPackageFragment) element));\n            } else if (element instanceof IPackageFragmentRoot) {\n                elementsToKotlin.addAll(collectCompilationUnits((IPackageFragmentRoot) element));\n            }\n        }\n        \n        return elementsToKotlin;\n    }\n    \n    private List<CompilationUnit> collectCompilationUnits(@NotNull IPackageFragmentRoot packageFragmentRoot) {\n        List<CompilationUnit> compilationUnits = new ArrayList<>();\n        try {\n            for (IJavaElement element : packageFragmentRoot.getChildren()) {\n                if (element instanceof IPackageFragment) {\n                    compilationUnits.addAll(collectCompilationUnits((IPackageFragment) element));\n                }\n            }\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return compilationUnits;\n    }\n    \n    private List<CompilationUnit> collectCompilationUnits(@NotNull IPackageFragment packageFragment) {\n        List<CompilationUnit> compilationUnits = new ArrayList<>();\n        try {\n            for (ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {\n                compilationUnits.add((CompilationUnit) compilationUnit);\n            }\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return compilationUnits;\n    }\n    \n    private Pair<IStatus, List<IFile>> convertToKotlin(@NotNull Set<CompilationUnit> compilationUnits, @NotNull Shell shell) {\n        try {\n            List<IFile> convertedFiles = new ArrayList<>();\n            CompositeUndoableOperation compositeOperation = new CompositeUndoableOperation(\"Convert Java to Kotlin\");\n            for (CompilationUnit compilationUnit : compilationUnits) {\n                ConvertedKotlinData convertedFile = getConvertedFileData(compilationUnit, shell);\n                compositeOperation.add(new CreateFileOperation(convertedFile.getFile(), null, \n                        new ByteArrayInputStream(convertedFile.getKotlinFileData().getBytes(StandardCharsets.UTF_8)), \"Create Kotlin File\")\n                );\n\n                // File created with CreateFileOperation inherits character encoding from parent container.\n                // Which, of course, can be different from UTF-8.\n                compositeOperation.add(\n                    new SetFileCharsetOperation(convertedFile.getFile(), \"UTF-8\")\n                );\n                \n                convertedFiles.add(convertedFile.getFile());\n            }\n                \n            DeleteResourcesOperation deleteCompilationUnits = CommandsUtilsKt.getDeleteOperation(compilationUnits);\n            compositeOperation.add(deleteCompilationUnits);\n            \n            closeEditors(compilationUnits);\n            PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(\n                    compositeOperation, null, getUIInfoAdapter(shell));\n            \n            return new Pair<>(Status.OK_STATUS, convertedFiles);\n        } catch (ExecutionException e) {\n            KotlinLogger.logError(e.getMessage(), null);\n            return new Pair<>(new Status(IStatus.ERROR, Activator.Companion.getPLUGIN_ID(), e.getMessage()), Collections.<IFile>emptyList());\n        }\n    }\n    \n    private ConvertedKotlinData getConvertedFileData(@NotNull CompilationUnit compilationUnit, @NotNull Shell shell) throws ExecutionException {\n        String contents = StringUtil.convertLineSeparators(new String(compilationUnit.getContents()));\n        IProject eclipseProject = compilationUnit.getJavaProject().getProject();\n        Project ideaProject = KotlinEnvironment.Companion.getEnvironment(eclipseProject).getProject();\n        \n        String translatedCode = ConverterUtilsKt.prettify(\n                JavaToKotlinTranslatorKt.translateToKotlin(contents, ideaProject));\n        KtFile jetFile = getJetFile(translatedCode, eclipseProject);\n        \n        String formattedCode = KotlinFormatterKt.formatCode(\n                jetFile.getNode().getText(),\n                jetFile.getName(),\n                KtPsiFactoryKt.KtPsiFactory(jetFile),\n                KotlinCodeStyleManagerKt.getCodeStyle(eclipseProject));\n        \n        String fileName = FileUtil.getNameWithoutExtension(compilationUnit.getElementName());\n        IFile file = FileCreationOp.makeFile((IPackageFragment) compilationUnit.getParent(), compilationUnit.getPackageFragmentRoot(), fileName);\n        if (file.exists()) {\n            throw new ExecutionException(\"Could not convert file: \" + compilationUnit.getElementName() + \". Because of existing file: \" + file.getName());\n        }\n        \n        return new ConvertedKotlinData(file, formattedCode);\n    }\n    \n    private String getDefaultLineDelimiter(CompilationUnit unit) {\n        try {\n            IBuffer buffer = unit.getBuffer();\n            IDocument document;\n            if (buffer instanceof IDocument) {\n                document = (IDocument) buffer;\n            } else {\n                document = new DocumentAdapter(buffer);\n            }\n            \n            return TextUtilities.getDefaultLineDelimiter(document);\n        } catch (JavaModelException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    private KtFile getJetFile(@NotNull String sourceCode, @NotNull IProject eclipseProject) {\n        Project ideaProject = KotlinEnvironment.Companion.getEnvironment(eclipseProject).getProject();\n        return new KtPsiFactory(ideaProject).createFile(sourceCode);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/j2k/SetFileCharsetOperation.java",
    "content": "package org.jetbrains.kotlin.ui.commands.j2k;\n\nimport static org.jetbrains.kotlin.ui.Activator.Companion;\n\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.operations.AbstractOperation;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IAdaptable;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.IStatus;\nimport org.eclipse.core.runtime.Status;\n\npublic class SetFileCharsetOperation extends AbstractOperation {\n\n    private static final String SET_FILE_CHARSET_OPERATION_TITLE = \"Set file charset\";\n\n    private final IFile file;\n    private String charset; \n    private boolean applied;\n\n    public SetFileCharsetOperation(IFile file, String charset) {\n        super(SET_FILE_CHARSET_OPERATION_TITLE);\n        this.file = file;\n        this.charset = charset;\n        this.applied = false;\n    }\n\n    @Override\n    public boolean canExecute() {\n        return !applied;\n    }\n\n    @Override\n    public boolean canRedo() {\n        return canExecute();\n    }\n\n    @Override\n    public boolean canUndo() {\n        return applied;\n    }\n\n    @Override\n    public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        return toggleEncoding(monitor, info);\n    }\n\n    @Override\n    public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        return execute(monitor, info);\n    }\n\n    @Override\n    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        return toggleEncoding(monitor, info);\n    }\n\n    private IStatus toggleEncoding(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {\n        try {\n            String previousCharset = file.getCharset();\n            file.setCharset(charset, monitor);\n            charset = previousCharset;\n            applied = !applied;\n            return Status.OK_STATUS;\n        } catch (CoreException e) {\n            return new Status(IStatus.ERROR, Companion.getPLUGIN_ID(), \"Unable to change file charset.\", e);\n        }\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/j2k/converterUtils.kt",
    "content": "package org.jetbrains.kotlin.ui.commands.j2k\n\nfun prettify(code: String?): String {\n    if (code == null) {\n        return \"\"\n    }\n\n    return code\n            .trim()\n            .replace(\"\\r\\n\", \"\\n\")\n            .replace(\" \\n\", \"\\n\")\n            .replace(\"\\n \", \"\\n\")\n            .replace(\"\\n+\".toRegex(), \"\\n\")\n            .replace(\" +\".toRegex(), \" \")\n            .trim()\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/psiVisualization/PsiContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands.psiVisualization;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.intellij.lang.ASTNode;\n\npublic class PsiContentProvider implements ITreeContentProvider {\n\n    @Override\n    public void dispose() {\n    }\n\n    @Override\n    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n    }\n\n    @Override\n    public Object[] getElements(Object inputElement) {\n        return getChildren(inputElement);\n    }\n\n    @Override\n    public Object[] getChildren(Object parentElement) {\n        return ((ASTNode) parentElement).getChildren(null);\n    }\n\n    @Override\n    public Object getParent(Object element) {\n        return null;\n    }\n\n    @Override\n    public boolean hasChildren(Object element) {\n        return ((ASTNode) element).getFirstChildNode() != null;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/psiVisualization/PsiVisualization.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands.psiVisualization;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.ISources;\nimport org.eclipse.ui.handlers.HandlerUtil;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor;\n\npublic class PsiVisualization extends AbstractHandler {\n\n    @Override\n    public Object execute(ExecutionEvent event) throws ExecutionException {\n        IEditorPart editor = HandlerUtil.getActiveEditor(event);\n\n        assert editor instanceof KotlinFileEditor : \"Unsupported editor class: \" + editor == null ? \"NULL\" : editor.getClass().getName();\n        \n        IFile file = EditorUtil.getFile(editor);\n        if (file != null) {\n            String sourceCode = EditorUtil.getSourceCode((KotlinEditor) editor);\n\n            new VisualizationPage(HandlerUtil.getActiveShell(event), sourceCode, file).open();\n        } else {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null);\n        }\n        \n        return null;\n    }\n\n    @Override\n    public void setEnabled(Object evaluationContext) {\n        Object editorObject = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_EDITOR_NAME);\n        setBaseEnabled(editorObject instanceof KotlinFileEditor);\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/commands/psiVisualization/VisualizationPage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.commands.psiVisualization;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.openapi.util.TextRange;\n\npublic final class VisualizationPage extends Dialog {\n\n    private final Point pageSize = new Point(750, 650);\n    private final String sourceCode;\n    private final IFile file;\n    \n    private final String title = \"Psi Viewer\";\n    \n    public VisualizationPage(Shell parentShell, String sourceCode, IFile file) {\n        super(parentShell);\n        \n        if (sourceCode == null || file == null || !file.exists()) {\n            throw new IllegalArgumentException();\n        }\n        \n        this.sourceCode = sourceCode;\n        this.file = file;\n    }\n    \n    @Override\n    protected Control createDialogArea(Composite parent) {\n        Composite composite = (Composite) super.createDialogArea(parent);\n        \n        createControls(composite);\n        \n        return composite;\n    }\n    \n    private void createControls(Composite composite) {\n        setDescriptionLabel(composite);\n        Text programText = setTextProgram(composite);\n        setTreeViewer(composite, programText);\n    }\n    \n    private void setTreeViewer(Composite composite, final Text programText) {\n        TreeViewer psiTreeViewer = new TreeViewer(composite);\n        psiTreeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));\n        psiTreeViewer.setContentProvider(new PsiContentProvider());\n        psiTreeViewer.setLabelProvider(new LabelProvider());\n        \n        ASTNode parsedAst = KotlinPsiManager.INSTANCE.getParsedFile(file).getNode();\n        psiTreeViewer.setInput(parsedAst);\n        \n        final String parsedText = parsedAst.getText();\n        \n        final IDocument document = EditorUtil.getDocument(file);\n        \n        psiTreeViewer.addDoubleClickListener(new IDoubleClickListener() {            \n            @Override\n            public void doubleClick(DoubleClickEvent event) {\n                IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();\n                ASTNode selectedNode = (ASTNode) thisSelection.getFirstElement();\n                TextRange selectedNodeRange = selectedNode.getTextRange();\n                \n                int start = LineEndUtil.convertLfToDocumentOffset(parsedText, selectedNodeRange.getStartOffset(), document);\n                int end = LineEndUtil.convertLfToDocumentOffset(parsedText, selectedNodeRange.getEndOffset(), document);\n                \n                programText.setSelection(start, end);\n                programText.showSelection();\n            }\n        });\n    }\n    \n    private void setDescriptionLabel(Composite composite) {\n        Label descriptionLabel = new Label(composite, SWT.LEFT | SWT.FILL);\n        descriptionLabel.setText(\"Shows PSI structure for Kotlin file: \" + file.getName());\n        \n        Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);\n        GridData sgd = new GridData(GridData.FILL_HORIZONTAL);\n        separator.setLayoutData(sgd);\n        \n    }\n    \n    private Text setTextProgram(Composite composite) {\n        final Text programText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);\n        programText.setEditable(false);\n        programText.setText(sourceCode);\n        GridData pgd = new GridData(GridData.FILL_HORIZONTAL);\n        pgd.heightHint = pageSize.y / 3;\n        programText.setLayoutData(pgd);\n        \n        return programText;\n    }\n\n    @Override\n    protected void createButtonsForButtonBar(Composite parent) {\n        Button closeButton = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);\n        closeButton.addSelectionListener(new SelectionAdapter() {\n            \n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                setReturnCode(OK);\n                close();\n            }\n        });\n    }\n    \n    @Override\n    protected Point getInitialSize() {\n        return pageSize;\n    }\n    \n    @Override\n    protected void configureShell(Shell shell) {\n        super.configureShell(shell);\n        shell.setText(title);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/debug/KotlinRunToLineAdapter.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.debug\n\nimport org.eclipse.debug.ui.actions.IRunToLineTarget\nimport org.eclipse.ui.IWorkbenchPart\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.debug.core.model.ISuspendResume\nimport org.eclipse.debug.core.model.IDebugElement\nimport org.eclipse.jface.text.ITextSelection\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.core.runtime.Status\nimport org.jetbrains.kotlin.ui.Activator\nimport org.eclipse.jdt.debug.ui.IJavaDebugUIConstants\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.eclipse.debug.core.model.IBreakpoint\nimport java.util.HashMap\nimport org.eclipse.jdt.internal.debug.ui.BreakpointUtils\nimport org.eclipse.jdt.debug.core.JDIDebugModel\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jdt.debug.core.IJavaLineBreakpoint\nimport org.eclipse.core.runtime.IAdaptable\nimport org.eclipse.debug.core.model.IDebugTarget\nimport org.eclipse.debug.ui.actions.RunToLineHandler\nimport org.eclipse.core.runtime.NullProgressMonitor\n\nobject KotlinRunToLineAdapter : IRunToLineTarget {\n    override fun runToLine(part: IWorkbenchPart, selection: ISelection, target: ISuspendResume) {\n        val editor = getEditor(part)\n        if (editor == null) throw CoreException(createErrorStatus(\"Missing editor for $part\"))\n        \n        val file = editor.eclipseFile\n        if (file == null) throw CoreException(createErrorStatus(\"Missing file for $editor\"))\n        \n        if (target is IAdaptable) {\n            val debugTarget = target.getAdapter(IDebugTarget::class.java)\n            if (debugTarget == null) return\n            \n            val lineNumber = (selection as ITextSelection).getStartLine() + 1\n            val typeName = findTopmostTypeName(editor.document, lineNumber, file)\n            \n            if (typeName == null) throw CoreException(createErrorStatus(\"Line is not valid $lineNumber\"))\n            \n            val breakpoint = createRunToLineBreakpoint(typeName.asString(), lineNumber)\n            val handler = RunToLineHandler(debugTarget, target, breakpoint)\n            handler.run(NullProgressMonitor())\n            return\n        }\n    }\n    \n    override fun canRunToLine(part: IWorkbenchPart, selection: ISelection, target: ISuspendResume): Boolean {\n        return target is IDebugElement && target.canResume()\n    }\n    \n    private fun createRunToLineBreakpoint(typeName: String, lineNumber: Int): IJavaLineBreakpoint {\n        val attributes = HashMap<String, Any>(4)\n        BreakpointUtils.addRunToLineAttributes(attributes)\n        return JDIDebugModel.createLineBreakpoint(ResourcesPlugin.getWorkspace().getRoot(), typeName, \n                lineNumber, -1, -1, 1, false, attributes)\n    }\n    \n    private fun createErrorStatus(message: String): Status {\n        return Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR, message, null)\n    }\n}\n\nprivate fun getEditor(part: IWorkbenchPart): KotlinFileEditor? {\n    return (part as? KotlinFileEditor) ?: (part.getAdapter(KotlinFileEditor::class.java) as? KotlinFileEditor)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/debug/KotlinToggleBreakpointAdapter.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.debug\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.debug.ui.actions.IToggleBreakpointsTarget\nimport org.eclipse.jdt.debug.core.IJavaLineBreakpoint\nimport org.eclipse.jdt.debug.core.JDIDebugModel\nimport org.eclipse.jface.text.BadLocationException\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.ui.IWorkbenchPart\nimport org.eclipse.ui.texteditor.ITextEditor\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtPsiUtil\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\n\nobject KotlinToggleBreakpointAdapter : IToggleBreakpointsTarget {\n    override public fun toggleLineBreakpoints(part: IWorkbenchPart, selection: ISelection) {\n        val editor = getEditor(part)\n        if (editor == null) return\n        \n        val file = EditorUtil.getFile(editor)\n        if (file == null) {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null)\n            return\n        }\n        \n        val lineNumber = (selection as ITextSelection).getStartLine() + 1\n        val document = editor.getDocumentProvider().getDocument(editor.getEditorInput())\n        val typeName = findTopmostTypeName(document, lineNumber, file)\n        if (typeName == null) return\n        \n        val existingBreakpoint = JDIDebugModel.lineBreakpointExists(file, typeName.asString(), lineNumber)\n        if (existingBreakpoint != null) {\n            existingBreakpoint.delete()\n        } else {\n            JDIDebugModel.createLineBreakpoint(file, typeName.asString(), lineNumber, -1, -1, 0, true, null)\n        }\n    }\n    \n    override public fun canToggleLineBreakpoints(part: IWorkbenchPart, selection: ISelection): Boolean = true\n    \n    override public fun toggleMethodBreakpoints(part: IWorkbenchPart, selection: ISelection) {}\n    \n    override public fun canToggleMethodBreakpoints(part: IWorkbenchPart, selection: ISelection): Boolean = true\n    \n    override public fun toggleWatchpoints(part: IWorkbenchPart, selection: ISelection) {}\n    \n    override public fun canToggleWatchpoints(part: IWorkbenchPart, selection: ISelection): Boolean = true\n    \n    private fun getEditor(part: IWorkbenchPart): ITextEditor? {\n        return if (part is ITextEditor) part else part.getAdapter(ITextEditor::class.java)\n    }\n}\n\nfun findTopmostTypeName(document: IDocument, lineNumber: Int, file: IFile): FqName? {\n    val kotlinParsedFile = KotlinPsiManager.getParsedFile(file)\n    return findTopmostType(document.getLineOffset(lineNumber - 1), kotlinParsedFile)\n}\n\nfun findTopmostType(offset: Int, jetFile: KtFile): FqName? {\n    val element = jetFile.findElementAt(offset)\n    val jetClassOrObject = KtPsiUtil.getTopmostParentOfTypes(element, KtClassOrObject::class.java)\n    if (jetClassOrObject != null) {\n        val classOrObject = jetClassOrObject as KtClassOrObject\n        val fqName = classOrObject.getFqName()\n        if (fqName != null) return fqName\n    }\n    \n    return JvmFileClassUtil.getFileClassInfoNoResolve(jetFile).fileClassFqName\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/debug/commands/KotlinStepIntoSelectionHandler.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.debug.commands\n\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jdt.internal.debug.ui.EvaluationContextManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.core.references.getReferenceExpression\nimport org.jetbrains.kotlin.core.references.resolveToSourceElements\nimport org.jetbrains.kotlin.core.references.createReferences\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElement\nimport org.jetbrains.kotlin.core.model.sourceElementsToLightElements\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.debug.core.IJavaStackFrame\nimport org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionHandler\nimport org.eclipse.jdt.debug.core.IJavaThread\nimport org.eclipse.jdt.core.IMethod\nimport org.jetbrains.kotlin.ui.debug.findTopmostType\nimport org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionUtils\nimport org.eclipse.ui.IEditorPart\nimport org.eclipse.debug.core.model.IThread\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.eclipse.jdt.core.IType\n\nclass KotlinStepIntoSelectionHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val editor = HandlerUtil.getActiveEditor(event) as KotlinFileEditor\n        val selection = editor.editorSite.selectionProvider.selection\n        if (selection is ITextSelection) {\n            stepIntoSelection(editor, selection)\n        }\n        \n        return null\n    }\n}\n\nprivate fun stepIntoSelection(editor: KotlinFileEditor, selection: ITextSelection) {\n    val frame = EvaluationContextManager.getEvaluationContext(editor)\n    if (frame == null || !frame.isSuspended) return\n    \n    val psiElement = EditorUtil.getPsiElement(editor, selection.offset) ?: return\n\n    val expression = getReferenceExpression(psiElement) ?: return\n\n    val sourceElements = createReferences(expression).resolveToSourceElements(expression.containingKtFile)\n    val javaElements = sourceElementsToLightElements(sourceElements)\n    if (javaElements.size > 1) {\n        KotlinLogger.logWarning(\"There are more than one java element for $sourceElements\")\n        return\n    }\n\n    val method = when (val element = javaElements.first()) {\n        is IMethod -> element\n        is IType -> element.getMethod(element.elementName, emptyArray())\n        else -> null\n    } ?: return\n\n    stepIntoElement(method, frame, selection, editor)\n}\n\nprivate fun stepIntoElement(method: IMethod, frame: IJavaStackFrame, selection: ITextSelection, editor: KotlinFileEditor) {\n    if (selection.startLine + 1 == frame.lineNumber) {\n        val handler = StepIntoSelectionHandler(frame.thread as IJavaThread, frame, method)\n        handler.step()\n    } else {\n        val refMethod = StepIntoSelectionUtils::class.java.getDeclaredMethod(\n                \"runToLineBeforeStepIn\",\n                IEditorPart::class.java,\n                String::class.java,\n                ITextSelection::class.java,\n                IThread::class.java,\n                IMethod::class.java)\n        refMethod.isAccessible = true\n        refMethod.invoke(null, editor, frame.receivingTypeName, selection, frame.thread, method)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/Configuration.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors;\n\nimport java.util.Map;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.IAdaptable;\nimport org.eclipse.jdt.internal.ui.text.JavaPartitionScanner;\nimport org.eclipse.jdt.ui.text.IColorManager;\nimport org.eclipse.jdt.ui.text.IJavaPartitions;\nimport org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.text.DefaultInformationControl;\nimport org.eclipse.jface.text.IAutoEditStrategy;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IInformationControl;\nimport org.eclipse.jface.text.IInformationControlCreator;\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.ITextHover;\nimport org.eclipse.jface.text.ITextViewer;\nimport org.eclipse.jface.text.Region;\nimport org.eclipse.jface.text.TextPresentation;\nimport org.eclipse.jface.text.contentassist.IContentAssistant;\nimport org.eclipse.jface.text.information.IInformationPresenter;\nimport org.eclipse.jface.text.information.IInformationProvider;\nimport org.eclipse.jface.text.information.IInformationProviderExtension;\nimport org.eclipse.jface.text.information.InformationPresenter;\nimport org.eclipse.jface.text.presentation.IPresentationReconciler;\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.quickassist.IQuickAssistAssistant;\nimport org.eclipse.jface.text.reconciler.IReconciler;\nimport org.eclipse.jface.text.rules.DefaultDamagerRepairer;\nimport org.eclipse.jface.text.source.DefaultAnnotationHover;\nimport org.eclipse.jface.text.source.IAnnotationHover;\nimport org.eclipse.jface.text.source.ISourceViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.texteditor.AbstractTextEditor;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.ui.editors.highlighting.KotlinTokenScanner;\nimport org.jetbrains.kotlin.ui.editors.hover.KotlinInformationProvider;\nimport org.jetbrains.kotlin.ui.editors.hover.KotlinTextHover;\nimport org.jetbrains.kotlin.ui.editors.outline.KotlinOutlinePopup;\n\npublic class Configuration extends JavaSourceViewerConfiguration {\n    private KotlinTokenScanner scanner;\n    private final KotlinEditor editor;\n\n    public Configuration(@NotNull IColorManager colorManager, @NotNull KotlinEditor editor, IPreferenceStore preferenceStore) {\n        super(colorManager, preferenceStore, editor.getJavaEditor(), IJavaPartitions.JAVA_PARTITIONING);\n        this.editor = editor;\n    }\n    \n    @Override\n    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {\n        return new String[] {\n            IDocument.DEFAULT_CONTENT_TYPE,\n            IJavaPartitions.JAVA_DOC,\n            IJavaPartitions.JAVA_MULTI_LINE_COMMENT,\n            IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,\n            IJavaPartitions.JAVA_STRING,\n            IJavaPartitions.JAVA_CHARACTER\n        };\n    }\n    \n    @Override\n    public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {\n        InformationPresenter presenter = new InformationPresenter(new IInformationControlCreator() {\n            @Override\n            public IInformationControl createInformationControl(Shell parent) {\n                int shellStyle= SWT.RESIZE;\n                int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;\n                return new KotlinOutlinePopup(editor, parent, shellStyle, treeStyle);\n            }\n        });\n        \n        presenter.setInformationProvider(new OutlineInformationProvider(editor.getJavaEditor()), IDocument.DEFAULT_CONTENT_TYPE);\n        presenter.setSizeConstraints(45, 15, true, false);\n        \n        return presenter;\n    }\n    \n    @Override\n    public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {\n        InformationPresenter presenter= new InformationPresenter(new IInformationControlCreator() {\n            @Override\n            public IInformationControl createInformationControl(Shell parent) {\n                return new DefaultInformationControl(parent, true);\n            }\n        });\n        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));\n        \n        IInformationProvider provider = new KotlinInformationProvider(editor);\n        for (String contentType : getConfiguredContentTypes(sourceViewer)) {\n            presenter.setInformationProvider(provider, contentType);\n        }\n        \n        presenter.setSizeConstraints(100, 12, false, true);\n        return presenter;\n    }\n\n    @Override\n    public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {\n        return new DefaultAnnotationHover();\n    }\n    \n    @Override\n    public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {\n        return getTextHover(sourceViewer, contentType);\n    }\n\n    @Override\n    public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {\n        return new KotlinTextHover(editor);\n    }\n\n    @Override\n    public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {\n        return null;\n    }\n    \n    @Override\n    public IReconciler getReconciler(ISourceViewer sourceViewer) {\n        return null;\n    }\n\n    @Nullable\n    public KotlinTokenScanner getScanner() {\n        if (scanner == null) {\n            scanner = KotlinTokenScanner.createScanner(fPreferenceStore, getColorManager(), editor);\n        }\n\n        return scanner;\n    }\n    \n    @Override\n    public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {\n        return new String[] { \"//\", \"\" };\n    }\n    \n    @Override\n    public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {\n        return null;\n    }\n    \n    @Override\n    public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {\n        return JavaPartitionScanner.JAVA_PARTITIONING;\n    }\n    \n    @Override\n    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\n        KotlinTokenScanner scanner = getScanner();\n        return scanner != null ? getKotlinPresentaionReconciler(scanner) : null;\n    }\n\n    @Override\n    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {\n        return null;\n    }\n    \n    private static class OutlineInformationProvider implements IInformationProvider, IInformationProviderExtension {\n        \n        private final AbstractTextEditor editor;\n        \n        public OutlineInformationProvider(AbstractTextEditor editor) {\n            this.editor = editor;\n        }\n        \n        @Override\n        public IRegion getSubject(ITextViewer textViewer, int offset) {\n            return new Region(offset, 0);\n        }\n        \n        @Override\n        public String getInformation(ITextViewer textViewer, IRegion subject) {\n            Object result = getInformation2(textViewer, subject);\n            return result != null ? result.toString() : null;\n        }\n        \n        @Override\n        public Object getInformation2(ITextViewer textViewer, IRegion subject) {\n            IFile file = EditorUtil.getFile(editor);\n            if (file != null) {\n                return KotlinPsiManager.INSTANCE.getParsedFile(file);\n            } \n            \n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null);\n            return null;\n        }\n    }\n    \n    @Override\n    protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {\n        Map<String, IAdaptable> targets = super.getHyperlinkDetectorTargets(sourceViewer);\n        targets.remove(\"org.eclipse.jdt.ui.javaCode\");\n        targets.put(\"org.jetbrains.kotlin.ui.editors.kotlinCode\", getEditor());\n        \n        return targets;\n    }\n    \n    public static KotlinPresentationReconciler getKotlinPresentaionReconciler(@NotNull KotlinTokenScanner scanner) {\n        DefaultDamagerRepairer kotlinDamagerRepairer = new DefaultDamagerRepairer(scanner);\n        \n        KotlinPresentationReconciler reconciler = new KotlinPresentationReconciler();\n        reconciler.setDamager(kotlinDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);\n        reconciler.setRepairer(kotlinDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);\n        \n        return reconciler;\n    }\n    \n    public static class KotlinPresentationReconciler extends PresentationReconciler {\n        private volatile IDocument lastDocument = null;\n        \n        public TextPresentation createRepairDescription(IRegion damage, IDocument document) {\n            if (document != lastDocument) {\n                setDocumentToDamagers(document);\n                setDocumentToRepairers(document);\n                lastDocument = document;\n            }\n            \n            return createPresentation(damage, document);\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/FileEditorConfiguration.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.ui.PreferenceConstants\nimport org.eclipse.jdt.ui.text.IColorManager\nimport org.eclipse.jface.preference.IPreferenceStore\nimport org.eclipse.jface.preference.PreferenceConverter\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.contentassist.ContentAssistant\nimport org.eclipse.jface.text.contentassist.IContentAssistant\nimport org.eclipse.jface.text.quickassist.IQuickAssistAssistant\nimport org.eclipse.jface.text.quickassist.QuickAssistAssistant\nimport org.eclipse.jface.text.reconciler.IReconciler\nimport org.eclipse.jface.text.reconciler.MonoReconciler\nimport org.eclipse.jface.text.source.ISourceViewer\nimport org.eclipse.swt.graphics.Color\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinCompletionProcessor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinContextInfoContentAssistProcessor\n\nclass FileEditorConfiguration(colorManager: IColorManager,\n        private val fileEditor: KotlinEditor,\n        preferenceStore: IPreferenceStore,\n        private val reconcilingStrategy: KotlinReconcilingStrategy): Configuration(colorManager, fileEditor, preferenceStore) {\n    override fun getQuickAssistAssistant(sourceViewer: ISourceViewer): IQuickAssistAssistant? {\n        val quickAssist = QuickAssistAssistant()\n        quickAssist.quickAssistProcessor = KotlinCorrectionProcessor(fileEditor)\n        quickAssist.setInformationControlCreator(getInformationControlCreator(sourceViewer))\n        return quickAssist\n    }\n\n    override fun getReconciler(sourceViewer: ISourceViewer): IReconciler {\n        return MonoReconciler(reconcilingStrategy, false)\n    }\n\n    override fun getAutoEditStrategies(sourceViewer: ISourceViewer, contentType: String) =\n            arrayOf(KotlinAutoIndentStrategy(fileEditor))\n\n    override fun getContentAssistant(sourceViewer: ISourceViewer): IContentAssistant = ContentAssistant(true).apply {\n        KotlinCompletionProcessor.createKotlinCompletionProcessors(fileEditor, this).forEach {\n            addContentAssistProcessor(it, IDocument.DEFAULT_CONTENT_TYPE)\n        }\n\n        addContentAssistProcessor(KotlinContextInfoContentAssistProcessor(fileEditor), IDocument.DEFAULT_CONTENT_TYPE)\n\n        val autoActivation = fPreferenceStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION)\n        enableAutoActivation(autoActivation)\n        \n        val delay = fPreferenceStore.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)\n        autoActivationDelay = delay\n        \n        val foregroundColor = getColor(fPreferenceStore, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, colorManager)\n        setContextInformationPopupForeground(foregroundColor)\n        setContextSelectorForeground(foregroundColor)\n        \n        val backgroundColor = getColor(fPreferenceStore, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, colorManager)\n        setContextInformationPopupBackground(backgroundColor)\n        setContextSelectorBackground(backgroundColor)\n        \n        val autoInsert = fPreferenceStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT)\n        enableAutoInsert(autoInsert)\n        \n        setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY)\n        setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE)\n        \n        enableColoredLabels(true)\n        \n        setShowEmptyList(true)\n    }\n}\n\nfun getColor(store: IPreferenceStore, key: String, manager: IColorManager): Color {\n    val rgb = PreferenceConverter.getColor(store, key)\n    return manager.getColor(rgb)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinActionGroup.kt",
    "content": "/*******************************************************************************\n\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.internal.ui.actions.JDTQuickMenuCreator\nimport org.eclipse.jdt.ui.actions.GenerateActionGroup\nimport org.eclipse.jdt.ui.actions.RefactorActionGroup\nimport org.eclipse.jface.action.IMenuManager\nimport org.eclipse.jface.action.MenuManager\nimport org.eclipse.jface.action.Separator\nimport org.eclipse.ui.actions.ActionGroup\nimport org.eclipse.ui.handlers.IHandlerActivation\nimport org.eclipse.ui.handlers.IHandlerService\nimport org.eclipse.ui.texteditor.ITextEditorActionConstants\nimport org.jetbrains.kotlin.ui.editors.organizeImports.KotlinOrganizeImportsAction\nimport org.jetbrains.kotlin.ui.overrideImplement.KotlinOverrideMembersAction\nimport org.jetbrains.kotlin.ui.refactorings.extract.KotlinExtractVariableAction\nimport org.jetbrains.kotlin.ui.refactorings.rename.KotlinRenameAction\n\nclass KotlinRefactorActionGroup(editor: KotlinCommonEditor, menuId: String, menuLabel: String, quickMenuId: String) :\n        KotlinActionGroup(editor, menuId, menuLabel, quickMenuId) {\n    \n    init {\n        installQuickAccessAction()\n    }\n    \n    override fun fillSubmenu(submenu: IMenuManager) {\n        with(submenu) {\n            add(Separator(RefactorActionGroup.GROUP_REORG))\n            addAction(KotlinRenameAction.ACTION_ID)\n            \n            add(Separator(RefactorActionGroup.GROUP_CODING))\n            addAction(KotlinExtractVariableAction.ACTION_ID)\n        }\n    }\n}\n\nclass KotlinGenerateActionGroup(editor: KotlinCommonEditor, menuId: String, menuLabel: String, quickMenuId: String) :\n        KotlinActionGroup(editor, menuId, menuLabel, quickMenuId) {\n    \n    init {\n        installQuickAccessAction()\n    }\n    \n    override fun fillSubmenu(submenu: IMenuManager) {\n        with(submenu) {\n            add(Separator(\"commentGroup\"))\n            addAction(\"ToggleComment\")\n            addAction(\"AddBlockComment\")\n            addAction(\"RemoveBlockComment\")\n            \n            add(Separator(\"editGroup\"))\n            addAction(\"Indent\")\n            addAction(\"Format\")\n            addAction(\"QuickFormat\")\n            \n            add(Separator(GenerateActionGroup.GROUP_IMPORT))\n            addAction(KotlinOrganizeImportsAction.ACTION_ID)\n            \n            add(Separator(GenerateActionGroup.GROUP_GENERATE))\n            addAction(KotlinOverrideMembersAction.ACTION_ID)\n        }\n    }\n}\n\nabstract class KotlinActionGroup(\n        private val editor: KotlinCommonEditor,\n        private val menuId: String,\n        private val menuLabel: String,\n        private val quickMenuId: String) : ActionGroup() {\n\n    var handlerService: IHandlerService? = null\n    var menuHandlerActivation: IHandlerActivation? = null\n    \n    override fun fillContextMenu(menu: IMenuManager) {\n        super.fillContextMenu(menu)\n        addSubmenu(menu)\n    }\n    \n    abstract fun fillSubmenu(submenu: IMenuManager)\n    \n    protected fun installQuickAccessAction() {\n        handlerService = editor.site.getService(IHandlerService::class.java) ?: return\n        \n        val menuHandler = object : JDTQuickMenuCreator(editor.javaEditor) {\n            override fun fillMenu(menu: IMenuManager) {\n                fillSubmenu(menu)\n            }\n        }.createHandler()\n        \n        menuHandlerActivation = handlerService?.activateHandler(quickMenuId, menuHandler)\n    }\n    \n    protected fun IMenuManager.addAction(actionId: String) {\n        val action = editor.getAction(actionId)\n        if (action != null && action.isEnabled) {\n            add(action)\n        }\n    }\n    \n    override fun dispose() {\n        super.dispose()\n        \n        if (handlerService != null && menuHandlerActivation != null) {\n            handlerService!!.deactivateHandler(menuHandlerActivation)\n        }\n    }\n    \n    private fun addSubmenu(menu: IMenuManager) {\n        val submenu = MenuManager(menuLabel, menuId).apply { setActionDefinitionId(quickMenuId) }\n        \n        fillSubmenu(submenu)\n        \n        menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, submenu)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinAutoIndentStrategy.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors;\n\nimport com.intellij.formatting.FormatterImpl;\nimport com.intellij.formatting.Indent;\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jface.text.*;\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManager;\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManagerKt;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.idea.formatter.KotlinSpacingRulesKt;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtPsiFactory;\nimport org.jetbrains.kotlin.ui.formatter.KotlinBlock;\nimport org.jetbrains.kotlin.ui.formatter.KotlinFormatterKt;\nimport org.jetbrains.kotlin.ui.formatter.KotlinSpacingBuilderUtilImpl;\n\npublic class KotlinAutoIndentStrategy implements IAutoEditStrategy {\n    \n    private static final char OPENING_BRACE_CHAR = '{';\n    private static final char CLOSING_BRACE_CHAR = '}';\n    private static final String CLOSING_BRACE_STRING = Character.toString(CLOSING_BRACE_CHAR);\n    \n    private final KotlinEditor editor;\n    \n    public KotlinAutoIndentStrategy(KotlinEditor editor) {\n        this.editor = editor;\n        new FormatterImpl();\n    }\n    \n    @Override\n    public void customizeDocumentCommand(IDocument document, DocumentCommand command) {\n        if (command.doit == false) {\n            return;\n        }\n\n        if (command.length == 0 && command.text != null && isNewLine(document, command.text)) {\n            autoEditAfterNewLine(document, command);\n        } else if (CLOSING_BRACE_STRING.equals(command.text)) {\n            autoEditBeforeCloseBrace(document, command);\n        }\n    }\n    \n    private void autoEditAfterNewLine(IDocument document, DocumentCommand command) {\n        if (command.offset == -1 || document.getLength() == 0) {\n            return;\n        }\n        \n        try {\n            int p = command.offset == document.getLength() ? command.offset - 1 : command.offset;\n            IRegion info = document.getLineInformationOfOffset(p);\n            \n            int start = info.getOffset();\n            \n            boolean afterOpenBrace = isAfterOpenBrace(document, command.offset - 1, start);\n            boolean beforeCloseBrace = isBeforeCloseBrace(document, command.offset, info.getOffset() + info.getLength());\n            int oldOffset = command.offset;\n            int newOffset = findEndOfWhiteSpace(document, command.offset - 1) + 1;\n            if (newOffset > 0 && !IndenterUtil.isWhiteSpaceOrNewLine(document.getChar(newOffset - 1))) {\n                command.offset = newOffset;\n                command.length = oldOffset - newOffset;\n            }\n            \n            IDocument tempDocument = new Document(document.get());\n            tempDocument.replace(command.offset, command.length, command.text + \" \");\n            \n            int newLineOffset = command.offset + command.text.length();\n            if (beforeCloseBrace && afterOpenBrace) {\n                tempDocument.replace(command.offset, 0, command.text);\n                String shift = getIndent(tempDocument, newLineOffset);\n                int beforeBraceIndent = shift.length() / IndenterUtil.getDefaultIndentSize();\n                if (beforeBraceIndent > 0) beforeBraceIndent--;\n                \n                command.caretOffset = newLineOffset + shift.length();\n                \n                shift += IndenterUtil.createWhiteSpace(beforeBraceIndent, 1, TextUtilities.getDefaultLineDelimiter(document));\n                \n                command.text += shift;\n                command.shiftsCaret = false;\n                command.length += document.get().indexOf(CLOSING_BRACE_CHAR, p) - p;\n            } else {\n                command.text += getIndent(tempDocument, newLineOffset + 1);\n            }\n        } catch (BadLocationException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    private String getIndent(IDocument tempDocument, int offset) throws BadLocationException {\n        IFile eclipseFile = editor.getEclipseFile();\n        assert eclipseFile != null : \"Eclipse IFile for \" + tempDocument + \" must not be null\";\n        \n        KtPsiFactory psiFactory = KotlinFormatterKt.createPsiFactory(eclipseFile);\n        KtFile ktFile = KotlinFormatterKt.createKtFile(tempDocument.get(), psiFactory, eclipseFile.getName());\n        \n        int line = tempDocument.getLineOfOffset(offset);\n\n\n        CodeStyleSettings settings = KotlinCodeStyleManagerKt.getCodeStyle(eclipseFile.getProject());\n        KotlinBlock rootBlock = new KotlinBlock(ktFile.getNode(), \n                KotlinFormatterKt.getNULL_ALIGNMENT_STRATEGY(), \n                Indent.getNoneIndent(), \n                null,\n                settings,\n                KotlinSpacingRulesKt.createSpacingBuilder(settings, KotlinSpacingBuilderUtilImpl.INSTANCE));\n        \n        int resolvedOffset = LineEndUtil.convertCrToDocumentOffset(tempDocument, offset);\n        KotlinFormatterKt.adjustIndent(ktFile, rootBlock, settings, resolvedOffset, tempDocument);\n        \n        IRegion lineInfo = tempDocument.getLineInformation(line);\n        \n        int lineOffset = lineInfo.getOffset();\n        int endOfWhitespace = findEndOfWhiteSpaceAfter(tempDocument, lineOffset, lineOffset + lineInfo.getLength());\n        return tempDocument.get(lineOffset, endOfWhitespace - lineOffset);\n    }\n    \n    private void autoEditBeforeCloseBrace(IDocument document, DocumentCommand command) {\n        if (isNewLineBefore(document, command.offset)) {\n            try {\n                IDocument tempDocument = new Document(document.get());\n                tempDocument.replace(command.offset, command.length, CLOSING_BRACE_STRING);\n                String indent = getIndent(tempDocument, command.offset);\n                \n                int spaceLength = command.offset - findEndOfWhiteSpaceBefore(document, command.offset - 1, 0) - 1;\n                command.offset -= spaceLength;\n                \n                command.text = indent + CLOSING_BRACE_STRING;\n                \n                document.replace(command.offset, spaceLength, \"\");\n            } catch (BadLocationException e) {\n                KotlinLogger.logAndThrow(e);\n            }\n        }\n    }\n    \n    private static int findEndOfWhiteSpaceAfter(IDocument document, int offset, int end) throws BadLocationException {\n        while (offset < end) {\n            if (!IndenterUtil.isWhiteSpaceChar(document.getChar(offset))) {\n                return offset;\n            }\n            \n            offset++;\n        }\n        \n        return end;\n    }\n    \n    private static int findEndOfWhiteSpaceBefore(IDocument document, int offset, int start) throws BadLocationException {\n        while (offset >= start) {\n            if (!IndenterUtil.isWhiteSpaceChar(document.getChar(offset))) {\n                return offset;\n            }\n            \n            offset--;\n        }\n        \n        return start;\n    }\n    \n    private static boolean isAfterOpenBrace(IDocument document, int offset, int startLineOffset) throws BadLocationException {\n        int nonEmptyOffset = findEndOfWhiteSpaceBefore(document, offset, startLineOffset);\n        return document.getChar(nonEmptyOffset) == OPENING_BRACE_CHAR;\n    }\n    \n    private static boolean isBeforeCloseBrace(IDocument document, int offset, int endLineOffset) throws BadLocationException {\n        int nonEmptyOffset = findEndOfWhiteSpaceAfter(document, offset, endLineOffset);\n        if (nonEmptyOffset == document.getLength()) {\n            nonEmptyOffset--;\n        }\n        return document.getChar(nonEmptyOffset) == CLOSING_BRACE_CHAR;\n    }\n    \n    private static int findEndOfWhiteSpace(IDocument document, int offset) throws BadLocationException {\n        while (offset > 0) {\n            char c = document.getChar(offset);\n            if (!IndenterUtil.isWhiteSpaceChar(c)) {\n                return offset;\n            }\n            \n            offset--;\n        }\n        \n        return offset;\n    }\n    \n    private static boolean isNewLineBefore(IDocument document, int offset) {\n        try {\n            offset--;\n            char prev = IndenterUtil.SPACE_CHAR;\n            StringBuilder bufBefore = new StringBuilder(prev);\n            while (IndenterUtil.isWhiteSpaceChar(prev) && offset > 0) {\n                prev = document.getChar(offset--);\n                bufBefore.append(prev);\n            }\n            \n            return containsNewLine(document, bufBefore.toString());\n        } catch (BadLocationException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return false;\n    }\n    \n    private static boolean containsNewLine(IDocument document, String text) {\n        String[] delimiters = document.getLegalLineDelimiters();\n        for (String delimiter : delimiters) {\n            if (text.contains(delimiter)) {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    \n    private static boolean isNewLine(IDocument document, String text) {\n        String[] delimiters = document.getLegalLineDelimiters();\n        for (String delimiter : delimiters) {\n            if (delimiter.equals(text)) {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinBracketInserter.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.source.ISourceViewer;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.custom.VerifyKeyListener;\nimport org.eclipse.swt.events.VerifyEvent;\nimport org.eclipse.swt.graphics.Point;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\n\npublic class KotlinBracketInserter implements VerifyKeyListener {\n    \n    private final List<PairConfiguration> bracketConfigurations = new ArrayList<PairConfiguration>();\n    private ISourceViewer viewer;\n    \n    private enum Type {\n        OPEN,\n        CLOSE\n    }\n    \n    private static class PairConfiguration {\n        private final char open;\n        private final char close;\n\n        public PairConfiguration(char open, char close) {\n            this.open = open;\n            this.close = close;\n        }\n        \n        public char getOpen() {\n            return open;\n        }\n        \n        public char getClose() {\n            return close;\n        }\n        \n    }\n\n    public void addBrackets(char open, char close) {\n        bracketConfigurations.add(new PairConfiguration(open, close));\n    }\n    \n    public void setSourceViewer(ISourceViewer sourceViewer) {\n        viewer = sourceViewer;\n    }\n\n    @Override\n    public void verifyKey(VerifyEvent event) {\n        if (!event.doit) {\n            return;\n        }\n        \n        if (!processChar(event.character, Type.OPEN) ||\n                !processChar(event.character, Type.CLOSE)) {\n            event.doit = false;\n            return;\n        }\n    }\n    \n    public boolean processChar(char ch, Type type) {\n        PairConfiguration pairConfiguration = getConfiguration(ch, type);\n        \n        return pairConfiguration == null || process(viewer.getDocument(), viewer.getSelectedRange(), type, pairConfiguration);\n    }\n    \n    private PairConfiguration getConfiguration(char ch, Type type) {\n        for (PairConfiguration conf : bracketConfigurations) {\n            if (type == Type.OPEN) {\n                if (conf.getOpen() == ch)\n                    return conf;\n            } else if (type == Type.CLOSE) {\n                if (conf.getClose() == ch)\n                    return conf;\n            }            \n        }\n        \n        return null;\n    }\n    \n    private boolean process(IDocument document, Point point, Type type, PairConfiguration configuration) {\n        int offset = point.x;\n        int length = point.y;\n        \n        try {\n            if (type == Type.OPEN) {\n                if (offset+length >= document.getLength() || document.getChar(offset + length) != configuration.getOpen()) {\n                    char[] pair = new char[] { configuration.getOpen(), configuration.getClose() };\n                    document.replace(offset, 0, String.valueOf(pair));\n                }\n                skip();\n                return false;\n            } else if (type == Type.CLOSE) {\n                if (offset + length < document.getLength() && document.getChar(offset + length) == configuration.getClose()) {\n                    skip();\n                    return false;\n                }\n            }\n        } catch (BadLocationException exc) {\n            KotlinLogger.logError(exc);\n        }\n        \n        return true;\n    }\n    \n    private void skip() {\n        StyledText textWidget = viewer.getTextWidget();\n        textWidget.setCaretOffset(textWidget.getCaretOffset() + 1);\n    }\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinClassFileEditor.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n\npackage org.jetbrains.kotlin.ui.editors\n\nimport com.intellij.openapi.util.text.StringUtil\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.debug.ui.actions.IToggleBreakpointsTarget\nimport org.eclipse.jdt.core.IClassFile\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectHistoryAction\nimport org.eclipse.jdt.internal.ui.text.JavaColorManager\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.source.SourceViewerConfiguration\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.ui.views.contentoutline.IContentOutlinePage\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.references.FILE_PROJECT\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtPsiFactory\nimport org.jetbrains.kotlin.psi.KtVisitor\nimport org.jetbrains.kotlin.ui.debug.KotlinToggleBreakpointAdapter\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\nimport org.jetbrains.kotlin.ui.editors.outline.KotlinOutlinePage\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectEnclosingAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectNextAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectPreviousAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSemanticSelectionAction\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\n\npublic class KotlinClassFileEditor : ClassFileEditor(), KotlinEditor {\n    override fun isEditable() = false\n    \n    override val isScript: Boolean\n        get() = false\n    \n    override val javaEditor = this\n\n    override val parsedFile: KtFile \n        get() {\n            val environment = KotlinEnvironment.getEnvironment(javaProject.project)\n            val ideaProject = environment.project\n            val jetFile = KtPsiFactory(ideaProject).createFile(StringUtil.convertLineSeparators(document.get(),\"\\n\"))\n            jetFile.putUserData(FILE_PROJECT, javaProject)\n            return jetFile\n        }\n\n    override val javaProject: IJavaProject\n        get() = classFile.getJavaProject()\n    \n    override val eclipseFile: IFile? = null\n\n    private val colorManager = JavaColorManager()\n    \n    private val kotlinOutlinePage : KotlinOutlinePage by lazy {\n        KotlinOutlinePage(this)\n    }\n    \n    override public fun <T> getAdapter(required: Class<T>): T? {\n        val adapter: Any? = when (required) {\n            IContentOutlinePage::class.java -> kotlinOutlinePage\n            IToggleBreakpointsTarget::class.java -> KotlinToggleBreakpointAdapter\n            else -> super<ClassFileEditor>.getAdapter(required)\n        }\n        \n        return required.cast(adapter)\n    }\n\n    override public fun createPartControl(parent:Composite) {\n        setSourceViewerConfiguration(Configuration(colorManager, this, getPreferenceStore()))\n        super<ClassFileEditor>.createPartControl(parent)\n    }\n\n    override protected fun isMarkingOccurrences() = false\n\n    override protected fun isTabsToSpacesConversionEnabled() =\n            IndenterUtil.isSpacesForTabs()\n\n    override protected fun createActions() {\n        super<ClassFileEditor>.createActions()\n\n        val selectionHistory = SelectionHistory(this)\n        val historyAction = StructureSelectHistoryAction(this, selectionHistory)\n        historyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST)\n        setAction(KotlinSemanticSelectionAction.HISTORY, historyAction)\n        selectionHistory.setHistoryAction(historyAction)\n\n        setAction(KotlinOpenDeclarationAction.OPEN_EDITOR_TEXT, KotlinOpenDeclarationAction(this))\n\n        setAction(KotlinSelectEnclosingAction.SELECT_ENCLOSING_TEXT, KotlinSelectEnclosingAction(this, selectionHistory))\n        setAction(KotlinSelectPreviousAction.SELECT_PREVIOUS_TEXT, KotlinSelectPreviousAction(this, selectionHistory))\n        setAction(KotlinSelectNextAction.SELECT_NEXT_TEXT, KotlinSelectNextAction(this, selectionHistory))\n    }\n\n    override public fun dispose() {\n        colorManager.dispose()\n        super<ClassFileEditor>.dispose()\n    }\n\n    override public fun setSelection(element:IJavaElement) {\n        when (element) {\n            is IClassFile -> revealClassInFile(findDeclarationInFile(element))\n            else -> KotlinOpenEditor.revealKotlinElement(this, element)\n        }\n    }\n\n    companion object {\n        public val EDITOR_ID:String = \"org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\"\n    }\n\n    private val classFile: IClassFile\n        get() = getEditorInput().getAdapter(IJavaElement::class.java) as IClassFile\n\n    override val document: IDocument\n        get() = getDocumentProvider().getDocument(getEditorInput())\n    \n    private fun findDeclarationInFile(classFile: IClassFile): KtClassOrObject? {\n        val fqName = classFile.getType().getFullyQualifiedName()\n        return parsedFile.accept(object: KtVisitor<KtClassOrObject?, String>() {\n            override fun visitClassOrObject(classOrObject: KtClassOrObject, classFqName: String): KtClassOrObject? =\n                    if (classOrObject.getFqName().toString() == classFqName) {\n                        classOrObject\n                    } else {\n                        super.visitClassOrObject(classOrObject, classFqName)\n                    }\n            \n            override fun visitKtElement(element: KtElement, classFqName: String): KtClassOrObject? =\n                    element.getChildren().asSequence().map { \n                        when(it) {\n                            is KtElement -> it.accept(this, classFqName)\n                            else -> null\n                        }\n                     }.filterNotNull().firstOrNull()\n                \n            override fun visitKtFile(file: KtFile, classFqName: String): KtClassOrObject? = \n                    visitKtElement(file, classFqName)\n        }, fqName)\n    }\n\n    private fun revealClassInFile(classDeclaration: KtClassOrObject?) {\n        if (classDeclaration != null) {\n            val correctedOffset = LineEndUtil.convertLfToDocumentOffset(parsedFile.getText(), classDeclaration.getTextOffset(), document);\n            selectAndReveal(correctedOffset, 0);\n        }\n    }\n    \n    //overriden for the purpose of highlighting\n    //because JavaEditor::doSetInput resets source viewer configuration\n    override fun setSourceViewerConfiguration(configuration: SourceViewerConfiguration) {\n        when(configuration) {\n            is Configuration -> super<ClassFileEditor>.setSourceViewerConfiguration(configuration)\n            else -> super<ClassFileEditor>.setSourceViewerConfiguration(Configuration(colorManager, this, getPreferenceStore()))\n        }\n    }\n    \n    //overriden to empty because ClassFileEditor's semantic highlighting crashes Kotlin syntax coloring\n    //TODO: rewrite when the semantic highlighting will be introduced\n    override protected fun installSemanticHighlighting() {\n        \n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinClassFileEditorInput.kt",
    "content": "package org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.core.IBuffer\nimport org.eclipse.jdt.core.IClassFile\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaModelException\nimport org.eclipse.jdt.internal.core.BufferManager\nimport org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput\nimport org.eclipse.jdt.internal.compiler.env.IBinaryType\nimport org.jetbrains.kotlin.core.resolve.KotlinSourceIndex\nimport org.eclipse.jdt.internal.core.PackageFragment\nimport org.eclipse.jdt.internal.core.ClassFile\nimport org.eclipse.jdt.internal.core.BinaryType\n\npublic class KotlinClassFileEditorInput(\n        classFile: IClassFile,\n        private val javaProject: IJavaProject?) : InternalClassFileEditorInput(classFile) {\n    \n    private val sourceShortName: String?\n    private val sourceFullPath: String?\n\n    init {\n        sourceShortName = (getClassFile().getType() as? BinaryType)?.getSourceFileName(null)?.toString()\n        \n        sourceFullPath = if (sourceShortName != null) {\n            val packageFragment = getClassFile().getParent() as PackageFragment\n            KotlinSourceIndex.getInstance(javaProject).resolvePath(packageFragment, sourceShortName)\n        } else {\n            null\n        }\n    }\n\n    private fun compareSources(another: KotlinClassFileEditorInput): Boolean {\n        if (sourceShortName == null || another.sourceShortName == null) {\n            return false\n        }\n        return when {\n            sourceShortName != another.sourceShortName -> false\n            getClassFile().getParent() == another.getClassFile().getParent() -> true\n            else -> sourceFullPath == another.sourceFullPath\n        }\n    }\n\n    override public fun equals(other: Any?): Boolean =\n            when {\n                super.equals(other) -> true\n                other is KotlinClassFileEditorInput -> compareSources(other)\n                else -> false\n            }\n\n    override fun getName() = sourceShortName ?: super.getName()\n\n    override fun getToolTipText() = sourceFullPath ?: super.getToolTipText()\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCommonEditor.kt",
    "content": "/*******************************************************************************\n\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.debug.ui.actions.IRunToLineTarget\nimport org.eclipse.debug.ui.actions.IToggleBreakpointsTarget\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.jdt.internal.ui.actions.ActionMessages\nimport org.eclipse.jdt.internal.ui.actions.CompositeActionGroup\nimport org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectHistoryAction\nimport org.eclipse.jdt.internal.ui.text.JavaColorManager\nimport org.eclipse.jdt.ui.actions.GenerateActionGroup\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.RefactorActionGroup\nimport org.eclipse.jdt.ui.text.IColorManager\nimport org.eclipse.jface.action.IMenuManager\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextViewerExtension\nimport org.eclipse.jface.text.source.SourceViewerConfiguration\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.actions.ActionContext\nimport org.eclipse.ui.views.contentoutline.IContentOutlinePage\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindReferencesInProjectAction\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindReferencesInWorkspaceAction\nimport org.jetbrains.kotlin.ui.debug.KotlinRunToLineAdapter\nimport org.jetbrains.kotlin.ui.debug.KotlinToggleBreakpointAdapter\nimport org.jetbrains.kotlin.ui.editors.annotations.KotlinLineAnnotationsReconciler\nimport org.jetbrains.kotlin.ui.editors.highlighting.KotlinSemanticHighlighter\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenSuperImplementationAction\nimport org.jetbrains.kotlin.ui.editors.organizeImports.KotlinOrganizeImportsAction\nimport org.jetbrains.kotlin.ui.editors.outline.KotlinOutlinePage\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectEnclosingAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectNextAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSelectPreviousAction\nimport org.jetbrains.kotlin.ui.editors.selection.KotlinSemanticSelectionAction\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\nimport org.jetbrains.kotlin.ui.overrideImplement.KotlinOverrideMembersAction\nimport org.jetbrains.kotlin.ui.refactorings.extract.KotlinExtractVariableAction\nimport org.jetbrains.kotlin.ui.refactorings.rename.KotlinRenameAction\n\nabstract class KotlinCommonEditor : CompilationUnitEditor(), KotlinEditor {\n    private val colorManager: IColorManager = JavaColorManager()\n\n    private val bracketInserter: KotlinBracketInserter = KotlinBracketInserter()\n\n    private val kotlinOutlinePage = KotlinOutlinePage(this)\n\n    private var kotlinSemanticHighlighter: KotlinSemanticHighlighter? = null\n\n    protected val kotlinReconcilingStrategy = KotlinReconcilingStrategy(this)\n\n    private val compositeContextGroup = CompositeActionGroup()\n\n    protected open fun doAfterSemanticHighlightingInstallation() {}\n\n    override fun <T> getAdapter(required: Class<T>): T? {\n        val adapter: Any? = when (required) {\n            IContentOutlinePage::class.java -> kotlinOutlinePage\n            IToggleBreakpointsTarget::class.java -> KotlinToggleBreakpointAdapter\n            IRunToLineTarget::class.java -> KotlinRunToLineAdapter\n            else -> super.getAdapter(required)\n        }\n\n        return required.cast(adapter)\n    }\n\n    override fun createPartControl(parent: Composite) {\n        sourceViewerConfiguration = FileEditorConfiguration(colorManager, this, preferenceStore, kotlinReconcilingStrategy)\n        kotlinReconcilingStrategy.addListener(KotlinLineAnnotationsReconciler)\n        kotlinReconcilingStrategy.addListener(kotlinOutlinePage)\n\n        super.createPartControl(parent)\n\n        val sourceViewer = sourceViewer\n        if (sourceViewer is ITextViewerExtension) {\n            bracketInserter.setSourceViewer(sourceViewer)\n            bracketInserter.addBrackets('{', '}')\n            sourceViewer.prependVerifyKeyListener(bracketInserter)\n        }\n    }\n\n    override fun isTabsToSpacesConversionEnabled(): Boolean = IndenterUtil.isSpacesForTabs()\n\n    override fun createActions() {\n        super.createActions()\n\n        setAction(\"QuickFormat\", null)\n\n        val formatAction = KotlinFormatAction(this)\n        setAction(KotlinFormatAction.FORMAT_ACTION_TEXT, formatAction)\n        markAsStateDependentAction(KotlinFormatAction.FORMAT_ACTION_TEXT, true)\n        markAsSelectionDependentAction(KotlinFormatAction.FORMAT_ACTION_TEXT, true)\n        PlatformUI.getWorkbench().helpSystem.setHelp(formatAction, IJavaHelpContextIds.FORMAT_ACTION)\n\n        val selectionHistory = SelectionHistory(this)\n        val historyAction = StructureSelectHistoryAction(this, selectionHistory)\n        historyAction.actionDefinitionId = IJavaEditorActionDefinitionIds.SELECT_LAST\n        setAction(KotlinSemanticSelectionAction.HISTORY, historyAction)\n        selectionHistory.setHistoryAction(historyAction)\n\n        setAction(KotlinOpenDeclarationAction.OPEN_EDITOR_TEXT, KotlinOpenDeclarationAction(this))\n\n        setAction(KotlinSelectEnclosingAction.SELECT_ENCLOSING_TEXT, KotlinSelectEnclosingAction(this, selectionHistory))\n\n        setAction(KotlinSelectPreviousAction.SELECT_PREVIOUS_TEXT, KotlinSelectPreviousAction(this, selectionHistory))\n\n        setAction(KotlinSelectNextAction.SELECT_NEXT_TEXT, KotlinSelectNextAction(this, selectionHistory))\n\n        setAction(KotlinOverrideMembersAction.ACTION_ID, KotlinOverrideMembersAction(this))\n\n        setAction(KotlinFindReferencesInProjectAction.ACTION_ID, KotlinFindReferencesInProjectAction(this))\n\n        setAction(KotlinFindReferencesInWorkspaceAction.ACTION_ID, KotlinFindReferencesInWorkspaceAction(this))\n\n        setAction(KotlinRenameAction.ACTION_ID, KotlinRenameAction(this))\n\n        setAction(KotlinExtractVariableAction.ACTION_ID, KotlinExtractVariableAction(this))\n\n        setAction(KotlinOpenSuperImplementationAction.ACTION_ID, KotlinOpenSuperImplementationAction(this))\n\n        setAction(KotlinOrganizeImportsAction.ACTION_ID, KotlinOrganizeImportsAction(this))\n\n        refactorActionGroup.dispose()\n        generateActionGroup.dispose()\n\n        compositeContextGroup.addGroup(\n                KotlinRefactorActionGroup(\n                        this,\n                        RefactorActionGroup.MENU_ID,\n                        ActionMessages.RefactorMenu_label,\n                        \"org.eclipse.jdt.ui.edit.text.java.refactor.quickMenu\"))\n\n        compositeContextGroup.addGroup(\n                KotlinGenerateActionGroup(\n                        this,\n                        GenerateActionGroup.MENU_ID,\n                        ActionMessages.SourceMenu_label,\n                        \"org.eclipse.jdt.ui.edit.text.java.source.quickMenu\"))\n    }\n\n    override fun editorContextMenuAboutToShow(menu: IMenuManager) {\n        super.editorContextMenuAboutToShow(menu)\n\n        val context = ActionContext(selectionProvider.selection)\n        compositeContextGroup.context = context\n        compositeContextGroup.fillContextMenu(menu)\n        compositeContextGroup.context = null\n    }\n\n    override fun setSourceViewerConfiguration(configuration: SourceViewerConfiguration) {\n        if (configuration is FileEditorConfiguration) {\n            super.setSourceViewerConfiguration(configuration)\n        } else {\n            // Hack to avoid adding Java's source viewer configuration (see setPreferenceStore in JavaEditor)\n            super.setSourceViewerConfiguration(\n                    FileEditorConfiguration(colorManager, this, preferenceStore, kotlinReconcilingStrategy))\n        }\n    }\n\n    override fun installSemanticHighlighting() {\n        val configuration = sourceViewerConfiguration as FileEditorConfiguration\n\n        kotlinSemanticHighlighter = configuration.scanner\n                ?.let {\n                    KotlinSemanticHighlighter(preferenceStore, colorManager, Configuration.getKotlinPresentaionReconciler(it), this)\n                }?.also {\n                    it.install(this::doAfterSemanticHighlightingInstallation)\n                    kotlinReconcilingStrategy.addListener(it)\n                }\n    }\n\n    override fun dispose() {\n        colorManager.dispose()\n\n        kotlinSemanticHighlighter?.let {\n            kotlinReconcilingStrategy.removeListener(it)\n            it.uninstall()\n        }\n\n        kotlinReconcilingStrategy.removeListener(KotlinLineAnnotationsReconciler)\n        kotlinReconcilingStrategy.removeListener(kotlinOutlinePage)\n        kotlinReconcilingStrategy.removeListener(KotlinLineAnnotationsReconciler)\n\n        val sourceViewer = sourceViewer\n        if (sourceViewer is ITextViewerExtension) {\n            sourceViewer.removeVerifyKeyListener(bracketInserter)\n        }\n\n        compositeContextGroup.dispose()\n\n        super.dispose()\n    }\n\n    override fun setSelection(element: IJavaElement) {\n        KotlinOpenEditor.revealKotlinElement(this, element)\n    }\n\n    override fun initializeKeyBindingScopes() {\n        setKeyBindingScopes(arrayOf<String>(\n                \"org.jetbrains.kotlin.eclipse.ui.kotlinEditorScope\",\n                \"org.eclipse.jdt.ui.javaEditorScope\"))\n    }\n\n    override fun installOccurrencesFinder(forceUpdate: Boolean) {\n        // Do nothing\n    }\n\n    override fun uninstallOccurrencesFinder() {\n        // Do nothing\n    }\n\n    // Use this method instead of property `document` when document is getting in deferred thread\n    fun getDocumentSafely(): IDocument? = documentProvider?.getDocument(editorInput)\n\n    fun isActive(): Boolean = isActiveEditor\n\n    override val eclipseFile: IFile?\n        get() = editorInput.getAdapter(IFile::class.java)\n\n    override val javaEditor: JavaEditor = this\n\n    override fun isEditable(): Boolean = eclipseFile != null\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinCorrectionProcessor.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext\nimport org.eclipse.jface.text.quickassist.IQuickAssistProcessor\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.swt.graphics.Point\nimport org.eclipse.ui.ide.IDE\nimport org.eclipse.ui.texteditor.MarkerAnnotation\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProcessor\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolution\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolutionGenerator\n\nclass KotlinCorrectionProcessor(val editor: KotlinEditor) : IQuickAssistProcessor {\n\n    override fun getErrorMessage(): String? = null\n\n    override fun canFix(annotation: Annotation): Boolean {\n        return annotation is MarkerAnnotation && IDE.getMarkerHelpRegistry().hasResolutions(annotation.marker)\n    }\n\n    override fun canAssist(invocationContext: IQuickAssistInvocationContext): Boolean = true\n\n    override fun computeQuickAssistProposals(invocationContext: IQuickAssistInvocationContext): Array<ICompletionProposal> {\n        val diagnostics = findDiagnosticsBy(invocationContext, editor)\n        val quickFixResolutions = KotlinMarkerResolutionGenerator.getResolutions(diagnostics)\n\n        return arrayListOf<ICompletionProposal>().apply {\n            val file = editor.eclipseFile\n            if (file != null) {\n                addAll(quickFixResolutions.toCompletionProposals(file))\n            }\n\n            addAll(KotlinQuickAssistProcessor.getAssists(editor))\n        }.toTypedArray()\n    }\n}\n\nfun List<KotlinMarkerResolution>.toCompletionProposals(file: IFile): List<ICompletionProposal> =\n    map { KotlinMarkerResolutionProposal(file, it) }\n\nprivate class KotlinMarkerResolutionProposal(\n        private val file: IFile,\n        private val resolution: KotlinMarkerResolution) : ICompletionProposal {\n    override fun getImage(): Image? = resolution.image\n\n    override fun getAdditionalProposalInfo(): String? = resolution.description\n\n    override fun apply(document: IDocument?) {\n        resolution.apply(file)\n    }\n\n    override fun getContextInformation(): IContextInformation? = null\n\n    override fun getDisplayString(): String? = resolution.label\n\n    override fun getSelection(document: IDocument?): Point? = null\n}\n\nfun findDiagnosticsBy(invocationContext: IQuickAssistInvocationContext, editor: KotlinEditor): List<Diagnostic> {\n    val offset = LineEndUtil.convertCrToDocumentOffset(editor.document, invocationContext.offset)\n    return editor.parsedFile?.let { ktFile ->\n        ktFile.getBindingContext().diagnostics.filter {\n            val range = it.psiElement.textRange\n            range.startOffset <= offset && offset <= range.endOffset\n        }\n    } ?: emptyList()\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinEditor.kt",
    "content": "package org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.core.resources.IFile\n\npublic interface KotlinEditor {\n    val javaEditor: JavaEditor\n    val parsedFile: KtFile?\n    val javaProject: IJavaProject?\n    val document: IDocument\n    val eclipseFile: IFile?\n    val isScript: Boolean\n    fun isEditable(): Boolean\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinElementHyperlink.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.hyperlink.IHyperlink\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors\nimport org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtProperty\nimport org.jetbrains.kotlin.psi.KtPropertyDelegate\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.ui.editors.codeassist.getParentOfType\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\nimport org.jetbrains.kotlin.ui.editors.navigation.gotoElement\n\nclass KTGenericHyperLink(\n    private val region: IRegion,\n    private val label: String,\n    private val editor: KotlinEditor,\n    private val targetDescriptor: DeclarationDescriptor,\n    private val fromElement: KtElement\n) :\n    IHyperlink {\n    override fun getHyperlinkRegion(): IRegion = region\n\n    override fun getTypeLabel(): String? = null\n\n    override fun getHyperlinkText(): String = label\n\n    override fun open() {\n        val tempPrj = editor.javaProject ?: return\n        gotoElement(targetDescriptor, fromElement, editor, tempPrj)\n    }\n\n}\n\nprivate const val HYPERLINK_TEXT = \"Open Kotlin Declaration\"\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinElementHyperlinkDetector.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.internal.ui.text.JavaWordFinder\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.Region\nimport org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector\nimport org.eclipse.jface.text.hyperlink.IHyperlink\nimport org.eclipse.ui.texteditor.ITextEditor\nimport org.jetbrains.kotlin.core.references.createReferences\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.psi.KtArrayAccessExpression\nimport org.jetbrains.kotlin.psi.KtCallExpression\nimport org.jetbrains.kotlin.psi.KtOperationReferenceExpression\nimport org.jetbrains.kotlin.psi.KtReferenceExpression\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\n\n@Suppress(\"unused\")\nclass KotlinElementHyperlinkDetector : AbstractHyperlinkDetector() {\n    override fun detectHyperlinks(\n        textViewer: ITextViewer,\n        region: IRegion?,\n        canShowMultipleHyperlinks: Boolean\n    ): Array<out IHyperlink>? {\n        val textEditor = getAdapter(ITextEditor::class.java)\n        if (region == null || textEditor !is KotlinEditor) return null\n\n        val tempProject = textEditor.javaProject ?: return null\n\n        val tempDocument = textEditor.documentProvider.getDocument(textEditor.editorInput)\n\n        var wordRegion = JavaWordFinder.findWord(tempDocument, region.offset)\n\n        var tempReferenceExpression: KtReferenceExpression? = null\n        if (wordRegion == null || wordRegion.length == 0) {\n            tempReferenceExpression = EditorUtil.getReferenceExpression(textEditor, region.offset)\n            if (tempReferenceExpression is KtOperationReferenceExpression) {\n                val tempOffset =\n                    LineEndUtil.convertLfOffsetForMixedDocument(tempDocument, tempReferenceExpression.textOffset)\n                wordRegion = Region(tempOffset, tempReferenceExpression.textLength)\n            } else if (tempReferenceExpression is KtArrayAccessExpression) {\n                val tempOffset =\n                    LineEndUtil.convertLfOffsetForMixedDocument(tempDocument, tempReferenceExpression.textOffset)\n                wordRegion = Region(tempOffset, tempReferenceExpression.textLength)\n            } else if (tempReferenceExpression is KtCallExpression) {\n                if (KotlinOpenDeclarationAction.getNavigationData(tempReferenceExpression, tempProject) != null) {\n                    val tempOffset =\n                        LineEndUtil.convertLfOffsetForMixedDocument(tempDocument, tempReferenceExpression.textOffset)\n                    wordRegion = Region(tempOffset, tempReferenceExpression.textLength)\n                }\n            }\n        }\n\n        val tempRenderer = DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions {\n            modifiers = emptySet()\n            includeAdditionalModifiers = false\n        }\n\n        val tempRef = tempReferenceExpression\n            ?: EditorUtil.getReferenceExpression(textEditor, region.offset)\n            ?: EditorUtil.getJetElement(textEditor, region.offset)\n            ?: return null\n\n        val context = tempRef.getBindingContext()\n        val tempTargets = createReferences(tempRef)\n            .flatMap { it.getTargetDescriptors(context) }\n\n        return tempTargets.map {\n            KTGenericHyperLink(\n                wordRegion,\n                tempRenderer.render(it),\n                textEditor,\n                it,\n                tempRef\n            )\n        }.toTypedArray().takeIf { it.isNotEmpty() }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinFileEditor.kt",
    "content": "/*******************************************************************************\n\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport com.intellij.openapi.util.text.StringUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtPsiFactory\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinExternalEditorInput\nimport org.jetbrains.kotlin.ui.editors.occurrences.KotlinMarkOccurrences\n\nopen class KotlinFileEditor : KotlinCommonEditor() {\n    override val isScript: Boolean\n        get() = false\n    \n    override val parsedFile: KtFile?\n        get() = computeJetFile()\n    \n    override val javaProject: IJavaProject? by lazy {\n        eclipseFile?.let { JavaCore.create(it.getProject()) }\n    }\n    \n    override val document: IDocument\n        get() = getDocumentProvider().getDocument(getEditorInput())\n    private val kotlinMarkOccurrences by lazy { KotlinMarkOccurrences(this) }\n\n    private fun computeJetFile(): KtFile? {\n        val file = eclipseFile\n        if (file != null && file.exists()) {\n            return KotlinPsiManager.getKotlinParsedFile(file) // File might be not under the source root\n        }\n        \n        if (javaProject == null) {\n            return null\n        }\n        \n        val environment = KotlinEnvironment.getEnvironment(javaProject!!.project)\n        val ideaProject = environment.project\n        return KtPsiFactory(ideaProject).createFile(StringUtil.convertLineSeparators(document.get(), \"\\n\"))\n    }\n\n    override fun installOccurrencesFinder(forceUpdate: Boolean) {\n        editorSite.page.addPostSelectionListener(kotlinMarkOccurrences)\n    }\n\n    override fun uninstallOccurrencesFinder() {\n        editorSite.page.removePostSelectionListener(kotlinMarkOccurrences)\n    }\n}\n\nclass KotlinExternalReadOnlyEditor : KotlinFileEditor() {\n    companion object {\n        const val EDITOR_ID = \"org.jetbrains.kotlin.ui.editors.KotlinExternalReadOnlyEditor\"\n    }\n    \n    override val parsedFile: KtFile?\n        get() = (getEditorInput() as KotlinExternalEditorInput).ktFile\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinFormatAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jface.text.ITextSelection\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.formatting.codeStyle\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.ui.formatter.EclipseDocumentRange\nimport org.jetbrains.kotlin.ui.formatter.createPsiFactory\nimport org.jetbrains.kotlin.ui.formatter.formatRange\n\nclass KotlinFormatAction(private val editor: KotlinEditor) : SelectionDispatchAction(editor.javaEditor.site) {\n    companion object {\n        val FORMAT_ACTION_TEXT: String = \"Format\"\n    }\n    \n    init {\n        setText(FORMAT_ACTION_TEXT)\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT)\n    }\n    \n    override fun run(selection: ITextSelection) {\n        val file = editor.eclipseFile\n        if (file == null) {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null)\n            return\n        }\n        \n        formatRange(editor.document, getRange(selection), createPsiFactory(file), file.name, file.project.codeStyle)\n        \n        KotlinPsiManager.commitFile(file, editor.document)\n    }\n    \n    private fun getRange(selection: ITextSelection): EclipseDocumentRange {\n        val selectionLength = selection.length\n        return if (selectionLength == 0) {\n            EclipseDocumentRange(0, editor.document.length)\n        } else {\n            EclipseDocumentRange(selection.offset, selection.offset + selectionLength)\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinReconcilingStrategy.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.ISafeRunnable\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.reconciler.DirtyRegion\nimport org.eclipse.jface.text.reconciler.IReconcilingStrategy\nimport org.eclipse.jface.util.SafeRunnable\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\n\ninterface KotlinReconcilingListener {\n    fun reconcile(file: IFile, editor: KotlinEditor)\n}\n\nclass KotlinReconcilingStrategy(val editor: KotlinEditor) : IReconcilingStrategy {\n    private val reconcilingListeners = hashSetOf<KotlinReconcilingListener>()\n    \n    private val RECONCILING_LOCK = Any()\n    \n    fun addListener(listener: KotlinReconcilingListener) {\n        reconcilingListeners.add(listener)\n    }\n    \n    fun removeListener(listener: KotlinReconcilingListener) {\n        reconcilingListeners.remove(listener)\n    }\n    \n    override fun setDocument(document: IDocument?) {}\n    \n    override fun reconcile(dirtyRegion: DirtyRegion?, subRegion: IRegion?) {}\n    \n    override fun reconcile(partition: IRegion?) {\n        synchronized (RECONCILING_LOCK) {\n        \tSafeRunnable.run(object : ISafeRunnable {\n        \t\toverride fun run() {\n        \t\t\tval file = editor.eclipseFile\n\t\t\t\t\tif (file != null) {\n\t\t\t\t\t\tresetCache(file)\n\t\t\t\t\t\tKotlinPsiManager.commitFile(file, editor.document)\n\t\t\t\t\t\t\n\t\t\t\t\t\treconcilingListeners.forEach { it.reconcile(file, editor) }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tKotlinLogger.logError(\"Failed to retrieve IFile from editor $editor\", null)\n\t\t\t\t\t}\n        \t\t}\n        \t\t\n        \t\toverride fun handleException(exception: Throwable) {\n        \t\t\tKotlinLogger.logError(exception)\n        \t\t}\n        \t})\n        }\n    }\n    \n    internal fun reconcile(runBefore: () -> Unit) {\n        synchronized (RECONCILING_LOCK) {\n            runBefore()\n            reconcile(null)\n        }\n    }\n    \n    private fun resetCache(file: IFile) {\n        KotlinAnalysisProjectCache.resetCache(file.project)\n        KotlinAnalysisFileCache.resetCache()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/KotlinScriptEditor.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.ui.tryUpdateScriptClasspath\n\nclass KotlinScriptEditor : KotlinCommonEditor() {\n    override val parsedFile: KtFile?\n        get() {\n            val file = eclipseFile ?: return null\n            return KotlinPsiManager.getKotlinFileIfExist(file, document.get())\n        }\n\n    override val javaProject: IJavaProject? by lazy {\n        eclipseFile?.let { JavaCore.create(it.project) }\n    }\n\n    override val document: IDocument\n        get() = documentProvider.getDocument(editorInput)\n\n    override val isScript: Boolean\n        get() = true\n\n    override fun dispose() {\n        eclipseFile?.let {\n            KotlinScriptEnvironment.removeKotlinEnvironment(it)\n            KotlinPsiManager.removeFile(it)\n        }\n    }\n\n    internal fun reconcile(runBeforeReconciliation: () -> Unit = {}) {\n        kotlinReconcilingStrategy.reconcile(runBeforeReconciliation)\n    }\n\n    override fun doAfterSemanticHighlightingInstallation() {\n        eclipseFile?.let { tryUpdateScriptClasspath(it) }\n    }\n}\n\nfun KotlinCommonEditor.isOpen(): Boolean {\n    for (window in PlatformUI.getWorkbench().workbenchWindows) {\n        for (page in window.pages) {\n            for (editorReference in page.editorReferences) {\n                if (editorReference.getEditor(false) == this) {\n                    return true\n                }\n            }\n        }\n    }\n\n    return false\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/annotations/AnnotationManager.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2014 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.annotations\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.jdt.core.IJavaModelMarker\nimport org.eclipse.jface.text.ISynchronizable\nimport org.eclipse.jface.text.Position\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.jface.text.source.IAnnotationModel\nimport org.eclipse.jface.text.source.IAnnotationModelExtension\nimport org.eclipse.ui.texteditor.AbstractTextEditor\nimport org.eclipse.ui.texteditor.MarkerAnnotation\nimport org.eclipse.ui.texteditor.MarkerUtilities\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinReconcilingListener\nimport org.jetbrains.kotlin.ui.editors.quickfix.addDiagnostics\nimport org.jetbrains.kotlin.ui.editors.quickfix.kotlinQuickFixes\nimport org.jetbrains.kotlin.ui.editors.quickfix.removeMarkers\n\nobject AnnotationManager {\n\n    const val ANNOTATION_ERROR_TYPE = \"org.jetbrains.kotlin.ui.annotation.error\"\n    const val ANNOTATION_WARNING_TYPE = \"org.jetbrains.kotlin.ui.annotation.warning\"\n    const val MARKED_TEXT = \"markedText\"\n    @JvmField\n    val IS_UNRESOLVED_REFERENCE = \"isUnresolvedReference\"\n    @JvmField\n    val MARKER_PROBLEM_TYPE = IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER\n    val CAN_FIX_PROBLEM = \"KotlinProblemCanBeFixed\"\n\n    fun updateAnnotations(editor: AbstractTextEditor, annotations: List<DiagnosticAnnotation>) {\n        val annotationModel = editor.documentProvider.getAnnotationModel(editor.editorInput)\n        if (annotationModel !is IAnnotationModelExtension) return\n\n        val newAnnotations = annotations.associateBy({ it }, { it.position })\n        val oldAnnotations = getLineMarkerAnnotations(annotationModel)\n        updateAnnotations(annotationModel, newAnnotations, oldAnnotations)\n    }\n\n    fun clearAllMarkersFromProject(project: IProject) {\n        try {\n            KotlinPsiManager.getFilesByProject(project).forEach {\n                it.removeMarkers()\n            }\n        } catch (e: CoreException) {\n            KotlinLogger.logError(e)\n        }\n    }\n\n    fun addProblemMarker(annotation: DiagnosticAnnotation, file: IFile) =\n        with(file.createMarker(MARKER_PROBLEM_TYPE)) {\n            setAttribute(IMarker.MESSAGE, annotation.text)\n            setAttribute(IMarker.SEVERITY, annotation.markerSeverity)\n            setAttribute(IMarker.CHAR_START, annotation.offset)\n            setAttribute(IMarker.CHAR_END, annotation.endOffset)\n            setAttribute(IMarker.LOCATION, \"line ${annotation.line}\")\n            setAttribute(IMarker.LINE_NUMBER, annotation.line)\n            setAttribute(MARKED_TEXT, annotation.markedText)\n            annotation.diagnostic?.let {\n                addDiagnostics(it)\n            }\n\n            val diagnostic = annotation.diagnostic\n            val isUnresolvedReference = if (diagnostic != null) {\n                DiagnosticAnnotationUtil.isUnresolvedReference(diagnostic.factory)\n            } else false\n            setAttribute(IS_UNRESOLVED_REFERENCE, isUnresolvedReference)\n\n            val canBeFixed = diagnostic?.let { kotlinQuickFixes.containsKey(it.factory) } ?: false\n            setAttribute(CAN_FIX_PROBLEM, canBeFixed)\n        }\n\n    fun removeAnnotations(editor: KotlinFileEditor, annotationType: String) {\n        updateAnnotations(editor, emptyMap(), annotationType)\n    }\n\n    fun updateAnnotations(editor: KotlinEditor, annotationMap: Map<Annotation, Position>, annotationType: String) {\n        val model = editor.javaEditor.documentProvider?.getAnnotationModel(editor.javaEditor.editorInput)\n        if (model != null) {\n            updateAnnotations(model, annotationMap, getAnnotations(model, annotationType))\n        }\n    }\n\n    private fun getAnnotations(model: IAnnotationModel, annontationType: String): List<Annotation> {\n        val annotations = arrayListOf<Annotation>()\n        for (annotation in model.annotationIterator) {\n            if (annotation is Annotation && annotation.type == annontationType) {\n                annotations.add(annotation)\n            }\n        }\n\n        return annotations\n    }\n\n    private fun <Ann : Annotation> updateAnnotations(\n        model: IAnnotationModel,\n        annotationMap: Map<Ann, Position>,\n        oldAnnotations: List<Annotation>\n    ) {\n        model.withLock {\n            (model as IAnnotationModelExtension).replaceAnnotations(oldAnnotations.toTypedArray(), annotationMap)\n        }\n    }\n\n    private fun getLineMarkerAnnotations(model: IAnnotationModel): List<Annotation> {\n        fun isLineMarkerAnnotation(ann: Annotation): Boolean {\n            return when (ann) {\n                is DiagnosticAnnotation -> true\n                is MarkerAnnotation -> MarkerUtilities.isMarkerType(ann.marker, IMarker.PROBLEM)\n                else -> false\n            }\n        }\n\n        return arrayListOf<Annotation>().apply {\n            model.annotationIterator.forEach {\n                if (it is Annotation && isLineMarkerAnnotation(it)) {\n                    add(it)\n                }\n            }\n        }\n    }\n}\n\nobject KotlinLineAnnotationsReconciler : KotlinReconcilingListener {\n    override fun reconcile(file: IFile, editor: KotlinEditor) {\n        val jetFile =\n            if (editor.isScript) editor.parsedFile else KotlinPsiManager.getKotlinFileIfExist(file, editor.document.get())\n\n        jetFile?.let {\n            val diagnostics = KotlinAnalyzer.analyzeFile(it).analysisResult.bindingContext.diagnostics\n            val annotations = DiagnosticAnnotationUtil.INSTANCE.handleDiagnostics(diagnostics)\n\n            DiagnosticAnnotationUtil.INSTANCE.addParsingDiagnosticAnnotations(file, annotations)\n            DiagnosticAnnotationUtil.INSTANCE.updateAnnotations(editor.javaEditor, annotations)\n        }\n    }\n}\n\nfun <T> IAnnotationModel.withLock(action: () -> T): T {\n    return if (this is ISynchronizable) {\n        synchronized(this.lockObject) {\n            action()\n        }\n    } else {\n        synchronized(this) {\n            action()\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/annotations/DiagnosticAnnotation.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.annotations\n\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.jface.text.Position\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation\nimport org.eclipse.jdt.core.ICompilationUnit\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\n\nclass DiagnosticAnnotation(\n    val line: Int,\n    val offset: Int,\n    val length: Int,\n    val annotationType: String,\n    val message: String,\n    val markedText: String,\n    val file: IFile,\n    val diagnostic: Diagnostic?) : Annotation(annotationType, true, message), IJavaAnnotation {\n    override fun getMarkerType(): String? = null\n    \n    override fun getArguments(): Array<String>? = null\n    \n    override fun hasOverlay(): Boolean = false\n    \n    override fun addOverlaid(annotation: IJavaAnnotation?) {\n//        skip\n    }\n    \n    override fun getId(): Int = -1\n    \n    override fun getOverlay(): IJavaAnnotation? = null\n\n    override fun isProblem(): Boolean {\n        return when(type) {\n            AnnotationManager.ANNOTATION_ERROR_TYPE, AnnotationManager.ANNOTATION_WARNING_TYPE -> true\n            else -> false\n        }\n    }\n    \n    override fun removeOverlaid(annotation: IJavaAnnotation?) {\n//        skip\n    }\n    \n    override fun getOverlaidIterator(): MutableIterator<IJavaAnnotation>? = null\n    \n    override fun getCompilationUnit(): ICompilationUnit? = null\n\n    \n    val markerSeverity = when (type) {\n        AnnotationManager.ANNOTATION_ERROR_TYPE -> IMarker.SEVERITY_ERROR\n        AnnotationManager.ANNOTATION_WARNING_TYPE -> IMarker.SEVERITY_WARNING\n        else -> 0\n    }\n}\n\nval DiagnosticAnnotation.position: Position\n    get() = Position(offset, length)\n\nval DiagnosticAnnotation.endOffset: Int\n    get() = offset + length"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/annotations/DiagnosticAnnotationUtil.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.annotations;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.openapi.vfs.VirtualFile;\nimport com.intellij.psi.PsiErrorElement;\nimport com.intellij.psi.PsiFile;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.jface.text.source.IAnnotationModel;\nimport org.eclipse.ui.texteditor.AbstractTextEditor;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.diagnostics.Diagnostic;\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory;\nimport org.jetbrains.kotlin.diagnostics.Errors;\nimport org.jetbrains.kotlin.diagnostics.Severity;\nimport org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.resolve.AnalyzingUtils;\nimport org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;\n\nimport java.util.*;\n\npublic class DiagnosticAnnotationUtil {\n\n    public static final DiagnosticAnnotationUtil INSTANCE = new DiagnosticAnnotationUtil();\n    \n    private DiagnosticAnnotationUtil() {\n    }\n    \n    @NotNull\n    public Map<IFile, List<DiagnosticAnnotation>> handleDiagnostics(@NotNull Diagnostics diagnostics) {\n        Map<IFile, List<DiagnosticAnnotation>> annotations = new HashMap<>();\n        for (Diagnostic diagnostic : diagnostics) {\n            if (diagnostic.getTextRanges().isEmpty()) {\n                continue;\n            }\n            \n            VirtualFile virtualFile = diagnostic.getPsiFile().getVirtualFile();\n            if (virtualFile == null) {\n                continue;\n            }\n            \n            IFile curFile = ResourcesPlugin.getWorkspace().getRoot().\n                    getFileForLocation(new Path(virtualFile.getPath()));\n            \n            if (!annotations.containsKey(curFile)) {\n                annotations.put(curFile, new ArrayList<>());\n            }\n\n            if (curFile != null) {\n            DiagnosticAnnotation annotation = createKotlinAnnotation(diagnostic, curFile);\n            annotations.get(curFile).add(annotation);\n        }\n        }\n\n        return annotations;\n    }\n    \n    public void addParsingDiagnosticAnnotations(@NotNull IFile file, @NotNull Map<IFile, List<DiagnosticAnnotation>> annotations) {\n        List<DiagnosticAnnotation> parsingAnnotations = createParsingDiagnosticAnnotations(file);\n        \n        if (annotations.containsKey(file)) {\n            annotations.get(file).addAll(parsingAnnotations);\n        } else {\n            annotations.put(file, parsingAnnotations);\n        }\n    }\n    \n    @NotNull\n    public List<DiagnosticAnnotation> createParsingDiagnosticAnnotations(@NotNull IFile file) {\n        KtFile jetFile = KotlinPsiManager.INSTANCE.getParsedFile(file);\n        List<DiagnosticAnnotation> result = new ArrayList<>();\n        for (PsiErrorElement syntaxError : AnalyzingUtils.getSyntaxErrorRanges(jetFile)) {\n            try {\n                result.add(createKotlinAnnotation(syntaxError, file));\n            } catch (BadLocationException e) {\n                KotlinLogger.logAndThrow(e);\n            }\n        }\n        \n        return result;\n    }\n    \n    @NotNull\n    private DiagnosticAnnotation createKotlinAnnotation(@NotNull PsiErrorElement psiErrorElement, @NotNull IFile file) throws BadLocationException {\n        PsiFile psiFile = psiErrorElement.getContainingFile();\n        \n        TextRange range = psiErrorElement.getTextRange();\n        int startOffset = range.getStartOffset();\n        int length = range.getLength();\n        String markedText = psiErrorElement.getText();\n        \n        if (range.isEmpty()) {\n            startOffset--;\n            length = 1;\n            markedText = psiFile.getText().substring(startOffset, startOffset + length);\n        }\n        \n        IDocument document = EditorUtil.getDocument(file);\n        int offset = LineEndUtil.convertLfToDocumentOffset(psiFile.getText(), startOffset, document);\n        \n        return new DiagnosticAnnotation(\n                document.getLineOfOffset(offset),\n                offset,\n                length,\n                AnnotationManager.ANNOTATION_ERROR_TYPE,\n                psiErrorElement.getErrorDescription(),\n                markedText,\n                file,\n                null);\n    }\n    \n    @NotNull\n    private DiagnosticAnnotation createKotlinAnnotation(@NotNull Diagnostic diagnostic, @NotNull IFile file) {\n        TextRange range = diagnostic.getTextRanges().get(0);\n        \n        IDocument document = EditorUtil.getDocument(file);\n        int offset = LineEndUtil.convertLfToDocumentOffset(diagnostic.getPsiFile().getText(), \n                range.getStartOffset(), document);\n        \n        int lineOfOffset = 0;\n        try {\n            lineOfOffset = document.getLineOfOffset(offset);\n        } catch (BadLocationException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return new DiagnosticAnnotation(lineOfOffset,\n                offset,\n                range.getLength(),\n                getAnnotationType(diagnostic.getSeverity()), \n                DefaultErrorMessages.render(diagnostic),\n                diagnostic.getPsiElement().getText(),\n                file,\n                diagnostic);\n    }\n    \n    @NotNull\n    private String getAnnotationType(@NotNull Severity severity) {\n        String annotationType = null;\n        switch (severity) {\n            case ERROR:\n                annotationType = AnnotationManager.ANNOTATION_ERROR_TYPE;\n                break;\n            case WARNING:\n                annotationType = AnnotationManager.ANNOTATION_WARNING_TYPE;\n                break;\n            case INFO:\n                throw new UnsupportedOperationException(\"Diagnostics with severith 'INFO' are not supported\");\n        }\n        \n        assert annotationType != null;\n        \n        return annotationType;\n    }\n    \n    public void updateAnnotations(\n            @NotNull AbstractTextEditor editor, \n            @NotNull Map<IFile, List<DiagnosticAnnotation>> annotations) {\n        List<DiagnosticAnnotation> newAnnotations;\n        IFile file = EditorUtil.getFile(editor);\n        if (file != null && annotations.containsKey(file)) {\n            newAnnotations = annotations.get(file);\n            assert newAnnotations != null : \"Null element in annotations map for file \" + file.getName();\n        } else {\n            newAnnotations = Collections.emptyList();\n        }\n        \n        AnnotationManager.INSTANCE.updateAnnotations(editor, newAnnotations);\n    }\n    \n    @Nullable\n    public DiagnosticAnnotation getAnnotationByOffset(@NotNull AbstractTextEditor editor, int offset) {\n        IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());\n        Iterator<?> annotationIterator = annotationModel.getAnnotationIterator();\n        while (annotationIterator.hasNext()) {\n            Annotation annotation = (Annotation) annotationIterator.next();\n            if (annotation instanceof DiagnosticAnnotation) {\n                DiagnosticAnnotation diagnosticAnnotation = (DiagnosticAnnotation) annotation;\n                \n                if (diagnosticAnnotation.getOffset() <= offset && offset <= DiagnosticAnnotationKt.getEndOffset(diagnosticAnnotation)) {\n                    return diagnosticAnnotation;\n                }\n            }\n        }\n        \n        return null;\n    }\n    \n    @Nullable\n    public IMarker getMarkerByOffset(@NotNull IFile file, int offset) {\n        try {\n            IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);\n            for (IMarker marker: markers) {\n                int startOffset = (int) marker.getAttribute(IMarker.CHAR_START);\n                int endOffset = (int) marker.getAttribute(IMarker.CHAR_END);\n                if (startOffset <= offset && offset <= endOffset) {\n                    return marker;\n                }\n            }\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    public static boolean isQuickFixable(@NotNull DiagnosticFactory<?> diagnostic) {\n        return isUnresolvedReference(diagnostic);\n    }\n\n    public static boolean isUnresolvedReference(@NotNull DiagnosticFactory<?> diagnostic) {\n        return Errors.UNRESOLVED_REFERENCE.equals(diagnostic);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/annotations/KotlinAnnotationImageProvider.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.annotations;\n\nimport org.eclipse.jdt.internal.ui.JavaPluginImages;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.ui.texteditor.IAnnotationImageProvider;\nimport org.jetbrains.kotlin.diagnostics.Diagnostic;\n\npublic class KotlinAnnotationImageProvider implements IAnnotationImageProvider {\n\n    @Override\n    public Image getManagedImage(Annotation annotation) {\n        if (annotation instanceof DiagnosticAnnotation) {\n            DiagnosticAnnotation diagnosticAnnotation = (DiagnosticAnnotation) annotation;\n            Diagnostic diagnostic = diagnosticAnnotation.getDiagnostic();\n            if (diagnostic != null && DiagnosticAnnotationUtil.isQuickFixable(diagnostic.getFactory())) {\n                switch (diagnosticAnnotation.getType()) {\n                    case AnnotationManager.ANNOTATION_ERROR_TYPE:\n                        return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_ERROR);\n                    case AnnotationManager.ANNOTATION_WARNING_TYPE:\n                        return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_WARNING);\n                }\n            }\n        }\n        \n        return null;\n    }\n\n    @Override\n    public String getImageDescriptorId(Annotation annotation) {\n        return null;\n    }\n\n    @Override\n    public ImageDescriptor getImageDescriptor(String imageDescritporId) {\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/CompletionElementType.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isExtension\n\nenum class CompletionElementType {\n\tKFUNCTION_TOP,\n\tKVARIABLE_TOP,\n\tKFUNCTION_EXT,\n\tKVARIABLE_EXT,\n\tKFUNCTION,\n\tKVARIABLE,\n\tKCLASS_OBJECT,\n\tUNKNOWN;\n\t\n\tcompanion object {\n\t\tfun from(descriptor: DeclarationDescriptor) : CompletionElementType {\n\t        return when(descriptor) {\n\t            is ClassDescriptor, is TypeParameterDescriptor, is TypeAliasDescriptor -> KCLASS_OBJECT\n\t            is FunctionDescriptor -> when {\n\t\t\t\t\tdescriptor.isExtension -> KFUNCTION_EXT\n\t\t\t\t\tdescriptor.isTopLevelInPackage() -> KFUNCTION_TOP\n\t\t\t\t\telse -> KFUNCTION\n\t\t\t\t}\n\t            is VariableDescriptor -> when {\n\t\t\t\t\tdescriptor.isExtension -> KVARIABLE_EXT\n\t\t\t\t\tdescriptor.isTopLevelInPackage() -> KVARIABLE_TOP\n\t\t\t\t\telse -> KVARIABLE\n\t\t\t\t}\n\t            else -> UNKNOWN\n\t\t\t}\n\t\t}\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/FilterPositionUtil.java",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist;\n\nimport org.jetbrains.annotations.Nullable;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.PsiComment;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.TokenType;\nimport com.intellij.psi.impl.source.tree.TreeUtil;\n\n// These functions were copied from com.intellij.psi.filters.FilterPositionUtil\npublic class FilterPositionUtil {\n    \n    @Nullable\n    public static PsiElement searchNonSpaceNonCommentBack(PsiElement element) {\n        return searchNonSpaceNonCommentBack(element, false);\n    }\n    \n    @Nullable\n    public static PsiElement searchNonSpaceNonCommentBack(PsiElement element, final boolean strict) {\n        if (element == null || element.getNode() == null)\n            return null;\n        ASTNode leftNeibour = TreeUtil.prevLeaf(element.getNode());\n        if (!strict) {\n            while (leftNeibour != null && (leftNeibour.getElementType() == TokenType.WHITE_SPACE\n                    || leftNeibour.getPsi() instanceof PsiComment)) {\n                leftNeibour = TreeUtil.prevLeaf(leftNeibour);\n            }\n        }\n        return leftNeibour != null ? leftNeibour.getPsi() : null;\n        \n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KeywordCompletion.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\n\nimport com.intellij.psi.*\nimport com.intellij.psi.filters.ClassFilter\nimport com.intellij.psi.filters.ElementFilter\nimport com.intellij.psi.filters.NotFilter\nimport com.intellij.psi.filters.OrFilter\nimport com.intellij.psi.filters.position.PositionElementFilter\nimport com.intellij.psi.tree.IElementType\nimport com.intellij.psi.tree.TokenSet\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.KtNodeTypes\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.descriptors.annotations.KotlinTarget\nimport org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*\nimport org.jetbrains.kotlin.lexer.KtKeywordToken\nimport org.jetbrains.kotlin.lexer.KtModifierKeywordToken\nimport org.jetbrains.kotlin.lexer.KtTokens.*\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.*\nimport org.jetbrains.kotlin.renderer.render\nimport org.jetbrains.kotlin.resolve.deprecatedParentTargetMap\nimport org.jetbrains.kotlin.resolve.possibleParentTargetPredicateMap\nimport org.jetbrains.kotlin.resolve.possibleTargetMap\n\nopen class KeywordLookupObject\n\n// This code is mostly copied from Idea plugin\nobject KeywordCompletion {\n    private val ALL_KEYWORDS = (KEYWORDS.types + SOFT_KEYWORDS.types).map { it as KtKeywordToken }\n\n    private val KEYWORDS_TO_IGNORE_PREFIX =\n        TokenSet.create(OVERRIDE_KEYWORD /* it's needed to complete overrides that should be work by member name too */)\n\n    private val COMPOUND_KEYWORDS = mapOf<KtKeywordToken, KtKeywordToken>(\n        COMPANION_KEYWORD to OBJECT_KEYWORD,\n        ENUM_KEYWORD to CLASS_KEYWORD,\n        ANNOTATION_KEYWORD to CLASS_KEYWORD,\n        SEALED_KEYWORD to CLASS_KEYWORD,\n        LATEINIT_KEYWORD to VAR_KEYWORD\n    )\n\n    private val KEYWORD_CONSTRUCTS = mapOf<KtKeywordToken, String>(\n        IF_KEYWORD to \"fun foo() { if (caret)\",\n        WHILE_KEYWORD to \"fun foo() { while(caret)\",\n        FOR_KEYWORD to \"fun foo() { for(caret)\",\n        TRY_KEYWORD to \"fun foo() { try {\\ncaret\\n}\",\n        CATCH_KEYWORD to \"fun foo() { try {} catch (caret)\",\n        FINALLY_KEYWORD to \"fun foo() { try {\\n}\\nfinally{\\ncaret\\n}\",\n        DO_KEYWORD to \"fun foo() { do {\\ncaret\\n}\",\n        INIT_KEYWORD to \"class C { init {\\ncaret\\n}\",\n        CONSTRUCTOR_KEYWORD to \"class C { constructor(caret)\",\n        COMPANION_KEYWORD to \"class C { companion object {\\ncaret\\n}\"\n    )\n\n    private val NO_SPACE_AFTER = listOf(\n        THIS_KEYWORD,\n        SUPER_KEYWORD,\n        NULL_KEYWORD,\n        TRUE_KEYWORD,\n        FALSE_KEYWORD,\n        BREAK_KEYWORD,\n        CONTINUE_KEYWORD,\n        ELSE_KEYWORD,\n        WHEN_KEYWORD,\n        FILE_KEYWORD,\n        DYNAMIC_KEYWORD,\n        GET_KEYWORD,\n        SET_KEYWORD\n    ).map { it.value } + \"companion object\"\n\n    fun complete(position: PsiElement, prefix: String, isJvmModule: Boolean, javaPrj: IJavaProject?, consumer: (String) -> Unit) {\n        if (!GENERAL_FILTER.isAcceptable(position, position)) return\n\n        val parserFilter = buildFilter(position, javaPrj)\n        for (keywordToken in ALL_KEYWORDS) {\n            var keyword = keywordToken.value\n\n            val nextKeyword = COMPOUND_KEYWORDS[keywordToken]\n            var applicableAsCompound = false\n            if (nextKeyword != null) {\n                fun PsiElement.isSpace() = this is PsiWhiteSpace && '\\n' !in getText()\n\n                var next = position.nextLeaf { !(it.isSpace() || it.text == \"$\") }?.text\n                if (next != null && next.startsWith(\"$\")) {\n                    next = next.substring(1)\n                }\n                if (next != nextKeyword.value)\n                    keyword += \" \" + nextKeyword.value\n                else\n                    applicableAsCompound = true\n            }\n\n            if (keywordToken == DYNAMIC_KEYWORD && isJvmModule) continue // not supported for JVM\n\n            // we use simple matching by prefix, not prefix matcher from completion\n            if (!keyword.startsWith(prefix) && keywordToken !in KEYWORDS_TO_IGNORE_PREFIX) continue\n\n            if (!parserFilter(keywordToken)) continue\n\n            val constructText = KEYWORD_CONSTRUCTS[keywordToken]\n            if (constructText != null && !applicableAsCompound) {\n                val element = keyword\n                consumer(element)\n            } else {\n                var element = keyword\n\n                consumer(element)\n            }\n        }\n    }\n\n    private val GENERAL_FILTER = NotFilter(\n        OrFilter(\n            CommentFilter(),\n            ParentFilter(ClassFilter(KtLiteralStringTemplateEntry::class.java)),\n            ParentFilter(ClassFilter(KtConstantExpression::class.java)),\n            LeftNeighbour(TextFilter(\".\")),\n            LeftNeighbour(TextFilter(\"?.\"))\n        )\n    )\n\n    private class CommentFilter() : ElementFilter {\n        override fun isAcceptable(element: Any?, context: PsiElement?) =\n            (element is PsiElement) && KtPsiUtil.isInComment(element)\n\n        override fun isClassAcceptable(hintClass: Class<out Any?>) = true\n    }\n\n    private class ParentFilter(filter: ElementFilter) : PositionElementFilter() {\n        init {\n            setFilter(filter)\n        }\n\n        override fun isAcceptable(element: Any?, context: PsiElement?): Boolean {\n            val parent = (element as? PsiElement)?.parent\n            return parent != null && (filter?.isAcceptable(parent, context) ?: true)\n        }\n    }\n\n    private fun buildFilter(position: PsiElement, javaPrj: IJavaProject?): (KtKeywordToken) -> Boolean {\n        var parent = position.parent\n        var prevParent = position\n        while (parent != null) {\n            when (parent) {\n                is KtBlockExpression -> {\n                    var prefixText = \"fun foo() { \"\n                    if (prevParent is KtExpression) {\n                        // check that we are right after a try-expression without finally-block or after if-expression without else\n                        val prevLeaf =\n                            prevParent.prevLeaf { it !is PsiWhiteSpace && it !is PsiComment && it !is PsiErrorElement }\n                        if (prevLeaf != null) {\n                            val isAfterThen =\n                                prevLeaf.goUpWhileIsLastChild().any { it.node.elementType == KtNodeTypes.THEN }\n\n                            var isAfterTry = false\n                            var isAfterCatch = false\n                            if (prevLeaf.node.elementType == RBRACE) {\n                                val blockParent = (prevLeaf.parent as? KtBlockExpression)?.parent\n                                when (blockParent) {\n                                    is KtTryExpression -> isAfterTry = true\n                                    is KtCatchClause -> {\n                                        isAfterTry = true; isAfterCatch = true\n                                    }\n                                }\n                            }\n\n                            if (isAfterThen) {\n                                if (isAfterTry) {\n                                    prefixText += \"if (a)\\n\"\n                                } else {\n                                    prefixText += \"if (a) {}\\n\"\n                                }\n                            }\n                            if (isAfterTry) {\n                                prefixText += \"try {}\\n\"\n                            }\n                            if (isAfterCatch) {\n                                prefixText += \"catch (e: E) {}\\n\"\n                            }\n                        }\n\n                        return buildFilterWithContext(prefixText, prevParent, position, javaPrj)\n                    } else {\n                        val lastExpression = prevParent\n                            .siblings(forward = false, withItself = false)\n                            .firstIsInstanceOrNull<KtExpression>()\n                        if (lastExpression != null) {\n                            val contextAfterExpression = lastExpression\n                                .siblings(forward = true, withItself = false)\n                                .takeWhile { it != prevParent }\n                                .joinToString { it.text }\n                            return buildFilterWithContext(\n                                prefixText + \"x\" + contextAfterExpression,\n                                prevParent,\n                                position,\n                                javaPrj\n                            )\n                        }\n                    }\n                }\n\n                is KtDeclarationWithInitializer -> {\n                    val initializer = parent.initializer\n                    if (prevParent == initializer) {\n                        return buildFilterWithContext(\"val v = \", initializer, position, javaPrj)\n                    }\n                }\n\n                is KtParameter -> {\n                    val default = parent.defaultValue\n                    if (prevParent == default) {\n                        return buildFilterWithContext(\"val v = \", default, position, javaPrj)\n                    }\n                }\n\n                is KtDeclaration -> {\n                    val scope = parent.parent\n                    when (scope) {\n                        is KtClassOrObject -> {\n                            return if (parent is KtPrimaryConstructor) {\n                                buildFilterWithReducedContext(\"class X \", parent, position, javaPrj)\n                            } else {\n                                buildFilterWithReducedContext(\"class X { \", parent, position, javaPrj)\n                            }\n                        }\n\n                        is KtFile -> return buildFilterWithReducedContext(\"\", parent, position, javaPrj)\n                    }\n                }\n            }\n\n\n            prevParent = parent\n            parent = parent.parent\n        }\n\n        return buildFilterWithReducedContext(\"\", null, position, javaPrj)\n    }\n\n    private fun PsiElement.goUpWhileIsLastChild(): Sequence<PsiElement> {\n        return generateSequence(this) {\n            if (it is PsiFile)\n                null\n            else if (it != it.parent.lastChild)\n                null\n            else\n                it.parent\n        }\n    }\n\n    private fun buildFilterWithContext(\n        prefixText: String,\n        contextElement: PsiElement,\n        position: PsiElement,\n        javaPrj: IJavaProject?\n    ): (KtKeywordToken) -> Boolean {\n        val offset = position.getStartOffsetInAncestor(contextElement)\n        val truncatedContext = contextElement.text!!.substring(0, offset)\n        return buildFilterByText(prefixText + truncatedContext, contextElement, javaPrj)\n    }\n\n    private fun buildFilterWithReducedContext(\n        prefixText: String,\n        contextElement: PsiElement?,\n        position: PsiElement,\n        javaPrj: IJavaProject?\n    ): (KtKeywordToken) -> Boolean {\n        val builder = StringBuilder()\n        buildReducedContextBefore(builder, position, contextElement)\n        return buildFilterByText(prefixText + builder.toString(), position, javaPrj)\n    }\n\n    private fun buildFilesWithKeywordApplication(\n        keywordTokenType: KtKeywordToken,\n        prefixText: String,\n        psiFactory: KtPsiFactory\n    ): Sequence<KtFile> {\n        return computeKeywordApplications(prefixText, keywordTokenType)\n            .map { application -> psiFactory.createFile(prefixText + application) }\n    }\n\n    fun computeKeywordApplications(prefixText: String, keyword: KtKeywordToken): Sequence<String> {\n        return when (keyword) {\n            SUSPEND_KEYWORD -> sequenceOf(\"suspend () -> Unit>\", \"suspend X\")\n            else -> {\n                if (prefixText.endsWith(\"@\"))\n                    sequenceOf(keyword.value + \":X Y.Z\")\n                else\n                    sequenceOf(keyword.value + \" X\")\n            }\n        }\n    }\n\n    private fun buildFilterByText(prefixText: String, position: PsiElement, javaPrj: IJavaProject?): (KtKeywordToken) -> Boolean {\n        val psiFactory = KtPsiFactory(position.project)\n        fun isKeywordCorrectlyApplied(keywordTokenType: KtKeywordToken, file: KtFile): Boolean {\n            val elementAt = file.findElementAt(prefixText.length)!!\n\n            when {\n                !elementAt.node!!.elementType.matchesKeyword(keywordTokenType) -> return false\n\n                elementAt.getNonStrictParentOfType<PsiErrorElement>() != null -> return false\n\n                isErrorElementBefore(elementAt) -> return false\n\n                keywordTokenType !is KtModifierKeywordToken -> return true\n\n                else -> {\n                    if (elementAt.parent !is KtModifierList) return true\n                    val container = elementAt.parent.parent\n                    val possibleTargets = when (container) {\n                        is KtParameter -> {\n                            if (container.ownerFunction is KtPrimaryConstructor)\n                                listOf(VALUE_PARAMETER, MEMBER_PROPERTY)\n                            else\n                                listOf(VALUE_PARAMETER)\n                        }\n\n                        is KtTypeParameter -> listOf(TYPE_PARAMETER)\n\n                        is KtEnumEntry -> listOf(ENUM_ENTRY)\n\n                        is KtClassBody -> listOf(\n                            CLASS_ONLY,\n                            INTERFACE,\n                            OBJECT,\n                            ENUM_CLASS,\n                            ANNOTATION_CLASS,\n                            MEMBER_FUNCTION,\n                            MEMBER_PROPERTY,\n                            FUNCTION,\n                            PROPERTY\n                        )\n\n                        is KtFile -> listOf(\n                            CLASS_ONLY,\n                            INTERFACE,\n                            OBJECT,\n                            ENUM_CLASS,\n                            ANNOTATION_CLASS,\n                            TOP_LEVEL_FUNCTION,\n                            TOP_LEVEL_PROPERTY,\n                            FUNCTION,\n                            PROPERTY\n                        )\n\n                        else -> null\n                    }\n                    val modifierTargets = possibleTargetMap[keywordTokenType]\n                    if (modifierTargets != null && possibleTargets != null && possibleTargets.none { it in modifierTargets }) return false\n\n                    val ownerDeclaration = container?.getParentOfType<KtDeclaration>(strict = true)\n                    val parentTarget = when (ownerDeclaration) {\n                        null -> FILE\n\n                        is KtClass -> {\n                            when {\n                                ownerDeclaration.isInterface() -> INTERFACE\n                                ownerDeclaration.isEnum() -> ENUM_CLASS\n                                ownerDeclaration.isAnnotation() -> ANNOTATION_CLASS\n                                else -> CLASS_ONLY\n                            }\n                        }\n\n                        is KtObjectDeclaration -> if (ownerDeclaration.isObjectLiteral()) OBJECT_LITERAL else OBJECT\n\n                        else -> return true\n                    }\n\n                    val tempLanguageVersionSettings =\n                        javaPrj?.project?.let { KotlinEnvironment.getEnvironment(it).compilerProperties.languageVersionSettings }\n                            ?: LanguageVersionSettingsImpl.DEFAULT\n\n                    return isPossibleParentTarget(keywordTokenType, parentTarget, tempLanguageVersionSettings)\n                }\n            }\n        }\n\n        return fun(keywordTokenType): Boolean {\n            val files = buildFilesWithKeywordApplication(keywordTokenType, prefixText, psiFactory)\n            return files.any { file -> isKeywordCorrectlyApplied(keywordTokenType, file); }\n        }\n    }\n\n    private fun isPossibleParentTarget(\n        modifier: KtModifierKeywordToken,\n        parentTarget: KotlinTarget,\n        languageVersionSettings: LanguageVersionSettings\n    ): Boolean {\n        val deprecatedTargets = deprecatedParentTargetMap[modifier]\n        if (deprecatedTargets != null) {\n            if (parentTarget in deprecatedTargets) return false\n        }\n\n        return possibleParentTargetPredicateMap[modifier]?.isAllowed(parentTarget, languageVersionSettings) ?: true\n    }\n\n    private fun isErrorElementBefore(token: PsiElement): Boolean {\n        for (leaf in token.prevLeafs) {\n            if (leaf is PsiWhiteSpace || leaf is PsiComment) continue\n            if (leaf.parentsWithSelf.any { it is PsiErrorElement }) return true\n            if (leaf.textLength != 0) break\n        }\n        return false\n    }\n\n    private fun IElementType.matchesKeyword(keywordType: KtKeywordToken): Boolean {\n        return when (this) {\n            keywordType -> true\n            NOT_IN -> keywordType == IN_KEYWORD\n            NOT_IS -> keywordType == IS_KEYWORD\n            else -> false\n        }\n    }\n\n    // builds text within scope (or from the start of the file) before position element excluding almost all declarations\n    private fun buildReducedContextBefore(builder: StringBuilder, position: PsiElement, scope: PsiElement?) {\n        if (position == scope) return\n        val parent = position.parent ?: return\n\n        buildReducedContextBefore(builder, parent, scope)\n\n        val prevDeclaration = position.siblings(forward = false, withItself = false).firstOrNull { it is KtDeclaration }\n\n        var child = parent.firstChild\n        while (child != position) {\n            if (child is KtDeclaration) {\n                if (child == prevDeclaration) {\n                    builder.appendReducedText(child)\n                }\n            } else {\n                builder.append(child!!.text)\n            }\n\n            child = child.nextSibling\n        }\n    }\n\n    private fun StringBuilder.appendReducedText(element: PsiElement) {\n        var child = element.firstChild\n        if (child == null) {\n            append(element.text!!)\n        } else {\n            while (child != null) {\n                when (child) {\n                    is KtBlockExpression, is KtClassBody -> append(\"{}\")\n                    else -> appendReducedText(child)\n                }\n\n                child = child.nextSibling\n            }\n        }\n    }\n\n    private fun PsiElement.getStartOffsetInAncestor(ancestor: PsiElement): Int {\n        if (ancestor == this) return 0\n        return parent!!.getStartOffsetInAncestor(ancestor) + startOffsetInParent\n    }\n}\n\nfun breakOrContinueExpressionItems(position: KtElement, breakOrContinue: String): Collection<String> {\n    val result = ArrayList<String>()\n\n    parentsLoop@\n    for (parent in position.parentsWithSelf) {\n        when (parent) {\n            is KtLoopExpression -> {\n                if (result.isEmpty()) {\n                    result.add(breakOrContinue)\n                }\n\n                val label = (parent.getParent() as? KtLabeledExpression)?.getLabelNameAsName()\n                if (label != null) {\n                    result.add(breakOrContinue + label.labelNameToTail())\n                }\n            }\n\n            is KtDeclarationWithBody -> break@parentsLoop //TODO: support non-local break's&continue's when they are supported by compiler\n        }\n    }\n    return result\n}\n\nprivate fun Name?.labelNameToTail(): String = if (this != null) \"@\" + render() else \"\"\n\ninline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? {\n    for (element in this) if (element is T) return element\n    return null\n}\n\ninline fun <reified T : PsiElement> PsiElement.getNonStrictParentOfType(): T? {\n    return PsiTreeUtil.getParentOfType(this, T::class.java, false)\n}\n\ninline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean): T? {\n    return PsiTreeUtil.getParentOfType(this, T::class.java, strict)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinCompletionProcessor.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiFile\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.ui.JavaPlugin\nimport org.eclipse.jdt.internal.ui.JavaPluginImages\nimport org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.Region\nimport org.eclipse.jface.text.contentassist.*\nimport org.eclipse.jface.text.templates.TemplateContext\nimport org.eclipse.jface.text.templates.TemplateProposal\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinImageProvider\nimport org.jetbrains.kotlin.idea.util.CallTypeAndReceiver\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtExpression\nimport org.jetbrains.kotlin.psi.KtSimpleNameExpression\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.completion.KotlinCompletionUtils\nimport org.jetbrains.kotlin.ui.editors.templates.KotlinApplicableTemplateContext\nimport org.jetbrains.kotlin.ui.editors.templates.KotlinDocumentTemplateContext\nimport org.jetbrains.kotlin.ui.editors.templates.KotlinTemplateManager\n\nsealed class KotlinBasicCompletionProposal {\n\n    abstract val descriptor: DeclarationDescriptor\n\n    class Proposal(val proposal: KotlinCompletionProposal, override val descriptor: DeclarationDescriptor) :\n        KotlinBasicCompletionProposal()\n\n    class Descriptor(override val descriptor: DeclarationDescriptor) : KotlinBasicCompletionProposal()\n}\n\nabstract class KotlinCompletionProcessor(\n    val editor: KotlinEditor,\n    private val assistant: ContentAssistant?,\n    private val needSorting: Boolean\n) : IContentAssistProcessor, ICompletionListener {\n\n    companion object {\n        private val VALID_PROPOSALS_CHARS = charArrayOf()\n        fun createKotlinCompletionProcessors(\n            editor: KotlinEditor,\n            assistant: ContentAssistant? = null,\n            needSorting: Boolean = false\n        ) = listOf<IContentAssistProcessor>(\n            object : KotlinCompletionProcessor(editor, assistant, needSorting) {\n                override fun computeProposals(\n                    identifierPart: String,\n                    psiElement: PsiElement?,\n                    simpleNameExpression: KtSimpleNameExpression?,\n                    viewer: ITextViewer,\n                    offset: Int\n                ): List<ICompletionProposal>? =\n                    simpleNameExpression?.let {\n                        collectCompletionProposals(\n                            generateBasicCompletionProposals(identifierPart, simpleNameExpression),\n                            identifierPart\n                        )\n                    }\n            },\n            object : KotlinCompletionProcessor(editor, assistant, needSorting) {\n                override fun computeProposals(\n                    identifierPart: String,\n                    psiElement: PsiElement?,\n                    simpleNameExpression: KtSimpleNameExpression?,\n                    viewer: ITextViewer,\n                    offset: Int\n                ): List<ICompletionProposal>? =\n                    simpleNameExpression?.takeIf { identifierPart.isNotBlank() }?.let {\n                        generateNonImportedCompletionProposals(\n                            identifierPart,\n                            simpleNameExpression,\n                            editor.javaProject!!\n                        )\n                    }\n            },\n            object : KotlinCompletionProcessor(editor, assistant, needSorting) {\n                override fun computeProposals(\n                    identifierPart: String,\n                    psiElement: PsiElement?,\n                    simpleNameExpression: KtSimpleNameExpression?,\n                    viewer: ITextViewer,\n                    offset: Int\n                ): List<ICompletionProposal>? =\n                    psiElement?.let {\n                        generateKeywordProposals(identifierPart, psiElement)\n                    }\n            },\n            object : KotlinCompletionProcessor(editor, assistant, needSorting) {\n                override fun computeProposals(\n                    identifierPart: String,\n                    psiElement: PsiElement?,\n                    simpleNameExpression: KtSimpleNameExpression?,\n                    viewer: ITextViewer,\n                    offset: Int\n                ): List<ICompletionProposal>? =\n                    psiElement?.let {\n                        generateTemplateProposals(psiElement.containingFile, viewer, offset, identifierPart)\n                    }\n            }\n        )\n    }\n\n    override fun computeCompletionProposals(viewer: ITextViewer, offset: Int): Array<ICompletionProposal> {\n        if (assistant != null) {\n            configureContentAssistant(assistant)\n        }\n\n        val generatedProposals = generateCompletionProposals(viewer, offset).let {\n            if (needSorting) sortProposals(it) else it\n        }\n\n        return generatedProposals.toTypedArray()\n    }\n\n    private fun sortProposals(proposals: List<ICompletionProposal>): List<ICompletionProposal> {\n        return proposals.sortedWith(KotlinCompletionSorter::compare)\n    }\n\n    private fun configureContentAssistant(contentAssistant: ContentAssistant) {\n        contentAssistant.setEmptyMessage(\"No Default Proposals\")\n        contentAssistant.setSorter(KotlinCompletionSorter)\n    }\n\n    private fun generateCompletionProposals(viewer: ITextViewer, offset: Int): List<ICompletionProposal> {\n        val (identifierPart, identifierStart) = getIdentifierInfo(viewer.document, offset)\n        val psiElement = KotlinCompletionUtils.getPsiElement(editor, identifierStart)\n        val simpleNameExpression = PsiTreeUtil.getParentOfType(psiElement, KtSimpleNameExpression::class.java)\n\n        return computeProposals(identifierPart, psiElement, simpleNameExpression, viewer, offset) ?: emptyList()\n    }\n\n    abstract fun computeProposals(\n        identifierPart: String,\n        psiElement: PsiElement?,\n        simpleNameExpression: KtSimpleNameExpression?,\n        viewer: ITextViewer,\n        offset: Int\n    ): List<ICompletionProposal>?\n\n    protected fun generateNonImportedCompletionProposals(\n        identifierPart: String,\n        expression: KtSimpleNameExpression,\n        javaProject: IJavaProject\n    ): List<KotlinCompletionProposal> {\n        val file = editor.eclipseFile ?: return emptyList()\n        val ktFile = editor.parsedFile ?: return emptyList()\n\n        val tempTypeProposals = lookupNonImportedTypes(expression, identifierPart, ktFile, javaProject).map {\n            val imageDescriptor = JavaElementImageProvider.getTypeImageDescriptor(false, false, it.modifiers, false)\n            val image = JavaPlugin.getImageDescriptorRegistry().get(imageDescriptor)\n\n            KotlinImportTypeCompletionProposal(it, image, file, identifierPart)\n        }\n\n        return tempTypeProposals\n    }\n\n    protected fun generateBasicCompletionProposals(\n        identifierPart: String,\n        expression: KtSimpleNameExpression\n    ): Collection<KotlinBasicCompletionProposal> {\n        val file = editor.eclipseFile ?: throw IllegalStateException(\"Failed to retrieve IFile from editor $editor\")\n        val ktFile = editor.parsedFile ?: throw IllegalStateException(\"Failed to retrieve KTFile from editor $editor\")\n\n        val nameFilter: (Name) -> Boolean = { name -> KotlinCompletionUtils.applicableNameFor(identifierPart, name) }\n\n        return KotlinCompletionUtils.getReferenceVariants(\n            expression,\n            nameFilter,\n            ktFile,\n            file,\n            identifierPart,\n            editor.javaProject!!\n        )\n    }\n\n    protected fun collectCompletionProposals(\n        descriptors: Collection<KotlinBasicCompletionProposal>,\n        part: String\n    ): List<ICompletionProposal> {\n        return descriptors.map { basicDescriptor ->\n            when (basicDescriptor) {\n                is KotlinBasicCompletionProposal.Descriptor -> {\n                    val descriptor = basicDescriptor.descriptor\n                    val completion = descriptor.name.identifier\n                    val image = KotlinImageProvider.getImage(descriptor)\n\n                    val tempRenderer = DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions {\n                        modifiers = emptySet()\n                        includeAdditionalModifiers = false\n                    }\n\n                    val presentableString = tempRenderer.render(descriptor)\n                    val containmentPresentableString = null\n\n                    val proposal = KotlinCompletionProposal(\n                        completion,\n                        image,\n                        presentableString,\n                        containmentPresentableString,\n                        null,\n                        completion,\n                        part,\n                        CompletionElementType.from(descriptor)\n                    )\n                    withKotlinInsertHandler(descriptor, proposal)\n                }\n                is KotlinBasicCompletionProposal.Proposal -> basicDescriptor.proposal\n            }\n        }\n    }\n\n    protected fun generateTemplateProposals(\n        psiFile: PsiFile, viewer: ITextViewer, offset: Int, identifierPart: String\n    ): List<ICompletionProposal> {\n\n        val contextTypeIds =\n            KotlinApplicableTemplateContext.getApplicableContextTypeIds(viewer, psiFile, offset - identifierPart.length)\n        val region = Region(offset - identifierPart.length, identifierPart.length)\n\n        val templateIcon = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_TEMPLATE)\n        val templates = KotlinApplicableTemplateContext.getTemplatesByContextTypeIds(contextTypeIds)\n\n        return templates\n            .filter { it.name.startsWith(identifierPart) }\n            .map {\n                val templateContext = createTemplateContext(region, it.contextTypeId)\n                TemplateProposal(it, templateContext, region, templateIcon)\n            }\n\n    }\n\n    private fun createTemplateContext(region: IRegion, contextTypeID: String): TemplateContext {\n        return KotlinDocumentTemplateContext(\n            KotlinTemplateManager.INSTANCE.contextTypeRegistry.getContextType(contextTypeID),\n            editor, region.offset, region.length\n        )\n    }\n\n    protected fun generateKeywordProposals(\n        identifierPart: String,\n        expression: PsiElement\n    ): List<KotlinCompletionProposal> {\n        val callTypeAndReceiver =\n            if (expression is KtSimpleNameExpression) CallTypeAndReceiver.detect(expression) else null\n\n        return arrayListOf<String>().apply {\n            KeywordCompletion.complete(expression, identifierPart, true, editor.javaProject) { keywordProposal ->\n                if (!KotlinCompletionUtils.applicableNameFor(identifierPart, keywordProposal)) return@complete\n\n                when (keywordProposal) {\n                    \"break\", \"continue\" -> {\n                        if (expression is KtSimpleNameExpression) {\n                            addAll(breakOrContinueExpressionItems(expression, keywordProposal))\n                        }\n                    }\n\n                    \"class\" -> {\n                        if (callTypeAndReceiver !is CallTypeAndReceiver.CALLABLE_REFERENCE) {\n                            add(keywordProposal)\n                        }\n                    }\n\n                    \"this\", \"return\" -> {\n                        if (expression is KtExpression) {\n                            add(keywordProposal)\n                        }\n                    }\n\n                    else -> add(keywordProposal)\n                }\n            }\n        }.map { KotlinKeywordCompletionProposal(it, identifierPart) }\n    }\n\n    override fun computeContextInformation(viewer: ITextViewer?, offset: Int): Array<IContextInformation> = emptyArray()\n\n    override fun getCompletionProposalAutoActivationCharacters(): CharArray = VALID_PROPOSALS_CHARS\n\n    override fun getContextInformationAutoActivationCharacters(): CharArray = charArrayOf()\n\n    override fun getErrorMessage(): String? = \"\"\n\n    override fun getContextInformationValidator() = null\n\n    override fun assistSessionStarted(event: ContentAssistEvent?) {\n    }\n\n    override fun assistSessionEnded(event: ContentAssistEvent?) {\n    }\n\n    override fun selectionChanged(proposal: ICompletionProposal?, smartToggle: Boolean) {}\n}\n\nprivate object KotlinCompletionSorter : ICompletionProposalSorter {\n    override fun compare(p1: ICompletionProposal, p2: ICompletionProposal): Int {\n\n\t\t// simple and lazy hashing to make relevance more accurate.\n        val relevance2 = ((p2.relevance() * p2.typeRelevance()) + (p2.typeRelevance() / 2))\n        val relevance1 = ((p1.relevance() * p1.typeRelevance()) + (p1.typeRelevance() / 2))\n\t\treturn when {\n            relevance2 > relevance1 -> 1\n            relevance2 < relevance1 -> -1\n\t\t\telse -> p1.sortString().compareTo(p2.sortString(), ignoreCase = true)\n\t\t}\n    }\n\n    private fun ICompletionProposal.sortString(): String =\n        if (this is KotlinCompletionProposal) replacementString else displayString\n\n    private fun ICompletionProposal.relevance(): Int = (this as? KotlinRelevanceCompletionProposal)?.getRelevance() ?: 0\n\n    private fun ICompletionProposal.typeRelevance(): Int {\n        return when (this) {\n            is KotlinKeywordCompletionProposal -> 0\n            is KotlinImportTypeCompletionProposal -> 1\n            is TemplateProposal -> 2\n            is KotlinTypedCompletionProposal -> 3 + type.ordinal\n            else -> 4\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinCompletionProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.core.search.TypeNameMatch\nimport org.eclipse.jdt.ui.JavaElementLabels\nimport org.eclipse.jface.text.DocumentEvent\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.eclipse.jface.text.contentassist.ICompletionProposalExtension2\nimport org.eclipse.jface.text.contentassist.ICompletionProposalExtension6\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.eclipse.jface.viewers.StyledString\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.swt.graphics.Point\nimport org.jetbrains.kotlin.builtins.isExtensionFunctionType\nimport org.jetbrains.kotlin.builtins.isFunctionType\nimport org.jetbrains.kotlin.core.imports.FunctionCandidate\nimport org.jetbrains.kotlin.core.imports.TypeCandidate\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.calls.util.getValueParametersCountFromFunctionType\nimport org.jetbrains.kotlin.ui.editors.codeassist.CaretPosition.AFTER_BRACKETS\nimport org.jetbrains.kotlin.ui.editors.codeassist.CaretPosition.IN_BRACKETS\nimport org.jetbrains.kotlin.ui.editors.completion.KotlinCompletionUtils\nimport org.jetbrains.kotlin.ui.editors.quickfix.placeImports\n\nfun withKotlinInsertHandler(\n    descriptor: DeclarationDescriptor,\n    proposal: KotlinCompletionProposal\n): ICompletionProposal {\n    return when (descriptor) {\n        is FunctionDescriptor -> {\n            val parameters = descriptor.valueParameters\n            when (parameters.size) {\n                0 -> KotlinFunctionCompletionProposal(proposal, AFTER_BRACKETS, false)\n\n                1 -> {\n                    val parameter = parameters.single()\n                    val parameterType = parameter.type\n                    if (parameterType.isFunctionType || parameterType.isExtensionFunctionType) {\n                        val parameterCount = getValueParametersCountFromFunctionType(parameterType)\n                        return if (parameterCount <= 1) {\n                            KotlinFunctionCompletionProposal(proposal, IN_BRACKETS, true)\n                        } else {\n                            val tempParamNames = getLambdaParamNames(parameter)\n                            KotlinFunctionCompletionProposal(proposal, IN_BRACKETS, true, tempParamNames)\n                        }\n                    }\n                    KotlinFunctionCompletionProposal(proposal, IN_BRACKETS, false)\n                }\n\n                else -> KotlinFunctionCompletionProposal(proposal, IN_BRACKETS, false)\n            }\n        }\n\n        else -> proposal\n    }\n}\n\nprivate fun getLambdaParamNames(parameter: ValueParameterDescriptor): String {\n    val typeCharMap = mutableMapOf<Char, Int>()\n    fun Char.nextParamName(): String {\n        val tempChar = lowercaseChar()\n        val tempCurrentNum = typeCharMap[tempChar]\n        return if (tempCurrentNum == null) {\n            typeCharMap[tempChar] = 2\n            \"$tempChar\"\n        } else {\n            typeCharMap[tempChar] = tempCurrentNum + 1\n            \"$tempChar$tempCurrentNum\"\n        }\n    }\n\n    val tempParamNames =\n        parameter.type.arguments.dropLast(1).joinToString(\", \", postfix = \" -> \") {\n            val tempAnnotation =\n                it.type.annotations.findAnnotation(FqName(ParameterName::class.qualifiedName!!))\n            tempAnnotation?.allValueArguments?.get(Name.identifier(ParameterName::name.name))\n                ?.value?.toString() ?: it.type.toString().first().nextParamName()\n        }\n    return tempParamNames\n}\n\nfun getIdentifierInfo(document: IDocument, offset: Int): IdentifierInfo {\n    val text = document.get()\n    var identStartOffset = offset\n    while ((identStartOffset != 0) && Character.isUnicodeIdentifierPart(text[identStartOffset - 1])) {\n        identStartOffset--\n    }\n    return IdentifierInfo(text!!.substring(identStartOffset, offset), identStartOffset)\n}\n\ndata class IdentifierInfo(val identifierPart: String, val identifierStart: Int)\n\ninterface KotlinRelevanceCompletionProposal {\n    fun getRelevance(): Int\n}\n\ninterface KotlinTypedCompletionProposal {\n\n    val type: CompletionElementType\n}\n\nopen class KotlinCompletionProposal constructor(\n    val replacementString: String,\n    private val img: Image?,\n    private val presentableString: String,\n    private val containmentPresentableString: String? = null,\n    private val information: IContextInformation? = null,\n    private val additionalInfo: String? = null,\n    @Volatile private var identifierPart: String,\n    override val type: CompletionElementType = CompletionElementType.UNKNOWN\n) : ICompletionProposal, ICompletionProposalExtension2, ICompletionProposalExtension6, KotlinTypedCompletionProposal, KotlinRelevanceCompletionProposal {\n\n    private var selectedOffset = -1\n    override fun getRelevance(): Int {\n        return computeCaseMatchingRelevance(identifierPart.toCharArray(), replacementString.toCharArray())\n    }\n\n    override fun apply(viewer: ITextViewer, trigger: Char, stateMask: Int, offset: Int) {\n        val document = viewer.document\n        val (identifierPart, identifierStart) = getIdentifierInfo(document, offset)\n        document.replace(identifierStart, offset - identifierStart, replacementString)\n\n        selectedOffset = offset - identifierPart.length + replacementString.length\n    }\n\n    override fun validate(document: IDocument, offset: Int, event: DocumentEvent): Boolean {\n        val identiferInfo = getIdentifierInfo(document, offset)\n        identifierPart = identiferInfo.identifierPart\n        return KotlinCompletionUtils.applicableNameFor(identiferInfo.identifierPart, replacementString)\n    }\n\n    override fun getSelection(document: IDocument): Point? = Point(selectedOffset, 0)\n\n    override fun getAdditionalProposalInfo(): String? = additionalInfo\n\n    override fun getDisplayString(): String = presentableString\n\n    override fun getImage(): Image? = img\n\n    override fun getContextInformation(): IContextInformation? = information\n\n    override fun getStyledDisplayString(): StyledString {\n        return if (containmentPresentableString != null) {\n            createStyledString(displayString, containmentPresentableString)\n        } else {\n            StyledString(displayString)\n        }\n    }\n\n    override fun selected(viewer: ITextViewer?, smartToggle: Boolean) {\n    }\n\n    override fun unselected(viewer: ITextViewer?) {\n    }\n\n    final override fun apply(document: IDocument) {\n        // should not be called\n    }\n}\n\nclass KotlinImportTypeCompletionProposal(\n    private val typeName: TypeNameMatch,\n    image: Image?,\n    val file: IFile,\n    identifierPart: String\n) :\n    KotlinCompletionProposal(\n        typeName.simpleTypeName,\n        image,\n        typeName.simpleTypeName,\n        typeName.fullyQualifiedName.removeSuffix(\".${typeName.simpleTypeName}\"),\n        identifierPart = identifierPart\n    ) {\n\n    private var importShift = -1\n\n    override fun apply(viewer: ITextViewer, trigger: Char, stateMask: Int, offset: Int) {\n        super.apply(viewer, trigger, stateMask, offset)\n        importShift = placeImports(listOf(TypeCandidate(typeName)), file, viewer.document)\n    }\n\n    override fun getSelection(document: IDocument): Point? {\n        val selection = super.getSelection(document)\n        return if (importShift > 0 && selection != null) Point(selection.x + importShift, 0) else selection\n    }\n\n    override fun getRelevance(): Int {\n        return -1\n    }\n}\n\nclass KotlinImportCallableCompletionProposal(\n    val descriptor: CallableDescriptor,\n    image: Image?,\n    val file: IFile,\n    identifierPart: String\n) :\n    KotlinCompletionProposal(\n        \"${descriptor.name.identifier}${if (descriptor is PropertyDescriptor) \"\" else \"()\"}\",\n        image,\n        DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(descriptor),\n        null,\n        identifierPart = identifierPart\n    ) {\n\n    private var importShift = -1\n\n    override fun apply(viewer: ITextViewer, trigger: Char, stateMask: Int, offset: Int) {\n        super.apply(viewer, trigger, stateMask, offset)\n        importShift = placeImports(listOf(FunctionCandidate(descriptor)), file, viewer.document)\n    }\n\n    override fun getSelection(document: IDocument): Point? {\n        val selection = super.getSelection(document)\n        return if (importShift > 0 && selection != null) Point(selection.x + importShift, 0) else selection\n    }\n\n    override fun getRelevance(): Int = -1\n}\n\nclass KotlinKeywordCompletionProposal(keyword: String, identifierPart: String) :\n    KotlinCompletionProposal(keyword, null, keyword, identifierPart = identifierPart)\n\nprivate fun createStyledString(simpleName: String, containingDeclaration: String): StyledString {\n    return StyledString().apply {\n        append(simpleName)\n        if (containingDeclaration.isNotBlank()) {\n            append(JavaElementLabels.CONCAT_STRING, StyledString.QUALIFIER_STYLER)\n            append(containingDeclaration, StyledString.QUALIFIER_STYLER)\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinContextInfoContentAssistProcessor.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.eclipse.jface.text.contentassist.IContentAssistProcessor\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nclass KotlinContextInfoContentAssistProcessor(private val editor: KotlinEditor) : IContentAssistProcessor {\n\n    private val kotlinParameterValidator by lazy {\n        KotlinParameterListValidator(editor)\n    }\n\n    override fun computeCompletionProposals(p0: ITextViewer?, p1: Int): Array<ICompletionProposal> = emptyArray()\n\n    override fun computeContextInformation(p0: ITextViewer?, offset: Int): Array<IContextInformation> {\n        return KotlinFunctionParameterInfoAssist.computeContextInformation(editor, offset)\n    }\n\n    override fun getCompletionProposalAutoActivationCharacters() = charArrayOf()\n\n    override fun getContextInformationAutoActivationCharacters() = VALID_INFO_CHARS\n\n    override fun getErrorMessage() = \"\"\n\n    override fun getContextInformationValidator() = kotlinParameterValidator\n\n    companion object {\n        private val VALID_INFO_CHARS = charArrayOf('(', ',')\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinFunctionCompletionProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.eclipse.jface.text.contentassist.ICompletionProposalExtension2\nimport org.eclipse.jface.text.contentassist.ICompletionProposalExtension6\nimport org.eclipse.swt.graphics.Point\n\nenum class CaretPosition {\n    IN_BRACKETS,\n    AFTER_BRACKETS\n}\n\nclass KotlinFunctionCompletionProposal(\n    private val proposal: KotlinCompletionProposal,\n    private val caretPosition: CaretPosition,\n    private val hasLambda: Boolean,\n    private val lambdaParamNames: String = \"\"\n) : ICompletionProposal by proposal, ICompletionProposalExtension2 by proposal,\n    ICompletionProposalExtension6 by proposal, KotlinTypedCompletionProposal by proposal,\n    KotlinRelevanceCompletionProposal by proposal {\n\n    init {\n        if (caretPosition == CaretPosition.AFTER_BRACKETS && hasLambda) {\n            throw IllegalArgumentException(\"CaretPosition.AFTER_BRACKETS with lambdaInfo != null combination is not supported\")\n        }\n    }\n\n    override fun apply(viewer: ITextViewer, trigger: Char, stateMask: Int, offset: Int) {\n        proposal.apply(viewer, trigger, stateMask, offset)\n\n        addBrackets(viewer, trigger, proposal.getSelection(viewer.document)!!.x)\n        if (trigger == '.') {\n            val closeBracketOffset = viewer.textWidget.caretOffset\n            viewer.document.replace(closeBracketOffset, 0, trigger.toString())\n            viewer.textWidget.caretOffset = closeBracketOffset + 1\n        }\n    }\n\n    override fun getSelection(document: IDocument): Point? = null\n\n\n    private fun addBrackets(viewer: ITextViewer, completionChar: Char, completionOffset: Int) {\n        val document = viewer.document\n        val braces = hasLambda && completionChar != '('\n\n        val openingBracket = if (braces) '{' else '('\n        val closingBracket = if (braces) '}' else ')'\n\n        var openingBracketOffset = indexOfSkippingSpace(document, openingBracket, completionOffset)\n        var inBracketsShift = 0\n        if (openingBracketOffset == -1) {\n            if (braces) {\n                document.replace(completionOffset, 0, \" { $lambdaParamNames }\")\n                inBracketsShift = 1\n            } else {\n                document.replace(completionOffset, 0, \"()\")\n            }\n        }\n\n        openingBracketOffset = indexOfSkippingSpace(document, openingBracket, completionOffset)\n        assert(openingBracketOffset != -1) { \"If there wasn't open bracket it should already have been inserted\" }\n\n        val closeBracketOffset = indexOfSkippingSpace(document, closingBracket, openingBracketOffset + 1)\n\n        if (shouldPlaceCaretInBrackets(completionChar) || closeBracketOffset == -1) {\n            viewer.setSelectedRange(openingBracketOffset + 1 + inBracketsShift, 0)\n        } else {\n            viewer.setSelectedRange(closeBracketOffset + 1, 0)\n        }\n    }\n\n    private fun indexOfSkippingSpace(document: IDocument, ch: Char, startIndex: Int): Int {\n        val text = document.get()\n        for (i in startIndex until text.length) {\n            val currentChar = text[i]\n            if (ch == currentChar) return i\n            if (currentChar != ' ' && currentChar != '\\t') return -1\n        }\n        return -1\n    }\n\n    private fun shouldPlaceCaretInBrackets(completionChar: Char): Boolean {\n        return when (completionChar) {\n            '.' -> false\n            '(' -> true\n            else -> caretPosition == CaretPosition.IN_BRACKETS\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinFunctionParameterInfoAssist.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.eclipse.swt.graphics.Image\nimport org.jetbrains.kotlin.core.resolve.EclipseDescriptorUtils\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinImageProvider\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtCallElement\nimport org.jetbrains.kotlin.psi.KtParameter\nimport org.jetbrains.kotlin.psi.KtSimpleNameExpression\nimport org.jetbrains.kotlin.psi.KtValueArgumentList\nimport org.jetbrains.kotlin.psi.psiUtil.getCallNameExpression\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.descriptorUtil.declaresOrInheritsDefaultValue\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.completion.KotlinCompletionUtils\n\nobject KotlinFunctionParameterInfoAssist {\n    fun computeContextInformation(editor: KotlinEditor, offset: Int): Array<IContextInformation> {\n        val file = editor.eclipseFile ?: throw IllegalStateException(\"Failed to retrieve IFile from editor $editor\")\n        val ktFile = editor.parsedFile ?: throw IllegalStateException(\"Failed to retrieve KTFile from editor $editor\")\n        val javaProject = editor.javaProject ?: throw IllegalStateException(\"Failed to retrieve JavaProject from editor $editor\")\n\n        val expression = getCallSimpleNameExpression(editor, offset) ?: return emptyArray()\n\n        val referencedName = expression.getReferencedName()\n\n        val nameFilter: (Name) -> Boolean = { name -> name.asString() == referencedName }\n        val variants = KotlinCompletionUtils.getReferenceVariants(\n            expression,\n            nameFilter,\n            ktFile,\n            file,\n            referencedName,\n            javaProject\n        )\n        \n        return variants.map { it.descriptor }\n                .flatMap { \n                    when (it) {\n                        is FunctionDescriptor -> listOf(it)\n                        is ClassDescriptor -> it.constructors\n                        else -> emptyList<FunctionDescriptor>()\n                    }\n                }\n                .filter { it.valueParameters.isNotEmpty() }\n                .map { KotlinFunctionParameterContextInformation(it) }\n                .toTypedArray()\n    }\n}\n\nfun getCallSimpleNameExpression(editor: KotlinEditor, offset: Int): KtSimpleNameExpression? {\n    val psiElement = EditorUtil.getPsiElement(editor, offset)\n    val argumentList = PsiTreeUtil.getParentOfType(psiElement, KtValueArgumentList::class.java) ?: return null\n\n    val argumentListParent = argumentList.parent\n    return if (argumentListParent is KtCallElement) argumentListParent.getCallNameExpression() else null\n}\n\nclass KotlinFunctionParameterContextInformation(descriptor: FunctionDescriptor) : IContextInformation {\n    private val displayString = DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.withOptions {\n        this.withDefinedIn = false\n    }.render(descriptor)\n    val renderedParameters = descriptor.valueParameters.map { renderParameter(it) }\n    private val informationString = renderedParameters.joinToString(\", \")\n    private val displayImage = KotlinImageProvider.getImage(descriptor)\n    val name = if (descriptor is ConstructorDescriptor) descriptor.containingDeclaration.name else descriptor.name\n    \n    override fun getContextDisplayString(): String = displayString\n    \n    override fun getImage(): Image? = displayImage\n    \n    override fun getInformationDisplayString(): String = informationString\n    \n    private fun renderParameter(parameter: ValueParameterDescriptor): String {\n        val result = StringBuilder()\n        \n        if (parameter.varargElementType != null) result.append(\"vararg \")\n        result.append(parameter.name)\n                .append(\": \")\n                .append(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(getActualParameterType(parameter)))\n        \n        if (parameter.declaresOrInheritsDefaultValue()) {\n            val parameterDeclaration = EclipseDescriptorUtils.descriptorToDeclaration(parameter)\n            if (parameterDeclaration != null) {\n                result.append(\" = ${getDefaultExpressionString(parameterDeclaration)}\")\n            }\n        }\n        \n        return result.toString()\n    }\n    \n    private fun getDefaultExpressionString(parameterDeclaration: SourceElement): String {\n        val parameterText: String? = if (parameterDeclaration is KotlinSourceElement) {\n                val parameter = parameterDeclaration.psi\n                (parameter as? KtParameter)?.defaultValue?.text\n            } else {\n                null\n            }\n        \n        return parameterText ?: \"...\"\n    }\n    \n    private fun getActualParameterType(descriptor: ValueParameterDescriptor): KotlinType {\n        return descriptor.varargElementType ?: descriptor.type\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/KotlinParameterListValidator.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport com.intellij.psi.PsiErrorElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.TextPresentation\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.eclipse.jface.text.contentassist.IContextInformationPresenter\nimport org.eclipse.jface.text.contentassist.IContextInformationValidator\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.custom.StyleRange\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.psi.KtValueArgumentList\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport kotlin.properties.Delegates\n\nclass KotlinParameterListValidator(val editor: KotlinEditor) : IContextInformationValidator,\n    IContextInformationPresenter {\n    var info: KotlinFunctionParameterContextInformation by Delegates.notNull()\n    var viewer: ITextViewer by Delegates.notNull()\n    var position: Int by Delegates.notNull()\n    var previousIndex: Int by Delegates.notNull()\n\n    override fun install(info: IContextInformation, viewer: ITextViewer, offset: Int) {\n        this.info = info as KotlinFunctionParameterContextInformation\n        this.viewer = viewer\n        this.position = offset\n        this.previousIndex = -1\n    }\n\n    override fun isContextInformationValid(offset: Int): Boolean {\n        EditorUtil.updatePsiFile(editor)\n\n        val document = viewer.document\n        val line = document.getLineInformationOfOffset(position)\n\n        if (offset < line.offset) return false\n\n        val currentArgumentIndex = getCurrentArgumentIndex(offset)\n        if (currentArgumentIndex == null || isIndexOutOfBound(currentArgumentIndex)) {\n            return false\n        }\n\n        val expression = getCallSimpleNameExpression(editor, offset)\n\n        return expression?.getReferencedName() == info.name.asString()\n    }\n\n    override fun updatePresentation(offset: Int, presentation: TextPresentation): Boolean {\n        val currentArgumentIndex = getCurrentArgumentIndex(offset)\n        if (currentArgumentIndex == null || previousIndex == currentArgumentIndex) {\n            return false\n        }\n        presentation.clear()\n        previousIndex = currentArgumentIndex\n\n        if (isIndexOutOfBound(currentArgumentIndex)) return false\n\n        val renderedParameter = info.renderedParameters[currentArgumentIndex]\n\n        val displayString = info.informationDisplayString\n        val start = displayString.indexOf(renderedParameter)\n        if (start >= 0) {\n            presentation.addStyleRange(StyleRange(0, start, null, null, SWT.NORMAL))\n\n            val end = start + renderedParameter.length\n            presentation.addStyleRange(StyleRange(start, end - start, null, null, SWT.BOLD))\n            presentation.addStyleRange(StyleRange(end, displayString.length - end, null, null, SWT.NORMAL))\n\n            return true\n        }\n\n        return true\n    }\n\n    private fun isIndexOutOfBound(index: Int): Boolean = info.renderedParameters.size <= index\n\n    //    Copied with some changes from JetFunctionParameterInfoHandler.java\n    private fun getCurrentArgumentIndex(offset: Int): Int? {\n        val psiElement = EditorUtil.getPsiElement(editor, offset)\n        val argumentList =\n            PsiTreeUtil.getNonStrictParentOfType(psiElement, KtValueArgumentList::class.java) ?: return null\n\n        val offsetInPSI = LineEndUtil.convertCrToDocumentOffset(editor.document, offset)\n        var child = argumentList.node.firstChildNode\n        var index = 0\n        while (child != null && child.startOffset < offsetInPSI) {\n            if (child.elementType == KtTokens.COMMA ||\n                (child.text == \",\" && child is PsiErrorElement)\n            ) ++index\n            child = child.treeNext\n        }\n\n        return index\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/VisibilityUtils.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.psi.KtClassBody\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtSimpleNameExpression\nimport org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression\nimport org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.scopes.LexicalScope\nimport org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver\nimport org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy\n\n// from idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt but without the second parameter\nfun PsiElement.getResolutionScope(bindingContext: BindingContext): LexicalScope {\n    for (parent in parentsWithSelf) {\n        if (parent is KtElement) {\n            val scope = bindingContext[BindingContext.LEXICAL_SCOPE, parent]\n            if (scope != null) return scope\n        }\n\n        if (parent is KtClassBody) {\n            val classDescriptor = bindingContext[BindingContext.CLASS, parent.getParent()] as? ClassDescriptorWithResolutionScopes\n            if (classDescriptor != null) {\n                return classDescriptor.getScopeForMemberDeclarationResolution()\n            }\n        }\n    }\n    error(\"Not in JetFile\")\n}\n\n//from idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt\nfun DeclarationDescriptorWithVisibility.isVisible(\n    from: DeclarationDescriptor,\n    bindingContext: BindingContext? = null,\n    element: KtSimpleNameExpression? = null\n): Boolean {\n    if (DescriptorVisibilities.isVisibleWithAnyReceiver(this, from, /*TODO true right?*/true)) return true\n\n    if (bindingContext == null || element == null) return false\n\n    val receiverExpression = element.getReceiverExpression()\n    if (receiverExpression != null) {\n        val receiverType = bindingContext.getType(receiverExpression) ?: return false\n        val explicitReceiver = ExpressionReceiver.create(receiverExpression, receiverType, bindingContext)\n        return DescriptorVisibilities.isVisible(explicitReceiver, this, from, /*TODO true right?*/true)\n    }\n    else {\n        val resolutionScope = element.getResolutionScope(bindingContext)\n        return resolutionScope.getImplicitReceiversHierarchy().any {\n            DescriptorVisibilities.isVisible(it.value, this, from, /*TODO true right?*/true)\n        }\n    }\n}\n\n//from idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt\nfun TypeParameterDescriptor.isVisible(where: DeclarationDescriptor?): Boolean {\n    val owner = getContainingDeclaration()\n    var parent = where\n    while (parent != null) {\n        if (parent == owner) return true\n        if (parent is ClassDescriptor && !parent.isInner()) return false\n        parent = parent.getContainingDeclaration()\n    }\n    return true\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/nonImportedCompletionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.jetbrains.kotlin.psi.KtSimpleNameExpression\nimport org.jetbrains.kotlin.idea.util.CallTypeAndReceiver\nimport org.eclipse.jdt.core.search.TypeNameMatchRequestor\nimport org.eclipse.jdt.core.search.TypeNameMatch\nimport org.eclipse.jdt.core.Flags\nimport org.eclipse.jdt.core.search.SearchEngine\nimport org.eclipse.jdt.core.search.SearchPattern\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.eclipse.jdt.core.JavaCore\nimport com.intellij.openapi.util.text.StringUtil\n\nfun lookupNonImportedTypes(\n        simpleNameExpression: KtSimpleNameExpression,\n        identifierPart: String,\n        ktFile: KtFile,\n        javaProject: IJavaProject): List<TypeNameMatch> {\n    if (!identifierPart.isCapitalized()) return emptyList()\n    \n    val callTypeAndReceiver = CallTypeAndReceiver.detect(simpleNameExpression)\n    \n    val isAnnotation = callTypeAndReceiver is CallTypeAndReceiver.ANNOTATION\n     \n    if ((callTypeAndReceiver !is CallTypeAndReceiver.TYPE &&\n            callTypeAndReceiver !is CallTypeAndReceiver.DEFAULT &&\n            !isAnnotation) ||\n            callTypeAndReceiver.receiver != null) {\n        return emptyList()\n    }\n    \n    val importsSet = ktFile.importDirectives\n            .mapNotNull { it.importedFqName?.asString() }\n            .toSet()\n    \n    val originPackage = ktFile.packageFqName.asString()\n    \n    // TODO: exclude variants by callType.descriptorKind\n    return searchFor(identifierPart, javaProject, isAnnotation)\n            .filter {\n                it.fullyQualifiedName !in importsSet &&\n                it.packageName !in importsSet &&\n                it.packageName != originPackage\n            }\n}\n\nprivate fun String.isCapitalized(): Boolean = isNotEmpty() && this[0].isUpperCase()\n\nprivate fun searchFor(identifierPart: String, javaProject: IJavaProject, isAnnotation: Boolean): List<TypeNameMatch> {\n    val foundTypes = arrayListOf<TypeNameMatch>()\n    val collector = object : TypeNameMatchRequestor() {\n        override fun acceptTypeNameMatch(match: TypeNameMatch) {\n            if (Flags.isPublic(match.modifiers)) {\n                foundTypes.add(match)\n            }\n        }\n    }\n    \n    val searchEngine = SearchEngine()\n    \n    val dependencyProjects = arrayListOf<IJavaProject>().apply {\n        addAll(ProjectUtils.getDependencyProjects(javaProject).map { JavaCore.create(it) })\n        add(javaProject)\n    }\n    \n    val javaProjectSearchScope = JavaSearchScopeFactory.getInstance().createJavaSearchScope(dependencyProjects.toTypedArray(), true)\n    searchEngine.searchAllTypeNames(null, \n                SearchPattern.R_EXACT_MATCH, \n                identifierPart.toCharArray(), \n                SearchPattern.R_CAMELCASE_MATCH, \n                if (isAnnotation) IJavaSearchConstants.ANNOTATION_TYPE else IJavaSearchConstants.TYPE, \n                javaProjectSearchScope, \n                collector,\n                IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, \n                null)\n    \n    return foundTypes\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/positionFilters.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.codeassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiNamedElement\nimport com.intellij.psi.PsiType\nimport com.intellij.psi.filters.ElementFilter\nimport com.intellij.psi.filters.position.PositionElementFilter\n\nclass TextFilter(val value: String) : ElementFilter {\n    override fun isAcceptable(element: Any?, context: PsiElement?): Boolean {\n        if (element == null) return false\n        return getTextByElement(element) == value\n    }\n\n    override fun isClassAcceptable(hintClass: Class<*>): Boolean = true\n    \n    private fun getTextByElement(element: Any): String? {\n        return when (element) {\n            is PsiType -> element.presentableText\n            is PsiNamedElement -> element.name\n            is PsiElement -> element.text\n            else -> null\n        }\n    }\n}\n\nclass LeftNeighbour(filter: ElementFilter) : PositionElementFilter() {\n    init {\n        setFilter(filter)\n    }\n    \n    override fun isAcceptable(element: Any?, context: PsiElement?): Boolean {\n        if (element !is PsiElement) return false\n        \n        val previous = FilterPositionUtil.searchNonSpaceNonCommentBack(element)\n        return if (previous != null) getFilter().isAcceptable(previous, context) else false\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/codeassist/relevanceSorting.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n\npackage org.jetbrains.kotlin.ui.editors.codeassist\n\nimport org.eclipse.jdt.internal.codeassist.RelevanceConstants.*\nimport org.eclipse.jdt.core.compiler.CharOperation\n\n// Inspired by CompletionEngine.computeRelevanceForCaseMatching\nfun computeCaseMatchingRelevance(part: CharArray, proposal: CharArray): Int {\n    return when {\n        CharOperation.equals(part, proposal, true) -> R_CASE + R_EXACT_NAME\n        CharOperation.prefixEquals(part, proposal, true) -> R_CASE\n        CharOperation.camelCaseMatch(part, proposal) -> R_CAMEL_CASE\n        CharOperation.equals(part, proposal, false) -> R_EXACT_NAME\n        else -> 0\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/completion/KotlinCompletionUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.completion\n\nimport com.intellij.openapi.util.text.StringUtilRt\nimport com.intellij.psi.PsiElement\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.search.SearchPattern\nimport org.eclipse.jdt.internal.ui.JavaPlugin\nimport org.eclipse.jdt.ui.PreferenceConstants\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.core.resolve.KotlinResolutionFacade\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility\nimport org.jetbrains.kotlin.descriptors.TypeParameterDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtSimpleNameExpression\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinBasicCompletionProposal\nimport org.jetbrains.kotlin.ui.editors.codeassist.getResolutionScope\nimport org.jetbrains.kotlin.ui.editors.codeassist.isVisible\n\nobject KotlinCompletionUtils {\n    private const val KOTLIN_DUMMY_IDENTIFIER = \"KotlinRulezzz\"\n    \n    fun applicableNameFor(prefix: String, name: Name): Boolean {\n        return !name.isSpecial && applicableNameFor(prefix, name.identifier)\n    }\n    \n    fun applicableNameFor(prefix: String, completion: String): Boolean {\n        return completion.startsWith(prefix) || \n            completion.toLowerCase().startsWith(prefix) || \n            SearchPattern.camelCaseMatch(prefix, completion)\n    }\n    \n    fun getReferenceVariants(\n        simpleNameExpression: KtSimpleNameExpression,\n        nameFilter: (Name) -> Boolean,\n        ktFile: KtFile,\n        file: IFile,\n        identifierPart: String?,\n        javaProject: IJavaProject\n    ): Collection<KotlinBasicCompletionProposal> {\n        val (analysisResult, container) = KotlinAnalyzer.analyzeFile(simpleNameExpression.containingKtFile)\n        if (container == null) return emptyList()\n        \n        val inDescriptor = simpleNameExpression\n                .getReferencedNameElement()\n                .getResolutionScope(analysisResult.bindingContext)\n                .ownerDescriptor\n        \n        val showNonVisibleMembers =\n            !JavaPlugin.getDefault().preferenceStore.getBoolean(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS)\n        \n        val visibilityFilter = { descriptor: DeclarationDescriptor ->\n            when (descriptor) {\n                is TypeParameterDescriptor -> descriptor.isVisible(inDescriptor)\n                \n                is DeclarationDescriptorWithVisibility -> {\n                    showNonVisibleMembers || descriptor.isVisible(inDescriptor, analysisResult.bindingContext, simpleNameExpression)\n                }\n                \n                else -> true\n            }\n        }\n        \n        val collectAll = (identifierPart == null || identifierPart.length > 2) || !KotlinScriptEnvironment.isScript(file)\n        val kind = if (collectAll) DescriptorKindFilter.ALL else DescriptorKindFilter.CALLABLES\n\n        return KotlinReferenceVariantsHelper(\n            analysisResult.bindingContext,\n            KotlinResolutionFacade(file, container, analysisResult.moduleDescriptor),\n            analysisResult.moduleDescriptor,\n            visibilityFilter\n        ).getReferenceVariants(simpleNameExpression, kind, nameFilter, javaProject, ktFile, file, identifierPart)\n    }\n    \n    fun getPsiElement(editor: KotlinEditor, identOffset: Int): PsiElement? {\n        val sourceCode = EditorUtil.getSourceCode(editor)\n        val sourceCodeWithMarker = StringBuilder(sourceCode).insert(identOffset, KOTLIN_DUMMY_IDENTIFIER).toString()\n        val jetFile: KtFile?\n        val file = editor.eclipseFile\n        if (file != null) {\n            jetFile = KotlinPsiManager.parseText(StringUtilRt.convertLineSeparators(sourceCodeWithMarker), file)\n        } else {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor $editor\", null)\n            return null\n        }\n        \n        if (jetFile == null) return null\n        \n        val offsetWithoutCR = LineEndUtil.convertCrToDocumentOffset(sourceCodeWithMarker, identOffset, editor.document)\n        return jetFile.findElementAt(offsetWithoutCR)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/completion/KotlinReferenceVariantsHelper.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.completion\n\nimport com.intellij.psi.PsiElement\nimport kotlinx.coroutines.*\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.core.Flags\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.core.search.*\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.jetbrains.kotlin.config.LanguageFeature\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.core.resolve.KotlinResolutionFacade\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinEclipseScope\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinImageProvider\nimport org.jetbrains.kotlin.idea.FrontendInternals\nimport org.jetbrains.kotlin.idea.imports.importableFqName\nimport org.jetbrains.kotlin.idea.resolve.ResolutionFacade\nimport org.jetbrains.kotlin.idea.util.*\nimport org.jetbrains.kotlin.incremental.KotlinLookupLocation\nimport org.jetbrains.kotlin.incremental.components.NoLookupLocation\nimport org.jetbrains.kotlin.js.resolve.diagnostics.findPsi\nimport org.jetbrains.kotlin.load.kotlin.toSourceElement\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor\nimport org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore\nimport org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager\nimport org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver\nimport org.jetbrains.kotlin.resolve.descriptorUtil.classValueType\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isExtension\nimport org.jetbrains.kotlin.resolve.scopes.*\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter.Companion.CALLABLES\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter.Companion.FUNCTIONS_MASK\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter.Companion.VARIABLES_MASK\nimport org.jetbrains.kotlin.resolve.scopes.receivers.ClassQualifier\nimport org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered\nimport org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope\nimport org.jetbrains.kotlin.resolve.source.getPsi\nimport org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.types.expressions.DoubleColonLHS\nimport org.jetbrains.kotlin.types.typeUtil.isSubtypeOf\nimport org.jetbrains.kotlin.types.typeUtil.isUnit\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinBasicCompletionProposal\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinImportCallableCompletionProposal\nimport org.jetbrains.kotlin.ui.refactorings.extract.parentsWithSelf\nimport java.util.*\n\nclass KotlinReferenceVariantsHelper(\n    val bindingContext: BindingContext,\n    private val resolutionFacade: KotlinResolutionFacade,\n    private val moduleDescriptor: ModuleDescriptor,\n    val visibilityFilter: (DeclarationDescriptor) -> Boolean\n) {\n    fun getReferenceVariants(\n        simpleNameExpression: KtSimpleNameExpression,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        javaProject: IJavaProject,\n        ktFile: KtFile,\n        file: IFile,\n        identifierPart: String?\n    ): Collection<KotlinBasicCompletionProposal> {\n        val callTypeAndReceiver = CallTypeAndReceiver.detect(simpleNameExpression)\n        var variants: Collection<KotlinBasicCompletionProposal> =\n            getReferenceVariants(\n                simpleNameExpression,\n                callTypeAndReceiver,\n                kindFilter,\n                nameFilter,\n                javaProject,\n                ktFile,\n                file,\n                identifierPart\n            ).filter {\n                !resolutionFacade.frontendService<DeprecationResolver>().isHiddenInResolution(it.descriptor) &&\n                        visibilityFilter(it.descriptor)\n            }\n\n        val tempFilter = ShadowedDeclarationsFilter.create(\n            bindingContext,\n            resolutionFacade,\n            simpleNameExpression,\n            callTypeAndReceiver\n        )\n        if (tempFilter != null) {\n            variants = variants.mapNotNull {\n                if (tempFilter.filter(listOf(it.descriptor)).isEmpty()) null else it\n            }\n        }\n\n        return variants.filter { kindFilter.accepts(it.descriptor) }\n    }\n\n    private fun getVariantsForImportOrPackageDirective(\n        receiverExpression: KtExpression?,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean\n    ): Collection<DeclarationDescriptor> {\n        if (receiverExpression != null) {\n            val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList()\n            val staticDescriptors = qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter)\n\n            val objectDescriptor = (qualifier as? ClassQualifier)?.descriptor?.takeIf { it.kind == ClassKind.OBJECT }\n                ?: return staticDescriptors\n\n            return staticDescriptors + objectDescriptor.defaultType.memberScope.getDescriptorsFiltered(\n                kindFilter,\n                nameFilter\n            )\n        } else {\n            val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT)\n            return rootPackage.memberScope.getDescriptorsFiltered(kindFilter, nameFilter)\n        }\n    }\n\n    private fun getVariantsForUserType(\n        receiverExpression: KtExpression?,\n        contextElement: PsiElement,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean\n    ): Collection<DeclarationDescriptor> {\n        if (receiverExpression != null) {\n            val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList()\n            return qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter)\n        } else {\n            val scope = contextElement.getResolutionScope(bindingContext, resolutionFacade)\n            return scope.collectDescriptorsFiltered(kindFilter, nameFilter, changeNamesForAliased = true)\n        }\n    }\n\n    private fun getVariantsForCallableReference(\n        callTypeAndReceiver: CallTypeAndReceiver.CALLABLE_REFERENCE,\n        contextElement: PsiElement,\n        useReceiverType: KotlinType?,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean\n    ): Collection<KotlinBasicCompletionProposal> {\n        val descriptors = LinkedHashSet<KotlinBasicCompletionProposal>()\n\n        val resolutionScope = contextElement.getResolutionScope(bindingContext, resolutionFacade)\n\n        val receiver = callTypeAndReceiver.receiver\n        if (receiver != null) {\n            val isStatic = bindingContext[BindingContext.DOUBLE_COLON_LHS, receiver] is DoubleColonLHS.Type\n\n            val explicitReceiverTypes: Collection<KotlinType> = useReceiverType?.let {\n                listOf(useReceiverType)\n            } ?: callTypeAndReceiver.receiverTypes(\n                bindingContext,\n                contextElement,\n                moduleDescriptor,\n                resolutionFacade,\n                stableSmartCastsOnly = false\n            )!!\n\n            val constructorFilter = { descriptor: ClassDescriptor -> if (isStatic) true else descriptor.isInner }\n            descriptors.addNonExtensionMembers(explicitReceiverTypes, kindFilter, nameFilter, constructorFilter)\n\n            descriptors.addScopeAndSyntheticExtensions(\n                resolutionScope,\n                explicitReceiverTypes,\n                CallType.CALLABLE_REFERENCE,\n                kindFilter,\n                nameFilter\n            )\n\n            if (isStatic) {\n                explicitReceiverTypes\n                    .mapNotNull { (it.constructor.declarationDescriptor as? ClassDescriptor)?.staticScope }\n                    .flatMapTo(descriptors) { scope ->\n                        scope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter)\n                            .map { KotlinBasicCompletionProposal.Descriptor(it) }\n                    }\n            }\n        } else {\n            descriptors.addNonExtensionCallablesAndConstructors(\n                resolutionScope,\n                kindFilter, nameFilter, constructorFilter = { !it.isInner },\n                classesOnly = false\n            )\n        }\n        return descriptors\n    }\n\n    private fun getReferenceVariants(\n        simpleNameExpression: KtSimpleNameExpression,\n        callTypeAndReceiver: CallTypeAndReceiver<*, *>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        javaProject: IJavaProject,\n        ktFile: KtFile,\n        file: IFile,\n        identifierPart: String?\n    ): Collection<KotlinBasicCompletionProposal> {\n        val callType = callTypeAndReceiver.callType\n\n        @Suppress(\"NAME_SHADOWING\")\n        val kindFilter = kindFilter.intersect(callType.descriptorKindFilter)\n\n        val receiverExpression: KtExpression?\n        when (callTypeAndReceiver) {\n            is CallTypeAndReceiver.IMPORT_DIRECTIVE -> {\n                return getVariantsForImportOrPackageDirective(callTypeAndReceiver.receiver, kindFilter, nameFilter)\n                    .map { KotlinBasicCompletionProposal.Descriptor(it) }\n            }\n\n            is CallTypeAndReceiver.PACKAGE_DIRECTIVE -> {\n                return getVariantsForImportOrPackageDirective(callTypeAndReceiver.receiver, kindFilter, nameFilter)\n                    .map { KotlinBasicCompletionProposal.Descriptor(it) }\n            }\n\n            is CallTypeAndReceiver.TYPE -> {\n                return getVariantsForUserType(\n                    callTypeAndReceiver.receiver,\n                    simpleNameExpression,\n                    kindFilter,\n                    nameFilter\n                ).map { KotlinBasicCompletionProposal.Descriptor(it) }\n            }\n\n            is CallTypeAndReceiver.ANNOTATION -> {\n                return getVariantsForUserType(\n                    callTypeAndReceiver.receiver,\n                    simpleNameExpression,\n                    kindFilter,\n                    nameFilter\n                ).map { KotlinBasicCompletionProposal.Descriptor(it) }\n            }\n\n            is CallTypeAndReceiver.CALLABLE_REFERENCE -> {\n                return getVariantsForCallableReference(\n                    callTypeAndReceiver,\n                    simpleNameExpression,\n                    null,\n                    kindFilter,\n                    nameFilter\n                )\n            }\n\n            is CallTypeAndReceiver.DEFAULT -> receiverExpression = null\n            is CallTypeAndReceiver.DOT -> receiverExpression = callTypeAndReceiver.receiver\n            is CallTypeAndReceiver.SUPER_MEMBERS -> receiverExpression = callTypeAndReceiver.receiver\n            is CallTypeAndReceiver.SAFE -> receiverExpression = callTypeAndReceiver.receiver\n            is CallTypeAndReceiver.INFIX -> receiverExpression = callTypeAndReceiver.receiver\n            is CallTypeAndReceiver.OPERATOR -> return emptyList()\n            is CallTypeAndReceiver.UNKNOWN -> return emptyList()\n            else -> throw RuntimeException()\n        }\n\n        val resolutionScope = simpleNameExpression.getResolutionScope(bindingContext, resolutionFacade)\n        val dataFlowInfo = bindingContext.getDataFlowInfoBefore(simpleNameExpression)\n        val containingDeclaration = resolutionScope.ownerDescriptor\n\n        val smartCastManager = resolutionFacade.frontendService<SmartCastManager>()\n        val languageVersionSettings = resolutionFacade.frontendService<LanguageVersionSettings>()\n\n        val implicitReceiverTypes = resolutionScope.getImplicitReceiversWithInstance(\n            languageVersionSettings.supportsFeature(LanguageFeature.DslMarkersSupport)\n        ).flatMap {\n            smartCastManager.getSmartCastVariantsWithLessSpecificExcluded(\n                it.value,\n                bindingContext,\n                containingDeclaration,\n                dataFlowInfo,\n                languageVersionSettings,\n                resolutionFacade.frontendService()\n            )\n        }.toSet()\n\n        val descriptors = LinkedHashSet<KotlinBasicCompletionProposal>()\n\n        val filterWithoutExtensions = kindFilter exclude DescriptorKindExclude.Extensions\n        if (receiverExpression != null) {\n            val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression]\n            if (qualifier != null) {\n                descriptors.addAll(\n                    qualifier.staticScope.collectStaticMembers(\n                        resolutionFacade,\n                        filterWithoutExtensions,\n                        nameFilter\n                    ).map { KotlinBasicCompletionProposal.Descriptor(it) }\n                )\n            }\n\n            val explicitReceiverTypes = callTypeAndReceiver.receiverTypes(\n                bindingContext,\n                simpleNameExpression,\n                moduleDescriptor,\n                resolutionFacade,\n                stableSmartCastsOnly = false\n            )!!\n\n            descriptors.processAll(\n                implicitReceiverTypes,\n                explicitReceiverTypes,\n                resolutionScope,\n                callType,\n                kindFilter,\n                nameFilter,\n                javaProject,\n                ktFile,\n                file,\n                identifierPart,\n                false\n            )\n        } else {\n            descriptors.processAll(\n                implicitReceiverTypes,\n                implicitReceiverTypes,\n                resolutionScope,\n                callType,\n                kindFilter,\n                nameFilter,\n                javaProject,\n                ktFile,\n                file,\n                identifierPart,\n                true\n            )\n\n            descriptors.addAll(\n                resolutionScope.collectDescriptorsFiltered(\n                    filterWithoutExtensions,\n                    nameFilter,\n                    changeNamesForAliased = true\n                ).map { KotlinBasicCompletionProposal.Descriptor(it) }\n            )\n        }\n\n        if (callType == CallType.SUPER_MEMBERS) { // we need to unwrap fake overrides in case of \"super.\" because ShadowedDeclarationsFilter does not work correctly\n            return descriptors.filterIsInstance<KotlinBasicCompletionProposal.Descriptor>()\n                .flatMapTo(LinkedHashSet<KotlinBasicCompletionProposal>()) { descriptor ->\n                    if (descriptor.descriptor is CallableMemberDescriptor && descriptor.descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {\n                        descriptor.descriptor.overriddenDescriptors.map { KotlinBasicCompletionProposal.Descriptor(it) }\n                    } else {\n                        listOf(descriptor)\n                    }\n                }\n        }\n\n        return descriptors.distinctBy { (it.descriptor as? ImportedFromObjectCallableDescriptor<*>)?.callableFromObject ?: it.descriptor }\n    }\n\n    private fun MutableSet<KotlinBasicCompletionProposal>.processAll(\n        implicitReceiverTypes: Collection<KotlinType>,\n        receiverTypes: Collection<KotlinType>,\n        resolutionScope: LexicalScope,\n        callType: CallType<*>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        javaProject: IJavaProject,\n        ktFile: KtFile,\n        file: IFile,\n        identifierPart: String?,\n        allowNoReceiver: Boolean\n    ) {\n        runBlocking {\n            val tempJobs = mutableListOf<Job>()\n            tempJobs += KotlinEclipseScope.launch {\n                addNonExtensionMembers(receiverTypes, kindFilter, nameFilter, constructorFilter = { it.isInner })\n            }\n            tempJobs += KotlinEclipseScope.launch {\n                addMemberExtensions(implicitReceiverTypes, receiverTypes, callType, kindFilter, nameFilter)\n            }\n            tempJobs += KotlinEclipseScope.launch {\n                addNotImportedTopLevelCallables(\n                    receiverTypes,\n                    kindFilter,\n                    nameFilter,\n                    javaProject,\n                    ktFile,\n                    file,\n                    identifierPart,\n                    allowNoReceiver\n                )\n                println(\"Finished!\")\n            }\n            tempJobs += KotlinEclipseScope.launch {\n                addScopeAndSyntheticExtensions(resolutionScope, receiverTypes, callType, kindFilter, nameFilter)\n            }\n            tempJobs.joinAll()\n        }\n    }\n\n    private suspend fun MutableSet<KotlinBasicCompletionProposal>.addNotImportedTopLevelCallables(\n        receiverTypes: Collection<KotlinType>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        javaProject: IJavaProject,\n        ktFile: KtFile,\n        file: IFile,\n        identifierPart: String?,\n        allowNoReceiver: Boolean\n    ) {\n        if (!identifierPart.isNullOrBlank()) {\n            val searchEngine = SearchEngine()\n\n            val dependencyProjects = arrayListOf<IJavaProject>().apply {\n                addAll(ProjectUtils.getDependencyProjects(javaProject).map { JavaCore.create(it) })\n                add(javaProject)\n            }\n\n            val javaProjectSearchScope =\n                JavaSearchScopeFactory.getInstance().createJavaSearchScope(dependencyProjects.toTypedArray(), false)\n\n            val tempClassNames = hashMapOf<String, String>()\n\n            val collector = object : MethodNameMatchRequestor() {\n                override fun acceptMethodNameMatch(match: MethodNameMatch) {\n                    if (Flags.isPublic(match.modifiers)) {\n                        tempClassNames[match.method.declaringType.getTypeQualifiedName('.')] =\n                            match.method.declaringType.packageFragment.elementName\n                    }\n                }\n            }\n\n            searchEngine.searchAllMethodNames(\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                identifierPart.toCharArray(),\n                SearchPattern.R_PREFIX_MATCH,\n                javaProjectSearchScope,\n                collector,\n                IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH,\n                null\n            )\n\n            val tempCapitalIdentifier =\n                identifierPart.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }\n\n            searchEngine.searchAllMethodNames(\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                null,\n                SearchPattern.R_EXACT_MATCH,\n                \"get$tempCapitalIdentifier\".toCharArray(),\n                SearchPattern.R_PREFIX_MATCH,\n                javaProjectSearchScope,\n                collector,\n                IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH,\n                null\n            )\n\n            val tempPackages = mutableListOf<PackageViewDescriptor>()\n\n            val tempClasses = tempClassNames.mapNotNull { (className, packageName) ->\n                val tempClassId = ClassId(FqName(packageName), FqName(className), false)\n                moduleDescriptor.findClassAcrossModuleDependencies(tempClassId) ?: run {\n                    tempPackages.add(resolutionFacade.moduleDescriptor.getPackage(FqName(packageName)))\n                    null\n                }\n            }\n\n            val importsSet = ktFile.importDirectives\n                .mapNotNull { it.importedFqName?.asString() }\n                .toSet()\n\n            val originPackage = ktFile.packageFqName.asString()\n\n            fun MemberScope.filterByKindAndName() = getDescriptorsFiltered(\n                kindFilter.intersect(CALLABLES),\n                nameFilter\n            ).asSequence()\n                .filterIsInstance<CallableDescriptor>()\n                .filter { callDesc ->\n                    val tempFuzzy = callDesc.fuzzyExtensionReceiverType()\n                    //We need all where the receiver matches.\n                    val anyReceiverMatch = tempFuzzy != null && receiverTypes.any { receiverType ->\n                        tempFuzzy.checkIsSuperTypeOf(receiverType) != null\n                    }\n                    //Or all, where we have no receiver, it's ok to have no receiver and the containing class of the callable Descriptor is not in the list of receivers, as this would give us the same completion twice.\n                    val isTopLevelOrObjectCallable = callDesc.isTopLevelInPackage() || (callDesc.containingDeclaration as? ClassDescriptor)?.let { containing ->\n                        val tempContainingKotlinType = containing.classValueType\n                        val tempIsObject = containing.kind == ClassKind.OBJECT\n                        val tempContainingIsReceiver =  tempContainingKotlinType != null && receiverTypes.any { receiver -> receiver.isSubtypeOf(tempContainingKotlinType) }\n                        tempIsObject && !tempContainingIsReceiver\n                    } == true\n                    val noReceiverMatches = allowNoReceiver && tempFuzzy == null && isTopLevelOrObjectCallable\n                    noReceiverMatches || anyReceiverMatch\n                }\n                .filter { callDesc ->\n                    callDesc.importableFqName?.asString() !in importsSet &&\n                            callDesc.importableFqName?.parent()?.asString() != originPackage\n                }.toList()\n\n            val tempDeferreds =\n                tempPackages.map { desc -> KotlinEclipseScope.async { desc.memberScope.filterByKindAndName() } } +\n                        tempClasses.map { desc -> KotlinEclipseScope.async { desc.unsubstitutedMemberScope.filterByKindAndName() } }\n\n            val tempDescriptors = tempDeferreds.awaitAll().flatten()\n\n            tempDescriptors\n                .map {\n                    KotlinBasicCompletionProposal.Proposal(\n                        KotlinImportCallableCompletionProposal(\n                            it,\n                            KotlinImageProvider.getImage(it),\n                            file,\n                            identifierPart\n                        ), it\n                    )\n                }.toCollection(this)\n        }\n    }\n\n    private fun MutableSet<KotlinBasicCompletionProposal>.addMemberExtensions(\n        dispatchReceiverTypes: Collection<KotlinType>,\n        extensionReceiverTypes: Collection<KotlinType>,\n        callType: CallType<*>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n    ) {\n        val memberFilter = kindFilter exclude DescriptorKindExclude.NonExtensions\n        for (dispatchReceiverType in dispatchReceiverTypes) {\n            for (member in dispatchReceiverType.memberScope.getDescriptorsFiltered(memberFilter, nameFilter)) {\n                addAll((member as CallableDescriptor).substituteExtensionIfCallable(extensionReceiverTypes, callType)\n                    .map { KotlinBasicCompletionProposal.Descriptor(it) })\n            }\n        }\n    }\n\n    private fun MutableSet<KotlinBasicCompletionProposal>.addNonExtensionMembers(\n        receiverTypes: Collection<KotlinType>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        constructorFilter: (ClassDescriptor) -> Boolean\n    ) {\n        for (receiverType in receiverTypes) {\n            addNonExtensionCallablesAndConstructors(\n                receiverType.memberScope.memberScopeAsImportingScope(),\n                kindFilter, nameFilter, constructorFilter,\n                false\n            )\n            receiverType.constructor.supertypes.forEach {\n                addNonExtensionCallablesAndConstructors(\n                    it.memberScope.memberScopeAsImportingScope(),\n                    kindFilter, nameFilter, constructorFilter,\n                    true\n                )\n            }\n        }\n    }\n\n    private fun MutableSet<KotlinBasicCompletionProposal>.addNonExtensionCallablesAndConstructors(\n        scope: HierarchicalScope,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean,\n        constructorFilter: (ClassDescriptor) -> Boolean,\n        classesOnly: Boolean\n    ) {\n        var filterToUse = DescriptorKindFilter(kindFilter.kindMask and CALLABLES.kindMask).exclude(\n            DescriptorKindExclude.Extensions\n        )\n\n        // should process classes if we need constructors\n        if (filterToUse.acceptsKinds(FUNCTIONS_MASK)) {\n            filterToUse = filterToUse.withKinds(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK)\n        }\n\n        for (descriptor in scope.collectDescriptorsFiltered(filterToUse, nameFilter, changeNamesForAliased = true)) {\n            if (descriptor is ClassDescriptor) {\n                if (descriptor.modality == Modality.ABSTRACT || descriptor.modality == Modality.SEALED) continue\n                if (!constructorFilter(descriptor)) continue\n                descriptor.constructors.map { KotlinBasicCompletionProposal.Descriptor(it) }\n                    .filterTo(this) { kindFilter.accepts(it.descriptor) }\n            } else if (!classesOnly && kindFilter.accepts(descriptor)) {\n                this.add(KotlinBasicCompletionProposal.Descriptor(descriptor))\n            }\n        }\n    }\n\n    private fun MutableSet<KotlinBasicCompletionProposal>.addScopeAndSyntheticExtensions(\n        scope: LexicalScope,\n        receiverTypes: Collection<KotlinType>,\n        callType: CallType<*>,\n        kindFilter: DescriptorKindFilter,\n        nameFilter: (Name) -> Boolean\n    ) {\n        if (kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) return\n        if (receiverTypes.isEmpty()) return\n\n        fun process(extensionOrSyntheticMember: CallableDescriptor) {\n            if (kindFilter.accepts(extensionOrSyntheticMember) && nameFilter(extensionOrSyntheticMember.name)) {\n                if (extensionOrSyntheticMember.isExtension) {\n                    addAll(\n                        extensionOrSyntheticMember.substituteExtensionIfCallable(receiverTypes, callType)\n                            .map { KotlinBasicCompletionProposal.Descriptor(it) })\n                } else {\n                    add(KotlinBasicCompletionProposal.Descriptor(extensionOrSyntheticMember))\n                }\n            }\n        }\n\n        for (descriptor in scope.collectDescriptorsFiltered(\n            kindFilter exclude DescriptorKindExclude.NonExtensions,\n            nameFilter,\n            changeNamesForAliased = true\n        )) {\n            process(descriptor as CallableDescriptor)\n        }\n\n        val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)\n        if (kindFilter.acceptsKinds(VARIABLES_MASK)) {\n            val lookupLocation =\n                (scope.ownerDescriptor.toSourceElement.getPsi() as? KtElement)?.let { KotlinLookupLocation(it) }\n                    ?: NoLookupLocation.FROM_IDE\n\n            for (extension in syntheticScopes.collectSyntheticExtensionProperties(receiverTypes, lookupLocation)) {\n                process(extension)\n            }\n        }\n\n        if (kindFilter.acceptsKinds(FUNCTIONS_MASK)) {\n            for (syntheticMember in syntheticScopes.collectSyntheticMemberFunctions(receiverTypes)) {\n                process(syntheticMember)\n            }\n        }\n    }\n\n    private fun <TDescriptor : DeclarationDescriptor> filterOutJavaGettersAndSetters(variants: Collection<TDescriptor>): Collection<TDescriptor> {\n        val accessorMethodsToRemove = HashSet<FunctionDescriptor>()\n        val filteredVariants = variants.filter { it !is SyntheticJavaPropertyDescriptor }\n\n        for (variant in filteredVariants) {\n            if (variant is SyntheticJavaPropertyDescriptor) {\n                accessorMethodsToRemove.add(variant.getMethod.original)\n\n                val setter = variant.setMethod\n                if (setter != null && setter.returnType?.isUnit() == true) { // we do not filter out non-Unit setters\n                    accessorMethodsToRemove.add(setter.original)\n                }\n            }\n        }\n\n        return filteredVariants.filter { it !is FunctionDescriptor || it.original !in accessorMethodsToRemove }\n    }\n\n    private fun excludeNonInitializedVariable(\n        variants: Collection<DeclarationDescriptor>,\n        contextElement: PsiElement\n    ): Collection<DeclarationDescriptor> {\n        for (element in contextElement.parentsWithSelf) {\n            val parent = element.parent\n            if (parent is KtVariableDeclaration && element == parent.initializer) {\n                return variants.filter { it.findPsi() != parent }\n            }\n            if (element is KtDeclaration) break // we can use variable inside lambda or anonymous object located in its initializer\n        }\n        return variants\n    }\n}\n\nprivate fun MemberScope.collectStaticMembers(\n    resolutionFacade: ResolutionFacade,\n    kindFilter: DescriptorKindFilter,\n    nameFilter: (Name) -> Boolean\n): Collection<DeclarationDescriptor> {\n    return getDescriptorsFiltered(kindFilter, nameFilter) + collectSyntheticStaticMembersAndConstructors(\n        resolutionFacade,\n        kindFilter,\n        nameFilter\n    )\n}\n\n@OptIn(FrontendInternals::class)\nfun ResolutionScope.collectSyntheticStaticMembersAndConstructors(\n    resolutionFacade: ResolutionFacade,\n    kindFilter: DescriptorKindFilter,\n    nameFilter: (Name) -> Boolean\n): List<FunctionDescriptor> {\n    val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)\n    val functionDescriptors = this.getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)\n    val classifierDescriptors = this.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS)\n    return (syntheticScopes.collectSyntheticStaticFunctions(functionDescriptors) + syntheticScopes.collectSyntheticConstructors(\n        classifierDescriptors\n    ))\n        .filter { kindFilter.accepts(it) && nameFilter(it.name) }\n}\n\n@OptIn(FrontendInternals::class)\nprivate inline fun <reified T : Any> ResolutionFacade.frontendService(): T = this.getFrontendService(T::class.java)\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinHighlightingColors.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.highlighting\n\nimport org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings\nimport org.eclipse.swt.graphics.RGB\n\nclass KotlinHighlightingAttributes private constructor() {\n    companion object {\n        fun withAttributes(changeAttributes: KotlinHighlightingAttributes.() -> Unit): KotlinHighlightingAttributes {\n            val attributes = KotlinHighlightingAttributes()\n            attributes.changeAttributes()\n            return attributes\n        }\n        \n        val LOCAL_FINAL_VARIABLE = withAttributes { \n            this.styleKey = SemanticHighlightings.LOCAL_VARIABLE\n        }\n        \n        val LOCAL_VARIABLE = withAttributes { \n            this.styleKey = SemanticHighlightings.LOCAL_VARIABLE\n            this.underline = true\n        }\n        \n        val PARAMETER_VARIABLE = withAttributes { \n            this.styleKey = SemanticHighlightings.PARAMETER_VARIABLE\n        }\n        \n        val FIELD = withAttributes { \n            this.styleKey = SemanticHighlightings.FIELD\n            this.underline = true\n        }\n        \n        val FINAL_FIELD = withAttributes { \n            this.styleKey = SemanticHighlightings.FIELD\n        }\n        \n        val STATIC_FIELD = withAttributes { \n            this.styleKey = SemanticHighlightings.STATIC_FIELD\n            this.underline = true\n        }\n        \n        val STATIC_FINAL_FIELD = withAttributes { \n            this.styleKey = SemanticHighlightings.STATIC_FINAL_FIELD\n        }\n        \n        val TYPE_PARAMETER = withAttributes { \n            this.styleKey = SemanticHighlightings.TYPE_VARIABLE\n        }\n        \n        val ANNOTATION = withAttributes { \n            this.styleKey = SemanticHighlightings.ANNOTATION\n        }\n        \n        val ENUM_CLASS = withAttributes { \n            this.styleKey = SemanticHighlightings.ENUM\n        }\n        \n        val INTERFACE = withAttributes { \n            this.styleKey = SemanticHighlightings.INTERFACE\n        }\n        \n        val CLASS = withAttributes { \n            this.styleKey = SemanticHighlightings.CLASS\n        }\n        \n        val FUNCTION_DECLARATION = withAttributes { \n            this.styleKey = SemanticHighlightings.METHOD_DECLARATION\n        }\n    }\n    \n    lateinit var styleKey: String\n    var underline = false\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinPositionUpdater.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.highlighting\n\nimport org.eclipse.jface.text.IPositionUpdater\nimport org.eclipse.jface.text.DocumentEvent\nimport org.eclipse.jface.text.Position\n\n// Inspired by org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter.HighlightinPositionUpdater\npublic class KotlinPositionUpdater(val category: String) : IPositionUpdater {\n    override fun update(event: DocumentEvent) {\n        val editionData = EditionData(event)\n        \n        for (position in event.getDocument().getPositions(category)) {\n            when {\n                editionData.end < position.offset -> {\n                    position.setOffset(position.offset + editionData.delta)\n                }\n                \n                position.end < editionData.offset -> { } // do nothing\n                \n                position.offset <= editionData.offset && editionData.end <= position.end -> {\n                    updateWithEditionInsidePosition(position, editionData)\n                } \n                \n                position.offset <= editionData.offset -> updateWithOverEnd(position, editionData)\n                \n                editionData.end <= position.end -> updateWithOverStart(position, editionData)\n                \n                else -> position.delete()\n            }\n        }\n    }\n    \n    private fun updateWithOverStart(position: Position, editionData: EditionData) {\n        val excludedLength = editionData.text\n            .takeLastWhile { Character.isJavaIdentifierPart(it) }\n            .length\n        val deleted = editionData.end - position.offset\n        val inserted = editionData.textLength - excludedLength\n        position.update(editionData.offset + excludedLength, position.getLength() - deleted + inserted)\n    }\n    \n    private fun updateWithOverEnd(position: Position, editionData: EditionData) {\n        val validSymbolsLength = editionData.text\n                .takeWhile { Character.isJavaIdentifierPart(it) }\n                .length\n        position.setLength(editionData.offset - position.offset + validSymbolsLength)\n    }\n    \n    private fun updateWithEditionInsidePosition(position: Position, editionData: EditionData) {\n        val allSymbolsValid = editionData.text.all { Character.isJavaIdentifierPart(it) }\n        if (allSymbolsValid) {\n            position.setLength(position.length + editionData.delta)\n        } else {\n            position.delete()\n        }\n    }\n}\n\nprivate val Position.end: Int\n    get() = offset + length\n\nprivate class EditionData(event: DocumentEvent) {\n    val offset = event.offset\n    val length = event.length\n    val end = offset + length\n    val text = event.text\n    val textLength = text?.length ?: 0\n    val delta = textLength - length\n}\n\nprivate fun Position.update(offset: Int, length: Int) {\n    this.setOffset(offset)\n    this.setLength(length)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlighting.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.highlighting\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer\nimport org.eclipse.jdt.ui.PreferenceConstants\nimport org.eclipse.jdt.ui.text.IColorManager\nimport org.eclipse.jface.preference.IPreferenceStore\nimport org.eclipse.jface.preference.PreferenceConverter\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextInputListener\nimport org.eclipse.jface.text.ITextPresentationListener\nimport org.eclipse.jface.text.TextPresentation\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.jface.util.IPropertyChangeListener\nimport org.eclipse.jface.util.PropertyChangeEvent\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.custom.StyleRange\nimport org.eclipse.swt.graphics.Color\nimport org.eclipse.swt.graphics.RGB\nimport org.eclipse.swt.graphics.TextStyle\nimport org.eclipse.swt.widgets.Display\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.runJob\nimport org.jetbrains.kotlin.ui.editors.Configuration.KotlinPresentationReconciler\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinReconcilingListener\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager\nimport org.jetbrains.kotlin.ui.editors.highlighting.HighlightPosition.SmartCast\nimport org.jetbrains.kotlin.ui.editors.highlighting.HighlightPosition.StyleAttributes\n\nprivate val SMART_CAST_ANNOTATION_TYPE = \"org.jetbrains.kotlin.ui.annotation.smartCast\"\n\nclass KotlinSemanticHighlighter(\n        val preferenceStore: IPreferenceStore, \n        val colorManager: IColorManager,\n        val presentationReconciler: KotlinPresentationReconciler,\n        val editor: KotlinEditor) : KotlinReconcilingListener, ITextPresentationListener, IPropertyChangeListener, ITextInputListener {\n    private val positionUpdater by lazy { KotlinPositionUpdater(category) }\n    \n    private val category by lazy { toString() }\n    \n    override fun applyTextPresentation(textPresentation: TextPresentation) {\n        if (!editor.document.containsPositionCategory(category)) {\n            KotlinLogger.logWarning(\"There is no position category for editor\")\n            return\n        }\n\n        val region = textPresentation.extent\n        val regionStart = region.offset\n        val regionEnd = regionStart + region.length\n        \n        editor.document.getPositions(category)\n            .filter { regionStart <= it.getOffset() && it.getOffset() + it.getLength() <= regionEnd }\n            .filterNot { it.isDeleted() }\n            .forEach { position ->\n                when (position) {\n                    is StyleAttributes -> {\n                        val styleRange = position.createStyleRange()\n                        \n                        textPresentation.replaceStyleRange(styleRange)\n                    }\n                }\n            }\n    }\n\n    override fun reconcile(file: IFile, editor: KotlinEditor) {\n        val document = when (editor) {\n            is KotlinCommonEditor -> editor.getDocumentSafely()\n            else -> null\n        }\n        \n        if (document == null) return\n        \n        KotlinPsiManager.commitFile(file, document)\n        \n        removeAllPositions(document)\n        \n        val ktFile = editor.parsedFile\n        if (ktFile == null) return\n        \n        val highlightingVisitor = KotlinSemanticHighlightingVisitor(ktFile, editor.document)\n        val smartCasts = arrayListOf<SmartCast>()\n        highlightingVisitor.computeHighlightingRanges().forEach { position -> \n            when (position) {\n                is StyleAttributes -> editor.document.addPosition(category, position)\n                is SmartCast -> smartCasts.add(position)\n            }\n            \n        }\n        \n        invalidateTextPresentation()\n        setupSmartCastsAsAnnotations(smartCasts)\n    }\n    \n    override fun propertyChange(event: PropertyChangeEvent) {\n        if (event.property.startsWith(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX)) {\n            editor.eclipseFile?.let { reconcile(it, editor) }\n        }\n    }\n    \n    override fun inputDocumentChanged(oldInput: IDocument?, newInput: IDocument?) {\n        if (newInput != null) {\n            manageDocument(newInput)\n            val file = editor.eclipseFile\n            if (file != null) reconcile(file, editor)\n        }\n    }\n    \n    override fun inputDocumentAboutToBeChanged(oldInput: IDocument?, newInput: IDocument?) {\n        if (oldInput != null) {\n            removeAllPositions(oldInput)\n            releaseDocument(oldInput)\n        }\n    }\n\n    fun install(callback: () -> Unit = {}) {\n        val viewer = editor.javaEditor.viewer\n        val file = editor.eclipseFile\n        if (file != null && viewer is JavaSourceViewer) {\n            manageDocument(editor.document)\n            \n            preferenceStore.addPropertyChangeListener(this)\n            \n            viewer.addTextInputListener(this)\n            viewer.prependTextPresentationListener(this)\n\n            runJob(\"Install semantic highlighting\", Job.DECORATE, null, {\n                reconcile(file, editor)\n                Status.OK_STATUS\n            }) {\n                callback()\n            }\n        } else {\n            KotlinLogger.logWarning(\"Cannot install Kotlin Semantic highlighter for viewer $viewer\")\n        }\n    }\n    \n    fun uninstall() {\n        val viewer = editor.javaEditor.viewer\n        if (viewer is JavaSourceViewer) {\n            viewer.removeTextPresentationListener(this)\n            viewer.removeTextInputListener(this)\n            \n            releaseDocument(editor.document)\n            \n            preferenceStore.removePropertyChangeListener(this)\n        }\n    }\n    \n    private fun manageDocument(document: IDocument) {\n        document.addPositionCategory(category)\n        document.addPositionUpdater(positionUpdater)\n    }\n    \n    private fun releaseDocument(document: IDocument) {\n        if (document.containsPositionCategory(category)) {\n            document.removePositionCategory(category)            \n        }\n        document.removePositionUpdater(positionUpdater)\n    }\n    \n    private fun setupSmartCastsAsAnnotations(positions: List<SmartCast>) {\n        val annotationMap = positions.associateBy { \n            Annotation(SMART_CAST_ANNOTATION_TYPE, false, \"Smart cast to ${it.typeName}\")\n        }\n        \n        AnnotationManager.updateAnnotations(editor, annotationMap, SMART_CAST_ANNOTATION_TYPE)\n    }\n    \n    private fun invalidateTextPresentation() {\n        val shell = editor.javaEditor.site?.shell\n        if (shell == null || shell.isDisposed) return\n\n        val display = shell.display\n        if (display == null || display.isDisposed) return\n        \n        display.asyncExec {\n            editor.javaEditor.viewer?.invalidateTextPresentation()\n        }\n    }\n    \n    private fun removeAllPositions(document: IDocument) {\n        document.getPositions(category).forEach { it.delete() }\n    }\n    \n    private fun StyleAttributes.createStyleRange(): StyleRange {\n        val styleKey = styleAttributes.styleKey\n        if (!isEnabled(styleKey, preferenceStore)) {\n            return createStyleRange(getOffset(), getLength())\n        }\n        \n        val textStyle = findTextStyle(styleAttributes, preferenceStore, colorManager)\n        return with(StyleRange(textStyle)) {\n            start = getOffset()\n            length = getLength()\n            \n            fontStyle = SWT.NORMAL\n            if (isBold(styleKey, preferenceStore)) fontStyle = fontStyle or SWT.BOLD\n            if (isItalic(styleAttributes.styleKey, preferenceStore)) fontStyle = fontStyle or SWT.ITALIC\n            \n            this\n        }\n    }\n}\n\nprivate fun findTextStyle(attributes: KotlinHighlightingAttributes, store: IPreferenceStore, colorManager: IColorManager): TextStyle {\n    val style = TextStyle()\n    val rgb = getColor(attributes.styleKey, store)\n    style.foreground = getColor(rgb, colorManager)\n    style.underline = attributes.underline\n    \n    return style\n}\n\nprivate fun getColor(rgb: RGB?, colorManager: IColorManager): Color? {\n    var color: Color? = null\n    Display.getDefault().syncExec {\n        color = colorManager.getColor(rgb)\n    }\n    \n    return color\n}\n\nprivate fun getColor(key: String, store: IPreferenceStore): RGB {\n    val preferenceKey = PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + key + \n            PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX\n    \n    return PreferenceConverter.getColor(store, preferenceKey)\n}\n\nprivate fun isBold(key: String, store: IPreferenceStore): Boolean {\n    val preferenceKey = PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + key + \n            PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX\n    \n    return store.getBoolean(preferenceKey)\n}\n\nprivate fun isItalic(key: String, store: IPreferenceStore): Boolean {\n    val preferenceKey = PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + key + \n            PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX\n    \n    return store.getBoolean(preferenceKey)\n}\n\nprivate fun isEnabled(key: String, store: IPreferenceStore): Boolean {\n    val preferenceKey = PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + key + \n            PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX\n    \n    return store.getBoolean(preferenceKey)\n}\n\nprivate fun createStyleRange(s: Int, l: Int) = with(StyleRange()) {\n    start = s\n    length = l\n    \n    this\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinSemanticHighlightingVisitor.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.highlighting\n\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.Position\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.descriptors.ClassKind.*\nimport org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.DescriptorUtils\n\npublic class KotlinSemanticHighlightingVisitor(val ktFile: KtFile, val document: IDocument) : KtVisitorVoid() {\n    private lateinit var bindingContext: BindingContext\n    \n    private val positions = arrayListOf<HighlightPosition>()\n    \n    fun computeHighlightingRanges(): List<HighlightPosition> {\n        positions.clear()\n        bindingContext = KotlinAnalysisFileCache.getAnalysisResult(ktFile).analysisResult.bindingContext\n        ktFile.acceptChildren(this)\n        return positions.toList() // make copy\n    }\n    \n    private fun highlight(styleAttributes: KotlinHighlightingAttributes, range: TextRange) {\n        positions.add(HighlightPosition.StyleAttributes(styleAttributes, range.offsetInDocument(ktFile, document), range.getLength()))\n    }\n    \n    private fun highlightSmartCast(range: TextRange, typeName: String) {\n        positions.add(HighlightPosition.SmartCast(typeName, range.offsetInDocument(ktFile, document), range.getLength()))\n    }\n    \n    override fun visitElement(element: PsiElement) {\n        element.acceptChildren(this)\n    }\n    \n    override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) {\n        val parentExpression = expression.getParent()\n        if (parentExpression is KtThisExpression || parentExpression is KtSuperExpression) return\n        \n        val target = bindingContext[BindingContext.REFERENCE_TARGET, expression]?.let {\n            if (it is ConstructorDescriptor) it.getContainingDeclaration() else it\n        }\n        \n        if (target == null) return\n        \n        val smartCast = bindingContext.get(BindingContext.SMARTCAST, expression)\n        val typeName = smartCast?.defaultType?.let { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }\n        \n        when (target) {\n            is TypeParameterDescriptor -> highlightTypeParameter(expression)\n            is ClassDescriptor -> highlightClassDescriptor(expression, target)\n            is PropertyDescriptor -> highlightProperty(expression, target, typeName)\n            is VariableDescriptor -> highlightVariable(expression, target, typeName)\n        }\n        super.visitSimpleNameExpression(expression)\n    }\n    \n    override fun visitTypeParameter(parameter: KtTypeParameter) {\n        val identifier = parameter.getNameIdentifier()\n        if (identifier != null) {\n            highlightTypeParameter(identifier)\n        }\n        \n        super.visitTypeParameter(parameter)\n    }\n    \n    override fun visitClassOrObject(classOrObject: KtClassOrObject) {\n        val identifier = classOrObject.getNameIdentifier()\n        val classDescriptor = bindingContext.get(BindingContext.CLASS, classOrObject)\n        if (identifier != null && classDescriptor != null) {\n            highlightClassDescriptor(identifier, classDescriptor)\n        }\n        \n        super.visitClassOrObject(classOrObject)\n    }\n    \n    override fun visitProperty(property: KtProperty) {\n        val nameIdentifier = property.getNameIdentifier()\n        if (nameIdentifier == null) return\n        val propertyDescriptor = bindingContext[BindingContext.VARIABLE, property]\n        if (propertyDescriptor is PropertyDescriptor) {\n            highlightProperty(nameIdentifier, propertyDescriptor)\n        } else {\n            visitVariableDeclaration(property)\n        }\n        \n        super.visitProperty(property)\n    }\n    \n    override fun visitParameter(parameter: KtParameter) {\n        val nameIdentifier = parameter.getNameIdentifier()\n        if (nameIdentifier == null) return\n        val propertyDescriptor = bindingContext[BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter]\n        if (propertyDescriptor is PropertyDescriptor) {\n            highlightProperty(nameIdentifier, propertyDescriptor)\n        } else {\n            visitVariableDeclaration(parameter)\n        }\n        \n        super.visitParameter(parameter)\n    }\n    \n    override fun visitNamedFunction(function: KtNamedFunction) {\n        val nameIdentifier = function.getNameIdentifier()\n        if (nameIdentifier != null) {\n            highlight(KotlinHighlightingAttributes.FUNCTION_DECLARATION, nameIdentifier.getTextRange())\n        }\n        \n        super.visitNamedFunction(function)\n    }\n    \n    private fun visitVariableDeclaration(declaration: KtNamedDeclaration) {\n        val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]\n        val nameIdentifier = declaration.getNameIdentifier()\n        if (nameIdentifier != null && declarationDescriptor != null) {\n            highlightVariable(nameIdentifier, declarationDescriptor)\n        }\n    }\n    \n    private fun highlightClassDescriptor(element: PsiElement, target: ClassDescriptor) {\n        when (target.kind) {\n            INTERFACE -> highlight(KotlinHighlightingAttributes.INTERFACE, element.getTextRange())\n            ANNOTATION_CLASS -> highlightAnnotation(element)\n            ENUM_ENTRY -> highlight(KotlinHighlightingAttributes.STATIC_FINAL_FIELD, element.getTextRange())\n            ENUM_CLASS -> highlight(KotlinHighlightingAttributes.ENUM_CLASS, element.getTextRange())\n            CLASS, OBJECT -> highlight(KotlinHighlightingAttributes.CLASS, element.getTextRange())\n        }\n    }\n    \n    private fun highlightAnnotation(expression: PsiElement) {\n        var range = expression.getTextRange()\n\n        // include '@' symbol if the reference is the first segment of KtAnnotationEntry\n        // if \"Deprecated\" is highlighted then '@' should be highlighted too in \"@Deprecated\"\n        val annotationEntry = PsiTreeUtil.getParentOfType(\n                expression, KtAnnotationEntry::class.java, false, KtValueArgumentList::class.java);\n        if (annotationEntry != null) {\n            val atSymbol = annotationEntry.getAtSymbol();\n            if (atSymbol != null) {\n                range = TextRange(atSymbol.getTextRange().getStartOffset(), expression.getTextRange().getEndOffset());\n            }\n        }\n        \n        highlight(KotlinHighlightingAttributes.ANNOTATION, range)\n    }\n    \n    private fun highlightTypeParameter(element: PsiElement) {\n        highlight(KotlinHighlightingAttributes.TYPE_PARAMETER, element.getTextRange())\n    }\n    \n    private fun highlightProperty(element: PsiElement, descriptor: PropertyDescriptor, typeName: String? = null) {\n        val range = element.getTextRange()\n        val mutable = descriptor.isVar()\n        val attributes = if (DescriptorUtils.isStaticDeclaration(descriptor)) {\n            if (mutable) KotlinHighlightingAttributes.STATIC_FIELD else KotlinHighlightingAttributes.STATIC_FINAL_FIELD\n        } else {\n            if (mutable) KotlinHighlightingAttributes.FIELD else KotlinHighlightingAttributes.FINAL_FIELD\n        }\n        if (typeName != null) highlightSmartCast(element.getTextRange(), typeName)\n        highlight(attributes, range)\n    }\n    \n    private fun highlightVariable(element: PsiElement, descriptor: DeclarationDescriptor, typeName: String? = null) {\n        if (descriptor !is VariableDescriptor) return\n        \n        val attributes = when (descriptor) {\n            is LocalVariableDescriptor -> {\n                if (descriptor.isVar()) {\n                    KotlinHighlightingAttributes.LOCAL_VARIABLE\n                } else {\n                    KotlinHighlightingAttributes.LOCAL_FINAL_VARIABLE\n                }\n            }\n            \n            is ValueParameterDescriptor -> KotlinHighlightingAttributes.PARAMETER_VARIABLE\n            else -> KotlinHighlightingAttributes.PARAMETER_VARIABLE\n        }\n        if (typeName != null) highlightSmartCast(element.getTextRange(), typeName)\n        highlight(attributes, element.getTextRange())\n    }\n}\n\nprivate fun TextRange.offsetInDocument(ktFile: KtFile, document: IDocument): Int {\n    return LineEndUtil.convertLfToDocumentOffset(ktFile.getText(), this.getStartOffset(), document)\n}\n\nsealed class HighlightPosition(offset: Int, length: Int) : Position(offset, length) {\n    class StyleAttributes(val styleAttributes: KotlinHighlightingAttributes, offset: Int, length: Int) : HighlightPosition(offset, length)\n    \n    class SmartCast(val typeName: String, offset: Int, length: Int) : HighlightPosition(offset, length)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinTokenScanner.java",
    "content": "package org.jetbrains.kotlin.ui.editors.highlighting;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.jdt.ui.text.IColorManager;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.ITokenScanner;\nimport org.eclipse.jface.text.rules.Token;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.model.KotlinCommonEnvironment;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironmentKt;\nimport org.jetbrains.kotlin.core.model.KotlinNature;\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtPsiFactory;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.formatter.KotlinFormatterKt;\n\nimport com.intellij.psi.PsiElement;\n\npublic class KotlinTokenScanner implements ITokenScanner {\n    private final KotlinEditor editor;\n    private final KotlinTokensFactory kotlinTokensFactory;\n    \n    private KtFile jetFile = null;\n    private int offset = 0;\n    private int rangeEnd = 0;\n    private PsiElement lastElement = null;\n    private IDocument document;\n    \n    private KotlinTokenScanner(\n            @NotNull IPreferenceStore preferenceStore, \n            @NotNull IColorManager colorManager,\n            @Nullable KotlinEditor editor) {\n        this.editor = editor;\n        kotlinTokensFactory = new KotlinTokensFactory(preferenceStore, colorManager);\n    }\n    \n    public static KotlinTokenScanner createScanner(\n            @NotNull IPreferenceStore preferenceStore, \n            @NotNull IColorManager colorManager,\n            @NotNull KotlinEditor editor) {\n        return new KotlinTokenScanner(preferenceStore, colorManager, editor);\n    }\n    \n    public static KotlinTokenScanner createScannerForCompareViewOfKtSourceFile(\n            @NotNull IPreferenceStore preferenceStore, \n            @NotNull IColorManager colorManager) {\n        return new KotlinTokenScanner(preferenceStore, colorManager, null);\n    }\n    \n    @Override\n    public void setRange(IDocument document, int offset, int length) {\n        this.document = document;\n        jetFile = createKtFile(document);\n        this.offset = LineEndUtil.convertCrToDocumentOffset(document, offset);\n        this.rangeEnd = LineEndUtil.convertCrToDocumentOffset(document, offset + length);\n        this.lastElement = null;\n    }\n\n    @Override\n    public IToken nextToken() {\n        if (rangeEnd <= offset) {\n            return Token.EOF;\n        }\n        \n        if (jetFile == null) return Token.EOF;\n        \n        lastElement = jetFile.findElementAt(offset);\n        if (lastElement != null) {\n            offset = lastElement.getTextRange().getEndOffset();\n            return kotlinTokensFactory.getToken(lastElement);\n        }\n        \n        return Token.EOF;\n    }\n\n    @Override\n    public int getTokenOffset() {\n        return LineEndUtil.convertLfToDocumentOffset(jetFile.getText(), lastElement.getTextOffset(), document);\n    }\n\n    @Override\n    public int getTokenLength() {\n        int length = lastElement.getTextLength();\n        if (TextUtilities.getDefaultLineDelimiter(document).length() > 1) {\n            length += IndenterUtil.getLineSeparatorsOccurences(lastElement.getText());\n        }\n        return length;\n    }\n    \n    @Nullable\n    private KtFile createKtFile(@NotNull IDocument document) {\n        if (editor != null) {\n            IFile eclipseFile = editor.getEclipseFile();\n            if (eclipseFile != null) {\n                return createKtFile(KotlinEnvironmentKt.getEnvironment(eclipseFile), eclipseFile.getName());\n            } \n            \n            if (editor.getJavaEditor().isEditorInputReadOnly()) {\n                return editor.getParsedFile();\n            }\n        } \n        \n        return createKtFile(getAnyKotlinEnvironmentForSourceFile(), \"dummy.kt\");\n    }\n    \n    private KtFile createKtFile(@Nullable KotlinCommonEnvironment environment, String fileName) {\n        if (environment == null) {\n            return null;\n        }\n        \n        return KotlinFormatterKt.createKtFile(document.get(), new KtPsiFactory(environment.getProject()), fileName);\n    }\n    \n    @Nullable\n    private static KotlinEnvironment getAnyKotlinEnvironmentForSourceFile() {\n        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();\n        for (IProject project : projects) {\n            if (project.isAccessible() && KotlinNature.Companion.hasKotlinNature(project)) {\n                return KotlinEnvironment.Companion.getEnvironment(project);\n            }\n        }\n        \n        return null;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinTokens.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.highlighting\n\nimport org.eclipse.jface.text.rules.IToken\nimport org.eclipse.jface.text.TextAttribute\nimport org.eclipse.jdt.ui.text.IColorManager\nimport org.eclipse.swt.SWT\nimport com.intellij.psi.impl.source.tree.LeafPsiElement\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport com.intellij.psi.PsiElement\nimport org.eclipse.jface.preference.PreferenceConverter\nimport org.eclipse.jface.preference.IPreferenceStore\nimport org.eclipse.jdt.ui.PreferenceConstants\nimport org.eclipse.jface.text.rules.Token\nimport org.jetbrains.kotlin.kdoc.lexer.KDocTokens\nimport org.eclipse.ui.texteditor.AbstractTextEditor\n\nclass KotlinTokensFactory(val preferenceStore: IPreferenceStore, val colorManager: IColorManager) {\n    val keywordToken = createToken(PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD)\n    val identifierToken = createToken()\n    val stringToken = createToken(PreferenceConstants.EDITOR_STRING_COLOR, PreferenceConstants.EDITOR_STRING_BOLD)\n    val singleLineCommentToken = createToken(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR)\n    val multiLineCommentToken = createToken(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR)\n    val kdocTagNameToken = createToken(boldKey = PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD)\n    val whitespaceToken = createToken()\n\n    fun getToken(leafElement: PsiElement): IToken {\n        if (leafElement !is LeafPsiElement) return Token.UNDEFINED\n\n        val elementType = leafElement.getElementType()\n        return when {\n            elementType in KtTokens.KEYWORDS ||\n            elementType in KtTokens.SOFT_KEYWORDS ||\n            elementType in KtTokens.MODIFIER_KEYWORDS -> keywordToken\n\n            KtTokens.IDENTIFIER == elementType -> identifierToken\n\n            elementType in KtTokens.STRINGS ||\n            KtTokens.OPEN_QUOTE == elementType ||\n            KtTokens.CLOSING_QUOTE == elementType -> stringToken\n\n            elementType in KtTokens.WHITESPACES -> whitespaceToken\n\n            elementType == KtTokens.EOL_COMMENT -> singleLineCommentToken\n\n            elementType in KtTokens.COMMENTS ||\n            elementType in KDocTokens.KDOC_HIGHLIGHT_TOKENS -> multiLineCommentToken\n\n            KDocTokens.TAG_NAME == elementType -> kdocTagNameToken\n\n            else -> Token.UNDEFINED\n        }\n    }\n    \n    fun isBlockToken(token: IToken): Boolean {\n        return when (token) {\n            multiLineCommentToken,\n            kdocTagNameToken,\n            Token.UNDEFINED -> true\n            \n            else -> false\n        }\n    }\n    \n    private fun createToken(colorKey: String = AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, boldKey: String? = null): Token {\n        val color = colorManager.getColor(PreferenceConverter.getColor(preferenceStore, colorKey))\n        val style = if (boldKey != null && preferenceStore.getBoolean(boldKey)) SWT.BOLD else SWT.NORMAL\n        \n        val attribute = TextAttribute(color, null, style)\n        return Token(attribute)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/highlighting/KotlinViewerCreator.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.highlighting\n\nimport org.eclipse.compare.IViewerCreator\nimport org.eclipse.jface.viewers.Viewer\nimport org.eclipse.compare.CompareConfiguration\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.compare.contentmergeviewer.TextMergeViewer\nimport org.eclipse.jface.text.TextViewer\nimport org.eclipse.jface.text.source.SourceViewer\nimport org.eclipse.jface.text.source.SourceViewerConfiguration\nimport org.eclipse.jface.text.presentation.IPresentationReconciler\nimport org.eclipse.jface.text.source.ISourceViewer\nimport org.eclipse.ui.IStorageEditorInput\nimport org.eclipse.jdt.internal.ui.JavaPlugin\nimport org.jetbrains.kotlin.ui.editors.highlighting.KotlinTokenScanner\nimport org.eclipse.jface.text.presentation.PresentationReconciler\nimport org.eclipse.jface.text.rules.DefaultDamagerRepairer\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jdt.internal.ui.text.JavaColorManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.ui.editors.Configuration\n\n\npublic class KotlinViewerCreator : IViewerCreator {\n\toverride fun createViewer(parent: Composite, configuration: CompareConfiguration): Viewer {\n\t\treturn KotlinMergeViewer(parent, configuration)\n\t}\n}\n\nclass KotlinMergeViewer(parent: Composite, configuration: CompareConfiguration): TextMergeViewer(parent, configuration) {\n\tprivate val colorManager = JavaColorManager()\n\t\n\toverride fun configureTextViewer(viewer: TextViewer) {\n\t\tif (viewer !is SourceViewer) return\n\t\t\n\t\tval configuration = object : SourceViewerConfiguration() {\n\t\t\toverride fun getPresentationReconciler(sourceViewer: ISourceViewer): IPresentationReconciler? {\n\t\t\t\tval scanner = KotlinTokenScanner.createScannerForCompareViewOfKtSourceFile(\n                        JavaPlugin.getDefault().getPreferenceStore(), colorManager)\n\t\t\t\treturn Configuration.getKotlinPresentaionReconciler(scanner)\n\t\t\t}\n\t\t}\n\t\t\n\t\tviewer.configure(configuration)\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/hover/KotlinInformationProvider.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.hover\n\nimport org.eclipse.jface.text.information.IInformationProvider\nimport org.eclipse.jface.text.information.IInformationProviderExtension\nimport org.eclipse.jface.text.information.IInformationProviderExtension2\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.IInformationControlCreator\nimport org.eclipse.jdt.internal.ui.text.JavaWordFinder\nimport org.eclipse.jdt.internal.ui.text.java.hover.JavadocBrowserInformationControlInput\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElement\nimport org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover\n\npublic class KotlinInformationProvider(val editor: KotlinEditor) : IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {\n    override fun getSubject(textViewer: ITextViewer?, offset: Int): IRegion? {\n        return if (textViewer != null) JavaWordFinder.findWord(textViewer.getDocument(), offset) else null\n    }\n    \n    override fun getInformation(textViewer: ITextViewer?, subject: IRegion?): String? = null // deprecated method\n    \n    override fun getInformation2(textViewer: ITextViewer?, subject: IRegion): Any? {\n        val jetElement = EditorUtil.getJetElement(editor, subject.getOffset())\n        if (jetElement == null) return null\n        \n        val sourceElements = jetElement.resolveToSourceDeclaration()\n        if (sourceElements.isEmpty()) return null\n        \n        val javaElements = sourceElements.filterIsInstance(EclipseJavaSourceElement::class.java)\n        if (javaElements.isNotEmpty()) {\n            val elements = javaElements.mapNotNull { it.getElementBinding().getJavaElement() }\n            return JavadocHover.getHoverInfo(elements.toTypedArray(), null, subject, null)\n        }\n        \n        return null\n    }\n    \n    override fun getInformationPresenterControlCreator(): IInformationControlCreator {\n        return JavadocHover.PresenterControlCreator(editor.javaEditor.getSite())\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/hover/KotlinJavadocTextHover.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.hover\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin\nimport org.eclipse.jdt.internal.ui.JavaPluginImages\nimport org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover\nimport org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.loadStyleSheet\nimport org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2\nimport org.eclipse.jface.action.ToolBarManager\nimport org.eclipse.jface.internal.text.html.BrowserInformationControl\nimport org.eclipse.jface.internal.text.html.BrowserInformationControlInput\nimport org.eclipse.jface.internal.text.html.HTMLPrinter\nimport org.eclipse.jface.resource.ColorRegistry\nimport org.eclipse.jface.resource.JFaceResources\nimport org.eclipse.jface.text.DefaultInformationControl\nimport org.eclipse.jface.text.IInformationControl\nimport org.eclipse.jface.text.IInformationControlCreator\nimport org.eclipse.jface.text.ITextHoverExtension\nimport org.eclipse.swt.graphics.RGB\nimport org.eclipse.swt.widgets.Shell\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.core.references.getReferenceExpression\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElement\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.jetbrains.kotlin.descriptors.ClassKind.ANNOTATION_CLASS\nimport org.jetbrains.kotlin.descriptors.ClassKind.CLASS\nimport org.jetbrains.kotlin.descriptors.ClassKind.ENUM_CLASS\nimport org.jetbrains.kotlin.descriptors.ClassKind.ENUM_ENTRY\nimport org.jetbrains.kotlin.descriptors.ClassKind.INTERFACE\nimport org.jetbrains.kotlin.descriptors.ClassKind.OBJECT\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.descriptors.ValueDescriptor\nimport org.jetbrains.kotlin.idea.kdoc.findKDoc\nimport org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET\nimport org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isExtension\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isExtensionProperty\nimport org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.navigation.findDeclarationInParsedFile\nimport org.jetbrains.kotlin.ui.editors.navigation.getSourceFileForElement\nimport org.jetbrains.kotlin.ui.editors.quickassist.resolveToDescriptor\nimport java.net.URL\n\nclass KotlinJavadocTextHover : KotlinEditorTextHover<BrowserInformationControlInput>, ITextHoverExtension {\n\n    class KotlinInformationControlCreator : IInformationControlCreator {\n\n        private companion object {\n            const val FONT = \"org.eclipse.jdt.ui.javadocfont\"\n        }\n\n        override fun createInformationControl(parent: Shell?): IInformationControl =\n            if (BrowserInformationControl.isAvailable(parent)) {\n                BrowserInformationControl(parent, FONT, ToolBarManager())\n            } else {\n                DefaultInformationControl(parent, true)\n            }\n    }\n\n    private val fHoverControlCreator: JavadocHover.HoverControlCreator by lazy {\n        JavadocHover.HoverControlCreator(KotlinInformationControlCreator())\n    }\n\n    override val hoverPriority: Int\n        get() = 2\n\n    override fun getHoverControlCreator(): IInformationControlCreator = fHoverControlCreator\n\n    override fun getHoverInfo(hoverData: HoverData): BrowserInformationControlInput? =\n        KotlinAnnotationBrowserInformationControlInput(hoverData.hoverElement)\n\n    override fun isAvailable(hoverData: HoverData): Boolean = true\n\n    override fun getHoverControlCreator(editor: KotlinEditor): IInformationControlCreator? =\n        JavadocHover.PresenterControlCreator(editor.javaEditor.site)\n\n    private class KotlinAnnotationBrowserInformationControlInput(\n        val element: KtElement,\n        previousInput: BrowserInformationControlInput? = null\n    ) : BrowserInformationControlInput(previousInput) {\n\n        companion object {\n            const val imageWidth = 16\n            const val imageHeight = 16\n            const val labelLeft = 20\n            const val labelTop = 2\n            val javadocStyleSheet: String by lazy { loadStyleSheet(\"/JavadocHoverStyleSheet.css\") }\n            val registry: ColorRegistry by lazy { JFaceResources.getColorRegistry() }\n            val fgRGB: RGB by lazy { registry.getRGB(\"org.eclipse.jdt.ui.Javadoc.foregroundColor\") }\n            val bgRGB: RGB by lazy { registry.getRGB(\"org.eclipse.jdt.ui.Javadoc.backgroundColor\") }\n\n            fun wrappedHeader(content: String) =\n                \"<h5><div style='word-wrap: break-word; position: relative; margin-left: ${labelLeft}px; padding-top: ${labelTop}px;'>$content</div></h5>\"\n\n            fun img(src: URL) =\n                \"<img style='border:none; position: absolute; width: ${imageWidth}px; height: ${imageHeight}px; left: -${labelLeft + 1}px;' src='$src'/>\"\n        }\n\n        private val expression = getReferenceExpression(element)\n\n        private val descriptor = expression?.let {\n            KotlinAnalysisFileCache.getAnalysisResult(element.containingKtFile).analysisResult.bindingContext[REFERENCE_TARGET, expression]\n        } ?: (element as? KtDeclaration)?.resolveToDescriptor()\n\n        override fun getHtml(): String? =\n            descriptor?.header?.let { header ->\n                val builder = StringBuilder()\n                HTMLPrinter.insertPageProlog(builder, 0, fgRGB, bgRGB, javadocStyleSheet)\n                builder.append(wrappedHeader(header))\n                val content = (descriptor.findKDoc() ?: getSourceFileForElement(element, descriptor)\n                    ?.findDeclarationForDescriptor(descriptor)?.docComment?.getDefaultSection())?.getContent()\n                    ?: element.getJavadocIfAvailable()\n                content?.let {\n                    builder.append(\"<body><br><p>$it</p></body>\")\n                }\n                HTMLPrinter.addPageEpilog(builder)\n                builder.toString()\n            }\n\n        override fun getInputElement(): Any? = element\n\n        override fun getInputName(): String = element.name.toString()\n\n        private fun KtElement.getJavadocIfAvailable(): String? =\n            (resolveToSourceDeclaration().firstOrNull() as? EclipseJavaSourceElement)?.elementBinding?.javaElement?.let {\n                JavadocContentAccess2.getHTMLContent(it, true)\n            }\n\n        private fun getImage(value: DeclarationDescriptorWithVisibility) =\n            JavaPlugin.getDefault().imagesOnFSRegistry.getImageURL(value.getImage())\n\n        private fun KtFile.findDeclarationForDescriptor(descriptor: DeclarationDescriptor): KtDeclaration? {\n            return findDeclarationInParsedFile(descriptor, this)\n        }\n\n        private val DeclarationDescriptor.header: String?\n            get() = when (this) {\n                is ValueDescriptor ->\n                    \"${img(getImage(this))} ${if (isExtensionProperty) \"${extensionReceiverParameter?.type}.\" else \"\"}$name: $type ${definedIn()}\"\n                is FunctionDescriptor ->\n                    \"${img(getImage(this))} fun ${if (isExtension) \"${extensionReceiverParameter?.type}.\" else \"\"}$name: (\" +\n                            valueParameters.joinToString(separator = \", \") { param -> \"${param.name}: ${param.type}\" } +\n                            \") -> $returnType ${definedIn()}\"\n                is ClassDescriptor ->\n                    \"${img(getImage(this))}  $kindString $name ${definedIn()}\"\n                else -> null\n            }\n\n        private fun DeclarationDescriptorWithVisibility.getImage() =\n            when {\n                this is ValueDescriptor -> when (visibility.name) {\n                    \"local\" -> JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE\n                    \"private\" -> JavaPluginImages.DESC_FIELD_PRIVATE\n                    \"public\" -> JavaPluginImages.DESC_FIELD_PUBLIC\n                    else -> JavaPluginImages.DESC_FIELD_DEFAULT\n                }\n                this is ClassDescriptor -> when (kind) {\n                    INTERFACE -> JavaPluginImages.DESC_OBJS_INTERFACE\n                    ENUM_CLASS, ENUM_ENTRY -> JavaPluginImages.DESC_OBJS_ENUM\n                    else -> JavaPluginImages.DESC_OBJS_CLASS\n                }\n                else -> when (visibility.name) {\n                    \"local\" -> JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE\n                    \"private\" -> JavaPluginImages.DESC_MISC_PRIVATE\n                    \"public\" -> JavaPluginImages.DESC_MISC_PUBLIC\n                    else -> JavaPluginImages.DESC_MISC_DEFAULT\n                }\n            }\n\n        private fun DeclarationDescriptor.definedIn() = with(containingDeclaration) {\n            \"defined in \" + when (this) {\n                is FunctionDescriptor -> \"fun $fqNameSafe\"\n                is LazyJavaPackageFragment -> \"package $fqName\"\n                is LazyClassDescriptor -> \"$kindString $name\"\n                else -> this\n            }\n        }\n\n        private val ClassDescriptor.kindString: String\n            get() = when (kind) {\n                CLASS -> \"class\"\n                INTERFACE -> \"interface\"\n                ENUM_CLASS -> \"enum class\"\n                ENUM_ENTRY -> \"enum entry\"\n                ANNOTATION_CLASS -> \"annotation class\"\n                OBJECT -> \"object\"\n                else -> \"\"\n            }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/hover/KotlinProblemTextHover.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.hover\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover\nimport org.eclipse.jface.text.IInformationControlCreator\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.Position\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.ui.texteditor.MarkerAnnotation\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotation\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolutionGenerator\nimport org.jetbrains.kotlin.ui.editors.quickfix.diagnostic\nimport org.jetbrains.kotlin.ui.editors.toCompletionProposals\n\nclass KotlinProblemTextHover: ProblemHover(), KotlinEditorTextHover<Any> {\n\n    override val hoverPriority: Int\n        get() = 1\n\n    override fun getHoverInfo(hoverData: HoverData): Any? =\n        hoverData.getRegion()?.let { region ->\n            getHoverInfo2(hoverData.editor.javaEditor.viewer, region)\n        }\n\n    override fun isAvailable(hoverData: HoverData): Boolean = true\n\n    override fun getHoverControlCreator(editor: KotlinEditor): IInformationControlCreator? =\n        hoverControlCreator\n\n    override fun createAnnotationInfo(\n        annotation: Annotation,\n        position: Position,\n        textViewer: ITextViewer\n    ): AnnotationInfo =\n        ProblemInfo(annotation, position, textViewer)\n\n    private class ProblemInfo(annotation: Annotation, position: Position, textViewer: ITextViewer) :\n        ProblemHover.ProblemInfo(annotation, position, textViewer) {\n\n        override fun getCompletionProposals(): Array<ICompletionProposal> = when (annotation) {\n            is MarkerAnnotation -> markerAnnotationFixes(annotation)\n            is DiagnosticAnnotation -> annotation.diagnostic?.fixes(annotation.file)\n            else -> null\n        } ?: emptyArray()\n\n        private fun markerAnnotationFixes(annotation: MarkerAnnotation): Array<ICompletionProposal>? =\n            with(annotation.marker) { diagnostic?.fixes(resource as IFile) }\n\n        private fun Diagnostic.fixes(file: IFile) =\n            KotlinMarkerResolutionGenerator.getResolutions(this).toCompletionProposals(file).toTypedArray()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/hover/KotlinTextHover.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.hover\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.internal.ui.text.JavaWordFinder\nimport org.eclipse.jface.text.IInformationControlCreator\nimport org.eclipse.jface.text.IRegion\nimport org.eclipse.jface.text.ITextHover\nimport org.eclipse.jface.text.ITextHoverExtension\nimport org.eclipse.jface.text.ITextHoverExtension2\nimport org.eclipse.jface.text.ITextViewer\nimport org.eclipse.jface.text.Region\nimport org.jetbrains.kotlin.core.model.loadExecutableEP\nimport org.jetbrains.kotlin.eclipse.ui.utils.findElementByDocumentOffset\nimport org.jetbrains.kotlin.eclipse.ui.utils.getOffsetByDocument\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult\n\nconst val TEXT_HOVER_EP_ID = \"org.jetbrains.kotlin.ui.editor.textHover\"\n\nclass KotlinTextHover(private val editor: KotlinEditor) : ITextHover, ITextHoverExtension, ITextHoverExtension2 {\n\n    private val extensionsHovers = loadExecutableEP<KotlinEditorTextHover<*>>(TEXT_HOVER_EP_ID)\n        .mapNotNull { it.createProvider() }\n        .sortedBy {\n            it.hoverPriority\n        }\n\n    private var bestHover: KotlinEditorTextHover<*>? = null\n\n    override fun getHoverRegion(textViewer: ITextViewer, offset: Int): IRegion? {\n        return JavaWordFinder.findWord(textViewer.document, offset)\n    }\n\n    override fun getHoverInfo(textViewer: ITextViewer?, hoverRegion: IRegion): String? {\n        return getHoverInfo2(textViewer, hoverRegion)?.toString()\n    }\n\n    override fun getHoverControlCreator(): IInformationControlCreator? {\n        return bestHover?.getHoverControlCreator(editor)\n    }\n\n    override fun getHoverInfo2(textViewer: ITextViewer?, hoverRegion: IRegion): Any? =\n        createHoverData(hoverRegion.offset)?.let { data ->\n            extensionsHovers.firstNotNullOfOrNull { hover ->\n                hover.takeIf { it.isAvailable(data) }?.getHoverInfo(data)?.also {\n                    bestHover = hover\n                }\n            }\n        } ?: also { bestHover = null }\n\n    private fun createHoverData(offset: Int): HoverData? {\n        val ktFile = editor.parsedFile ?: return null\n        val psiElement = ktFile.findElementByDocumentOffset(offset, editor.document) ?: return null\n        val ktElement = PsiTreeUtil.getParentOfType(psiElement, KtElement::class.java) ?: return null\n\n        return HoverData(ktElement, editor)\n    }\n}\n\ninterface KotlinEditorTextHover<out Info> {\n    val hoverPriority: Int\n\n    fun getHoverInfo(hoverData: HoverData): Info?\n\n    fun isAvailable(hoverData: HoverData): Boolean\n\n    fun getHoverControlCreator(editor: KotlinEditor): IInformationControlCreator?\n}\n\ndata class HoverData(val hoverElement: KtElement, val editor: KotlinEditor)\n\nfun HoverData.getRegion(): Region? {\n    val (element, editor) = this\n\n    val psiTextRange = element.textRange\n    val document = if (editor is KotlinCommonEditor) editor.getDocumentSafely() else editor.document\n    document ?: return null\n\n    val startOffset = element.getOffsetByDocument(document, psiTextRange.startOffset)\n\n    return Region(startOffset, psiTextRange.length)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/JarNavigationUtils.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.navigation\n\nimport com.intellij.openapi.vfs.VirtualFile\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.Path\nimport java.io.File\n\nprivate val ARCHIVE_EXTENSION = \"jar\"\n\nfun getAcrhivedFileFromPath(url: String) =\n\tResourcesPlugin.getWorkspace().getRoot().getFile(pathFromUrlInArchive(url))\n\nfun pathFromUrlInArchive(url: String) = \n    Path(url.replace(\"!\",\"\"))\n\nfun getFqNameInsideArchive(globalPath: String) =\n\tglobalPath.substringAfterLast(ARCHIVE_EXTENSION)\n\t.substringAfter('!')\n\t.substringAfter(File.separatorChar)\n\t.replace(File.separatorChar, '/')\n\t\n\nfun isArchived(file :IFile) = \n\tfile.getFullPath().toOSString().contains(ARCHIVE_EXTENSION)\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/KotlinOpenDeclarationAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.ui.actions.ActionMessages\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jface.text.ITextSelection\nimport org.jetbrains.kotlin.core.references.createReferences\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nclass KotlinOpenDeclarationAction(val editor: KotlinEditor) : SelectionDispatchAction(editor.javaEditor.site) {\n    companion object {\n        const val OPEN_EDITOR_TEXT = \"OpenEditor\"\n\n        fun getNavigationData(ktElement: KtElement, javaProject: IJavaProject): NavigationData? {\n            val context = ktElement.getBindingContext()\n            return createReferences(ktElement)\n                .asSequence()\n                .flatMap { it.getTargetDescriptors(context).asSequence() }\n                .mapNotNull { descriptor ->\n                    val elementWithSource = getElementWithSource(descriptor, javaProject.project)\n                    if (elementWithSource != null) NavigationData(elementWithSource, descriptor) else null\n                }\n                .firstOrNull()\n        }\n\n        data class NavigationData(val sourceElement: SourceElement, val descriptor: DeclarationDescriptor)\n    }\n\n    init {\n        text = ActionMessages.OpenAction_declaration_label\n        actionDefinitionId = IJavaEditorActionDefinitionIds.OPEN_EDITOR\n    }\n\n    override fun run(selection: ITextSelection) {\n        val selectedExpression = EditorUtil.getReferenceExpression(editor, selection.offset) ?:\n            EditorUtil.getJetElement(editor, selection.offset) ?: return\n        val javaProject = editor.javaProject ?: return\n\n        val data = getNavigationData(selectedExpression, javaProject) ?: return\n\n        gotoElement(data.sourceElement, data.descriptor, selectedExpression, editor, javaProject)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/KotlinOpenEditorFromConsole.kt",
    "content": "/*******************************************************************************\n\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport org.eclipse.ui.console.IPatternMatchListenerDelegate\nimport org.eclipse.ui.console.PatternMatchEvent\nimport org.eclipse.ui.console.TextConsole\nimport org.eclipse.ui.console.IHyperlink\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.eclipse.jface.text.BadLocationException\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\n\nprivate val NAVIGATION_DESCRIPTION_REGEX = \"at (.+)\\\\((.+\\\\.kt)\\\\:(\\\\d+)\\\\)\".toRegex()\n\nclass KotlinOpenEditorFromConsole : IPatternMatchListenerDelegate {\n    private @Volatile var console: TextConsole? = null\n    \n    override fun connect(console: TextConsole) {\n        this.console = console\n    }    \n    \n    override fun disconnect() {\n        this.console = null\n    }\n    \n    @Suppress(\"UNUSED_VARIABLE\")\n    override fun matchFound(event: PatternMatchEvent) {\n        val linkText = console?.document?.get(event.offset, event.length)\n        if (linkText == null) return\n        \n        val navigationDescription = NAVIGATION_DESCRIPTION_REGEX.find(linkText)?.groupValues\n        if (navigationDescription == null) return\n        \n        val (allDescription, fqName, fileName, lineNumber) = navigationDescription\n        \n        val linkOffset = event.offset + 4 + fqName.length // at (linkOffset)\n        val linkLength = fileName.length + 1 + lineNumber.length // link:link\n        \n        if (canNavigate(fqName, lineNumber)) {\n            console?.addHyperlink(object : IHyperlink {\n                override fun linkActivated() {\n                    openEditor(fqName, lineNumber)\n                }\n                \n                override fun linkExited() {\n                }\n                \n                override fun linkEntered() {\n                }\n            }, linkOffset, linkLength)\n        }\n    }\n    \n    private fun canNavigate(fqName: String, lineNumber: String): Boolean {\n        val type = findType(fqName)\n        if (type == null) return false\n        \n        val kotlinSourceFiles = KotlinOpenEditor.findSourceFiles(type)\n        if (kotlinSourceFiles.size != 1) return false\n        \n        val resource = KotlinPsiManager.getEclipseFile(kotlinSourceFiles.first())\n        if (resource == null) return false\n        \n        val document = EditorUtil.getDocument(resource)\n        try {\n            val lineRegion = document.getLineInformation(lineNumber.toInt() - 1)\n            if (lineRegion.offset > document.length) {\n                return false\n            }\n        } catch (e: BadLocationException) {\n            return false\n        }\n        \n        return true\n    }\n    \n    private fun openEditor(fqName: String, lineNumber: String) {\n        val type = findType(fqName)\n        if (type == null) return\n        \n        try {\n            val editorPart = EditorUtility.openInEditor(type, true)\n            if (editorPart is KotlinFileEditor) {\n                val lineRegion = editorPart.document.getLineInformation(lineNumber.toInt() - 1)\n                editorPart.selectAndReveal(lineRegion.offset, 0)\n            }\n        } catch (e: BadLocationException) {\n//            As we've already validated that we can navigate to that line number,\n//            this exception may occur only if some lines or file have been deleted\n        }\n        \n        return\n    }\n    \n    private fun findType(fqName: String): IType? {\n        val typeFqName = fqName.substringBeforeLast(\".\")\n        return ProjectUtils.accessibleKotlinProjects.asSequence()\n                .map { JavaCore.create(it) }\n                .mapNotNull { it.findType(typeFqName) }\n                .firstOrNull()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/KotlinOpenSuperImplementationAction.kt",
    "content": "/*******************************************************************************\n\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.commands.AbstractHandler\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.jdt.internal.ui.actions.ActionMessages\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.viewers.ArrayContentProvider\nimport org.eclipse.jface.window.Window\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.dialogs.ListDialog\nimport org.eclipse.ui.handlers.HandlerUtil\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.MemberDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.stubs.KotlinStubWithFqName\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.OverridingUtil\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.overrideImplement.KotlinCallableLabelProvider\n\nclass KotlinOpenSuperImplementationActionHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val editor = HandlerUtil.getActiveEditor(event)\n        if (editor !is KotlinCommonEditor) return null\n\n        KotlinOpenSuperImplementationAction(editor).run()\n\n        return null\n    }\n}\n\nclass KotlinOpenAllSuperImplementationActionHandler : AbstractHandler() {\n    override fun execute(event: ExecutionEvent): Any? {\n        val editor = HandlerUtil.getActiveEditor(event)\n        if (editor !is KotlinCommonEditor) return null\n\n        KotlinOpenSuperImplementationAction(editor, true).run()\n\n        return null\n    }\n}\n\nclass KotlinOpenSuperImplementationAction(\n    private val editor: KotlinCommonEditor,\n    private val recursive: Boolean = false\n) : SelectionDispatchAction(editor.site) {\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION\n        text = ActionMessages.OpenSuperImplementationAction_label\n        description = ActionMessages.OpenSuperImplementationAction_description\n    }\n\n    companion object {\n        const val ACTION_ID = \"OpenSuperImplementation\"\n    }\n\n    override fun run(selection: ITextSelection) {\n        val ktFile = editor.parsedFile\n        val project = editor.javaProject\n        if (ktFile == null || project == null) return\n\n        val psiElement = EditorUtil.getPsiElement(editor, selection.offset) ?: return\n\n        val declaration: KtTypeParameterListOwnerStub<out KotlinStubWithFqName<out KtTypeParameterListOwnerStub<*>>> =\n            PsiTreeUtil.getParentOfType(\n                psiElement,\n                KtNamedFunction::class.java,\n                KtClass::class.java,\n                KtProperty::class.java,\n                KtObjectDeclaration::class.java\n            ) ?: return\n\n        val descriptor = resolveToDescriptor(declaration)\n        if (descriptor !is DeclarationDescriptor) return\n\n        val superDeclarations =\n            if (recursive) findSuperDeclarationsRecursive(descriptor) else findSuperDeclarations(descriptor)\n        if (superDeclarations.isEmpty()) return\n\n        val superDeclaration = when (superDeclarations.size) {\n            1 -> superDeclarations.first()\n            else -> chooseFromSelectionDialog(superDeclarations)\n        } ?: return\n\n        gotoElement(superDeclaration, declaration, editor, project)\n    }\n\n    private fun chooseFromSelectionDialog(declarations: Set<MemberDescriptor>): MemberDescriptor? {\n        val shell = PlatformUI.getWorkbench().activeWorkbenchWindow.shell\n        val dialog = ListDialog(shell)\n\n        dialog.setTitle(\"Super Declarations\")\n        dialog.setMessage(\"Select a declaration to navigate\")\n        dialog.setContentProvider(ArrayContentProvider())\n        dialog.setLabelProvider(KotlinCallableLabelProvider())\n\n        dialog.setInput(declarations.toTypedArray())\n\n        if (dialog.open() == Window.CANCEL) {\n            return null\n        }\n\n        val result = dialog.result\n        if (result == null || result.size != 1) {\n            return null\n        }\n\n        return result[0] as MemberDescriptor\n    }\n\n    private fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor? {\n        val context =\n            KotlinAnalysisFileCache.getAnalysisResult(declaration.containingKtFile).analysisResult.bindingContext\n        return context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]\n    }\n\n    private fun findSuperDeclarations(descriptor: DeclarationDescriptor): Set<MemberDescriptor> {\n        val superDescriptors = when (descriptor) {\n            is ClassDescriptor -> {\n                descriptor.typeConstructor.supertypes.mapNotNull {\n                    val declarationDescriptor = it.constructor.declarationDescriptor\n                    if (declarationDescriptor is ClassDescriptor) declarationDescriptor else null\n                }.toSet()\n            }\n\n            is CallableMemberDescriptor -> descriptor.getDirectlyOverriddenDeclarations().toSet()\n\n            else -> emptySet<MemberDescriptor>()\n        }\n\n        return superDescriptors\n    }\n\n    private fun findSuperDeclarationsRecursive(descriptor: DeclarationDescriptor): Set<MemberDescriptor> {\n        val tempResult = mutableSetOf<MemberDescriptor>()\n        var tempNewResults = setOf(descriptor)\n        while (tempNewResults.isNotEmpty()) {\n            val tempSuperResults = tempNewResults.flatMapTo(hashSetOf()) { findSuperDeclarations(it) }\n            tempSuperResults -= tempResult\n            tempResult += tempSuperResults\n            tempNewResults = tempSuperResults\n        }\n        return tempResult\n    }\n\n    private fun <D : CallableMemberDescriptor> D.getDirectlyOverriddenDeclarations(): Collection<D> {\n        val result = LinkedHashSet<D>()\n        for (overriddenDescriptor in overriddenDescriptors) {\n            @Suppress(\"UNCHECKED_CAST\")\n            when (overriddenDescriptor.kind) {\n                DECLARATION -> result.add(overriddenDescriptor as D)\n                FAKE_OVERRIDE, DELEGATION -> result.addAll((overriddenDescriptor as D).getDirectlyOverriddenDeclarations())\n                SYNTHESIZED -> {\n                    //do nothing\n                }\n                else -> throw AssertionError(\"Unexpected callable kind ${overriddenDescriptor.kind}: $overriddenDescriptor\")\n            }\n        }\n        return OverridingUtil.filterOutOverridden(result)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/StringInput.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport org.eclipse.core.resources.IStorage\nimport org.eclipse.jface.resource.ImageDescriptor\nimport org.eclipse.ui.IPersistableElement\nimport org.eclipse.ui.IStorageEditorInput\nimport org.jetbrains.kotlin.psi.KtFile\n\nopen class StringInput internal constructor(private val storage: StringStorage) : IStorageEditorInput {\n    override fun exists(): Boolean {\n        return true\n    }\n\n    override fun getImageDescriptor(): ImageDescriptor? = null\n\n    override fun getName(): String? = storage.name\n\n    override fun getPersistable(): IPersistableElement? = null\n\n    override fun getStorage(): IStorage? = storage\n\n    override fun getToolTipText(): String? = storage.fqName\n\n    override fun <T> getAdapter(required: Class<T>?): T? = storage.getAdapter(required)\n\n    override fun equals(other: Any?): Boolean {\n        if (other is StringInput) {\n            return storage.equals(other.storage)\n        }\n        return false\n    }\n\n    override fun hashCode(): Int = storage.hashCode()\n}\n\nclass KotlinExternalEditorInput(val ktFile: KtFile, storage: StringStorage) : StringInput(storage)"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/StringStorage.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport org.eclipse.core.resources.IStorage\nimport org.eclipse.core.runtime.IPath\nimport java.io.InputStream\n\ndata class StringStorage(\n        private val content: String,\n        private val name: String,\n        private val packageFqName: String) : IStorage {\n    \n    override fun getName(): String = name\n\n    override fun getContents(): InputStream? = content.byteInputStream()\n\n    override fun getFullPath(): IPath? = null\n\n    override fun <T> getAdapter(adapter: Class<T>?): T? = null\n\n    override fun isReadOnly(): Boolean = true\n\n    val fqName: String\n        get() = \"$packageFqName/$name\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/navigationUtils.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport com.intellij.openapi.vfs.VirtualFile\nimport com.intellij.psi.PsiClass\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.IClassFile\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.IPackageFragment\nimport org.eclipse.jdt.core.dom.IBinding\nimport org.eclipse.jdt.core.dom.IMethodBinding\nimport org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader\nimport org.eclipse.jdt.internal.core.SourceMapper\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.eclipse.jdt.ui.JavaUI\nimport org.eclipse.jface.util.OpenStrategy\nimport org.eclipse.ui.IEditorPart\nimport org.eclipse.ui.IReusableEditor\nimport org.eclipse.ui.IStorageEditorInput\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.ide.IDE\nimport org.eclipse.ui.texteditor.AbstractTextEditor\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinNature\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.core.resolve.EclipseDescriptorUtils\nimport org.jetbrains.kotlin.core.resolve.KotlinSourceIndex\nimport org.jetbrains.kotlin.core.resolve.lang.java.resolver.EclipseJavaSourceElement\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElement\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.load.java.sources.JavaSourceElement\nimport org.jetbrains.kotlin.load.java.structure.JavaElement\nimport org.jetbrains.kotlin.load.java.structure.impl.JavaElementImpl\nimport org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass\nimport org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryPackageSourceElement\nimport org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement\nimport org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass\nimport org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtPsiFactory\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.resolve.source.PsiSourceElement\nimport org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor\nimport org.jetbrains.kotlin.serialization.deserialization.getName\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinExternalReadOnlyEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinScriptEditor\nimport org.jetbrains.kotlin.ui.formatter.createKtFile\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\n\nprivate val KOTLIN_SOURCE_PATH = Path(ProjectUtils.buildLibPath(KotlinClasspathContainer.LIB_RUNTIME_SRC_NAME))\nprivate val RUNTIME_SOURCE_MAPPER = KOTLIN_SOURCE_PATH.createSourceMapperWithRoot()\n\nfun gotoElement(descriptor: DeclarationDescriptor, fromElement: KtElement,\n                fromEditor: KotlinEditor, javaProject: IJavaProject) {\n    val elementWithSource = getElementWithSource(descriptor, javaProject.project)\n    if (elementWithSource != null) gotoElement(elementWithSource, descriptor, fromElement, fromEditor, javaProject)\n}\n\nfun getElementWithSource(descriptor: DeclarationDescriptor, project: IProject): SourceElement? {\n    val sourceElements = EclipseDescriptorUtils.descriptorToDeclarations(descriptor, project)\n    return sourceElements.find { element -> element != SourceElement.NO_SOURCE }\n}\n\nfun gotoElement(\n        element: SourceElement, \n        descriptor: DeclarationDescriptor, \n        fromElement: KtElement, \n        fromEditor: KotlinEditor, \n        project: IJavaProject) {\n    when (element) {\n        is EclipseJavaSourceElement -> {\n            val binding = (element.javaElement as EclipseJavaElement<*>).binding\n            gotoJavaDeclaration(binding)\n        }\n        \n        is KotlinSourceElement -> gotoKotlinDeclaration(element.psi, fromElement, fromEditor, project)\n        \n        is KotlinJvmBinarySourceElement -> gotoElementInBinaryClass(element.binaryClass, descriptor, fromElement, project)\n        \n        is KotlinJvmBinaryPackageSourceElement -> gotoClassByPackageSourceElement(element, fromElement, descriptor, project)\n    }\n}\n\nprivate fun getClassFile(binaryClass: VirtualFileKotlinClass, javaProject: IJavaProject): IClassFile? {\n    val file = binaryClass.file\n    val fragment = javaProject.findPackageFragment(pathFromUrlInArchive(file.parent.path))\n    return fragment?.getClassFile(file.name)\n}\n\nprivate fun findImplementingClassInClasspath(\n            binaryClass: VirtualFileKotlinClass, \n            descriptor: DeclarationDescriptor, \n            javaProject: IJavaProject): IClassFile? {\n        return if (KotlinClassHeader.Kind.MULTIFILE_CLASS == binaryClass.classHeader.kind) \n            getImplementingFacadePart(binaryClass, descriptor, javaProject)\n        else \n            getClassFile(binaryClass, javaProject)\n    }\n    \nprivate fun getImplementingFacadePart(\n        binaryClass: VirtualFileKotlinClass, \n        descriptor: DeclarationDescriptor,\n        javaProject: IJavaProject): IClassFile? {\n    if (descriptor !is DeserializedCallableMemberDescriptor) return null\n    \n    val className = getImplClassName(descriptor)\n    if (className == null) {\n        KotlinLogger.logWarning(\"Class file with implementation of $descriptor is null\")\n        return null\n    }\n    \n    val classFile = getClassFile(binaryClass, javaProject)\n    if (classFile == null) {\n        KotlinLogger.logWarning(\"Class file for $binaryClass is null\")\n        return null\n    }\n    \n    val fragment = classFile.getParent() as IPackageFragment\n    val file = fragment.getClassFile(className.asString() + \".class\")\n    \n    return if (file.exists()) file else null\n}\n\n//implemented via Reflection because Eclipse has issues with ProGuard-shrunken compiler\n//in com.google.protobuf.GeneratedMessageLite.ExtendableMessage\nprivate fun getImplClassName(memberDescriptor: DeserializedCallableMemberDescriptor): Name? {\n    val nameIndex: Int\n    \n    try\n    {\n        val getProtoMethod = DeserializedCallableMemberDescriptor::class.java.getMethod(\"getProto\")\n        val proto = getProtoMethod!!.invoke(memberDescriptor)\n        val implClassNameField = Class.forName(\"org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf\").getField(\"implClassName\")\n        val implClassName = implClassNameField!!.get(null)\n        val protobufCallable = Class.forName(\"org.jetbrains.kotlin.serialization.ProtoBuf\\$Callable\")\n        val getExtensionMethod = protobufCallable!!.getMethod(\"getExtension\", implClassName!!.javaClass)\n        val indexObj = getExtensionMethod!!.invoke(proto, implClassName)\n    \n        if (indexObj !is Int) return null\n    \n        nameIndex = indexObj.toInt()\n    } catch (e: ReflectiveOperationException) {\n        KotlinLogger.logAndThrow(e)\n        return null\n    } catch (e: IllegalArgumentException) {\n        KotlinLogger.logAndThrow(e)\n        return null\n    } catch (e: SecurityException) {\n        KotlinLogger.logAndThrow(e)\n        return null\n    }\n    \n    return memberDescriptor.nameResolver.getName(nameIndex)\n}\n\nprivate fun gotoClassByPackageSourceElement(\n        sourceElement: KotlinJvmBinaryPackageSourceElement,\n        fromElement: KtElement,\n        descriptor: DeclarationDescriptor, \n        javaProject: IJavaProject) {\n    if (descriptor !is DeserializedCallableMemberDescriptor) return \n    \n    val binaryClass = sourceElement.getContainingBinaryClass(descriptor)\n    if (binaryClass == null) {\n        KotlinLogger.logWarning(\"Containing binary class for $sourceElement is null\")\n        return\n    }\n    \n    gotoElementInBinaryClass(binaryClass, descriptor, fromElement, javaProject)\n}\n\nprivate fun gotoElementInBinaryClass(\n        binaryClass: KotlinJvmBinaryClass, \n        descriptor: DeclarationDescriptor,\n        fromElement: KtElement,\n        javaProject: IJavaProject) {\n    if (binaryClass !is VirtualFileKotlinClass) return\n    \n    val classFile = findImplementingClassInClasspath(binaryClass, descriptor, javaProject)\n\n    val targetEditor = if (classFile != null) {\n        KotlinOpenEditor.openKotlinClassFileEditor(classFile, OpenStrategy.activateOnOpen())\n    } else {\n        tryToFindExternalClassInStdlib(binaryClass, fromElement, javaProject)\n    }\n    \n    if (targetEditor !is KotlinEditor) return\n    \n    val targetKtFile = targetEditor.parsedFile ?: return\n    val offset = findDeclarationInParsedFileOffset(descriptor, targetKtFile)\n    val start = LineEndUtil.convertLfToDocumentOffset(targetKtFile.getText(), offset, targetEditor.document)\n    \n    targetEditor.javaEditor.selectAndReveal(start, 0)\n}\n\nprivate fun gotoKotlinDeclaration(element: PsiElement, fromElement: KtElement, fromEditor: KotlinEditor, javaProject: IJavaProject) {\n    val targetEditor = findEditorForReferencedElement(element, fromElement, fromEditor, javaProject)\n    if (targetEditor !is KotlinEditor) return\n    \n    val start = element.getTextDocumentOffset(targetEditor.document)\n    targetEditor.selectAndReveal(start, 0)\n}\n\nprivate fun tryToFindExternalClassInStdlib(\n        binaryClass: VirtualFileKotlinClass,\n        fromElement: KtElement,\n        javaProject: IJavaProject): IEditorPart? {\n    if (KotlinNature.hasKotlinNature(javaProject.project)) {\n        // If project has Kotlin nature, then search in stdlib should be done earlier by searching class in the classpath\n        return null\n    }\n    \n    val (name, pckg, source) = findSourceForElementInStdlib(binaryClass) ?: return null\n    val content = String(source)\n    val ktFile = createKtFile(content, KtPsiFactory(fromElement), \"dummy.kt\")\n    \n    return openKotlinEditorForExternalFile(content, name, pckg, ktFile)\n}\n\nfun getSourceFileForElement(element: KtElement, descriptor: DeclarationDescriptor): KtFile? {\n    val sourceDeclaration = element.resolveToSourceDeclaration().firstOrNull()\n    return when {\n        sourceDeclaration is KotlinSourceElement ->\n            sourceDeclaration.psi.containingKtFile\n        sourceDeclaration is KotlinJvmBinaryPackageSourceElement &&\n                descriptor is DeserializedCallableMemberDescriptor ->\n            (sourceDeclaration.getContainingBinaryClass(descriptor) as? VirtualFileKotlinClass)?.let {\n                val (_, _, source) =  findSourceForElementInStdlib(it) ?: return null\n                val content = String(source)\n                createKtFile(content, KtPsiFactory(element), \"dummy.kt\")\n            }\n        else -> null\n    }\n}\n\nprivate fun findSourceForElementInStdlib(binaryClass: VirtualFileKotlinClass): ExternalSourceFile? {\n    val (sourceName, packagePath) = findSourceFilePath(binaryClass.file)\n    \n    val source = KotlinSourceIndex.getSource(RUNTIME_SOURCE_MAPPER, sourceName, packagePath, KOTLIN_SOURCE_PATH)\n    \n    return if (source != null) ExternalSourceFile(sourceName, packagePath.toPortableString(), source) else null\n}\n\nprivate data class ExternalSourceFile(val name: String, val packageFqName: String, val source: CharArray)\n\nprivate fun findEditorForReferencedElement(\n        element: PsiElement,\n        fromElement: KtElement, \n        fromEditor: KotlinEditor,\n        javaProject: IJavaProject): AbstractTextEditor? {\n    // if element is in the same file\n    if (fromElement.getContainingFile() == element.getContainingFile()) {\n        return fromEditor.javaEditor\n    }\n    \n    val virtualFile = element.getContainingFile().getVirtualFile()\n    if (virtualFile == null) return null\n    \n    val filePath = virtualFile.path\n    val targetFile = ResourcesPlugin.getWorkspace().root.getFileForLocation(Path(filePath)) ?: getAcrhivedFileFromPath(filePath)\n    \n    return findEditorPart(targetFile, element, javaProject) as? AbstractTextEditor\n}\n\nprivate fun gotoJavaDeclaration(binding: IBinding) {\n    val javaElement = if (binding is IMethodBinding && binding.isConstructor()) \n        binding.getDeclaringClass().getJavaElement() // because <init>() may correspond to null java element\n     else\n        binding.javaElement\n    \n    if (javaElement != null) {\n        val editorPart = EditorUtility.openInEditor(javaElement, OpenStrategy.activateOnOpen())\n        JavaUI.revealInEditor(editorPart, javaElement)\n    }\n}\n\nprivate fun findSourceFilePath(virtualFile: VirtualFile): Pair<String, IPath> {\n    val reader = ClassFileReader(virtualFile.contentsToByteArray(), virtualFile.name.toCharArray())\n    val sourceName = String(reader.sourceFileName())\n    \n    val fileNameWithPackage = Path(String(reader.getName()))\n    val packagePath = fileNameWithPackage.removeLastSegments(1)\n    \n    return Pair(sourceName, packagePath)\n}\n\nprivate fun findEditorPart(\n        targetFile: IFile, \n        element: PsiElement,\n        javaProject: IJavaProject): IEditorPart? {\n    if (targetFile.exists()) return openInEditor(targetFile)\n    \n    val editor = tryToFindSourceInJavaProject(element, javaProject)\n    if (editor != null) {\n        return editor\n    }\n    \n    //external jar\n    if (targetFile.getFullPath().toOSString().contains(\"jar\")) {\n        val elementFile = element.getContainingFile()\n        if (elementFile == null) return null\n        \n        val directory = elementFile.getContainingDirectory()\n        return openKotlinEditorForExternalFile(\n                elementFile.text,\n                elementFile.name,\n                getFqNameInsideArchive(directory.toString()),\n                elementFile as KtFile)\n    }\n    \n    return null\n}\n\nprivate fun tryToFindSourceInJavaProject(element: PsiElement, javaProject: IJavaProject): AbstractTextEditor? {\n    val psiClass = PsiTreeUtil.getParentOfType(element, PsiClass::class.java, false) ?: return null\n    val targetType = javaProject.findType(psiClass.getQualifiedName()) ?: return null\n    \n    return EditorUtility.openInEditor(targetType, true) as? AbstractTextEditor?\n}\n\nprivate fun openKotlinEditorForExternalFile(\n        sourceText: String,\n        sourceName: String,\n        packageFqName: String,\n        ktFile: KtFile): IEditorPart? {\n    val storage = StringStorage(sourceText, sourceName, packageFqName)\n    val input = KotlinExternalEditorInput(ktFile, storage)\n    return openEditorForExternalFile(input, KotlinExternalReadOnlyEditor.EDITOR_ID)\n}\n\nprivate fun openJavaEditorForExternalFile(\n        sourceText: String,\n        sourceName: String,\n        packageFqName: String): IEditorPart? {\n    val storage = StringStorage(sourceText, sourceName, packageFqName)\n    val input = StringInput(storage)\n    return openEditorForExternalFile(input, JavaUI.ID_CU_EDITOR)\n}\n\nprivate fun openEditorForExternalFile(storageInput: IStorageEditorInput, editorId: String): IEditorPart? {\n    val page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()\n    if (page == null) return null\n\n    val reusedEditor = page.findEditor(storageInput)\n    if (reusedEditor != null) {\n        page.reuseEditor(reusedEditor as IReusableEditor?, storageInput)\n    }\n\n    return page.openEditor(storageInput, editorId)\n}\n\nprivate fun openInEditor(file: IFile): IEditorPart {\n    val page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()\n    return IDE.openEditor(page, file, false)\n}\n\nprivate fun IPath.createSourceMapperWithRoot(): SourceMapper = SourceMapper(this, \"\", emptyMap<Any, Any>())"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/navigation/psiDeclarationFinder.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.navigation\n\nimport com.intellij.lang.java.JavaLanguage\nimport com.intellij.psi.PsiClass\nimport com.intellij.psi.PsiFileFactory\nimport com.intellij.psi.PsiMethod\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.Document\nimport org.jetbrains.kotlin.descriptors.CallableDescriptor\nimport org.jetbrains.kotlin.descriptors.ConstructorDescriptor\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.load.java.structure.JavaElement\nimport org.jetbrains.kotlin.load.java.structure.impl.JavaElementImpl\nimport org.jetbrains.kotlin.psi.KtCallableDeclaration\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtNamedDeclaration\nimport org.jetbrains.kotlin.psi.KtPrimaryConstructor\nimport org.jetbrains.kotlin.psi.KtVisitor\nimport org.jetbrains.kotlin.resolve.DescriptorUtils\n\n\nprivate class KotlinSearchDeclarationVisitor(private val descriptor: DeclarationDescriptor): KtVisitor<KtNamedDeclaration?, Void?>() {\n    override fun visitKtFile(file: KtFile, data: Void?): KtNamedDeclaration? = \n            visitKtElement(file, data)\n    \n    override fun visitKtElement(element: KtElement, data: Void?): KtNamedDeclaration? =\n            element.getChildren().asSequence().map { \n                when(it) {\n                    is KtElement -> it.accept(this, data)\n                    else -> null\n                }\n             }.filterNotNull().firstOrNull()\n    \n    override fun visitNamedDeclaration(declaration: KtNamedDeclaration, data: Void?): KtNamedDeclaration? {\n        if (compareDeclarations(declaration, descriptor)) {\n            return declaration\n        } else {\n            return super.visitNamedDeclaration(declaration, data)\n        }\n    }\n    \n    override fun visitClassOrObject(classOrObject: KtClassOrObject, data: Void?): KtNamedDeclaration? {\n        if (classOrObject.getPrimaryConstructor() == null && isConstructorForClass(classOrObject, descriptor)) {\n            return classOrObject\n        } else {\n            return super.visitClassOrObject(classOrObject, data)\n        }\n    }\n    \n    override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor, data: Void?): KtNamedDeclaration? {\n        if (compareConstructors(constructor, descriptor)) {\n            return constructor\n        }\n        return null\n    }\n    \n    private fun isConstructorForClass(classOrObject: KtClassOrObject, possibleConstructor: DeclarationDescriptor) = \n            possibleConstructor is ConstructorDescriptor &&\n            areFqNamesEqual(possibleConstructor.getContainingDeclaration(), classOrObject)\n    \n    private fun compareConstructors(declaration: KtPrimaryConstructor, descriptor: DeclarationDescriptor) =\n            isConstructorForClass(declaration.getContainingClassOrObject(), descriptor)\n    \n    private fun compareDeclarations(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Boolean {\n        if (!areFqNamesEqual(descriptor, declaration)) {\n            return false\n        }\n        if (descriptor is CallableDescriptor) {\n            if (declaration is KtCallableDeclaration) {\n                return descriptor.getValueParameters().size == declaration.getValueParameters().size\n            } else {\n                return false\n            }\n        } else {\n            return true\n        }\n    }\n    \n    private fun areFqNamesEqual(descriptor: DeclarationDescriptor, declaration: KtNamedDeclaration) = \n            DescriptorUtils.getFqName(descriptor) == declaration.getFqName()?.toUnsafe()\n}\n\nfun findDeclarationInParsedFile(descriptor: DeclarationDescriptor, parsedFile: KtFile): KtNamedDeclaration? {\n    val visitor = KotlinSearchDeclarationVisitor(descriptor)\n    return parsedFile.accept(visitor, null)\n}\n\nfun findDeclarationInParsedFileOffset(descriptor: DeclarationDescriptor, parsedFile: KtFile): Int =\n    findDeclarationInParsedFile(descriptor, parsedFile)?.textOffset ?: 0\n\nfun findDeclarationInJavaFile(javaElement: JavaElement, javaSource: String): Int? {\n    val navigationElement = if (javaElement is JavaElementImpl<*>) javaElement.psi else null\n    if (navigationElement == null) return null\n    \n    val sourcePsi = PsiFileFactory.getInstance(navigationElement.project)\n            .createFileFromText(\"dummy.java\", JavaLanguage.INSTANCE, javaSource)\n    \n    val offset = when (navigationElement) {\n        is PsiClass -> {\n            val classes = PsiTreeUtil.findChildrenOfType(sourcePsi, PsiClass::class.java)\n            val sourceElement = classes.find { it.qualifiedName == navigationElement.qualifiedName } ?: return null\n            sourceElement.getTextOffset()\n        }\n        \n        is PsiMethod -> {\n            val methods = PsiTreeUtil.findChildrenOfType(sourcePsi, PsiMethod::class.java)\n            val sourceElement = methods.find {\n                it.name == navigationElement.name &&\n                it.parameterList.parametersCount == navigationElement.parameterList.parametersCount\n            } ?: return null\n            \n            sourceElement.getTextOffset()\n        }\n        \n        else -> null\n    }\n    \n    return if (offset != null) {\n        return LineEndUtil.convertLfToDocumentOffset(sourcePsi.text, offset, Document(javaSource))\n    } else {\n        null\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/occurrences/KotlinMarkOccurrences.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.occurrences\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.eclipse.core.runtime.Status\nimport org.eclipse.core.runtime.jobs.Job\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.text.Position\nimport org.eclipse.jface.text.source.Annotation\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.search.ui.text.Match\nimport org.eclipse.ui.ISelectionListener\nimport org.eclipse.ui.IWorkbenchPart\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.runJob\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinScopedQuerySpecification\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager\nimport org.jetbrains.kotlin.ui.refactorings.rename.getLengthOfIdentifier\nimport org.jetbrains.kotlin.ui.search.KotlinElementMatch\nimport org.jetbrains.kotlin.ui.search.KotlinQueryParticipant\nimport org.jetbrains.kotlin.ui.search.getContainingClassOrObjectForConstructor\n\nclass KotlinMarkOccurrences(private val kotlinEditor: KotlinCommonEditor) : ISelectionListener {\n    companion object {\n        private const val ANNOTATION_TYPE = \"org.eclipse.jdt.ui.occurrences\"\n    }\n    \n    override fun selectionChanged(part: IWorkbenchPart, selection: ISelection) {\n        if (!kotlinEditor.isActive()) return\n        \n        runJob(\"Update occurrence annotations\", Job.DECORATE) { \n            if (part is KotlinCommonEditor && selection is ITextSelection) {\n                val file = part.eclipseFile\n                if (file == null || !file.exists()) return@runJob Status.CANCEL_STATUS\n                \n                val document = part.getDocumentSafely() ?: return@runJob Status.CANCEL_STATUS\n\n                KotlinPsiManager.getKotlinFileIfExist(file, document.get())\n                \n                val ktElement = EditorUtil.getJetElement(part, selection.offset) ?: return@runJob Status.CANCEL_STATUS\n\n                val occurrences = findOccurrences(part, ktElement, file)\n                updateOccurrences(part, occurrences)\n            }\n            \n            Status.OK_STATUS\n        }\n    }\n    \n    private fun updateOccurrences(editor: KotlinEditor, occurrences: List<Position>) {\n        val annotationMap = occurrences.associateBy { Annotation(ANNOTATION_TYPE, false, null) }\n        AnnotationManager.updateAnnotations(editor, annotationMap, ANNOTATION_TYPE)\n    }\n    \n    private fun findOccurrences(editor: KotlinCommonEditor, jetElement: KtElement, file: IFile): List<Position> {\n        val sourceElements = jetElement.resolveToSourceDeclaration()\n        if (sourceElements.isEmpty()) return emptyList()\n        \n        val searchingElements = getSearchingElements(sourceElements)\n        \n        val querySpecification = KotlinScopedQuerySpecification(searchingElements, listOf(file), \n                IJavaSearchConstants.ALL_OCCURRENCES, \"Searching in ${file.name}\")\n        \n        val occurrences = arrayListOf<Match>()\n        KotlinQueryParticipant().search({ occurrences.add(it) }, querySpecification, NullProgressMonitor())\n        \n        return occurrences.mapNotNull {\n            if (it !is KotlinElementMatch) return@mapNotNull null\n            \n            val element = it.jetElement\n            val length = getLengthOfIdentifier(element) ?: return@mapNotNull null\n\n            val document = editor.getDocumentSafely() ?: return@mapNotNull null\n            Position(element.getTextDocumentOffset(document), length)\n        }\n    }\n    \n    private fun getSearchingElements(sourceElements: List<SourceElement>): List<SourceElement> {\n        val classOrObjects = getContainingClassOrObjectForConstructor(sourceElements)\n        return classOrObjects.ifEmpty { sourceElements }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/organizeImports/KotlinOrganizeImportsAction.kt",
    "content": "/*******************************************************************************\n\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.organizeImports\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.jdt.internal.ui.actions.ActionMessages\nimport org.eclipse.jdt.internal.ui.dialogs.MultiElementListSelectionDialog\nimport org.eclipse.jdt.internal.ui.util.TypeNameMatchLabelProvider\nimport org.eclipse.jdt.ui.JavaUI\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jface.viewers.LabelProvider\nimport org.eclipse.jface.window.Window\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.ui.ISharedImages\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.formatting.codeStyle\nimport org.jetbrains.kotlin.core.imports.*\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.core.resolve.KotlinResolutionFacade\nimport org.jetbrains.kotlin.eclipse.ui.utils.getBindingContext\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinPackageEntry\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinPackageEntry.Companion.ALL_OTHER_ALIAS_IMPORTS_ENTRY\nimport org.jetbrains.kotlin.idea.core.formatter.KotlinPackageEntryTable\nimport org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings\nimport org.jetbrains.kotlin.idea.imports.OptimizedImportsBuilder\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.resolve.ImportPath\nimport org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.editors.quickfix.placeImports\nimport org.jetbrains.kotlin.ui.editors.quickfix.replaceImports\n\n\nclass KotlinOrganizeImportsAction(private val editor: KotlinCommonEditor) : SelectionDispatchAction(editor.site) {\n    init {\n        actionDefinitionId = IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS\n\n        text = ActionMessages.OrganizeImportsAction_label\n        toolTipText = ActionMessages.OrganizeImportsAction_tooltip\n        description = ActionMessages.OrganizeImportsAction_description\n\n        PlatformUI.getWorkbench().helpSystem.setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION)\n    }\n\n    companion object {\n        const val ACTION_ID = \"OrganizeImports\"\n    }\n\n    override fun run() {\n        val bindingContext = editor.getBindingContext() ?: return\n        val ktFile = editor.parsedFile ?: return\n        val file = editor.eclipseFile ?: return\n        val (result, container) = KotlinAnalyzer.analyzeFile(ktFile)\n        val resolutionFacade = container?.let { KotlinResolutionFacade(file, it, result.moduleDescriptor) } ?: return\n        val environment = KotlinEnvironment.getEnvironment(file.project)\n\n        val languageVersionSettings = environment.compilerProperties.languageVersionSettings\n        val candidatesFilter = DefaultImportPredicate(JvmPlatformAnalyzerServices, languageVersionSettings)\n\n        val referencesToImport = bindingContext.diagnostics\n            .filter { it.factory in FIXABLE_DIAGNOSTICS && it.psiFile == ktFile }\n            .map { it.psiElement }\n            .distinctBy { it.text }\n\n        val (uniqueImports, ambiguousImports) = findImportCandidates(\n            referencesToImport,\n            bindingContext,\n            resolutionFacade,\n            candidatesFilter\n        )\n\n        val allRequiredImports = uniqueImports.toMutableList()\n        if (ambiguousImports.isNotEmpty()) {\n            val chosenImports = chooseImports(ambiguousImports) ?: return\n\n            allRequiredImports.addAll(chosenImports)\n        }\n\n        placeImports(allRequiredImports, file, editor.document)\n\n        KotlinPsiManager.commitFile(file, editor.document)\n\n        optimizeImports(languageVersionSettings)\n    }\n\n    private fun optimizeImports(languageVersionSettings: LanguageVersionSettings) {\n        val ktFile = editor.parsedFile ?: return\n        val file = editor.eclipseFile ?: return\n        val importsData = collectDescriptorsToImport(ktFile)\n        val kotlinCodeStyleSettings = file.project.codeStyle.kotlinCustomSettings\n\n        val optimizedImports = prepareOptimizedImports(ktFile, importsData, kotlinCodeStyleSettings, languageVersionSettings) ?: return\n\n        replaceImports(\n            optimizedImports.sortedWith(ImportPathComparator(kotlinCodeStyleSettings.PACKAGES_IMPORT_LAYOUT))\n                .map { it.toString() }, file, editor.document\n        )\n    }\n\n    // null signalizes about cancelling operation\n    private fun chooseImports(ambiguousImports: List<List<ImportCandidate>>): List<ImportCandidate>? {\n        val dialog = MultiElementListSelectionDialog(shell, ImportCandidatesLabelProvider)\n        dialog.setTitle(ActionMessages.OrganizeImportsAction_selectiondialog_title)\n        dialog.setMessage(ActionMessages.OrganizeImportsAction_selectiondialog_message)\n\n        val arrayImports = Array(ambiguousImports.size) { i ->\n            Array(ambiguousImports[i].size) { j ->\n                ambiguousImports[i][j]\n            }\n        }\n\n        dialog.setElements(arrayImports)\n\n        return if (dialog.open() == Window.OK) {\n            dialog.result.mapNotNull { (it as Array<*>).firstOrNull() as? ImportCandidate }\n        } else {\n            null\n        }\n    }\n}\n\nfun prepareOptimizedImports(\n    file: KtFile,\n    importsData: OptimizedImportsBuilder.InputData,\n    settings: KotlinCodeStyleSettings,\n    languageVersionSettings: LanguageVersionSettings\n): List<ImportPath>? =\n    OptimizedImportsBuilder(\n        file,\n        importsData,\n        OptimizedImportsBuilder.Options(\n            settings.NAME_COUNT_TO_USE_STAR_IMPORT,\n            settings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS\n        ) { fqName -> fqName.asString() in settings.PACKAGES_TO_USE_STAR_IMPORTS },\n        languageVersionSettings.apiVersion\n    ).buildOptimizedImports()\n\nobject ImportCandidatesLabelProvider : LabelProvider() {\n    private val typeLabelProvider = TypeNameMatchLabelProvider(TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED)\n\n    override fun getImage(element: Any?): Image? = when (element) {\n        is TypeCandidate -> typeLabelProvider.getImage(element.match)\n        is FunctionCandidate -> JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)\n        else -> null\n    }\n\n    override fun getText(element: Any?): String? = when (element) {\n        is TypeCandidate -> typeLabelProvider.getText(element.match)\n        is FunctionCandidate -> element.fullyQualifiedName\n        else -> element.toString()\n            .also { KotlinLogger.logWarning(\"Unknown type of import candidate: $element\") }\n    }\n}\n\ninternal class ImportPathComparator(private val packageTable: KotlinPackageEntryTable) : Comparator<ImportPath> {\n\n    override fun compare(import1: ImportPath, import2: ImportPath): Int {\n        val ignoreAlias = import1.hasAlias() && import2.hasAlias()\n\n        return compareValuesBy(\n            import1,\n            import2,\n            { import -> bestEntryMatchIndex(import, ignoreAlias) },\n            { import -> import.toString() }\n        )\n    }\n\n    private fun bestEntryMatchIndex(path: ImportPath, ignoreAlias: Boolean): Int {\n        var bestEntryMatch: KotlinPackageEntry? = null\n        var bestIndex: Int = -1\n\n        for ((index, entry) in packageTable.getEntries().withIndex()) {\n            if (entry.isBetterMatchForPackageThan(bestEntryMatch, path, ignoreAlias)) {\n                bestEntryMatch = entry\n                bestIndex = index\n            }\n        }\n\n        return bestIndex\n    }\n}\n\nprivate fun KotlinPackageEntry.isBetterMatchForPackageThan(entry: KotlinPackageEntry?, path: ImportPath, ignoreAlias: Boolean): Boolean {\n    if (!matchesImportPath(path, ignoreAlias)) return false\n    if (entry == null) return true\n\n    // Any matched package is better than ALL_OTHER_IMPORTS_ENTRY\n    if (this == KotlinPackageEntry.ALL_OTHER_IMPORTS_ENTRY) return false\n    if (entry == KotlinPackageEntry.ALL_OTHER_IMPORTS_ENTRY) return true\n\n    if (entry.withSubpackages != withSubpackages) return !withSubpackages\n\n    return entry.packageName.count { it == '.' } < packageName.count { it == '.' }\n}\n\n/**\n * In current implementation we assume that aliased import can be matched only by\n * [ALL_OTHER_ALIAS_IMPORTS_ENTRY] which is always present.\n */\nprivate fun KotlinPackageEntry.matchesImportPath(importPath: ImportPath, ignoreAlias: Boolean): Boolean {\n    if (!ignoreAlias && importPath.hasAlias()) {\n        return this == ALL_OTHER_ALIAS_IMPORTS_ENTRY\n    }\n\n    if (this == KotlinPackageEntry.ALL_OTHER_IMPORTS_ENTRY) return true\n\n    return matchesPackageName(importPath.pathStr)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/organizeImports/importsCollector.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.organizeImports\n\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.core.references.canBeResolvedViaImport\nimport org.jetbrains.kotlin.core.references.createReferences\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.idea.imports.OptimizedImportsBuilder\nimport org.jetbrains.kotlin.idea.imports.importableFqName\nimport org.jetbrains.kotlin.incremental.components.NoLookupLocation\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe\nimport org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor\nimport org.jetbrains.kotlin.resolve.scopes.HierarchicalScope\nimport org.jetbrains.kotlin.resolve.scopes.utils.*\nimport org.jetbrains.kotlin.ui.editors.codeassist.getResolutionScope\nimport java.util.HashSet\nimport kotlin.collections.LinkedHashMap\nimport kotlin.collections.LinkedHashSet\n\nfun collectDescriptorsToImport(file: KtFile): OptimizedImportsBuilder.InputData {\n    val visitor = CollectUsedDescriptorsVisitor(file)\n    file.accept(visitor)\n    val tempDescriptors = visitor.descriptorsToImport.mapTo(hashSetOf()) { OptimizedImportsBuilder.ImportableDescriptor(it, it.fqNameSafe) }\n    return OptimizedImportsBuilder.InputData(tempDescriptors, visitor.namesToImport, emptyList(), emptySet() /*TODO??*/)\n}\n\nprivate class CollectUsedDescriptorsVisitor(val file: KtFile) : KtVisitorVoid() {\n    private val currentPackageName = file.packageFqName\n\n    val descriptorsToImport = LinkedHashSet<DeclarationDescriptor>()\n    val namesToImport = LinkedHashMap<FqName, HashSet<Name>>()\n\n    private val bindingContext = file.getBindingContext()\n\n    private val aliases: Map<FqName, List<Name>> = file.importDirectives\n        .asSequence()\n        .filter { !it.isAllUnder && it.alias != null }\n        .mapNotNull { it.importPath }\n        .groupBy(keySelector = { it.fqName }, valueTransform = { it.importedName as Name })\n\n    override fun visitElement(element: PsiElement) {\n        element.acceptChildren(this)\n    }\n\n    override fun visitImportList(importList: KtImportList) {\n    }\n\n    override fun visitPackageDirective(directive: KtPackageDirective) {\n    }\n    \n    override fun visitReferenceExpression(expression: KtReferenceExpression) {\n        val references = createReferences(expression)\n        for (reference in references) {\n\n            val names = reference.resolvesByNames\n\n            val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, expression]\n                    ?.let { listOf(it) }\n                    ?: reference.getTargetDescriptors(bindingContext)\n\n            val referencedName = (expression as? KtNameReferenceExpression)?.getReferencedNameAsName()\n\n            for (target in targets) {\n                val importableFqName = target.importableFqName ?: continue\n                val parentFqName = importableFqName.parent()\n                if (target is PackageViewDescriptor && parentFqName == FqName.ROOT) continue // no need to import top-level packages\n                if (target !is PackageViewDescriptor && parentFqName == currentPackageName && (importableFqName !in aliases)) continue\n\n                if (!reference.canBeResolvedViaImport(target)) continue\n\n                val importableDescriptor = target.getImportableDescriptor()\n\n                if (isAccessibleAsMember(importableDescriptor, expression, bindingContext)) continue\n\n                val descriptorNames = (aliases[importableFqName].orEmpty() + importableFqName.shortName()).intersect(names)\n                namesToImport.getOrPut(importableFqName) { LinkedHashSet() } += descriptorNames\n                descriptorsToImport += importableDescriptor\n            }\n        }\n\n        super.visitReferenceExpression(expression)\n    }\n\n    private fun isAccessibleAsMember(target: DeclarationDescriptor, place: KtElement, bindingContext: BindingContext): Boolean {\n        if (target.containingDeclaration !is ClassDescriptor) return false\n\n        fun isInScope(scope: HierarchicalScope): Boolean {\n            return when (target) {\n                is FunctionDescriptor ->\n                    scope.findFunction(target.name, NoLookupLocation.FROM_IDE) { it == target } != null\n\n                is PropertyDescriptor ->\n                    scope.findVariable(target.name, NoLookupLocation.FROM_IDE) { it == target } != null\n\n                is ClassDescriptor ->\n                    scope.findClassifier(target.name, NoLookupLocation.FROM_IDE) == target\n\n                else -> false\n            }\n        }\n\n        val resolutionScope = place.getResolutionScope(bindingContext)\n        val noImportsScope = resolutionScope.replaceImportingScopes(null)\n\n        if (isInScope(noImportsScope)) return true\n        if (target !is ClassDescriptor) { // classes not accessible through receivers, only their constructors\n            if (resolutionScope.getImplicitReceiversHierarchy().any { isInScope(it.type.memberScope.memberScopeAsImportingScope()) }) return true\n        }\n        return false\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/outline/KotlinOutlinePage.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.outline\n\nimport org.eclipse.jface.viewers.ITreeSelection\nimport org.eclipse.jface.viewers.SelectionChangedEvent\nimport org.eclipse.jface.viewers.TreeViewer\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.ui.views.contentoutline.ContentOutlinePage\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiFile\nimport org.jetbrains.kotlin.ui.editors.KotlinReconcilingListener\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.eclipse.swt.widgets.Display\nimport org.eclipse.ui.views.contentoutline.IContentOutlinePage\nimport org.jetbrains.kotlin.ui.editors.KotlinReconcilingStrategy\n\nclass KotlinOutlinePage(val editor: KotlinEditor) : ContentOutlinePage(), KotlinReconcilingListener {\n    override fun reconcile(file: IFile, editor: KotlinEditor) {\n        Display.getDefault().asyncExec { refresh() }\n    }\n    \n    override fun createControl(parent: Composite?) {\n        super.createControl(parent)\n        \n        with(getTreeViewer()) {\n            setContentProvider(PsiContentProvider())\n            setLabelProvider(PsiLabelProvider())\n            addSelectionChangedListener(this@KotlinOutlinePage)\n        }\n        setInputAndExpand()\n    }\n    \n    override fun selectionChanged(event: SelectionChangedEvent) {\n        super.selectionChanged(event)\n        \n        val treeSelection = event.getSelection()\n        if (treeSelection is ITreeSelection && !treeSelection.isEmpty()) {\n            val psiElement = treeSelection.getFirstElement() as PsiElement\n            val offset = psiElement.getTextDocumentOffset(editor.document)\n            editor.javaEditor.selectAndReveal(offset, 0) //TODO: reveal Kotlin Element?\n        }\n    }\n    \n    private fun setInputAndExpand() {\n        with(getTreeViewer()) {\n            val psiFile = editor.parsedFile\n            setInput(psiFile)\n            expandAll()\n        }\n    }\n    \n    private fun refresh() {\n        getTreeViewer()?.let {\n            if (!it.getControl().isDisposed()) {\n                setInputAndExpand()\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/outline/KotlinOutlinePopup.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.outline;\n\nimport org.eclipse.jface.dialogs.PopupDialog;\nimport org.eclipse.jface.text.IInformationControl;\nimport org.eclipse.jface.text.IInformationControlExtension;\nimport org.eclipse.jface.text.IInformationControlExtension2;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.DisposeEvent;\nimport org.eclipse.swt.events.DisposeListener;\nimport org.eclipse.swt.events.FocusListener;\nimport org.eclipse.swt.events.KeyAdapter;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\nimport org.eclipse.swt.widgets.Tree;\nimport org.eclipse.swt.widgets.TreeItem;\nimport org.jetbrains.kotlin.eclipse.ui.utils.OffsetUtilsKt;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\nimport com.intellij.psi.PsiElement;\n\npublic class KotlinOutlinePopup extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {\n    \n    private TreeViewer treeViewer;\n    private final KotlinEditor editor;\n    private final int treeStyle;\n    private Text filterInputText;\n    \n    public KotlinOutlinePopup(KotlinEditor editor, Shell parent, int shellStyle, int treeStyle) {\n        this(editor, parent, shellStyle, treeStyle, true, true, false, true, true, null, null);\n    }\n\n    public KotlinOutlinePopup(KotlinEditor editor, Shell parent, int shellStyle, int treeStyle, boolean takeFocusOnOpen, boolean persistSize,\n            boolean persistLocation, boolean showDialogMenu, boolean showPersistActions, String titleText, String infoText) {\n        super(parent, shellStyle, takeFocusOnOpen, persistSize, persistLocation, showDialogMenu, showPersistActions, titleText, infoText);\n        \n        this.editor = editor;\n        this.treeStyle = treeStyle;\n        \n        create();\n    }\n    \n    @Override\n    protected Control createDialogArea(Composite parent) {\n        treeViewer = createTreeViewer(parent, treeStyle);\n\n        Tree tree = treeViewer.getTree();\n        tree.addKeyListener(new KeyAdapter() {\n            @Override\n            public void keyPressed(KeyEvent e)  {\n                if (e.character == SWT.ESC) { \n                    dispose();\n                }\n            }\n        });\n\n        tree.addSelectionListener(new SelectionAdapter() {\n            @Override\n            public void widgetDefaultSelected(SelectionEvent e) {\n                gotoSelectedElement();\n            }\n        });\n        \n        installInputFilter();\n        \n        return treeViewer.getControl();\n    }\n    \n    protected Text createFilterText(Composite parent) {\n        filterInputText = new Text(parent, SWT.NONE);\n\n        GridData data = new GridData(GridData.FILL_HORIZONTAL);\n        data.horizontalAlignment = GridData.FILL;\n        data.verticalAlignment = GridData.CENTER;\n        filterInputText.setLayoutData(data);\n\n        filterInputText.addKeyListener(new KeyAdapter() {\n            @Override\n            public void keyPressed(KeyEvent e) {\n                switch (e.keyCode) {\n                    case SWT.CR: case SWT.LF:\n                        gotoSelectedElement();\n                        break;\n                    case SWT.ARROW_DOWN: case SWT.ARROW_UP:\n                        treeViewer.getTree().setFocus();\n                        break;\n                    case SWT.ESC:\n                        dispose();\n                        break;\n                }\n            }\n        });\n\n        return filterInputText;\n    }\n    \n    private void installInputFilter() {\n        filterInputText.addModifyListener(new ModifyListener() {\n            @Override\n            public void modifyText(ModifyEvent e) {\n                selectFirstMatch();\n            }\n        });\n    }\n    \n    @Override\n    protected Control createTitleMenuArea(Composite parent) {\n        filterInputText = createFilterText(parent);\n        filterInputText.setFocus();\n\n        return null;\n    }\n    \n    private void selectFirstMatch() {\n        Tree tree = treeViewer.getTree();\n        for (TreeItem item : tree.getItems()) {\n            if (selectFirstMatch(item, filterInputText.getText())) {\n                break;\n            }\n        }\n    }\n    \n    private boolean selectFirstMatch(TreeItem item, String text) {\n        if (item.getText().toLowerCase().startsWith(text.toLowerCase())) {\n            treeViewer.getTree().select(item);\n            treeViewer.getTree().showItem(item);\n            return true;\n        }\n        \n        for (TreeItem childItem : item.getItems()) {\n            selectFirstMatch(childItem, text);\n        }\n        \n        return false;\n    }\n    \n    protected TreeViewer createTreeViewer(Composite parent, int style) {\n        Tree tree = new Tree(parent, SWT.SINGLE | style);\n        GridData gridData = new GridData(GridData.FILL_BOTH);\n        gridData.heightHint = tree.getItemHeight() * 14;\n        tree.setLayoutData(gridData);\n        \n        treeViewer = new TreeViewer(tree);\n        treeViewer.setLabelProvider(new PsiLabelProvider());\n        treeViewer.setContentProvider(new PsiContentProvider());\n        \n        return treeViewer;\n    }\n    \n    private void gotoSelectedElement() {\n        Object treeSelection = ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\n        if (treeSelection instanceof PsiElement) {\n            PsiElement psiElement = (PsiElement) treeSelection;\n            int offset = OffsetUtilsKt.getTextDocumentOffset(psiElement, editor.getDocument());\n             \n            editor.getJavaEditor().selectAndReveal(offset, 0);\n            close();\n       }\n    }\n\n    @Override\n    public void widgetDisposed(DisposeEvent e) {\n        filterInputText = null;\n        treeViewer = null;\n    }\n\n    @Override\n    public void setInput(Object input) {\n        PsiElement element = editor.getParsedFile();\n        treeViewer.setInput(element);\n    }\n\n    @Override\n    public boolean hasContents() {\n        return treeViewer != null && treeViewer.getInput() != null;\n    }\n\n    @Override\n    public void setInformation(String information) {\n    }\n\n    @Override\n    public void setSizeConstraints(int maxWidth, int maxHeight) {\n    }\n\n    @Override\n    public Point computeSizeHint() {\n        return getShell().getSize();\n    }\n\n    @Override\n    public void setVisible(boolean visible) {\n        if (visible) {\n            open();\n        } else {\n            getShell().setVisible(false);\n        }\n    }\n\n    @Override\n    public void setSize(int width, int height) {\n        getShell().setSize(width, height);\n    }\n\n    @Override\n    public void setLocation(Point location) {\n        if (!getPersistLocation() || getDialogSettings() == null)\n            getShell().setLocation(location);\n    }\n\n    @Override\n    public void dispose() {\n        close();\n    }\n\n    @Override\n    public void addDisposeListener(DisposeListener listener) {\n        getShell().addDisposeListener(listener);\n    }\n\n    @Override\n    public void removeDisposeListener(DisposeListener listener) {\n        getShell().removeDisposeListener(listener);\n    }\n\n    @Override\n    public void setForegroundColor(Color foreground) {\n        applyForegroundColor(foreground, getContents());\n    }\n\n    @Override\n    public void setBackgroundColor(Color background) {\n        applyBackgroundColor(background, getContents());\n    }\n\n    @Override\n    public boolean isFocusControl() {\n        return getShell().getDisplay().getActiveShell() == getShell();\n    }\n\n    @Override\n    public void setFocus() {\n        treeViewer.refresh();\n        treeViewer.expandAll();\n        filterInputText.forceFocus();\n    }\n\n    @Override\n    public void addFocusListener(FocusListener listener) {\n        getShell().addFocusListener(listener);\n    }\n\n    @Override\n    public void removeFocusListener(FocusListener listener) {\n        getShell().removeFocusListener(listener);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/outline/PsiContentProvider.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.outline\n\nimport org.eclipse.jface.viewers.ITreeContentProvider\nimport org.eclipse.jface.viewers.Viewer\nimport org.jetbrains.kotlin.psi.KtDeclarationContainer\nimport org.jetbrains.kotlin.psi.KtScriptInitializer\n\nclass PsiContentProvider : ITreeContentProvider {\n    override fun dispose() {\n    }\n\n    override fun inputChanged(viewer: Viewer?, oldInput: Any?, newInput: Any?) {\n    }\n\n    override fun getElements(inputElement: Any?): Array<Any> = getChildren(inputElement)\n\n    override fun getChildren(parentElement: Any?): Array<Any> {\n        if (parentElement !is KtDeclarationContainer) {\n            return arrayOf<Any>()\n        }\n        \n        return parentElement\n                .declarations\n                .filter { it !is KtScriptInitializer }\n                .toTypedArray()\n    }\n\n    override fun getParent(element: Any?): Any? = null\n\n    override fun hasChildren(element: Any?): Boolean = getChildren(element).isNotEmpty()\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/outline/PsiLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.outline;\n\nimport java.util.List;\n\nimport org.eclipse.jdt.ui.ISharedImages;\nimport org.eclipse.jdt.ui.JavaUI;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Image;\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache;\nimport org.jetbrains.kotlin.descriptors.CallableDescriptor;\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor;\nimport org.jetbrains.kotlin.psi.KtClass;\nimport org.jetbrains.kotlin.psi.KtClassInitializer;\nimport org.jetbrains.kotlin.psi.KtDeclaration;\nimport org.jetbrains.kotlin.psi.KtElement;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtFunction;\nimport org.jetbrains.kotlin.psi.KtPackageDirective;\nimport org.jetbrains.kotlin.psi.KtParameter;\nimport org.jetbrains.kotlin.psi.KtProperty;\nimport org.jetbrains.kotlin.psi.KtTypeReference;\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer;\nimport org.jetbrains.kotlin.resolve.BindingContext;\nimport org.jetbrains.kotlin.types.KotlinType;\n\npublic class PsiLabelProvider extends LabelProvider {\n    \n    public static final String CLASS_INITIALIZER = \"<class initializer>\";\n    \n    @Override\n    public String getText(Object element) {\n        if (element instanceof KtElement) {\n            return getPresentableElement((KtElement) element);\n        }\n        \n        return \"\";\n    }\n    \n    @Override\n    public Image getImage(Object element) {\n        String imageName = null;\n        if (element instanceof KtClass) {\n            if (((KtClass) element).isInterface()) {\n                imageName = ISharedImages.IMG_OBJS_INTERFACE;\n            } else {\n                imageName = ISharedImages.IMG_OBJS_CLASS;\n            }\n        } else if (element instanceof KtPackageDirective) {\n            imageName = ISharedImages.IMG_OBJS_PACKAGE;\n        } else if (element instanceof KtFunction) {\n            imageName = ISharedImages.IMG_OBJS_PUBLIC;\n        } else if (element instanceof KtProperty) {\n            imageName = ISharedImages.IMG_FIELD_PUBLIC;\n        }\n        \n        if (imageName != null) {\n            return JavaUI.getSharedImages().getImage(imageName);\n        }\n        \n        return null;\n    }\n    \n    // Source code is taken from org.jetbrains.kotlin.idea.projectView.JetDeclarationTreeNode, updateImple()\n    private String getPresentableElement(KtElement declaration) {\n        String text = \"\";\n        if (declaration != null) {\n            text = declaration.getName();\n            if (text == null) return \"\";\n            if (declaration instanceof KtClassInitializer) {\n                text = CLASS_INITIALIZER;\n            } else if (declaration instanceof KtProperty) {\n                KtProperty property = (KtProperty) declaration;\n                KtTypeReference ref = property.getTypeReference();\n                if (ref != null) {\n                    text += \" \";\n                    text += \":\";\n                    text += \" \";\n                    text += ref.getText();\n                } else {\n                    text += computeReturnType(property);\n                }\n            } else if (declaration instanceof KtFunction) {\n                KtFunction function = (KtFunction) declaration;\n                KtTypeReference receiverTypeRef = function.getReceiverTypeReference();\n                if (receiverTypeRef != null) {\n                    text = receiverTypeRef.getText() + \".\" + text;\n                }\n                text += \"(\";\n                List<KtParameter> parameters = function.getValueParameters();\n                for (KtParameter parameter : parameters) {\n                    if (parameter.getName() != null) {\n                        text += parameter.getName();\n                        text += \" \";\n                        text += \":\";\n                        text += \" \";\n                    }\n                    KtTypeReference typeReference = parameter.getTypeReference();\n                    if (typeReference != null) {\n                        text += typeReference.getText();\n                    }\n                    text += \", \";\n                }\n                if (parameters.size() > 0) text = text.substring(0, text.length() - 2);\n                text += \")\";\n                KtTypeReference typeReference = function.getTypeReference();\n                if (typeReference != null) {\n                    text += \" \";\n                    text += \":\";\n                    text += \" \";\n                    text += typeReference.getText();\n                } else {\n                    text += computeReturnType(function);\n                }\n            }\n        }\n        \n        return text;\n    }\n    \n    private String computeReturnType(KtDeclaration ktDeclaration) {\n        KtFile ktFile = ktDeclaration.getContainingKtFile();\n        BindingContext bindingContext = KotlinAnalysisFileCache.INSTANCE.getAnalysisResult(ktFile).getAnalysisResult().getBindingContext();\n        DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, ktDeclaration);\n        if (declarationDescriptor instanceof CallableDescriptor) {\n            CallableDescriptor callableDescriptor = (CallableDescriptor) declarationDescriptor;\n            KotlinType returnType = callableDescriptor.getReturnType();\n            if (returnType != null) {\n                return \" : \" + DescriptorRenderer.ONLY_NAMES_WITH_SHORT_TYPES.renderType(returnType);\n            }\n        }\n        \n        return \"\";\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinChangeReturnTypeProposal.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.Errors\nimport org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil\nimport org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers\nimport org.jetbrains.kotlin.idea.util.approximateWithResolvableType\nimport org.jetbrains.kotlin.psi.KtCallExpression\nimport org.jetbrains.kotlin.psi.KtExpression\nimport org.jetbrains.kotlin.psi.KtFunction\nimport org.jetbrains.kotlin.psi.KtReturnExpression\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.bindingContextUtil.getTargetFunction\nimport org.jetbrains.kotlin.resolve.diagnostics.Diagnostics\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.types.typeUtil.makeNullable\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.codeassist.getResolutionScope\n\nclass KotlinChangeReturnTypeProposal(editor: KotlinEditor) : KotlinQuickAssistProposal(editor) {\n    private lateinit var function: KtFunction\n    private lateinit var type: KotlinType\n    \n    private val activeDiagnostics = listOf(\n            Errors.CONSTANT_EXPECTED_TYPE_MISMATCH,\n            Errors.TYPE_MISMATCH,\n            Errors.NULL_FOR_NONNULL_TYPE,\n            Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH)\n    \n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val oldTypeRef = function.typeReference\n        val renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(type)\n        if (oldTypeRef != null) {\n            replace(oldTypeRef, renderedType)\n        } else {\n            val anchor = function.valueParameterList\n            if (anchor != null) {\n                insertAfter(anchor, \": $renderedType\")\n            }\n        }\n    }\n    \n    override fun getDisplayString(): String {\n        val functionName = function.name\n        val renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(type)\n        return if (functionName != null) {\n            \"Change '$functionName' function return type to '$renderedType'\"\n        } else {\n            \"Change function return type to '$renderedType'\"\n        }\n    }\n    \n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val bindingContext = getBindingContext() ?: return false\n\n        val activeDiagnostic = getActiveDiagnostic(psiElement.textOffset, bindingContext.diagnostics) ?: return false\n\n        val expression = PsiTreeUtil.getNonStrictParentOfType(activeDiagnostic.psiElement, KtExpression::class.java)\n            ?: return false\n\n        val expressionType = when (activeDiagnostic.factory) {\n            Errors.TYPE_MISMATCH -> {\n                val diagnosticWithParameters = Errors.TYPE_MISMATCH.cast(activeDiagnostic)\n                diagnosticWithParameters.b\n            }\n            \n            Errors.NULL_FOR_NONNULL_TYPE -> {\n                val diagnosticWithParameters = Errors.NULL_FOR_NONNULL_TYPE.cast(activeDiagnostic)\n                val expectedType = diagnosticWithParameters.a\n                expectedType.makeNullable()\n            }\n            \n            Errors.CONSTANT_EXPECTED_TYPE_MISMATCH -> bindingContext.getType(expression)\n            \n            Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH -> {\n                val diagnosticWithParameters = Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH.cast(activeDiagnostic)\n                diagnosticWithParameters.b\n            }\n            \n            else -> null\n        } ?: return false\n\n        val expressionParent = expression.parent\n        val ktFunction = if (expressionParent is KtReturnExpression) {\n            expressionParent.getTargetFunction(bindingContext)\n        } else {\n            PsiTreeUtil.getParentOfType(expression, KtFunction::class.java, true)\n        }\n        \n        if (ktFunction !is KtFunction) return false\n        \n        return when {\n            QuickFixUtil.canFunctionOrGetterReturnExpression(ktFunction, expression) -> {\n                val scope = ktFunction.getResolutionScope(bindingContext)\n                type = expressionType.approximateWithResolvableType(scope, false)\n                function = ktFunction\n                true\n            }\n            \n            expression is KtCallExpression -> {\n                type = expressionType\n                function = ktFunction\n                true\n            }\n            \n            else -> false\n        }\n    }\n    \n    private fun getActiveDiagnostic(offset: Int, diagnostics: Diagnostics): Diagnostic? {\n        return diagnostics.find { diagnostic ->\n            if (diagnostic.textRanges.isEmpty()) return@find false\n            \n            val range = diagnostic.textRanges.first()\n            range.startOffset <= offset && offset <= range.endOffset && diagnostic.factory in activeDiagnostics\n        }\n    }\n    \n    private fun getBindingContext(): BindingContext? {\n        val ktFile = editor.parsedFile ?: return null\n\n        return ktFile.getBindingContext()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinConvertToBlockBodyAssistProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.builtins.KotlinBuiltIns\nimport org.jetbrains.kotlin.core.formatting.codeStyle\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.getBindingContext\nimport org.jetbrains.kotlin.psi.KtBlockExpression\nimport org.jetbrains.kotlin.psi.KtDeclarationWithBody\nimport org.jetbrains.kotlin.psi.KtExpression\nimport org.jetbrains.kotlin.psi.KtFunctionLiteral\nimport org.jetbrains.kotlin.psi.KtNamedFunction\nimport org.jetbrains.kotlin.psi.KtPropertyAccessor\nimport org.jetbrains.kotlin.psi.KtPsiFactory\nimport org.jetbrains.kotlin.psi.KtPsiUtil\nimport org.jetbrains.kotlin.psi.KtReturnExpression\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.formatter.formatRange\nimport org.jetbrains.kotlin.types.isError\n\nclass KotlinConvertToBlockBodyAssistProposal(editor: KotlinEditor) : KotlinQuickAssistProposal(editor) {\n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val declaration = PsiTreeUtil.getParentOfType(psiElement, KtDeclarationWithBody::class.java) ?: return false\n        if (declaration is KtFunctionLiteral || declaration.hasBlockBody() || !declaration.hasBody()) return false\n\n        when (declaration) {\n            is KtNamedFunction -> {\n                val bindingContext = declaration.getBindingContext()\n                val returnType: KotlinType = declaration.returnType(bindingContext) ?: return false\n                \n                // do not convert when type is implicit and unknown\n                if (!declaration.hasDeclaredReturnType() && returnType.isError) return false\n                 \n                return true\n            }\n\n            is KtPropertyAccessor -> return true\n\n            else -> error(\"Unknown declaration type: $declaration\")\n        }\n    }\n\n    override fun getDisplayString() = \"Convert to block body\"\n\n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val declaration = PsiTreeUtil.getParentOfType(psiElement, KtDeclarationWithBody::class.java)!!\n        val context = declaration.getBindingContext()!!\n\n        val shouldSpecifyType = declaration is KtNamedFunction\n                && !declaration.hasDeclaredReturnType()\n                && !KotlinBuiltIns.isUnit(declaration.returnType(context)!!)\n\n        val factory = KtPsiFactory(declaration)\n\n        replaceBody(declaration, factory, context, editor)\n\n        if (shouldSpecifyType) {\n            specifyType(declaration, factory, context)\n        }\n    }\n\n    private fun replaceBody(declaration: KtDeclarationWithBody, factory: KtPsiFactory, context: BindingContext, editor: KotlinEditor) {\n        val newBody = convert(declaration, context, factory)\n        var newBodyText = newBody.getNode().text\n\n        val anchorToken = declaration.getEqualsToken()\n        if (anchorToken!!.getNextSibling() !is PsiWhiteSpace) {\n            newBodyText = factory.createWhiteSpace().getText() + newBodyText\n        }\n\n        replaceBetween(anchorToken, declaration.getBodyExpression()!!, newBodyText)\n        val anchorStartOffset = anchorToken.textRange.startOffset\n        val file = editor.eclipseFile ?: return\n        formatRange(\n                editor.document,\n                TextRange(anchorStartOffset, anchorStartOffset + newBodyText.length),\n                factory,\n                file.name,\n                file.project.codeStyle)\n    }\n\n    private fun specifyType(declaration: KtDeclarationWithBody, factory: KtPsiFactory, context: BindingContext) {\n        val returnType = (declaration as KtNamedFunction).returnType(context).toString()\n        val stringToInsert = listOf(factory.createColon(), factory.createWhiteSpace())\n                .joinToString(separator = \"\") { it.getText() } + returnType\n        insertAfter(declaration.getValueParameterList()!!, stringToInsert)\n    }\n\n    private fun convert(declaration: KtDeclarationWithBody, bindingContext: BindingContext, factory: KtPsiFactory): KtExpression {\n        val body = declaration.getBodyExpression()!!\n\n        fun generateBody(returnsValue: Boolean): KtExpression {\n            val bodyType = bindingContext.getType(body)\n            val needReturn = returnsValue &&\n                    (bodyType == null || (!KotlinBuiltIns.isUnit(bodyType) && !KotlinBuiltIns.isNothing(bodyType)))\n\n            val expression = factory.createExpression(body.getText())\n            val block: KtBlockExpression = if (needReturn) {\n                factory.createBlock(\"return xyz\")\n            } else {\n                return factory.createBlock(expression.getText())\n            }\n            val returnExpression = PsiTreeUtil.getChildOfType(block, KtReturnExpression::class.java)\n            val returned = returnExpression?.getReturnedExpression() ?: return factory.createBlock(\"return ${expression.getText()}\")\n            if (KtPsiUtil.areParenthesesNecessary(expression, returned, returnExpression!!)) {\n                return factory.createBlock(\"return (${expression.getText()})\")\n            }\n            return factory.createBlock(\"return ${expression.getText()}\")\n        }\n\n        val newBody = when (declaration) {\n            is KtNamedFunction -> {\n                val returnType = declaration.returnType(bindingContext)!!\n                generateBody(!KotlinBuiltIns.isUnit(returnType) && !KotlinBuiltIns.isNothing(returnType))\n            }\n\n            is KtPropertyAccessor -> generateBody(declaration.isGetter())\n\n            else -> throw RuntimeException(\"Unknown declaration type: $declaration\")\n        }\n        return newBody\n    }\n\n    private fun KtNamedFunction.returnType(context: BindingContext): KotlinType? {\n        val descriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, this] ?: return null\n        return (descriptor as FunctionDescriptor).getReturnType()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinConvertToExpressionBodyAssistProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.TextUtilities\nimport org.jetbrains.kotlin.builtins.DefaultBuiltIns\nimport org.jetbrains.kotlin.builtins.KotlinBuiltIns\nimport org.jetbrains.kotlin.core.formatting.codeStyle\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.types.isError\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.selection.handlers.siblings\nimport org.jetbrains.kotlin.ui.formatter.formatCode\n\npublic class KotlinConvertToExpressionBodyAssistProposal(editor: KotlinEditor) : KotlinQuickAssistProposal(editor) {\n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val declaration = PsiTreeUtil.getParentOfType(psiElement, KtDeclarationWithBody::class.java) ?: return false\n        val context = declaration.getContainingKtFile().getBindingContext() ?: return false\n        val value = calcValue(declaration, context)\n        return value != null && !containsReturn(value)\n    }\n\n    override fun getDisplayString(): String {\n        return \"Convert to expression body\"\n    }\n\n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val declaration = PsiTreeUtil.getParentOfType(psiElement, KtDeclarationWithBody::class.java)!!\n        val analysisResultWithProvider = getAnalysisResultWithProvider(declaration.getContainingKtFile())\n        val context = analysisResultWithProvider.analysisResult.bindingContext\n        val value = calcValue(declaration, context)!!\n\n        val setUnitType: Boolean = if (!declaration.hasDeclaredReturnType() && declaration is KtNamedFunction) {\n            val valueType = context.getType(value)\n            valueType != null && !KotlinBuiltIns.isUnit(valueType)\n        } else {\n            false\n        }\n\n        replaceBody(declaration, value, editor)\n\n        val omitType = (declaration.hasDeclaredReturnType() || setUnitType) &&\n                declaration is KtCallableDeclaration\n\n        insertAndSelectType(declaration, setUnitType, omitType, editor)\n\n    }\n\n    private fun replaceBody(declaration: KtDeclarationWithBody, newBody: KtExpression, editor: KotlinEditor) {\n        val body = declaration.getBodyExpression()!!\n        val psiFactory = KtPsiFactory(declaration)\n        val eqToken = psiFactory.createEQ().getText()\n\n        val lineDelimiter = TextUtilities.getDefaultLineDelimiter(editor.javaEditor.getViewer().getDocument())\n        val file = editor.eclipseFile ?: return\n        val valueText = formatCode(newBody.node.text, file.name, psiFactory, file.project.codeStyle)\n\n        replace(body, \"$eqToken $valueText\")\n    }\n\n    private fun insertAndSelectType(declaration: KtDeclarationWithBody, setUnitType: Boolean, omitType: Boolean, editor: KotlinEditor) {\n        val body = declaration.getBodyExpression()!!\n\n        if (omitType && !setUnitType) {\n            val callableDeclaration = declaration as KtCallableDeclaration\n            val typeRef = callableDeclaration.getTypeReference()!!\n            val colon = callableDeclaration.getColon()!!\n            val range = TextRange(getStartOffset(colon, editor), getEndOffset(typeRef, editor))\n            editor.javaEditor.selectAndReveal(range.getStartOffset(), range.getLength())\n        }\n        if (setUnitType) {\n            val elementToPlaceTypeAfter = body.siblings(forward = false, withItself = false).\n                    first { it !is PsiWhiteSpace }\n            val offset = getEndOffset(elementToPlaceTypeAfter, editor)\n            val stringToInsert = \": ${DefaultBuiltIns.Instance.getUnitType().toString()}\"\n            insertAfter(elementToPlaceTypeAfter, stringToInsert)\n            if (omitType) {\n                editor.javaEditor.selectAndReveal(offset, stringToInsert.length)\n            }\n        }\n    }\n\n    private fun calcValue(declaration: KtDeclarationWithBody, context: BindingContext): KtExpression? {\n        if (declaration is KtFunctionLiteral) return null\n        val body = declaration.getBodyExpression()\n        if (!declaration.hasBlockBody() || body !is KtBlockExpression) return null\n\n        val statement = body.getStatements().singleOrNull() ?: return null\n        when (statement) {\n            is KtReturnExpression -> {\n                return statement.getReturnedExpression()\n            }\n\n            //TODO: IMO this is not good code, there should be a way to detect that KtExpression does not have value\n            is KtDeclaration, is KtLoopExpression -> return null // is KtExpression but does not have value\n\n            else -> {\n                if (statement is KtBinaryExpression && statement.getOperationToken() == KtTokens.EQ) return null // assignment does not have value\n                val expressionType = context.getType(statement) ?: return null\n                if (!KotlinBuiltIns.isUnit(expressionType) && !KotlinBuiltIns.isNothing(expressionType)) return null\n                return statement\n            }\n        }\n    }\n\n    private fun containsReturn(element: PsiElement): Boolean {\n        if (element is KtReturnExpression) return true\n        //TODO: would be better to have some interface of declaration where return can be used\n        if (element is KtNamedFunction || element is KtPropertyAccessor) return false // can happen inside\n\n        var child = element.getFirstChild()\n        while (child != null) {\n            if (containsReturn(child)) return true\n            child = child.getNextSibling()\n        }\n\n        return false\n    }\n}\n\nfun KtCallableDeclaration.setType(type: KotlinType) {\n    if (type.isError) return\n    val typeReference = KtPsiFactory(getProject()).createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type))\n    setTypeReference(typeReference)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinImplementMethodsProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.openapi.util.text.StringUtil\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.builtins.KotlinBuiltIns\nimport org.jetbrains.kotlin.core.formatting.codeStyle\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.renderer.ClassifierNamePolicy\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.renderer.DescriptorRendererModifier\nimport org.jetbrains.kotlin.renderer.OverrideRenderingPolicy\nimport org.jetbrains.kotlin.resolve.OverrideResolver\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.formatter.EclipseDocumentRange\nimport org.jetbrains.kotlin.ui.formatter.formatRange\nimport java.util.*\n\nprivate const val DEFAULT_EXCEPTION_CALL = \"TODO()\"\nprivate const val DEFAULT_PROPERTY_BODY = \"TODO()\"\n\npublic class KotlinImplementMethodsProposal(\n        editor: KotlinEditor,\n        private val functionBody: String = DEFAULT_EXCEPTION_CALL,\n        private val propertyBody: String = DEFAULT_PROPERTY_BODY) : KotlinQuickAssistProposal(editor) {\n    private val OVERRIDE_RENDERER = DescriptorRenderer.withOptions {\n        defaultParameterValueRenderer = null\n        modifiers = setOf(DescriptorRendererModifier.OVERRIDE)\n        withDefinedIn = false\n        classifierNamePolicy = ClassifierNamePolicy.SHORT\n        overrideRenderingPolicy = OverrideRenderingPolicy.RENDER_OVERRIDE\n        unitReturnType = false\n        typeNormalizer = IdeDescriptorRenderers.APPROXIMATE_FLEXIBLE_TYPES\n    }\n\n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val classOrObject = PsiTreeUtil.getParentOfType(psiElement, KtClassOrObject::class.java, false)\n        if (classOrObject == null) return\n\n        val missingImplementations = collectMethodsToGenerate(classOrObject)\n        if (missingImplementations.isEmpty()) {\n            return\n        }\n\n        generateMethods(document, classOrObject, missingImplementations)\n    }\n\n    override fun getDisplayString(): String = \"Implement Members\"\n\n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val classOrObject = PsiTreeUtil.getParentOfType(psiElement, KtClassOrObject::class.java, false)\n        if (classOrObject != null) {\n            return collectMethodsToGenerate(classOrObject).isNotEmpty()\n        }\n\n        return false\n    }\n\n    public fun generateMethods(document: IDocument, classOrObject: KtClassOrObject, selectedElements: Set<CallableMemberDescriptor>) {\n        var body = classOrObject.getBody()\n        val psiFactory = KtPsiFactory(classOrObject.getProject())\n        if (body == null) {\n            val bodyText = \"${psiFactory.createWhiteSpace().getText()}${psiFactory.createEmptyClassBody().getText()}\"\n            insertAfter(classOrObject, bodyText)\n        } else {\n            removeWhitespaceAfterLBrace(body, editor.document, editor)\n        }\n\n        val insertOffset = findLBraceEndOffset(editor.document, getStartOffset(classOrObject, editor))\n        if (insertOffset == null) return\n\n        val generatedText =\n            generateOverridingMembers(selectedElements, classOrObject)\n                .joinToString(separator = \"\\n\", postfix = \"\\n\") { it.node.text }\n\n        document.replace(insertOffset, 0, generatedText)\n        \n        val file = editor.eclipseFile ?: return\n        formatRange(\n                document,\n                EclipseDocumentRange(insertOffset, insertOffset + generatedText.length),\n                psiFactory,\n                file.name,\n                file.project.codeStyle)\n    }\n\n    private fun removeWhitespaceAfterLBrace(body: KtClassBody, document: IDocument, editor: KotlinEditor) {\n        val lBrace = body.lBrace\n        if (lBrace != null) {\n            val sibling = lBrace.getNextSibling()\n            val needNewLine = sibling.getNextSibling() is KtDeclaration\n            if (sibling is PsiWhiteSpace && !needNewLine) {\n                document.replace(getStartOffset(sibling, editor), sibling.getTextLength(), \"\")\n            }\n        }\n    }\n\n    private fun findLBraceEndOffset(document: IDocument, startIndex: Int): Int? {\n        val text = document.get()\n        for (i in startIndex..text.lastIndex) {\n            if (text[i] == '{') return i + 1\n        }\n\n        return null\n    }\n\n    private fun generateOverridingMembers(selectedElements: Set<CallableMemberDescriptor>,\n                                          classOrObject: KtClassOrObject): List<KtElement> {\n        val overridingMembers = ArrayList<KtElement>()\n        for (selectedElement in selectedElements) {\n            if (selectedElement is SimpleFunctionDescriptor) {\n                overridingMembers.add(overrideFunction(classOrObject, selectedElement))\n            } else if (selectedElement is PropertyDescriptor) {\n                overridingMembers.add(overrideProperty(classOrObject, selectedElement))\n            }\n        }\n        return overridingMembers\n    }\n\n    private fun overrideFunction(classOrObject: KtClassOrObject,\n                                 descriptor: FunctionDescriptor): KtNamedFunction {\n        val newDescriptor: FunctionDescriptor = descriptor.copy(descriptor.getContainingDeclaration(), Modality.OPEN, descriptor.getVisibility(),\n                descriptor.getKind(), /* copyOverrides = */ true)\n        newDescriptor.setOverriddenDescriptors(listOf(descriptor))\n\n        val returnType = descriptor.getReturnType()\n        val returnsNotUnit = returnType != null && !KotlinBuiltIns.isUnit(returnType)\n        val isAbstract = descriptor.getModality() == Modality.ABSTRACT\n\n        val delegation = generateUnsupportedOrSuperCall(descriptor, functionBody)\n\n        val body = \"{\\n\" + (if (returnsNotUnit && !isAbstract) \"return \" else \"\") + delegation + \"\\n}\"\n\n        return KtPsiFactory(classOrObject.getProject()).createFunction(OVERRIDE_RENDERER.render(newDescriptor) + body)\n    }\n\n    private fun overrideProperty(classOrObject: KtClassOrObject,\n                                 descriptor: PropertyDescriptor): KtElement {\n        val newDescriptor = descriptor.copy(descriptor.getContainingDeclaration(), Modality.OPEN, descriptor.getVisibility(),\n                descriptor.getKind(), /* copyOverrides = */ true) as PropertyDescriptor\n        newDescriptor.setOverriddenDescriptors(listOf(descriptor))\n\n        val body = StringBuilder()\n        body.append(\"\\nget()\")\n        body.append(\" = \")\n        body.append(generateUnsupportedOrSuperCall(descriptor, propertyBody))\n        if (descriptor.isVar()) {\n            body.append(\"\\nset(value) {\\n}\")\n        }\n        return KtPsiFactory(classOrObject.getProject()).createProperty(OVERRIDE_RENDERER.render(newDescriptor) + body)\n    }\n\n    private fun generateUnsupportedOrSuperCall(descriptor: CallableMemberDescriptor,\n                                               exception: String = functionBody): String {\n        val isAbstract = descriptor.getModality() == Modality.ABSTRACT\n        if (isAbstract) {\n            return \"$exception\"\n        } else {\n            val builder = StringBuilder()\n            builder.append(\"super.${descriptor.escapedName()}\")\n\n            if (descriptor is FunctionDescriptor) {\n                val paramTexts = descriptor.getValueParameters().map {\n                    val renderedName = it.escapedName()\n                    if (it.varargElementType != null) \"*$renderedName\" else renderedName\n                }\n                paramTexts.joinTo(builder, prefix = \"(\", postfix = \")\")\n            }\n\n            return builder.toString()\n        }\n    }\n\n    private fun findInsertAfterAnchor(body: KtClassBody): PsiElement? {\n        val afterAnchor = body.lBrace\n        if (afterAnchor == null) return null\n\n        val offset = getCaretOffset(editor)\n        val offsetCursorElement = PsiTreeUtil.findFirstParent(body.getContainingFile().findElementAt(offset)) {\n            it.getParent() == body\n        }\n\n        if (offsetCursorElement is PsiWhiteSpace) {\n            return removeAfterOffset(offset, offsetCursorElement)\n        }\n\n        if (offsetCursorElement != null && offsetCursorElement != body.rBrace) {\n            return offsetCursorElement\n        }\n\n        return afterAnchor\n    }\n\n    private fun removeAfterOffset(offset: Int, whiteSpace: PsiWhiteSpace): PsiElement {\n        val spaceNode = whiteSpace.getNode()\n        if (spaceNode.getTextRange().contains(offset)) {\n            var beforeWhiteSpaceText = spaceNode.getText().substring(0, offset - spaceNode.getStartOffset())\n            if (!StringUtil.containsLineBreak(beforeWhiteSpaceText)) {\n                // Prevent insertion on same line\n                beforeWhiteSpaceText += \"\\n\"\n            }\n\n            val factory = KtPsiFactory(whiteSpace.getProject())\n\n            val insertAfter = whiteSpace.getPrevSibling()\n            whiteSpace.delete()\n\n            val beforeSpace = factory.createWhiteSpace(beforeWhiteSpaceText)\n            insertAfter.getParent().addAfter(beforeSpace, insertAfter)\n\n            return insertAfter.getNextSibling()\n        }\n\n        return whiteSpace\n    }\n\n    public fun collectMethodsToGenerate(classOrObject: KtClassOrObject): Set<CallableMemberDescriptor> {\n        val descriptor = classOrObject.resolveToDescriptor()\n        if (descriptor is ClassDescriptor) {\n            return OverrideResolver.getMissingImplementations(descriptor)\n        }\n        return emptySet()\n    }\n\n\n    fun DeclarationDescriptor.escapedName() = DescriptorRenderer.COMPACT.renderName(name, false)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinIntentionUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport org.jetbrains.kotlin.psi.KtNamedDeclaration\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.eclipse.jdt.core.JavaCore\nimport org.jetbrains.kotlin.resolve.BindingContextUtils\nimport org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext\n\nfun KtNamedDeclaration.canRemoveTypeSpecificationByVisibility(bindingContext: BindingContext): Boolean {\n    val isOverride = getModifierList()?.hasModifier(KtTokens.OVERRIDE_KEYWORD) ?: false\n    if (isOverride) return true\n\n    val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this]\n    return descriptor !is DeclarationDescriptorWithVisibility || !descriptor.getVisibility().isPublicAPI\n}\n\nfun KtElement.resolveToDescriptor(): DeclarationDescriptor {\n    val jetFile = this.getContainingKtFile()\n    val analysisResult = KotlinAnalyzer.analyzeFile(jetFile).analysisResult\n    return BindingContextUtils.getNotNull(\n            analysisResult.bindingContext, \n            BindingContext.DECLARATION_TO_DESCRIPTOR,\n            this,\n            \"Descriptor wasn't found for declaration \" + this.toString() + \"\\n\" + this.getElementTextWithContext())\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssist.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.ITextSelection\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nabstract class KotlinQuickAssist(val editor: KotlinEditor) {\n    \n    abstract fun isApplicable(psiElement: PsiElement): Boolean\n    \n    fun isApplicable(): Boolean = getActiveElement()?.let(::isApplicable) ?: false\n    \n    protected fun getActiveElement(): PsiElement? {\n        val file = editor.eclipseFile\n        if (file == null) {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null)\n            return null\n        }\n        \n        val document = editor.document\n        val ktFile = KotlinPsiManager.getKotlinFileIfExist(file, document.get())\n        if (ktFile == null) return null\n        \n        val caretOffset = LineEndUtil.convertCrToDocumentOffset(document, getCaretOffset(editor))\n        val activeElement = ktFile.findElementAt(caretOffset)\n        return if (activeElement !is PsiWhiteSpace) activeElement else ktFile.findElementAt(caretOffset - 1)\n    }\n    \n    protected fun getCaretOffset(activeEditor: KotlinEditor): Int {\n        val selection = activeEditor.javaEditor.getSelectionProvider().getSelection()\n        return if (selection is ITextSelection)\n            selection.getOffset()\n        else\n            activeEditor.javaEditor.getViewer().getTextWidget().getCaretOffset()\n    }\n    \n    protected fun getCaretOffsetInPSI(activeEditor: KotlinEditor, document: IDocument): Int {\n        return LineEndUtil.convertCrToDocumentOffset(document, getCaretOffset(activeEditor))\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssistProcessor.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.quickassist\n\nimport org.eclipse.jdt.ui.text.java.IJavaCompletionProposal\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nobject KotlinQuickAssistProcessor {\n    fun getAssists(editor: KotlinEditor) : List<KotlinQuickAssistProposal> {\n        return getSingleKotlinQuickAssistProposals(editor)\n                .filter { it.isApplicable() }\n    }\n    \n    private fun getSingleKotlinQuickAssistProposals(editor: KotlinEditor) : List<KotlinQuickAssistProposal> {\n        return listOf(\n            KotlinReplaceGetAssistProposal(editor), \n            KotlinSpecifyTypeAssistProposal(editor),\n            KotlinRemoveExplicitTypeAssistProposal(editor),\n            KotlinImplementMethodsProposal(editor),\n            KotlinConvertToExpressionBodyAssistProposal(editor),\n            KotlinConvertToBlockBodyAssistProposal(editor),\n            KotlinChangeReturnTypeProposal(editor))\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssistProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.JavaPluginImages\nimport org.eclipse.jdt.ui.text.java.IJavaCompletionProposal\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.contentassist.IContextInformation\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.swt.graphics.Point\nimport org.jetbrains.kotlin.core.resolve.AnalysisResultWithProvider\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.eclipse.ui.utils.getEndLfOffset\nimport org.jetbrains.kotlin.eclipse.ui.utils.getOffsetByDocument\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nabstract class KotlinQuickAssistProposal(editor: KotlinEditor) : KotlinQuickAssist(editor), IJavaCompletionProposal {\n    abstract fun apply(document: IDocument, psiElement: PsiElement)\n    \n    abstract override fun getDisplayString(): String\n    \n    override fun apply(document: IDocument) {\n        getActiveElement()?.let { apply(document, it) }\n    }\n    \n    fun getActiveFile(): IFile? {\n        return editor.eclipseFile\n    }\n    \n    fun getEndOffset(element:PsiElement, editor: KotlinEditor): Int {\n        return element.getEndLfOffset(editor.document)\n    }\n    \n    fun insertAfter(element: PsiElement, text: String) {\n        insertAfter(element, text, editor.javaEditor.getViewer().getDocument())\n    }\n    \n    fun replaceBetween(from: PsiElement, till: PsiElement, text: String) {\n        replaceBetween(from, till, text, editor.javaEditor.getViewer().getDocument())\n    }\n    \n    fun replace(toReplace: PsiElement, text: String) {\n        replaceBetween(toReplace, toReplace, text)\n    }\n    \n    protected fun getAnalysisResultWithProvider(jetFile:KtFile): AnalysisResultWithProvider {\n        return KotlinAnalyzer.analyzeFile(jetFile)\n    }\n    \n    override fun getSelection(document:IDocument?): Point? = null\n    \n    override fun getAdditionalProposalInfo(): String? = null\n    \n    override fun getImage(): Image? = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)\n    \n    override fun getContextInformation(): IContextInformation? = null\n    \n    override fun getRelevance(): Int = 0\n}\n\nfun getStartOffset(element: PsiElement, editor: KotlinEditor): Int {\n    return getStartOffset(element, editor.document)\n}\n\nfun getStartOffset(element: PsiElement, document: IDocument): Int {\n    return element.getOffsetByDocument(document, element.getTextRange().getStartOffset())\n}\n\nfun insertBefore(element: PsiElement, text: String, fileDocument: IDocument) {\n    fileDocument.replace(getStartOffset(element, fileDocument), 0, text)\n}\n\nfun replaceBetween(from: PsiElement, till: PsiElement, text: String, fileDocument: IDocument) {\n    val startOffset = getStartOffset(from, fileDocument)\n    val endOffset = getEndOffset(till, fileDocument)\n    fileDocument.replace(startOffset, endOffset - startOffset, text)\n}\n\nfun getEndOffset(element: PsiElement, editor: KotlinEditor): Int {\n    return getEndOffset(element, editor.document)\n}\n\nfun getEndOffset(element: PsiElement, fileDocument: IDocument): Int {\n    return element.getEndLfOffset(fileDocument)\n}\n\nfun replace(toReplace: PsiElement, text: String, fileDocument: IDocument) {\n    replaceBetween(toReplace, toReplace, text, fileDocument)\n}\n\nfun remove(element: PsiElement, fileDocument: IDocument) {\n    replace(element, \"\", fileDocument)\n}\n\nfun insertAfter(element: PsiElement, text: String, fileDocument: IDocument) {\n    fileDocument.replace(getEndOffset(element, fileDocument), 0, text)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinQuickAssistProposalsGenerator.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nabstract class KotlinQuickAssistProposalsGenerator(editor: KotlinEditor) : KotlinQuickAssist(editor) {\n    fun getProposals(): List<KotlinQuickAssistProposal> {\n        val activeElement = getActiveElement()\n        if (activeElement == null) return emptyList()\n        \n        return getProposals(editor, activeElement)\n    }\n    \n    fun hasProposals(): Boolean = getProposals().isNotEmpty()\n    \n    protected abstract fun getProposals(kotlinFileEditor: KotlinEditor, psiElement: PsiElement): List<KotlinQuickAssistProposal>\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinRemoveExplicitTypeAssistProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\npublic class KotlinRemoveExplicitTypeAssistProposal(editor: KotlinEditor) : KotlinQuickAssistProposal(editor) {\n    private var displayString: String? = null\n    \n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val element = PsiTreeUtil.getNonStrictParentOfType(psiElement, KtCallableDeclaration::class.java)\n        if (element == null) return false\n        \n        if (element.getContainingFile() is KtCodeFragment) return false\n        if (element.getTypeReference() == null) return false\n\n        val caretOffset = getCaretOffsetInPSI(editor, editor.document)\n        \n        val initializer = (element as? KtDeclarationWithInitializer)?.getInitializer()\n        if (initializer != null && initializer.getTextRange().containsOffset(caretOffset)) return false\n        \n        val bindingContext = element.getBindingContext()\n        if (bindingContext == null) return false\n        \n        return when (element) {\n            is KtProperty -> initializer != null\n            is KtNamedFunction -> !element.hasBlockBody() && initializer != null\n            is KtParameter -> element.isLoopParameter()\n            else -> false\n        }\n    }\n    \n    override fun getDisplayString(): String {\n        return \"Remove explicit type specification\"\n    }\n    \n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val element = PsiTreeUtil.getNonStrictParentOfType(psiElement, KtCallableDeclaration::class.java)!!\n        val anchor = getAnchor(element)\n        \n        if (anchor == null) return\n        \n        removeTypeAnnotation(document, anchor, element.getTypeReference()!!)\n    }\n    \n    private fun removeTypeAnnotation(document: IDocument, removeAfter: PsiElement, typeReference: KtTypeReference) {\n        val endOffset = getEndOffset(removeAfter, editor)\n        val endOfType = getEndOffset(typeReference, editor)\n        document.replace(endOffset, endOfType - endOffset, \"\")\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinReplaceGetAssistProposal.java",
    "content": "package org.jetbrains.kotlin.ui.editors.quickassist;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.ListIterator;\n\nimport org.eclipse.jface.text.BadLocationException;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer;\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil;\nimport org.jetbrains.kotlin.psi.KtCallExpression;\nimport org.jetbrains.kotlin.psi.KtExpression;\nimport org.jetbrains.kotlin.psi.KtQualifiedExpression;\nimport org.jetbrains.kotlin.psi.KtSuperExpression;\nimport org.jetbrains.kotlin.psi.KtValueArgument;\nimport org.jetbrains.kotlin.psi.ValueArgument;\nimport org.jetbrains.kotlin.resolve.BindingContext;\nimport org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;\nimport org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument;\nimport org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;\nimport org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.util.PsiTreeUtil;\n\npublic class KotlinReplaceGetAssistProposal extends KotlinQuickAssistProposal {\n    \n    public KotlinReplaceGetAssistProposal(KotlinEditor editor) {\n        super(editor);\n    }\n\n    @Override\n    public void apply(@NotNull IDocument document, @NotNull PsiElement psiElement) {\n        KtCallExpression callElement = PsiTreeUtil.getParentOfType(psiElement, KtCallExpression.class);\n        if (callElement == null) {\n            return;\n        }\n        \n        KtQualifiedExpression qualifiedExpression = PsiTreeUtil.getParentOfType(psiElement, KtQualifiedExpression.class);\n        if (qualifiedExpression == null) {\n            return; \n        }\n        \n        IFile file = getEditor().getEclipseFile();\n        if (file == null) {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + getEditor(), null);\n            return;\n        }\n\n        String arguments = getArguments(qualifiedExpression, file);\n        if (arguments == null) {\n            return;\n        }\n        \n        replaceGetForElement(qualifiedExpression, arguments);\n    }\n    \n    private void replaceGetForElement(@NotNull KtQualifiedExpression element, @NotNull String arguments) {\n        IDocument document = getEditor().getDocument();\n        \n        try {\n            int textLength = element.getTextLength();\n            if (TextUtilities.getDefaultLineDelimiter(document).length() > 1) {\n                textLength += IndenterUtil.getLineSeparatorsOccurences(element.getText());\n            }\n            \n            int startOffset = KotlinQuickAssistProposalKt.getStartOffset(element, getEditor());\n            String receiverExpressionText = element.getReceiverExpression().getText();\n            \n            document.replace(\n                    startOffset, \n                    textLength, \n                    receiverExpressionText + \"[\" + arguments + \"]\");\n            \n            getEditor().getJavaEditor().getViewer().getTextWidget().setCaretOffset(startOffset + receiverExpressionText.length());\n        } catch (BadLocationException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    @Nullable\n    private String getArguments(@NotNull KtQualifiedExpression element, @NotNull IFile file) {\n        StringBuilder buffer = new StringBuilder();\n        List<ValueArgument> valueArguments = getPositionalArguments(element, file);\n        \n        if (valueArguments == null) return null;\n        \n        boolean firstArgument = true;\n        for (ValueArgument valueArgument : valueArguments) {\n            if (!firstArgument) buffer.append(\", \");\n            firstArgument = false;\n            \n            KtExpression argumentExpression = valueArgument.getArgumentExpression();\n            if (argumentExpression == null) continue;\n            buffer.append(argumentExpression.getText());\n        }\n        \n        return buffer.toString();\n    }\n    \n    @Nullable\n    public static List<ValueArgument> getPositionalArguments(@NotNull KtQualifiedExpression element, @NotNull IFile file) {\n        ResolvedCall<?> resolvedCall = getResolvedCall(element, file);\n        if (resolvedCall == null) return null;\n        \n        List<ResolvedValueArgument> resolvedValueArguments = resolvedCall.getValueArgumentsByIndex();\n        if (resolvedValueArguments == null) return null;\n        \n        int indexOfFirstDefaultArgument = resolvedValueArguments.indexOf(DefaultValueArgument.DEFAULT);\n        \n        List<ResolvedValueArgument> valueArgumentGroups = new ArrayList<>();\n        if (indexOfFirstDefaultArgument >= 0) {\n            ListIterator<ResolvedValueArgument> iter = resolvedValueArguments.listIterator(indexOfFirstDefaultArgument);\n            while (iter.hasNext()) {\n                ResolvedValueArgument valueArgument = iter.next();\n                if (valueArgument != DefaultValueArgument.DEFAULT) {\n                    return null; \n                }\n            }\n            \n            valueArgumentGroups = resolvedValueArguments.subList(0, indexOfFirstDefaultArgument);\n        } else {\n            valueArgumentGroups = resolvedValueArguments;\n        }\n        \n        List<ValueArgument> valueArguments = new ArrayList<>();\n        for (ResolvedValueArgument valueArgumentGroup : valueArgumentGroups) {\n            for (ValueArgument va : valueArgumentGroup.getArguments()) {\n                valueArguments.add(va);\n            }\n        }\n        \n        return valueArguments;\n    }\n    \n    @Nullable\n    private static ResolvedCall<?> getResolvedCall(@NotNull KtQualifiedExpression element, @NotNull IFile file) {\n        KtExpression call = element.getSelectorExpression();\n        if (!(call instanceof KtCallExpression)) return null;\n        \n        KtCallExpression jetCallExpression = (KtCallExpression) call; \n        \n        BindingContext bindingContext = getBindingContext(element, file);\n        \n        return bindingContext != null ? \n                CallUtilKt.getResolvedCall(jetCallExpression.getCalleeExpression(), bindingContext) : null;\n    }\n    \n    @Nullable\n    private static BindingContext getBindingContext(@NotNull KtQualifiedExpression element, @NotNull IFile file) {\n        KtExpression call = element.getSelectorExpression();\n        if (!(call instanceof KtCallExpression)) return null;\n        \n        BindingContext bindingContext = KotlinAnalyzer.INSTANCE\n                .analyzeFile(KotlinPsiManager.INSTANCE.getParsedFile(file))\n                .getAnalysisResult()\n                .getBindingContext();\n        \n        return bindingContext;\n    }\n    \n    @Override\n    public boolean isApplicable(@NotNull PsiElement psiElement) {\n        KtCallExpression callExpression = PsiTreeUtil.getParentOfType(psiElement, KtCallExpression.class);\n        if (callExpression == null) {\n            return false;\n        }\n        \n        KtExpression calleeExpression = callExpression.getCalleeExpression();\n\n        if (calleeExpression == null) {\n            return false;\n        }\n        \n        List<KtValueArgument> valueArguments = callExpression.getValueArguments();\n        if (valueArguments.isEmpty()) return false;\n        \n        for (KtValueArgument argument : valueArguments) {\n            if (argument.isNamed()) {\n                return false;\n            }\n        }\n        \n        KtQualifiedExpression qualifiedExpression = PsiTreeUtil.getParentOfType(psiElement, KtQualifiedExpression.class);\n        if (qualifiedExpression != null && !isReceiverExpressionWithValue(qualifiedExpression)) {\n            return false;\n        }\n        \n        return \"get\".equals(calleeExpression.getText()) && \n                callExpression.getTypeArgumentList() == null &&\n                valueArguments.size() > 0;\n    }\n    \n    private boolean isReceiverExpressionWithValue(@NotNull KtQualifiedExpression expression) {\n        KtExpression receiver = expression.getReceiverExpression();\n        if (receiver instanceof KtSuperExpression) return false;\n        \n        IFile file = getEditor().getEclipseFile();\n        if (file == null) return false;\n        \n        BindingContext bindingContext = getBindingContext(expression, file);\n        if (bindingContext != null) {\n            return bindingContext.getType(receiver) != null;\n        }\n        \n        return false;\n    }\n\n    @NotNull\n    @Override\n    public String getDisplayString() {\n        return \"Replace 'get' with index operator\";\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickassist/KotlinSpecifyTypeAssistProposal.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickassist\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.CallableDescriptor\nimport org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.types.ErrorUtils\nimport org.jetbrains.kotlin.types.KotlinType\nimport org.jetbrains.kotlin.types.isError\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\npublic class KotlinSpecifyTypeAssistProposal(editor: KotlinEditor) : KotlinQuickAssistProposal(editor) {\n    private var displayString: String? = null\n    \n    override fun isApplicable(psiElement: PsiElement): Boolean {\n        val element = PsiTreeUtil.getNonStrictParentOfType(psiElement, KtCallableDeclaration::class.java)\n        if (element == null) return false\n        \n        if (element.getContainingFile() is KtCodeFragment) return false\n        if (element is KtFunctionLiteral) return false\n        if (element is KtConstructor<*>) return false\n        if (element.getTypeReference() != null) return false\n        \n        val caretOffset = getCaretOffsetInPSI(editor, editor.document)\n        \n        val initializer = (element as? KtDeclarationWithInitializer)?.getInitializer()\n        if (initializer != null && initializer.getTextRange().containsOffset(caretOffset)) return false\n\n        if (element is KtNamedFunction && element.hasBlockBody()) return false\n        \n        if (getTypeForDeclaration(element).isError) return false\n\n        displayString = if (element is KtFunction) \"Specify return type explicitly\" else \"Specify type explicitly\"\n        \n        return true\n    }\n    \n    override fun getDisplayString(): String = displayString ?: \"\"\n    \n    override fun apply(document: IDocument, psiElement: PsiElement) {\n        val element = PsiTreeUtil.getNonStrictParentOfType(psiElement, KtCallableDeclaration::class.java)!!\n        val type = getTypeForDeclaration(element)\n        val anchor = getAnchor(element)\n        \n        if (anchor != null) {\n            val offset = addTypeAnnotation(editor, document, anchor, type)\n            editor.javaEditor.getViewer().setSelectedRange(offset, 0)\n        }\n    }\n    \n    private fun addTypeAnnotation(editor: KotlinEditor, document: IDocument, element: PsiElement, type: KotlinType): Int {\n        val offset = getEndOffset(element, editor)\n        val text = \": ${IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(type)}\"\n        document.replace(getEndOffset(element, editor), 0, text)\n        \n        return offset + text.length\n    }\n    \n    private fun getTypeForDeclaration(declaration: KtCallableDeclaration): KotlinType {\n        val bindingContext = declaration.getBindingContext()\n        if (bindingContext == null) return ErrorUtils.createErrorType(\"null type\")\n        \n        val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]\n        val type = (descriptor as? CallableDescriptor)?.getReturnType()\n        return type ?: ErrorUtils.createErrorType(\"null type\")\n    }\n}\n\nfun getAnchor(element: KtCallableDeclaration): PsiElement? {\n    return when (element){\n        is KtProperty -> element.getNameIdentifier()\n        is KtNamedFunction -> element.getValueParameterList()\n        is KtParameter -> element.getNameIdentifier()\n        else -> null\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinAddModifierResolution.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickfix\n\nimport com.intellij.psi.PsiComment\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiNameIdentifierOwner\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.psi.tree.IElementType\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.resolve.EclipseDescriptorUtils\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory\nimport org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2\nimport org.jetbrains.kotlin.lexer.KtModifierKeywordToken\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.lexer.KtTokens.*\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.siblings\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.quickassist.insertBefore\nimport org.jetbrains.kotlin.ui.editors.quickassist.replace\n\nfun DiagnosticFactory<*>.createAddModifierFix(modifier: KtModifierKeywordToken): KotlinDiagnosticQuickFix =\n    createAddModifierFix(modifier, KtModifierListOwner::class.java)\n\n\nfun <T : KtModifierListOwner> DiagnosticFactory<*>.createAddModifierFix(\n    modifier: KtModifierKeywordToken,\n    modifierOwnerClass: Class<T>\n): KotlinDiagnosticQuickFix {\n    val thisFactory = this\n    return object : KotlinDiagnosticQuickFix {\n\n        override val handledErrors = listOf(thisFactory)\n\n        override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> =\n            PsiTreeUtil.getNonStrictParentOfType(diagnostic.psiElement, modifierOwnerClass)?.takeUnless {\n                modifier == KtTokens.ABSTRACT_KEYWORD && it is KtObjectDeclaration\n            }?.let { modifierListOwner ->\n                listOf(KotlinAddModifierResolution(modifierListOwner, modifier))\n            } ?: emptyList()\n    }\n}\n\nfun DiagnosticFactory<*>.createAddOperatorModifierFix(modifier: KtModifierKeywordToken): KotlinDiagnosticQuickFix {\n    return object : KotlinDiagnosticQuickFix {\n        override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n            val functionDescriptor = (diagnostic as? DiagnosticWithParameters2<*, *, *>)?.a as? FunctionDescriptor\n                ?: return emptyList()\n            val sourceElement = EclipseDescriptorUtils.descriptorToDeclaration(functionDescriptor) ?: return emptyList()\n            if (sourceElement !is KotlinSourceElement) return emptyList()\n\n            val target = sourceElement.psi as? KtModifierListOwner ?: return emptyList()\n\n            return listOf(KotlinAddModifierResolution(target, modifier))\n        }\n\n        override val handledErrors: List<DiagnosticFactory<*>>\n            get() = listOf(this@createAddOperatorModifierFix)\n    }\n}\n\nfun DiagnosticFactory<*>.createMakeClassOpenFix(): KotlinDiagnosticQuickFix =\n    KotlinMakeClassOpenQuickFix(this)\n\nclass KotlinMakeClassOpenQuickFix(private val diagnosticTrigger: DiagnosticFactory<*>) : KotlinDiagnosticQuickFix {\n    override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n        val typeReference = diagnostic.psiElement as KtTypeReference\n\n        val ktFile = typeReference.containingKtFile\n\n        val bindingContext = ktFile.getBindingContext()\n\n        val type = bindingContext[BindingContext.TYPE, typeReference] ?: return emptyList()\n\n        val classDescriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return emptyList()\n        val sourceElement = EclipseDescriptorUtils.descriptorToDeclaration(classDescriptor) ?: return emptyList()\n        if (sourceElement !is KotlinSourceElement) return emptyList()\n\n        val declaration = sourceElement.psi as? KtClass ?: return emptyList()\n        if (declaration.isEnum()) return emptyList()\n\n        return listOf(KotlinAddModifierResolution(declaration, OPEN_KEYWORD))\n    }\n\n    override val handledErrors: List<DiagnosticFactory<*>>\n        get() = listOf(diagnosticTrigger)\n}\n\nclass KotlinAddModifierResolution(\n    private val element: KtModifierListOwner,\n    private val modifier: KtModifierKeywordToken\n) : KotlinMarkerResolution {\n\n    companion object {\n        private val modalityModifiers = setOf(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD)\n    }\n\n    override fun apply(file: IFile) {\n        addModifier(element, modifier)\n    }\n\n    override fun getLabel(): String? {\n        if (modifier in modalityModifiers) {\n            return \"Make '${getElementName(element)}' ${modifier.value}\"\n        }\n        return \"Add '${modifier.value}' modifier\"\n    }\n}\n\nfun getElementName(modifierListOwner: KtModifierListOwner): String? = when (modifierListOwner) {\n    is PsiNameIdentifierOwner -> modifierListOwner.nameIdentifier?.text\n    is KtPropertyAccessor -> modifierListOwner.namePlaceholder.text\n    else -> null\n} ?: modifierListOwner.text\n\n// TODO: move to file with util functions\nfun openEditorAndGetDocument(ktElement: KtElement): IDocument? {\n    val ktFile = ktElement.containingKtFile\n    return KotlinPsiManager.getEclipseFile(ktFile)?.let {\n        val editor = EditorUtility.openInEditor(it, true)\n        if (editor is KotlinEditor) editor.document else null\n    }\n}\n\nfun addModifier(owner: KtModifierListOwner, modifier: KtModifierKeywordToken) {\n    val elementDocument = openEditorAndGetDocument(owner)\n    if (elementDocument == null) return\n\n    val modifierList = owner.modifierList\n    if (modifierList == null) {\n        val anchor = owner.firstChild!!\n            .siblings(forward = true)\n            .dropWhile { it is PsiComment || it is PsiWhiteSpace }\n            .first()\n\n        insertBefore(anchor, \"${modifier.value} \", elementDocument)\n\n        return\n    } else {\n        addModifier(modifierList, modifier, elementDocument)\n    }\n}\n\nprivate fun addModifier(modifierList: KtModifierList, modifier: KtModifierKeywordToken, elementDocument: IDocument) {\n    if (modifierList.hasModifier(modifier)) return\n\n    val newModifier = KtPsiFactory(modifierList).createModifier(modifier)\n    val modifiersToReplace = MODIFIERS_TO_REPLACE[modifier] ?: setOf()\n\n    generateSequence(modifierList.firstChild) { it.nextSibling }\n        .plus(newModifier)\n        .filterNot { it is PsiWhiteSpace }\n        .filterNot { it.type in modifiersToReplace }\n        .sortedBy { MODIFIERS_ORDER[it.type] ?: -1 }\n        .map { if (it is KtAnnotationEntry) \"${it.text}\\n\" else \"${it.text} \" }\n        .joinToString(separator = \"\")\n        .dropLast(1)\n        .also { replace(modifierList, it, elementDocument) }\n}\n\nprivate val PsiElement.type: IElementType get() = node.elementType\n\nprivate val MODIFIERS_TO_REPLACE = mapOf(\n    OVERRIDE_KEYWORD to setOf(OPEN_KEYWORD),\n    ABSTRACT_KEYWORD to setOf(OPEN_KEYWORD, FINAL_KEYWORD),\n    OPEN_KEYWORD to setOf(FINAL_KEYWORD, ABSTRACT_KEYWORD),\n    FINAL_KEYWORD to setOf(ABSTRACT_KEYWORD, OPEN_KEYWORD),\n    PUBLIC_KEYWORD to setOf(PROTECTED_KEYWORD, PRIVATE_KEYWORD, INTERNAL_KEYWORD),\n    PROTECTED_KEYWORD to setOf(PUBLIC_KEYWORD, PRIVATE_KEYWORD, INTERNAL_KEYWORD),\n    PRIVATE_KEYWORD to setOf(PUBLIC_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD),\n    INTERNAL_KEYWORD to setOf(PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD)\n)\n\nprivate val MODIFIERS_ORDER = listOf(\n    PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, INTERNAL_KEYWORD,\n    FINAL_KEYWORD, OPEN_KEYWORD, ABSTRACT_KEYWORD,\n    OVERRIDE_KEYWORD,\n    INNER_KEYWORD, ENUM_KEYWORD, COMPANION_KEYWORD, INFIX_KEYWORD, OPERATOR_KEYWORD\n)\n    .withIndex()\n    .associate { it.value to it.index }"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinAutoImportQuickFix.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickfix\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.eclipse.jdt.ui.ISharedImages\nimport org.eclipse.jdt.ui.JavaUI\nimport org.eclipse.jface.text.IDocument\nimport org.eclipse.jface.text.TextUtilities\nimport org.eclipse.swt.graphics.Image\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.imports.DefaultImportPredicate\nimport org.jetbrains.kotlin.core.imports.FIXABLE_DIAGNOSTICS\nimport org.jetbrains.kotlin.core.imports.ImportCandidate\nimport org.jetbrains.kotlin.core.imports.findImportCandidatesForReference\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.core.resolve.KotlinResolutionFacade\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getEndLfOffset\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtImportList\nimport org.jetbrains.kotlin.psi.KtPackageDirective\nimport org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\n\nobject KotlinAutoImportQuickFix : KotlinDiagnosticQuickFix {\n    override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n        val ktFile = diagnostic.psiElement.containingFile as? KtFile ?: return emptyList()\n        val file = KotlinPsiManager.getEclipseFile(ktFile) ?: return emptyList()\n        val bindingContext = ktFile.getBindingContext()\n        val (result, container) = KotlinAnalyzer.analyzeFile(ktFile)\n        val resolutionFacade = container?.let { KotlinResolutionFacade(file, it, result.moduleDescriptor) }\n            ?: return emptyList()\n\n        val environment = KotlinPsiManager.getJavaProject(ktFile)\n            ?.let { KotlinEnvironment.getEnvironment(it.project) }\n            ?: return emptyList()\n        val languageVersionSettings = environment.compilerProperties.languageVersionSettings\n\n        val defaultImportsPredicate = DefaultImportPredicate(JvmPlatformAnalyzerServices, languageVersionSettings)\n        return findImportCandidatesForReference(\n            diagnostic.psiElement,\n            bindingContext,\n            resolutionFacade,\n            defaultImportsPredicate\n        ).map { KotlinAutoImportResolution(it) }\n    }\n\n    override val handledErrors: Collection<DiagnosticFactory<*>>\n        get() = FIXABLE_DIAGNOSTICS\n}\n\nfun placeImports(chosenCandidates: List<ImportCandidate>, file: IFile, document: IDocument): Int {\n    return placeStrImports(chosenCandidates.mapNotNull { it.fullyQualifiedName }, file, document)\n}\n\nfun replaceImports(newImports: List<String>, file: IFile, document: IDocument) {\n    val ktFile = KotlinPsiManager.getParsedFile(file)\n    val importDirectives = ktFile.importDirectives\n    if (importDirectives.isEmpty()) {\n        placeStrImports(newImports, file, document)\n        return\n    }\n\n    val imports = buildImportsStr(newImports, document)\n\n    val startOffset = importDirectives.first().getTextDocumentOffset(document)\n    val lastImportDirectiveOffset = importDirectives.last().getEndLfOffset(document)\n    val endOffset = if (newImports.isEmpty()) {\n        val next = ktFile.importList!!.nextSibling\n        if (next is PsiWhiteSpace) next.getEndLfOffset(document) else lastImportDirectiveOffset\n    } else {\n        lastImportDirectiveOffset\n    }\n\n    document.replace(startOffset, endOffset - startOffset, imports)\n}\n\nprivate fun placeStrImports(importsDirectives: List<String>, file: IFile, document: IDocument): Int {\n    if (importsDirectives.isEmpty()) return -1\n\n    val placeElement = findNodeToNewImport(file)\n    if (placeElement == null) return -1\n\n    val breakLineBefore = computeBreakLineBeforeImport(placeElement)\n    val breakLineAfter = computeBreakLineAfterImport(placeElement)\n\n    val lineDelimiter = TextUtilities.getDefaultLineDelimiter(document)\n\n    val imports = buildImportsStr(importsDirectives, document)\n    val newImports = \"${IndenterUtil.createWhiteSpace(0, breakLineBefore, lineDelimiter)}$imports\" +\n            \"${IndenterUtil.createWhiteSpace(0, breakLineAfter, lineDelimiter)}\"\n\n    document.replace(placeElement.getEndLfOffset(document), 0, newImports)\n\n    return newImports.length\n}\n\nprivate fun buildImportsStr(importsDirectives: List<String>, document: IDocument): String {\n    val lineDelimiter = TextUtilities.getDefaultLineDelimiter(document)\n    return importsDirectives.joinToString(lineDelimiter) { \"import $it\" }\n}\n\nclass KotlinAutoImportResolution(private val candidate: ImportCandidate) : KotlinMarkerResolution {\n    override fun apply(file: IFile) {\n        val editor = EditorUtility.openInEditor(file, true) as KotlinEditor\n        placeImports(listOf(candidate), file, editor.document)\n    }\n\n    override fun getLabel(): String? = \"Import '${candidate.simpleName}' (${candidate.packageName})\"\n\n    override fun getImage(): Image? = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_IMPDECL)\n}\n\nprivate fun computeBreakLineAfterImport(element: PsiElement): Int {\n    if (element is KtPackageDirective) {\n        val nextSibling = element.getNextSibling()\n        if (nextSibling is KtImportList) {\n            val importList = nextSibling\n            if (importList.getImports().isNotEmpty()) {\n                return 2\n            } else {\n                return countBreakLineAfterImportList(nextSibling.getNextSibling())\n            }\n        }\n    }\n\n    return 0\n}\n\nprivate fun countBreakLineAfterImportList(psiElement: PsiElement): Int {\n    if (psiElement is PsiWhiteSpace) {\n        val countBreakLineAfterHeader = IndenterUtil.getLineSeparatorsOccurences(psiElement.getText())\n        return when (countBreakLineAfterHeader) {\n            0 -> 2\n            1 -> 1\n            else -> 0\n        }\n    }\n\n    return 2\n}\n\nprivate fun computeBreakLineBeforeImport(element: PsiElement): Int {\n    if (element is KtPackageDirective) {\n        return when {\n            element.isRoot -> 0\n            else -> 2\n        }\n    }\n\n    return 1\n}\n\nprivate fun findNodeToNewImport(file: IFile): PsiElement? {\n    val jetFile = KotlinPsiManager.getParsedFile(file)\n    val jetImportDirective = jetFile.importDirectives\n    return if (jetImportDirective.isNotEmpty()) jetImportDirective.last() else jetFile.packageDirective\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinMakeOverridenMemberOpenResolution.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickfix\n\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.descriptors.isOverridable\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory2\nimport org.jetbrains.kotlin.diagnostics.Errors\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.KtCallableDeclaration\nimport org.jetbrains.kotlin.psi.KtModifierListOwner\nimport org.jetbrains.kotlin.psi.KtNamedDeclaration\nimport org.jetbrains.kotlin.resolve.source.PsiSourceElement\nimport java.util.ArrayList\n\nfun DiagnosticFactory<*>.createMakeDeclarationOpenFix() = MakeOverriddenMemberOpenFix()\n\nclass MakeOverriddenMemberOpenFix : KotlinDiagnosticQuickFix {\n\n    override val handledErrors: List<DiagnosticFactory<*>>\n        get() = listOf(Errors.OVERRIDING_FINAL_MEMBER)\n\n    override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n        val overrideFinalDiagnostic = Errors.OVERRIDING_FINAL_MEMBER.cast(diagnostic)\n        val badOverriden: CallableMemberDescriptor = overrideFinalDiagnostic.a\n        \n        val firstNotOverridable: CallableMemberDescriptor? = getFirstDeclaredNonOverridableOverriddenDescriptor(badOverriden)\n        if (firstNotOverridable == null) return listOf()\n        \n        val source = firstNotOverridable.source as? PsiSourceElement\n        if (source == null) return listOf()\n        \n        val modifierListOwner = (source.psi as? KtModifierListOwner)\n        if (modifierListOwner == null) return listOf()\n        \n        return listOf(KotlinAddOpenToMemberResolution(modifierListOwner, firstNotOverridable.containingDeclaration.name))\n    }\n    \n    companion object {\n        private fun getFirstDeclaredNonOverridableOverriddenDescriptor(callableMemberDescriptor: CallableMemberDescriptor): CallableMemberDescriptor? {\n            if (!callableMemberDescriptor.isOverridable && callableMemberDescriptor.kind == Kind.DECLARATION) return callableMemberDescriptor\n            \n            val nonOverridableOverriddenDescriptors = retainNonOverridableMembers(callableMemberDescriptor.overriddenDescriptors)\n            for (overriddenDescriptor in nonOverridableOverriddenDescriptors) {\n                when (overriddenDescriptor.kind) {\n                    Kind.DECLARATION -> return overriddenDescriptor\n\n                    Kind.FAKE_OVERRIDE, Kind.DELEGATION ->\n                        return getFirstDeclaredNonOverridableOverriddenDescriptor(overriddenDescriptor)\n\n                    Kind.SYNTHESIZED -> {\n                        /* do nothing */\n                    } \n\n                    else -> throw UnsupportedOperationException(\"Unexpected callable kind ${overriddenDescriptor.kind}\")\n                }\n            }\n            \n            return null\n        }\n\n        private fun retainNonOverridableMembers(callableMemberDescriptors: Collection<CallableMemberDescriptor>): Collection<CallableMemberDescriptor> {\n            return callableMemberDescriptors.filter { !it.isOverridable }\n        }\n    }\n}\n\nclass KotlinAddOpenToMemberResolution(private val element: KtModifierListOwner, private val containinName: Name) : KotlinMarkerResolution {\n    override fun apply(file: IFile) {\n        addModifier(element, KtTokens.OPEN_KEYWORD)\n    }\n    \n    override fun getLabel(): String? {\n        return \"Make $containinName.${getElementName(element)} open\"\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinMarkerResolutionGenerator.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.quickfix\n\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.ui.IMarkerResolution\nimport org.eclipse.ui.IMarkerResolutionGenerator\nimport org.eclipse.ui.IMarkerResolutionGenerator2\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager.CAN_FIX_PROBLEM\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager.MARKER_PROBLEM_TYPE\n\nclass KotlinMarkerResolutionGenerator : IMarkerResolutionGenerator, IMarkerResolutionGenerator2 {\n\n    override fun getResolutions(marker: IMarker): Array<IMarkerResolution> =\n        getResolutions(listOfNotNull(marker.diagnostic)).toTypedArray()\n\n    override fun hasResolutions(marker: IMarker): Boolean =\n        marker.type == MARKER_PROBLEM_TYPE && marker.getAttribute(CAN_FIX_PROBLEM, false)\n\n    companion object {\n        fun getResolutions(diagnostics: List<Diagnostic>): List<KotlinMarkerResolution> =\n            diagnostics.flatMap { getResolutions(it) }\n\n        fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> =\n            kotlinQuickFixes.getOrDefault(diagnostic.factory, mutableListOf()).flatMap { quickFix ->\n                (quickFix as? KotlinDiagnosticQuickFix)?.getResolutions(diagnostic) ?: listOf()\n            }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinQuickFix.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.quickfix\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.jdt.internal.ui.JavaPluginImages\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.ui.IMarkerResolution\nimport org.eclipse.ui.IMarkerResolution2\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_FUNCTION_WITH_BODY\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_MEMBER_NOT_IMPLEMENTED\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_PROPERTY_WITH_GETTER\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_PROPERTY_WITH_INITIALIZER\nimport org.jetbrains.kotlin.diagnostics.Errors.ABSTRACT_PROPERTY_WITH_SETTER\nimport org.jetbrains.kotlin.diagnostics.Errors.FINAL_SUPERTYPE\nimport org.jetbrains.kotlin.diagnostics.Errors.FINAL_UPPER_BOUND\nimport org.jetbrains.kotlin.diagnostics.Errors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY\nimport org.jetbrains.kotlin.diagnostics.Errors.INACCESSIBLE_OUTER_CLASS_EXPRESSION\nimport org.jetbrains.kotlin.diagnostics.Errors.INCOMPATIBLE_MODIFIERS\nimport org.jetbrains.kotlin.diagnostics.Errors.INFIX_MODIFIER_REQUIRED\nimport org.jetbrains.kotlin.diagnostics.Errors.MUST_BE_INITIALIZED_OR_BE_ABSTRACT\nimport org.jetbrains.kotlin.diagnostics.Errors.NESTED_CLASS_NOT_ALLOWED\nimport org.jetbrains.kotlin.diagnostics.Errors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY\nimport org.jetbrains.kotlin.diagnostics.Errors.NON_FINAL_MEMBER_IN_FINAL_CLASS\nimport org.jetbrains.kotlin.diagnostics.Errors.NON_FINAL_MEMBER_IN_OBJECT\nimport org.jetbrains.kotlin.diagnostics.Errors.NOTHING_TO_OVERRIDE\nimport org.jetbrains.kotlin.diagnostics.Errors.OPERATOR_MODIFIER_REQUIRED\nimport org.jetbrains.kotlin.diagnostics.Errors.OVERRIDING_FINAL_MEMBER\nimport org.jetbrains.kotlin.diagnostics.Errors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY\nimport org.jetbrains.kotlin.diagnostics.Errors.PRIVATE_SETTER_FOR_OPEN_PROPERTY\nimport org.jetbrains.kotlin.diagnostics.Errors.REDUNDANT_MODIFIER\nimport org.jetbrains.kotlin.diagnostics.Errors.REDUNDANT_MODIFIER_FOR_TARGET\nimport org.jetbrains.kotlin.diagnostics.Errors.REDUNDANT_MODIFIER_IN_GETTER\nimport org.jetbrains.kotlin.diagnostics.Errors.REPEATED_MODIFIER\nimport org.jetbrains.kotlin.diagnostics.Errors.SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY\nimport org.jetbrains.kotlin.diagnostics.Errors.VIRTUAL_MEMBER_HIDDEN\nimport org.jetbrains.kotlin.diagnostics.Errors.WRONG_MODIFIER_CONTAINING_DECLARATION\nimport org.jetbrains.kotlin.diagnostics.Errors.WRONG_MODIFIER_TARGET\nimport org.jetbrains.kotlin.lexer.KtTokens.ABSTRACT_KEYWORD\nimport org.jetbrains.kotlin.lexer.KtTokens.INFIX_KEYWORD\nimport org.jetbrains.kotlin.lexer.KtTokens.INNER_KEYWORD\nimport org.jetbrains.kotlin.lexer.KtTokens.OPEN_KEYWORD\nimport org.jetbrains.kotlin.lexer.KtTokens.OPERATOR_KEYWORD\nimport org.jetbrains.kotlin.lexer.KtTokens.OVERRIDE_KEYWORD\nimport org.jetbrains.kotlin.psi.KtClass\n\nval kotlinQuickFixes = hashMapOf<DiagnosticFactory<*>, MutableList<KotlinQuickFix>>().apply {\n    initializeQuickFixes().flatMap { quickFix -> quickFix.handledErrors.map { Pair(it, quickFix) } }\n        .groupBy { it.first }\n        .forEach { entry ->\n            getOrPut(entry.key) { mutableListOf() }.addAll(entry.value.map { it.second })\n        }\n}\n\ninterface KotlinQuickFix {\n\n    val handledErrors: Collection<DiagnosticFactory<*>>\n\n    // this function must be fast and optimistic\n    fun canFix(diagnostic: Diagnostic): Boolean = handledErrors.contains(diagnostic.factory)\n}\n\ninterface KotlinDiagnosticQuickFix : KotlinQuickFix {\n    fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution>\n}\n\ninterface KotlinMarkerResolution : IMarkerResolution, IMarkerResolution2 {\n    fun apply(file: IFile)\n\n    override fun run(marker: IMarker) {\n        val resource = marker.resource\n        if (resource is IFile) {\n            apply(resource)\n        }\n    }\n\n    override fun getImage(): Image? = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)\n\n    override fun getDescription(): String? = null\n}\n\nprivate fun initializeQuickFixes(): List<KotlinQuickFix> {\n    return listOf(\n        KotlinAutoImportQuickFix,\n\n        OVERRIDING_FINAL_MEMBER.createMakeDeclarationOpenFix(),\n\n        MUST_BE_INITIALIZED_OR_BE_ABSTRACT.createAddModifierFix(ABSTRACT_KEYWORD),\n        MUST_BE_INITIALIZED_OR_BE_ABSTRACT.createAddModifierFix(ABSTRACT_KEYWORD),\n        ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED.createAddModifierFix(ABSTRACT_KEYWORD),\n        NON_ABSTRACT_FUNCTION_WITH_NO_BODY.createAddModifierFix(ABSTRACT_KEYWORD),\n        ABSTRACT_MEMBER_NOT_IMPLEMENTED.createAddModifierFix(ABSTRACT_KEYWORD),\n\n        ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.createAddModifierFix(ABSTRACT_KEYWORD, KtClass::class.java),\n        ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.createAddModifierFix(ABSTRACT_KEYWORD, KtClass::class.java),\n\n        VIRTUAL_MEMBER_HIDDEN.createAddModifierFix(OVERRIDE_KEYWORD),\n\n        NON_FINAL_MEMBER_IN_FINAL_CLASS.createAddModifierFix(OPEN_KEYWORD, KtClass::class.java),\n        NON_FINAL_MEMBER_IN_OBJECT.createAddModifierFix(OPEN_KEYWORD, KtClass::class.java),\n\n        INACCESSIBLE_OUTER_CLASS_EXPRESSION.createAddModifierFix(INNER_KEYWORD, KtClass::class.java),\n        NESTED_CLASS_NOT_ALLOWED.createAddModifierFix(INNER_KEYWORD),\n\n        FINAL_SUPERTYPE.createMakeClassOpenFix(),\n        FINAL_UPPER_BOUND.createMakeClassOpenFix(),\n\n        ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_PROPERTY_WITH_INITIALIZER.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_PROPERTY_WITH_GETTER.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_PROPERTY_WITH_SETTER.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n        ABSTRACT_FUNCTION_WITH_BODY.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD),\n\n        NOTHING_TO_OVERRIDE.createRemoveModifierFromListOwnerFactory(OVERRIDE_KEYWORD),\n\n        NON_FINAL_MEMBER_IN_FINAL_CLASS.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD),\n        NON_FINAL_MEMBER_IN_OBJECT.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD),\n\n        REDUNDANT_MODIFIER.createRemoveModifierFactory(true),\n        REDUNDANT_MODIFIER_IN_GETTER.createRemoveModifierFactory(true),\n\n        INCOMPATIBLE_MODIFIERS.createRemoveModifierFactory(),\n\n        GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.createRemoveModifierFactory(),\n        SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY.createRemoveModifierFactory(),\n        PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY.createRemoveModifierFactory(),\n        PRIVATE_SETTER_FOR_OPEN_PROPERTY.createRemoveModifierFactory(),\n        REDUNDANT_MODIFIER_IN_GETTER.createRemoveModifierFactory(),\n        WRONG_MODIFIER_TARGET.createRemoveModifierFactory(),\n        REDUNDANT_MODIFIER_FOR_TARGET.createRemoveModifierFactory(),\n        WRONG_MODIFIER_CONTAINING_DECLARATION.createRemoveModifierFactory(),\n        REPEATED_MODIFIER.createRemoveModifierFactory(),\n\n        OPERATOR_MODIFIER_REQUIRED.createAddOperatorModifierFix(OPERATOR_KEYWORD),\n        INFIX_MODIFIER_REQUIRED.createAddOperatorModifierFix(INFIX_KEYWORD)\n    )\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/KotlinRemoveModifierResolution.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.quickfix\n\nimport org.jetbrains.kotlin.psi.KtModifierListOwner\nimport org.jetbrains.kotlin.lexer.KtModifierKeywordToken\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.ui.editors.quickassist.remove\nimport org.jetbrains.kotlin.diagnostics.DiagnosticFactory\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport com.intellij.psi.util.PsiTreeUtil\nimport com.intellij.psi.PsiWhiteSpace\n\nfun DiagnosticFactory<*>.createRemoveModifierFromListOwnerFactory(\n        modifier: KtModifierKeywordToken,\n        isRedundant: Boolean = false): KotlinDiagnosticQuickFix {\n    return object : KotlinDiagnosticQuickFix {\n        override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n            val modifierListOwner = PsiTreeUtil.getParentOfType(diagnostic.psiElement, KtModifierListOwner::class.java, false)\n            if (modifierListOwner == null) return emptyList()\n            \n            return listOf(KotlinRemoveModifierResolution(modifierListOwner, modifier, isRedundant))\n        }\n        \n        override val handledErrors: List<DiagnosticFactory<*>>\n            get() = listOf(this@createRemoveModifierFromListOwnerFactory)\n    }\n}\n\nfun DiagnosticFactory<*>.createRemoveModifierFactory(isRedundant: Boolean = false): KotlinDiagnosticQuickFix {\n    return object : KotlinDiagnosticQuickFix {\n        override fun getResolutions(diagnostic: Diagnostic): List<KotlinMarkerResolution> {\n            val psiElement = diagnostic.psiElement\n            val elementType = psiElement.node.elementType as? KtModifierKeywordToken ?: return emptyList()\n            \n            val modifierListOwner = PsiTreeUtil.getParentOfType(psiElement, KtModifierListOwner::class.java) ?: return emptyList()\n            return listOf(KotlinRemoveModifierResolution(modifierListOwner, elementType, isRedundant))\n            \n        }\n        \n        override val handledErrors: List<DiagnosticFactory<*>>\n            get() = listOf(this@createRemoveModifierFactory)\n    }\n}\n\nclass KotlinRemoveModifierResolution(\n        private val element: KtModifierListOwner,\n        private val modifier: KtModifierKeywordToken,\n        private val isRedundant: Boolean) : KotlinMarkerResolution {\n    \n    override fun apply(file: IFile) {\n        removeModifier(element, modifier)\n    }\n    \n    override fun getLabel(): String {\n        val modifierText = modifier.value\n        return when {\n            isRedundant -> \"Remove redundant '$modifierText' modifier\"\n            \n            modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD ->\n                \"Make '${getElementName(element)}' not $modifierText\"\n            \n            else -> \"Remove '$modifierText' modifier\"\n        }\n    }\n}\n\nprivate fun removeModifier(owner: KtModifierListOwner, modifier: KtModifierKeywordToken) {\n    val document = openEditorAndGetDocument(owner)\n    if (document == null) return\n    \n    val modifierList = owner.modifierList\n    if (modifierList == null) return\n    \n    modifierList.getModifier(modifier)?.let { m ->\n        val sibling = m.nextSibling\n        if (sibling is PsiWhiteSpace) {\n            remove(sibling, document)\n        } else if (sibling == null) {\n            val modifiersSibling = modifierList.nextSibling\n            if (modifiersSibling is PsiWhiteSpace) {\n                remove(modifiersSibling, document)\n            }\n        }\n        \n        remove(m, document)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/quickfix/MarkerExtensions.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.quickfix\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.core.resources.IResource\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\n\nprivate const val ANNOTATION_DIAGNOSTIC_HASH = \"annotationDiagnostic\"\n\nprivate val resourceDiagnosticsMapping = hashMapOf<IFile, HashMap<Int, Diagnostic>>()\n\nval IMarker.diagnostic: Diagnostic?\n    get() = annotationCode?.let { code ->\n        (resource as? IFile)?.let { file ->\n            resourceDiagnosticsMapping[file]?.get(code)\n        }\n    }\n\nprivate var IMarker.annotationCode: Int?\n    get() = getAttribute(ANNOTATION_DIAGNOSTIC_HASH) as? Int\n    set(value) = setAttribute(ANNOTATION_DIAGNOSTIC_HASH, value)\n\ninternal fun IMarker.addDiagnostics(diagnostic: Diagnostic) {\n    val hashCode = diagnostic.hashCode()\n    resourceDiagnosticsMapping.getOrPut(resource as IFile) { hashMapOf() }[hashCode] = diagnostic\n    annotationCode = hashCode\n}\n\ninternal fun IFile.removeMarkers() {\n    deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)\n    resourceDiagnosticsMapping.remove(this)\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/KotlinSelectEnclosingAction.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory;\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.selection.handlers.KotlinElementSelectioner;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\n\npublic class KotlinSelectEnclosingAction extends KotlinSemanticSelectionAction {\n    \n    private static final String ACTION_DESCRIPTION = \"Select enclosing element\";\n    \n    public static final String SELECT_ENCLOSING_TEXT = \"SelectEnclosing\";\n    \n    public KotlinSelectEnclosingAction(KotlinEditor editor, SelectionHistory history) {\n        super(editor, history);\n        setText(ACTION_DESCRIPTION);\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_ENCLOSING);\n    }\n    \n    @Override\n    protected @NotNull TextRange runInternalSelection(PsiElement enclosingElement, TextRange selectedRange,\n            String selectedText) {\n        return KotlinElementSelectioner.INSTANCE.selectEnclosing(enclosingElement, selectedRange);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/KotlinSelectNextAction.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory;\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.selection.handlers.KotlinElementSelectioner;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\n\npublic class KotlinSelectNextAction extends KotlinSemanticSelectionAction {\n    \n    private static final String ACTION_DESCRIPTION = \"Select next element\";\n    \n    public static final String SELECT_NEXT_TEXT = \"SelectNext\";\n    \n    public KotlinSelectNextAction(KotlinEditor editor, SelectionHistory history) {\n        super(editor, history);\n        setText(ACTION_DESCRIPTION);\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT);\n    }\n    \n    @Override\n    protected @NotNull TextRange runInternalSelection(PsiElement enclosingElement, TextRange selectedRange,\n            String selectedText) {\n        PsiElement selectionCandidate = findSelectionCandidate(enclosingElement,\n                PsiElementChildrenIterable.forwardChildrenIterator(enclosingElement), selectedRange, selectedText);\n        KotlinElementSelectioner elementSelectioner = KotlinElementSelectioner.INSTANCE;\n        \n        if (selectionCandidate == null) {\n            return elementSelectioner.selectEnclosing(enclosingElement, selectedRange);\n        }\n        return elementSelectioner.selectNext(enclosingElement, selectionCandidate, selectedRange);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/KotlinSelectPreviousAction.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory;\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.selection.handlers.KotlinElementSelectioner;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\n\npublic class KotlinSelectPreviousAction extends KotlinSemanticSelectionAction {\n    \n    private static final String ACTION_DESCRIPTION = \"Select previous element\";\n    \n    public static final String SELECT_PREVIOUS_TEXT = \"SelectPrevious\";\n    \n    public KotlinSelectPreviousAction(KotlinEditor editor, SelectionHistory history) {\n        super(editor, history);\n        setText(ACTION_DESCRIPTION);\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_PREVIOUS);\n    }\n    \n    @Override\n    protected @NotNull TextRange runInternalSelection(PsiElement enclosingElement, TextRange selectedRange,\n            String selectedText) {\n        PsiElement selectionCandidate = findSelectionCandidate(enclosingElement,\n                PsiElementChildrenIterable.backwardChildrenIterator(enclosingElement), selectedRange, selectedText);\n        if (selectionCandidate == null) {\n            return KotlinElementSelectioner.INSTANCE.selectEnclosing(enclosingElement, selectedRange);\n        }\n        return KotlinElementSelectioner.INSTANCE.selectPrevious(enclosingElement, selectionCandidate, selectedRange);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/KotlinSemanticSelectionAction.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection;\n\nimport org.eclipse.jdt.core.SourceRange;\nimport org.eclipse.jdt.internal.ui.javaeditor.selectionactions.SelectionHistory;\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.PsiWhiteSpace;\n\nabstract public class KotlinSemanticSelectionAction extends SelectionDispatchAction {\n    \n    public final static String HISTORY = \"RestoreLastSelection\";\n    \n    protected KotlinEditor editor;\n    protected SelectionHistory history;\n    \n    protected KotlinSemanticSelectionAction(KotlinEditor editor, SelectionHistory history) {\n        super(editor.getJavaEditor().getSite());\n        this.editor = editor;\n        this.history = history;\n    }\n    \n    protected enum ElementSelection {\n        NotSelected, PartiallySelected, StrictlyWithinSelection, IsEqualToSelection, IsEnclosingSelection\n    }\n    \n    @Override\n    public void run(ITextSelection selection) {\n        IDocument document = editor.getDocument();\n        KtFile jetFile = editor.getParsedFile();\n        \n        if (jetFile == null) {\n            return;\n        }\n        \n        TextRange crRange = new TextRange(selection.getOffset(), selection.getOffset() + selection.getLength());\n        TextRange selectedRange = LineEndUtil.lfRangeFromCrRange(crRange, document);\n        PsiElement enclosingElement = getEnclosingElementForSelection(jetFile, selectedRange);\n        if (enclosingElement == null) {\n            return;\n        }\n        TextRange elementRange = runInternalSelection(enclosingElement, selectedRange, selection.getText());\n        history.remember(new SourceRange(selection.getOffset(), selection.getLength()));\n        try {\n            history.ignoreSelectionChanges();\n            \n            TextRange convertedRange = LineEndUtil.crRangeFromLfRange(jetFile.getText(), elementRange, document);\n            editor.getJavaEditor().selectAndReveal(convertedRange.getStartOffset(), convertedRange.getLength());\n        } finally {\n            history.listenToSelectionChanges();\n        }\n    }\n    \n    @Nullable\n    public static PsiElement getEnclosingElementForSelection(PsiFile parsedCode, TextRange selectedRange) {\n        PsiElement selectedElement = parsedCode.findElementAt(selectedRange.getStartOffset());\n        if (selectedElement instanceof PsiWhiteSpace) {\n            PsiElement shiftedElement = parsedCode.findElementAt(selectedRange.getStartOffset() - 1);\n            if (!(shiftedElement instanceof PsiWhiteSpace)) {\n                selectedElement = shiftedElement;\n            }\n        }\n        while (selectedElement != null\n                && checkSelection(selectedElement, selectedRange) != ElementSelection.IsEnclosingSelection) {\n            selectedElement = selectedElement.getParent();\n        }\n        return selectedElement;\n    }\n    \n    @NotNull\n    abstract protected TextRange runInternalSelection(PsiElement enclosingElement, TextRange selectedRange,\n            String selectedText);\n    \n    static ElementSelection checkSelection(PsiElement element, TextRange selectedRange) {\n        TextRange elementRange = element.getTextRange();\n        \n        int selectionStartOffset = selectedRange.getStartOffset();\n        int selectionEndOffset = selectedRange.getEndOffset();\n        int elementStartOffset = elementRange.getStartOffset();\n        int elementEndOffset = elementRange.getEndOffset();\n        \n        if (selectionStartOffset == selectionEndOffset) {\n            if (selectionEndOffset < elementStartOffset || elementEndOffset < selectionStartOffset) {\n                return ElementSelection.NotSelected;\n            }\n        } else if (selectionEndOffset <= elementStartOffset || elementEndOffset <= selectionStartOffset) {\n            return ElementSelection.NotSelected;\n        }\n        \n        if (selectionStartOffset <= elementStartOffset && elementEndOffset <= selectionEndOffset) {\n            if (selectionStartOffset < elementStartOffset || elementEndOffset < selectionEndOffset) {\n                return ElementSelection.StrictlyWithinSelection;\n            }\n            \n            return ElementSelection.IsEqualToSelection;\n        }\n        \n        if (elementStartOffset <= selectionStartOffset && selectionEndOffset <= elementEndOffset) {\n            return ElementSelection.IsEnclosingSelection;\n        }\n        \n        return ElementSelection.PartiallySelected;\n    }\n    \n    @Nullable\n    protected PsiElement findSelectionCandidate(@NotNull PsiElement enclosingElement,\n            PsiElementChildrenIterable elementChildren, TextRange selectedRange, String selectedText) {\n        boolean isSelectionCandidate = false;\n        \n        // if selected text is all whitespaces then select enclosing\n        if (!selectedText.isEmpty() && selectedText.trim().isEmpty()) {\n            return null;\n        }\n        \n        for (PsiElement currentChild : elementChildren) {\n            ElementSelection selectionType = checkSelection(currentChild, selectedRange);\n            // if all completely selected elements are not the children of the\n            // enclosing element, then select enclosing element\n            if (selectionType == ElementSelection.PartiallySelected && !(currentChild instanceof PsiWhiteSpace)) {\n                return null;\n            }\n            if (selectionType == ElementSelection.NotSelected) {\n                // if we're already looking for selection candidate, select if\n                // not whitespace\n                if (!(currentChild instanceof PsiWhiteSpace) && !currentChild.getText().isEmpty()\n                        && isSelectionCandidate) {\n                    return currentChild;\n                }\n            } else {\n                // next child is selection candidate\n                isSelectionCandidate = true;\n            }\n        }\n        \n        return null;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/PsiElementChildrenIterable.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection;\n\nimport java.util.Iterator;\n\nimport com.intellij.psi.PsiElement;\n\npublic class PsiElementChildrenIterable implements Iterable<PsiElement> {\n    \n    private class PsiChildrenIterator implements Iterator<PsiElement> {\n        \n        private PsiElement currentElement;\n        private final boolean reverse;\n        \n        public PsiChildrenIterator(PsiElement enclosingElement, boolean reverse) {\n            if (reverse) {\n                currentElement = enclosingElement.getLastChild();\n            } else {\n                currentElement = enclosingElement.getFirstChild();\n            }\n            this.reverse = reverse;\n        }\n        \n        @Override\n        public boolean hasNext() {\n            return currentElement != null;\n        }\n        \n        @Override\n        public PsiElement next() {\n            PsiElement result = currentElement;\n            if (currentElement != null) {\n                if (reverse) {\n                    currentElement = currentElement.getPrevSibling();\n                } else {\n                    currentElement = currentElement.getNextSibling();\n                }\n            }\n            return result;\n        }\n        \n        @Override\n        public void remove() {\n            throw new UnsupportedOperationException();\n        }\n    }\n    \n    private final Iterator<PsiElement> iterator;\n    \n    private PsiElementChildrenIterable(PsiElement enclosingElement, boolean reverse) {\n        iterator = new PsiChildrenIterator(enclosingElement, reverse);\n    }\n    \n    @Override\n    public Iterator<PsiElement> iterator() {\n        return iterator;\n    }\n    \n    public static PsiElementChildrenIterable forwardChildrenIterator(PsiElement enclosingElement) {\n        return new PsiElementChildrenIterable(enclosingElement, false);\n    }\n    \n    public static PsiElementChildrenIterable backwardChildrenIterator(PsiElement enclosingElement) {\n        return new PsiElementChildrenIterable(enclosingElement, true);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinBlockSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport org.jetbrains.kotlin.psi.KtWhenExpression\nimport org.jetbrains.kotlin.psi.KtBlockExpression\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.openapi.util.TextRange\n\npublic class KotlinBlockSelectionHandler: KotlinDefaultSelectionHandler() {\n\toverride fun canSelect(enclosingElement: PsiElement)\n\t\t= enclosingElement is KtBlockExpression || enclosingElement is KtWhenExpression\n\n\toverride fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange): TextRange {\n\t\tval elementStart = findBlockContentStart(enclosingElement);\n\t\tval elementEnd = findBlockContentEnd(enclosingElement)\n\t\tif (elementStart >= elementEnd) {\n\t\t\treturn enclosingElement.getTextRange()\n\t\t}\n\t\tval resultRange = TextRange(elementStart, elementEnd)\n\t\tif (resultRange == selectedRange || selectedRange !in resultRange) {\n\t\t\treturn enclosingElement.getTextRange()\n\t\t}\n\t\treturn resultRange;\n\t}\n\n\toverride fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n\t\tif (selectionCandidate.getNode().getElementType() == KtTokens.LBRACE) {\n\t\t\treturn selectEnclosing(enclosingElement, selectedRange)\n\t\t}\n\t\treturn selectionWithElementAppendedToBeginning(selectedRange, selectionCandidate)\n\t}\n\n\toverride fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n\t\tif (selectionCandidate.getNode().getElementType() == KtTokens.RBRACE) {\n\t\t\treturn selectEnclosing(enclosingElement, selectedRange)\n\t\t}\n\t\treturn selectionWithElementAppendedToEnd(selectedRange, selectionCandidate)\n\t}\n\n\tprivate fun findBlockContentStart(block: PsiElement): Int {\n\t    val element = block.allChildren\n        .dropWhile { it.getNode().getElementType() != KtTokens.LBRACE }\n        .drop(1)\n        .dropWhile { it is PsiWhiteSpace }\n        .firstOrNull() ?: block\n\t\treturn element.getTextRange().getStartOffset()\n\t}\n\n\tprivate fun findBlockContentEnd(block: PsiElement): Int {\n\t    val element = block.allChildren\n            .toList()\n            .reversed()\n            .asSequence()\n            .dropWhile { it.getNode().getElementType() != KtTokens.RBRACE }\n            .drop(1)\n            .dropWhile { it is PsiWhiteSpace }\n            .firstOrNull() ?: block\n\t\treturn element.getTextRange().getEndOffset()\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinDeclarationSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.openapi.util.TextRange\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport com.intellij.psi.PsiComment\nimport com.intellij.psi.PsiWhiteSpace\n\npublic class KotlinDeclarationSelectionHandler: KotlinDefaultSelectionHandler() {\n    override fun canSelect(enclosingElement: PsiElement)\n    = enclosingElement is KtDeclaration\n\n    override fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n        val bodyRange = getBodyRange(enclosingElement)\n        if (selectionCandidate.getTextRange() in bodyRange) {\n            return selectEnclosing(enclosingElement, selectedRange)\n        }\n        if (selectionCandidate is PsiComment) {\n            return selectionWithElementAppendedToEnd(selectedRange, selectionCandidate)\n        }\n        return enclosingElement.getTextRange()\n    }\n\n    override fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n        val bodyRange = getBodyRange(enclosingElement)\n        if (selectionCandidate.getTextRange() in bodyRange) {\n            return selectEnclosing(enclosingElement, selectedRange)\n        }\n        if (selectionCandidate is PsiComment) {\n            return selectionWithElementAppendedToBeginning(selectedRange, selectionCandidate)\n        }\n        return enclosingElement.getTextRange()\n    }\n\n    override fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange): TextRange {\n        val bodyRange = getBodyRange(enclosingElement)\n        if (selectedRange !in bodyRange || bodyRange == selectedRange) {\n            return enclosingElement.getTextRange()\n        }\n        return bodyRange;\n    }\n\n    private fun getBodyRange(enclosingElement: PsiElement): TextRange {\n\n        val firstNonCommentChild = enclosingElement.allChildren\n            .firstOrNull { it !is PsiWhiteSpace && it !is PsiComment }\n            ?: enclosingElement.getFirstChild()\n\n        var lastNonCommentChild = enclosingElement.allChildren\n            .toList()\n            .reversed()\n            .asSequence()\n            .firstOrNull { it !is PsiWhiteSpace && it !is PsiComment }\n            ?: enclosingElement.getLastChild()\n\n        return TextRange(firstNonCommentChild.startOffset, lastNonCommentChild.endOffset)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinDefaultSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\n\npublic open class KotlinDefaultSelectionHandler:KotlinElementSelectionHandler {\n    \n    override fun canSelect(enclosingElement:PsiElement)\n        = true\n\n    override fun selectEnclosing(enclosingElement:PsiElement, selectedRange:TextRange)\n        = enclosingElement.getTextRange()\n\n    override fun selectPrevious(enclosingElement:PsiElement, selectionCandidate:PsiElement, selectedRange:TextRange)\n        = selectionWithElementAppendedToBeginning(selectedRange, selectionCandidate)\n\n    override fun selectNext(enclosingElement:PsiElement, selectionCandidate:PsiElement, selectedRange:TextRange)\n        = selectionWithElementAppendedToEnd(selectedRange, selectionCandidate)\n\n     protected fun selectionWithElementAppendedToEnd(selection: TextRange, element: PsiElement):TextRange\n     \t= TextRange(selection.getStartOffset(), element.endOffset)\n    \n    protected fun selectionWithElementAppendedToBeginning(selection: TextRange, element: PsiElement):TextRange\n     \t= TextRange(element.startOffset, selection.getEndOffset())\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinDocSectionSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport org.jetbrains.kotlin.kdoc.psi.impl.KDocSection\nimport com.intellij.psi.PsiElement\nimport com.intellij.openapi.util.TextRange\n\npublic class KotlinDocSectionSelectionHandler: KotlinElementSelectionHandler {\n\toverride fun canSelect(enclosingElement: PsiElement)\n\t\t= enclosingElement is KDocSection\n\n\toverride fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange)\n\t\t= KotlinElementSelectioner.selectEnclosing(enclosingElement.getParent(), selectedRange)\n\n\toverride fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange)\n\t\t= selectEnclosing(enclosingElement, selectedRange)\n\n\toverride fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange)\n\t\t= selectEnclosing(enclosingElement, selectedRange)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinElementSelectionHandler.java",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers;\n\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiElement;\n\npublic interface KotlinElementSelectionHandler {\n    public boolean canSelect(PsiElement enclosingElement);\n    \n    public TextRange selectEnclosing(PsiElement enclosingElement, TextRange selectedRange);\n    \n    public TextRange selectPrevious(PsiElement enclosingElement, PsiElement selectionCandidate, TextRange selectedRange);\n    \n    public TextRange selectNext(PsiElement enclosingElement, PsiElement selectionCandidate, TextRange selectedRange);    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinElementSelectioner.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport java.util.ArrayList\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.PsiElement\n\npublic object KotlinElementSelectioner {\n    private val selectionHandlers = listOf(\n        KotlinListSelectionHandler(),\n        KotlinBlockSelectionHandler(),\n        KotlinWhiteSpaceSelectionHandler(),\n        KotlinDocSectionSelectionHandler(),\n        KotlinDeclarationSelectionHandler(),\n        KotlinStringTemplateSelectionHandler(),\n        KotlinNonTraversableSelectionHanlder()//must be last\n        )\n\n    private val defaultHandler = KotlinDefaultSelectionHandler()\n\n    public fun selectEnclosing(enclosingElement:PsiElement, selectedRange:TextRange):TextRange\n    \t= findHandler(enclosingElement).selectEnclosing(enclosingElement, selectedRange)\n\n    public fun selectNext(enclosingElement:PsiElement, selectionCandidate:PsiElement, selectedRange:TextRange):TextRange\n    \t= findHandler(enclosingElement).selectNext(enclosingElement, selectionCandidate, selectedRange)\n\n    public fun selectPrevious(enclosingElement:PsiElement, selectionCandidate:PsiElement, selectedRange:TextRange):TextRange\n    \t= findHandler(enclosingElement).selectPrevious(enclosingElement, selectionCandidate, selectedRange)\n\n    private fun findHandler(enclosingElement:PsiElement)\n\t    = selectionHandlers.firstOrNull {\n\t        it.canSelect(enclosingElement)\n\t    }\n\t    ?: defaultHandler\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinListSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.psi.KtParameterList\nimport org.jetbrains.kotlin.psi.KtValueArgumentList\nimport org.jetbrains.kotlin.psi.KtTypeParameterList\nimport org.jetbrains.kotlin.psi.KtTypeArgumentList\nimport com.intellij.openapi.util.TextRange\nimport org.jetbrains.kotlin.psi.KtValueArgument\nimport org.jetbrains.kotlin.psi.KtParameter\nimport org.jetbrains.kotlin.psi.KtTypeParameter\nimport org.jetbrains.kotlin.psi.KtTypeProjection\n\npublic class KotlinListSelectionHandler: KotlinDefaultSelectionHandler() {\n    override fun canSelect(enclosingElement: PsiElement) =\n\t    enclosingElement is KtParameterList ||\n\t    enclosingElement is KtValueArgumentList ||\n\t    enclosingElement is KtTypeParameterList ||\n\t    enclosingElement is KtTypeArgumentList\n\n    override fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange): TextRange {\n        val elementRange = enclosingElement.getTextRange();\n        //delete parentheses\n        val resultRange = TextRange(elementRange.getStartOffset() + 1, elementRange.getEndOffset()-1)\n        if (resultRange == selectedRange || selectedRange !in resultRange) {\n            return KotlinElementSelectioner.selectEnclosing(enclosingElement.getParent(), selectedRange)\n        }\n        return resultRange\n    }\n\n    private fun isElementOfListPartType(element: PsiElement): Boolean =\n\t    element is KtValueArgument || element is KtParameter ||\n\t    element is KtTypeParameter || element is KtTypeProjection\n\n    override fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n        var elementToSelect = selectionCandidate.siblings(forward = false, withItself = true)\n            .firstOrNull { isElementOfListPartType(it) }\n        if (elementToSelect == null) {\n            return selectEnclosing(enclosingElement, selectedRange)\n        }\n        return selectionWithElementAppendedToBeginning(selectedRange, elementToSelect)\n    }\n\n    override fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n        var elementToSelect = selectionCandidate.siblings(forward = true, withItself = true)\n            .firstOrNull { isElementOfListPartType(it) }\n        if (elementToSelect == null) {\n            return selectEnclosing(enclosingElement, selectedRange)\n        }\n        return selectionWithElementAppendedToEnd(selectedRange, elementToSelect)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinNonTraversableSelectionHanlder.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.openapi.util.TextRange\nimport org.jetbrains.kotlin.kdoc.psi.api.KDoc\nimport org.jetbrains.kotlin.psi.KtExpression\n\npublic class KotlinNonTraversableSelectionHanlder: KotlinDefaultSelectionHandler() {\n\toverride fun canSelect(enclosingElement: PsiElement) = \n\t\t\tenclosingElement is KDoc ||\n\t\t\tenclosingElement is KtExpression //must be the last before default \n\t\n\toverride fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange) = \n\t\tselectEnclosing(enclosingElement, selectedRange)\n\t\n\toverride fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange) = \n\t\tselectEnclosing(enclosingElement, selectedRange)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinStringTemplateSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport org.jetbrains.kotlin.psi.KtStringTemplateExpression\nimport com.intellij.psi.PsiElement\nimport com.intellij.openapi.util.TextRange\n\npublic class KotlinStringTemplateSelectionHandler: KotlinDefaultSelectionHandler() {\n\toverride fun canSelect(enclosingElement: PsiElement)\n\t\t= enclosingElement is KtStringTemplateExpression\n\t\n\toverride fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange): TextRange {\n\t\tval literalRange = super.selectEnclosing(enclosingElement, selectedRange)\n\t\tval resultRange = TextRange(literalRange.getStartOffset()+1, literalRange.getEndOffset()-1)\n\t\tif (!resultRange.contains(selectedRange) || resultRange.equals(selectedRange)) {\n\t\t\treturn literalRange\n\t\t}\n\t\t//drop quotes\n\t\treturn TextRange(literalRange.getStartOffset()+1, literalRange.getEndOffset()-1)\n\t}\n\t\n\toverride fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange): TextRange {\n\t\tif (selectionCandidate.getNextSibling() == null) {// is quote sign\n\t\t\treturn enclosingElement.getTextRange()\n\t\t}\n\t\treturn selectionWithElementAppendedToEnd(selectedRange, selectionCandidate)\n\t}\n\t\n\toverride fun selectPrevious(enclosingElement: PsiElement, selectionCandidate:PsiElement, selectedRange: TextRange): TextRange {\n\t\tif (selectionCandidate.getPrevSibling() == null) {// is quote sign\n\t\t\treturn enclosingElement.getTextRange()\n\t\t}\n\t\treturn selectionWithElementAppendedToBeginning(selectedRange, selectionCandidate)\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/KotlinWhiteSpaceSelectionHandler.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.openapi.util.TextRange\n\npublic class KotlinWhiteSpaceSelectionHandler: KotlinElementSelectionHandler {\n\n\toverride fun canSelect(enclosingElement: PsiElement)\n\t\t= enclosingElement is PsiWhiteSpace\n\n\toverride fun selectEnclosing(enclosingElement: PsiElement, selectedRange: TextRange)\n\t\t= KotlinElementSelectioner.selectEnclosing(enclosingElement.getParent(), selectedRange)\n\n\toverride fun selectNext(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange)\n\t\t= selectEnclosing(enclosingElement, selectedRange)\n\n\toverride fun selectPrevious(enclosingElement: PsiElement, selectionCandidate: PsiElement, selectedRange: TextRange)\n\t\t= selectEnclosing(enclosingElement, selectedRange)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/selection/handlers/PsiUtils.kt",
    "content": "package org.jetbrains.kotlin.ui.editors.selection.handlers\n\nimport com.intellij.psi.PsiElement\nimport org.jetbrains.kotlin.psi.psiUtil.PsiChildRange\n\npublic val PsiElement.allChildren: PsiChildRange\n    get() {\n        val first = getFirstChild()\n        return if (first != null) PsiChildRange(first, getLastChild()) else PsiChildRange.EMPTY\n    }\npublic fun PsiElement.siblings(forward: Boolean = true, withItself: Boolean = true): Sequence<PsiElement> {\n    val stepFun = if (forward) { e: PsiElement -> e.getNextSibling() } else { e: PsiElement -> e.getPrevSibling() }\n    val sequence = generateSequence(this, stepFun)\n    return if (withItself) sequence else sequence.drop(1)\n}\npublic val PsiElement.startOffset: Int\n    get() = getTextRange().getStartOffset()\n\npublic val PsiElement.endOffset: Int\n    get() = getTextRange().getEndOffset()"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/templates/KotlinApplicableTemplateContext.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.templates;\n\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.eclipse.jface.text.ITextViewer;\nimport org.eclipse.jface.text.templates.Template;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.psi.KtFile;\n\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFile;\n\npublic class KotlinApplicableTemplateContext {\n    \n    @NotNull\n    public static List<Template> getTemplatesByContextTypeIds(List<String> contextTypeIds) {\n        List<Template> possibleTeplates = new ArrayList<Template>(); \n        for (String contextTypeId : contextTypeIds) {\n            Template[] templates = KotlinTemplateManager.INSTANCE.getTemplateStore().getTemplates(contextTypeId);\n            for (Template template : templates) {\n                possibleTeplates.add(template);\n            }\n        }\n        \n        return possibleTeplates;\n    }\n    \n    @NotNull\n    public static List<String> getApplicableContextTypeIds(@NotNull ITextViewer viewer, @NotNull PsiFile psiFile, int offset) {\n        int offsetWithoutCr = LineEndUtil.convertCrToDocumentOffset(viewer.getDocument(), offset);\n        \n        List<String> contextTypeIds = new ArrayList<String>();\n        for (String contextTypeId : getAllContextTypeIds()) {\n            PsiElement psiElement = psiFile.findElementAt(offsetWithoutCr - 1);\n            if (isContextApplicableAt(psiElement, contextTypeId)) {\n                contextTypeIds.add(contextTypeId);\n            }\n        }\n        \n        return contextTypeIds;\n    }\n    \n    private static boolean isContextApplicableAt(@Nullable PsiElement psiElement, @NotNull String contextType) {\n        if (psiElement == null) {\n            if (KotlinTemplateContextType.KOTLIN_ID_TOP_LEVEL_DECLARATIONS.equals(contextType)) {\n                return true;\n            }\n        } else {\n            psiElement = psiElement.getParent();\n            if (psiElement instanceof KtFile) {\n                if (KotlinTemplateContextType.KOTLIN_ID_TOP_LEVEL_DECLARATIONS.equals(contextType)) {\n                    return true;\n                }\n            }\n        }\n        \n        return false;\n    }\n    \n    @NotNull\n    private static Set<String> getAllContextTypeIds() {\n        Set<String> contextTypeIds = new HashSet<String>();\n        \n        Template[] templates = KotlinTemplateManager.INSTANCE.getTemplateStore().getTemplates();\n        for (Template template : templates) {\n            String contextTypeId = template.getContextTypeId();\n            if (!contextTypeIds.contains(contextTypeId)) {\n                contextTypeIds.add(contextTypeId);\n            }\n        }\n        \n        return contextTypeIds;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/templates/KotlinDocumentTemplateContext.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.templates;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.jface.text.templates.DocumentTemplateContext;\nimport org.eclipse.jface.text.templates.Template;\nimport org.eclipse.jface.text.templates.TemplateBuffer;\nimport org.eclipse.jface.text.templates.TemplateContextType;\nimport org.eclipse.jface.text.templates.TemplateException;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\npublic class KotlinDocumentTemplateContext extends DocumentTemplateContext {\n\n    private final KotlinEditor editor; \n    \n    public KotlinDocumentTemplateContext(TemplateContextType type, KotlinEditor editor, int offset, int length) {\n        super(type, editor.getDocument(), offset, length);\n        this.editor = editor;\n    }\n    \n    @Override\n    public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {\n        TemplateBuffer templateBuffer = super.evaluate(template);\n        \n        KotlinTemplateFormatter templateFormatter = new KotlinTemplateFormatter();\n        \n        IFile file = editor.getEclipseFile();\n\n        assert file != null : \"Failed to retrieve IFile from editor \" + editor;\n\n        String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getDocument());\n        templateFormatter.format(templateBuffer, lineDelimiter, file.getProject());\n        \n        return templateBuffer;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/templates/KotlinTemplateContextType.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.templates;\n\nimport org.eclipse.jface.text.templates.GlobalTemplateVariables;\nimport org.eclipse.jface.text.templates.TemplateContextType;\n\npublic class KotlinTemplateContextType extends TemplateContextType {\n    \n    public static final String CONTEXT_TYPE_REGISTRY = \"org.jetbrains.kotlin.ui.editors.KotlinFileEditor\";\n    public static final String KOTLIN_ID_TOP_LEVEL_DECLARATIONS = \"kotlin-top-level-declarations\";\n\n    public KotlinTemplateContextType() {\n        addResolver(new GlobalTemplateVariables.Cursor());\n        addResolver(new GlobalTemplateVariables.WordSelection());\n        addResolver(new GlobalTemplateVariables.Dollar());\n        addResolver(new GlobalTemplateVariables.Date());\n        addResolver(new GlobalTemplateVariables.Year());\n        addResolver(new GlobalTemplateVariables.Time());\n        addResolver(new GlobalTemplateVariables.User());\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/templates/KotlinTemplateFormatter.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.templates;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.SortedMap;\nimport java.util.TreeMap;\n\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.jface.text.templates.TemplateBuffer;\nimport org.eclipse.jface.text.templates.TemplateVariable;\nimport org.jetbrains.kotlin.core.formatting.KotlinCodeStyleManagerKt;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtPsiFactory;\nimport org.jetbrains.kotlin.psi.KtPsiFactoryKt;\nimport org.jetbrains.kotlin.ui.formatter.KotlinFormatterKt;\n\nimport com.intellij.openapi.project.Project;\n\npublic class KotlinTemplateFormatter {\n    \n    // Source code has been taken from EcliHX plugin\n    // eclihx.ui.internal.ui.editors.templates.TemplateFormatter\n    private static class VariableOffsetsTracker {\n\n        private static final int MARKER_SIZE = 6;\n        private static final String MARKER_PREFIX = \"##__\";\n        private static final String MARKER_FORMAT_STRING = \"##__%02d\";\n\n        static {\n            assert MARKER_FORMAT_STRING.startsWith(MARKER_PREFIX);\n            assert String.format(MARKER_FORMAT_STRING, 0).length() == MARKER_SIZE;\n        }\n\n        private final String markedString;\n\n        // Marker id to variable\n        private final Map<Integer, TemplateVariable> variablesIds = new HashMap<Integer, TemplateVariable>();\n\n        private String unmarkedString;\n        private TemplateVariable[] updatedVariables;\n\n        public VariableOffsetsTracker(String text, TemplateVariable[] variables) {\n\n            // Collect variables offsets\n            SortedMap<Integer, TemplateVariable> initialOffsets = new TreeMap<Integer, TemplateVariable>();\n            for (TemplateVariable variable : variables) {\n                for (int offset : variable.getOffsets()) {\n                    initialOffsets.put(offset, variable);\n                }\n            }\n\n            int id = 0;\n            StringBuffer buffer = new StringBuffer(text);\n\n            for (Entry<Integer, TemplateVariable> pair : initialOffsets.entrySet()) {\n                int originalOffset = pair.getKey();\n                TemplateVariable templateVariable = pair.getValue();\n\n                int newOffset = originalOffset + id * MARKER_SIZE;\n\n                buffer.insert(newOffset, String.format(MARKER_FORMAT_STRING, id));\n                variablesIds.put(id, templateVariable);\n\n                id++;\n            }\n\n            markedString = buffer.toString();\n        }\n\n        public void unmark(String formattedString) {\n            StringBuffer unmarkedBuffer = new StringBuffer(formattedString);\n\n            int variableOffset = unmarkedBuffer.indexOf(MARKER_PREFIX);\n\n            // Collection on new offsets for each variable\n            final Map<TemplateVariable, ArrayList<Integer>> variablesOffsets = new HashMap<TemplateVariable, ArrayList<Integer>>();\n\n            // Remove markers and collect information about offsets.\n            while (variableOffset != -1) {\n                String idString = unmarkedBuffer.substring(variableOffset + MARKER_PREFIX.length(), variableOffset\n                        + MARKER_SIZE);\n                int id = Integer.parseInt(idString);\n\n                TemplateVariable variable = variablesIds.get(id);\n\n                if (!variablesOffsets.containsKey(variable)) {\n                    variablesOffsets.put(variable, new ArrayList<Integer>());\n                }\n\n                variablesOffsets.get(variable).add(variableOffset);\n\n                // Remove marker\n                unmarkedBuffer.replace(variableOffset, variableOffset + MARKER_SIZE, \"\");\n\n                // Update loop condition variable - move to next variable\n                variableOffset = unmarkedBuffer.indexOf(MARKER_PREFIX, variableOffset);\n            }\n\n            // Update variables\n            for (Entry<TemplateVariable, ArrayList<Integer>> variableToOffsets : variablesOffsets.entrySet()) {\n                TemplateVariable variable = variableToOffsets.getKey();\n                ArrayList<Integer> offsets = variableToOffsets.getValue();\n\n                variable.setOffsets(toIntArray(offsets));\n            }\n\n            // Store results\n            unmarkedString = unmarkedBuffer.toString();\n            updatedVariables = variablesOffsets.keySet().toArray(new TemplateVariable[variablesOffsets.keySet().size()]);\n        }\n\n        public String getMarkedString() {\n            return markedString;\n        }\n\n        public String getUnmarkedString() {\n            if (unmarkedString == null) {\n                throw new IllegalStateException(\"should be unmarked before\");\n            }\n\n            return unmarkedString;\n        }\n\n        public TemplateVariable[] getCorrectedVariables() {\n            if (updatedVariables == null) {\n                throw new IllegalStateException(\"should be unmarked before\");\n            }\n\n            return updatedVariables;\n        }\n\n        private static int[] toIntArray(List<Integer> list) {\n            int[] ret = new int[list.size()];\n            for (int i = 0; i < ret.length; i++)\n                ret[i] = list.get(i);\n            return ret;\n        }\n    }\n    \n    public void format(TemplateBuffer buffer, String lineDelimiter, IProject eclipseProject) { \n        VariableOffsetsTracker offsetsTracker = new VariableOffsetsTracker(buffer.getString(), buffer.getVariables());\n        Project ideaProject = KotlinEnvironment.Companion.getEnvironment(eclipseProject).getProject();\n        KtFile parsedFile = new KtPsiFactory(ideaProject).createFile(offsetsTracker.getMarkedString());\n\n        KtPsiFactory psiFactory = KtPsiFactoryKt.KtPsiFactory(parsedFile);\n        String formatted = KotlinFormatterKt.formatCode(parsedFile.getNode().getText(), parsedFile.getName(), \n                psiFactory, KotlinCodeStyleManagerKt.getCodeStyle(eclipseProject));\n        \n        offsetsTracker.unmark(formatted);\n        \n        buffer.setContent(offsetsTracker.getUnmarkedString(), offsetsTracker.getCorrectedVariables());\n    } \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/editors/templates/KotlinTemplateManager.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.editors.templates;\n\nimport java.io.IOException;\n\nimport org.eclipse.jface.text.templates.ContextTypeRegistry;\nimport org.eclipse.jface.text.templates.persistence.TemplateStore;\nimport org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;\nimport org.eclipse.ui.editors.text.templates.ContributionTemplateStore;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.ui.Activator;\n\npublic class KotlinTemplateManager {\n    \n    public static final KotlinTemplateManager INSTANCE = new KotlinTemplateManager();\n    \n    private TemplateStore templateStore;\n    private ContributionContextTypeRegistry contextTypeRegistry;\n    \n    private final String TEMPLATES_KEY = \"org.jetbrains.kotlin.ui.templates.key\";\n    \n    private KotlinTemplateManager() {\n    }\n    \n    public ContextTypeRegistry getContextTypeRegistry() {\n        if (contextTypeRegistry == null) {\n            contextTypeRegistry = new ContributionContextTypeRegistry(KotlinTemplateContextType.CONTEXT_TYPE_REGISTRY);\n        }\n        \n        contextTypeRegistry.addContextType(KotlinTemplateContextType.KOTLIN_ID_TOP_LEVEL_DECLARATIONS);\n        \n        return contextTypeRegistry;\n    }\n    \n    public TemplateStore getTemplateStore() {\n        if (templateStore == null) {\n            templateStore = new ContributionTemplateStore(getContextTypeRegistry(), Activator.Companion.getDefault().getPreferenceStore(), TEMPLATES_KEY);\n            try {\n                templateStore.load();\n            } catch (IOException e) {\n                KotlinLogger.logAndThrow(e);\n            }\n        }\n        \n        return templateStore;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/AbstractBlock.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.formatter\n\nimport java.util.Collections\nimport com.intellij.formatting.ASTBlock\nimport com.intellij.formatting.Alignment\nimport com.intellij.formatting.Block\nimport com.intellij.formatting.ChildAttributes\nimport com.intellij.formatting.Indent\nimport com.intellij.formatting.Wrap\nimport com.intellij.lang.ASTNode\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.psi.TokenType\n\nprivate val EMPTY: List<Block> = emptyList()\n\nprivate fun isIncomplete(node: ASTNode?): Boolean {\n    var lastChild = if (node == null) null else node.getLastChildNode()\n    while (lastChild != null && lastChild.getElementType() == TokenType.WHITE_SPACE) {\n        lastChild = lastChild.getTreePrev()\n    }\n    \n    if (lastChild == null) return false\n    \n    if (lastChild.getElementType() === TokenType.ERROR_ELEMENT) return true\n    \n    return isIncomplete(lastChild)\n}\n\nabstract class AbstractBlock(\n        private val myNode: ASTNode,\n        private val myWrap: Wrap?,\n        private val myAlignment: Alignment?) : ASTBlock {\n    private var mySubBlocks: List<Block>? = null\n    private var myIncomplete: Boolean? = null\n    \n    protected abstract fun buildChildren(): List<Block>\n    \n    protected var isBuildIndentsOnly = false\n    \n    override fun getAlignment(): Alignment? = myAlignment\n    \n    override fun getNode(): ASTNode = myNode\n    \n    override fun getWrap(): Wrap? = myWrap\n    \n    override fun getTextRange(): TextRange = myNode.getTextRange()\n    \n    override fun getSubBlocks(): List<Block> {\n        if (mySubBlocks == null) {\n            mySubBlocks = buildChildren()\n        }\n        return mySubBlocks!!\n    }\n    \n    override fun getIndent(): Indent? = null\n    \n    override fun getChildAttributes(newChildIndex: Int): ChildAttributes {\n        return ChildAttributes(getChildIndent(), getFirstChildAlignment())\n    }\n    \n    private fun getFirstChildAlignment(): Alignment? {\n        return subBlocks.asSequence().mapNotNull { it.alignment }.firstOrNull()\n    }\n    \n    protected fun getChildIndent(): Indent? = null\n    \n    override fun isIncomplete(): Boolean {\n        if (myIncomplete == null) {\n            myIncomplete = isIncomplete(node)\n        }\n        return myIncomplete!!\n    }\n    \n    override fun toString(): String = \"${node.text} $textRange\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/AlignmentStrategy.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.formatter;\n\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport org.jetbrains.kotlin.psi.KtClass;\nimport org.jetbrains.kotlin.psi.KtClassInitializer;\nimport org.jetbrains.kotlin.psi.KtFunction;\nimport org.jetbrains.kotlin.psi.KtPropertyAccessor;\n\nimport com.intellij.lang.ASTNode;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.tree.IElementType;\n\npublic class AlignmentStrategy {\n    \n    private static final Set<String> BLOCK_ELEMENT_TYPES = new HashSet<String>(Arrays.asList(\n            \"IF\", \"FOR\", \"WHILE\", \"CLASS_BODY\", \"FUNCTION_LITERAL_EXPRESSION\", \n            \"WHEN\", \"WHEN_ENTRY\", \"DO_WHILE\", \"PROPERTY_ACCESSOR\"));\n    \n    public AlignmentStrategy(ASTNode parsedFile, int lineIndentation, String lineDelimiter) {\n    }\n    \n    public static int computeIndent(ASTNode node) {\n        int indent = 0;\n        while(node != null) {\n            indent = AlignmentStrategy.updateIndent(node, indent);\n            node = node.getTreeParent();\n        }\n        \n        return indent;\n    }\n    \n    public static int updateIndent(ASTNode node, int indent) {\n        return isBlockElement(node) ? indent + 1 : indent;\n    }\n    \n    public static boolean isBlockElement(ASTNode node) {\n        IElementType elementType = node.getElementType();\n        if (\"BLOCK\".equals(elementType.toString())) {\n            PsiElement parent = node.getPsi().getParent();\n            if (parent instanceof KtFunction || parent instanceof KtClass || parent instanceof KtClassInitializer \n                    || parent instanceof KtPropertyAccessor) {\n                return true;\n            } \n        } else if (BLOCK_ELEMENT_TYPES.contains(elementType.toString())) {\n            return true;\n        }\n        \n        return false;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/AlignmentStrategy.kt",
    "content": "package org.jetbrains.kotlin.ui.formatter\n\nimport com.intellij.psi.tree.IElementType\nimport com.intellij.formatting.Alignment\nimport java.util.HashMap\n\nabstract class KotlinAlignmentStrategy {\n    companion object {\n        val nullStrategy = wrap(null)\n        \n        fun wrap(alignment: Alignment?, vararg filterTypes: IElementType): KotlinAlignmentStrategy {\n            return SharedAlignmentStrategy(alignment, true, *filterTypes)\n        }\n        \n        fun wrap(alignment: Alignment, ignoreFilterTypes: Boolean, vararg filterTypes: IElementType): KotlinAlignmentStrategy {\n            return SharedAlignmentStrategy(alignment, ignoreFilterTypes, *filterTypes)\n        }\n        \n        fun createAlignmentPerTypeStrategy(targetTypes:Collection<IElementType>, allowBackwardShift: Boolean): AlignmentPerTypeStrategy {\n            return AlignmentPerTypeStrategy(targetTypes, null, allowBackwardShift, Alignment.Anchor.LEFT)\n        }\n        \n        fun createAlignmentPerTypeStrategy(\n                targetTypes: Collection<IElementType>, \n                parentType: IElementType?, \n                allowBackwardShift: Boolean,\n                anchor:Alignment.Anchor = Alignment.Anchor.LEFT): AlignmentPerTypeStrategy {\n            return AlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, anchor)\n        }\n    }\n    \n    fun getAlignment(childType: IElementType?): Alignment? = getAlignment(null, childType)\n    \n    abstract fun getAlignment(parentType: IElementType?, childType: IElementType?): Alignment?\n    \n    private class SharedAlignmentStrategy(\n            val myAlignment: Alignment?,\n            val myIgnoreFilterTypes: Boolean, \n            vararg disabledElementTypes: IElementType) : KotlinAlignmentStrategy() {\n        \n        private val myFilterElementTypes = disabledElementTypes.toSet()\n        \n        override fun getAlignment(parentType: IElementType?, childType: IElementType?): Alignment? {\n            return if (myFilterElementTypes.contains(childType) xor myIgnoreFilterTypes) myAlignment else null\n        }\n    }\n    \n    class AlignmentPerTypeStrategy(\n            targetElementTypes: Collection<IElementType>,\n            private val myParentType: IElementType?,\n            private val myAllowBackwardShift: Boolean,\n            anchor: Alignment.Anchor) : KotlinAlignmentStrategy() {\n        \n        private val myAlignments = HashMap<IElementType, Alignment>()\n        init {\n            for (elementType in targetElementTypes) {\n                myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift, anchor))\n            }\n        }\n        \n        override fun getAlignment(parentType: IElementType?, childType: IElementType?): Alignment? {\n            if (myParentType != null && parentType != null && myParentType !== parentType) {\n                return null\n            }\n            \n            return myAlignments[childType]\n        }\n        \n        fun renewAlignment(elementType: IElementType) {\n            myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift))\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/EclipseDocumentFormattingModel.java",
    "content": "package org.jetbrains.kotlin.ui.formatter;\n\nimport com.intellij.formatting.Block;\nimport com.intellij.formatting.FormattingDocumentModel;\nimport com.intellij.formatting.FormattingModelEx;\nimport com.intellij.lang.ASTNode;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.openapi.util.text.StringUtil;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport com.intellij.psi.codeStyle.CommonCodeStyleSettings;\nimport com.intellij.psi.impl.source.SourceTreeToPsiMap;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.NullProgressMonitor;\nimport org.eclipse.jdt.internal.corext.refactoring.changes.TextChangeCompatibility;\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.ltk.core.refactoring.DocumentChange;\nimport org.eclipse.text.edits.ReplaceEdit;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class EclipseDocumentFormattingModel implements FormattingModelEx {\n    \n    private final Project myProject;\n    private final ASTNode myASTNode;\n    private final EclipseFormattingModel myDocumentModel;\n    @NotNull\n    private final Block myRootBlock;\n    protected boolean myCanModifyAllWhiteSpaces = false;\n    private final IDocument document;\n    private final List<ReplaceEdit> edits = new ArrayList<>();\n    private final CodeStyleSettings settings;\n    \n    public EclipseDocumentFormattingModel(final PsiFile file, @NotNull final Block rootBlock,\n            final EclipseFormattingModel documentModel, @NotNull final IDocument document,\n            @NotNull CodeStyleSettings settings) {\n        myASTNode = SourceTreeToPsiMap.psiElementToTree(file);\n        myDocumentModel = documentModel;\n        myRootBlock = rootBlock;\n        myProject = file.getProject();\n        this.document = document;\n        this.settings = settings;\n    }\n    \n    @Override\n    @NotNull\n    public Block getRootBlock() {\n        return myRootBlock;\n    }\n    \n    @Override\n    @NotNull\n    public FormattingDocumentModel getDocumentModel() {\n        return myDocumentModel;\n    }\n    \n    @Override\n    public TextRange replaceWhiteSpace(TextRange textRange, String whiteSpace) {\n        return replaceWhiteSpace(textRange, null, whiteSpace);\n    }\n    \n    @Override\n    public TextRange replaceWhiteSpace(TextRange textRange, @Nullable ASTNode nodeAfter, String whiteSpace) {\n        CharSequence whiteSpaceToUse = getDocumentModel().adjustWhiteSpaceIfNecessary(whiteSpace,\n                textRange.getStartOffset(), textRange.getEndOffset(), nodeAfter, false);\n        \n        replace(textRange, whiteSpaceToUse.toString());\n        return textRange;\n    }\n    \n    @Override\n    public TextRange shiftIndentInsideRange(ASTNode node, TextRange range, int indent) {\n        try {\n            shiftIndentInside(range, indent);\n            return range;\n        } catch (BadLocationException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    @Override\n    public void commitChanges() {\n        DocumentChange documentChange = new DocumentChange(\"Format code\", document);\n        for (ReplaceEdit edit : edits) {\n            TextChangeCompatibility.addTextEdit(documentChange, \"Kotlin change\", edit);\n        }\n        \n        try {\n            documentChange.perform(new NullProgressMonitor());\n        } catch (CoreException e) {\n            KotlinLogger.logError(e);\n        }\n    }\n    \n    private int shiftIndentInside(final TextRange elementRange, final int shift) throws BadLocationException {\n        final StringBuilder buffer = new StringBuilder();\n        StringBuilder afterWhiteSpace = new StringBuilder();\n        int whiteSpaceLength = 0;\n        boolean insideWhiteSpace = true;\n        int line = 0;\n        for (int i = elementRange.getStartOffset(); i < elementRange.getEndOffset(); i++) {\n            final char c = document.getChar(i);\n            switch (c) {\n            case '\\n':\n                if (line > 0) {\n                    createWhiteSpace(whiteSpaceLength + shift, buffer);\n                }\n                buffer.append(afterWhiteSpace.toString());\n                insideWhiteSpace = true;\n                whiteSpaceLength = 0;\n                afterWhiteSpace = new StringBuilder();\n                buffer.append(c);\n                line++;\n                break;\n            case ' ':\n                if (insideWhiteSpace) {\n                    whiteSpaceLength += 1;\n                } else {\n                    afterWhiteSpace.append(c);\n                }\n                break;\n            case '\\t':\n                if (insideWhiteSpace) {\n                    whiteSpaceLength += getIndentOptions().TAB_SIZE;\n                } else {\n                    afterWhiteSpace.append(c);\n                }\n                \n                break;\n            default:\n                insideWhiteSpace = false;\n                afterWhiteSpace.append(c);\n            }\n        }\n        if (line > 0) {\n            createWhiteSpace(whiteSpaceLength + shift, buffer);\n        }\n        buffer.append(afterWhiteSpace.toString());\n        \n        replace(elementRange, buffer.toString());\n        \n        return buffer.length();\n    }\n    \n    private void createWhiteSpace(final int whiteSpaceLength, StringBuilder buffer) {\n        if (whiteSpaceLength < 0)\n            return;\n        \n        // TODO: create whitespace with tabs if needed\n        StringUtil.repeatSymbol(buffer, ' ', whiteSpaceLength);\n    }\n    \n    private CommonCodeStyleSettings.IndentOptions getIndentOptions() {\n        return settings.getIndentOptions();\n    }\n    \n    public Project getProject() {\n        return myProject;\n    }\n    \n    @Nullable\n    public static String mergeWsWithCdataMarker(String whiteSpace, final String s, final int cdataPos) {\n        final int firstCrInGeneratedWs = whiteSpace.indexOf('\\n');\n        final int secondCrInGeneratedWs = firstCrInGeneratedWs != -1\n                ? whiteSpace.indexOf('\\n', firstCrInGeneratedWs + 1) : -1;\n        final int firstCrInPreviousWs = s.indexOf('\\n');\n        final int secondCrInPreviousWs = firstCrInPreviousWs != -1 ? s.indexOf('\\n', firstCrInPreviousWs + 1) : -1;\n        \n        boolean knowHowToModifyCData = false;\n        \n        if (secondCrInPreviousWs != -1 && secondCrInGeneratedWs != -1 && cdataPos > firstCrInPreviousWs\n                && cdataPos < secondCrInPreviousWs) {\n            whiteSpace = whiteSpace.substring(0, secondCrInGeneratedWs)\n                    + s.substring(firstCrInPreviousWs + 1, secondCrInPreviousWs)\n                    + whiteSpace.substring(secondCrInGeneratedWs);\n            knowHowToModifyCData = true;\n        }\n        if (!knowHowToModifyCData)\n            whiteSpace = null;\n        return whiteSpace;\n    }\n    \n    private void replace(TextRange range, String whiteSpace) {\n        String convertedWhiteSpace = StringUtil.convertLineSeparators(whiteSpace, TextUtilities.getDefaultLineDelimiter(document));\n        int startOffset = convertOffset(range.getStartOffset());\n        int endOffset = convertOffset(range.getEndOffset());\n        ReplaceEdit edit = new ReplaceEdit(startOffset, endOffset - startOffset, convertedWhiteSpace);\n        edits.add(edit);\n    }\n    \n    private int convertOffset(int offset) {\n        return LineEndUtil.convertLfOffsetForMixedDocument(document, offset);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/EclipseFormattingModel.java",
    "content": "package org.jetbrains.kotlin.ui.formatter;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport com.intellij.formatting.FormattingDocumentModel;\nimport com.intellij.lang.ASTNode;\nimport com.intellij.lang.Language;\nimport com.intellij.openapi.diagnostic.Logger;\nimport com.intellij.openapi.editor.Document;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.psi.PsiDocumentManager;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.psi.codeStyle.CodeStyleSettings;\nimport com.intellij.psi.formatter.WhiteSpaceFormattingStrategy;\nimport com.intellij.psi.formatter.WhiteSpaceFormattingStrategyFactory;\n\npublic class EclipseFormattingModel implements FormattingDocumentModel {\n    \n    private final WhiteSpaceFormattingStrategy myWhiteSpaceStrategy;\n    // private final CharBuffer myBuffer = CharBuffer.allocate(1);\n    @NotNull\n    private final Document myDocument;\n    private final PsiFile myFile;\n    \n    private static final Logger LOG = Logger.getInstance(\"#com.intellij.psi.formatter.FormattingDocumentModelImpl\");\n    private final CodeStyleSettings mySettings;\n    \n    private final int maxDepthToCheck = 10;\n    private final String applyChangeStateClassName = \"com.intellij.formatting.engine.ApplyChangesState\";\n    private final String prepareMethodName = \"prepare\";\n    \n    private final boolean forLineIndentation;\n    \n    public EclipseFormattingModel(\n            @NotNull final Document document, \n            PsiFile file, \n            CodeStyleSettings settings,\n            boolean forLineIndentation) {\n        myDocument = document;\n        myFile = file;\n        if (file != null) {\n            Language language = file.getLanguage();\n            myWhiteSpaceStrategy = WhiteSpaceFormattingStrategyFactory.getStrategy(language);\n        } else {\n            myWhiteSpaceStrategy = WhiteSpaceFormattingStrategyFactory.getStrategy();\n        }\n        mySettings = settings;\n        this.forLineIndentation = forLineIndentation;\n    }\n    \n    @Nullable\n    public static Document getDocumentToBeUsedFor(final PsiFile file) {\n        final Project project = file.getProject();\n        final Document document = PsiDocumentManager.getInstance(project).getDocument(file);\n        if (document == null)\n            return null;\n        if (PsiDocumentManager.getInstance(project).isUncommited(document))\n            return null;\n        \n        return document;\n    }\n    \n    @Override\n    public int getLineNumber(int offset) {\n        if (offset > myDocument.getTextLength()) {\n            LOG.error(String.format(\"Invalid offset detected (%d). Document length: %d. Target file: %s\", offset,\n                    myDocument.getTextLength(), myFile));\n        }\n        return myDocument.getLineNumber(offset);\n    }\n    \n    @Override\n    public int getLineStartOffset(int line) {\n        return myDocument.getLineStartOffset(line);\n    }\n    \n    @Override\n    public CharSequence getText(final TextRange textRange) {\n        if (textRange.getStartOffset() < 0 || textRange.getEndOffset() > myDocument.getTextLength()) {\n            LOG.error(String.format(\n                    \"Please submit a ticket to the tracker and attach current source file to it!%nInvalid processing detected: given text \"\n                            + \"range (%s) targets non-existing regions (the boundaries are [0; %d)). File's language: %s\",\n                    textRange, myDocument.getTextLength(), myFile.getLanguage()));\n        }\n        return myDocument.getCharsSequence().subSequence(textRange.getStartOffset(), textRange.getEndOffset());\n    }\n    \n    @Override\n    public int getTextLength() {\n        return myDocument.getTextLength();\n    }\n    \n    @NotNull\n    @Override\n    public Document getDocument() {\n        if (forLineIndentation) { // Optimization to avoid getStackTrace() calls\n            return myDocument;\n        }\n        \n        // In the compiler we have shrinked version of DocumentEx interface which doesn't have setInBulkUpdate method\n        // This workaround allows us to avoid place in FormatProcessor where setInBulkUpdate is called \n        int i = 0;\n        for (StackTraceElement element : Thread.currentThread().getStackTrace()) {\n            if (i > maxDepthToCheck) {\n                break;\n            }\n            \n            if (prepareMethodName.equals(element.getMethodName()) && applyChangeStateClassName.equals(element.getClassName())) {\n                return KotlinFormatterKt.getMockDocument(myDocument);\n            }\n            \n            i++;\n        }\n        return myDocument;\n    }\n    \n    public PsiFile getFile() {\n        return myFile;\n    }\n    \n    @Override\n    public boolean containsWhiteSpaceSymbolsOnly(int startOffset, int endOffset) {\n        WhiteSpaceFormattingStrategy strategy = myWhiteSpaceStrategy;\n        if (strategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset) {\n            return true;\n        }\n        return false;\n    }\n    \n    @NotNull\n    @Override\n    public CharSequence adjustWhiteSpaceIfNecessary(@NotNull CharSequence whiteSpaceText, int startOffset,\n            int endOffset, @Nullable ASTNode nodeAfter, boolean changedViaPsi) {\n        if (!changedViaPsi) {\n            return myWhiteSpaceStrategy.adjustWhiteSpaceIfNecessary(whiteSpaceText, myDocument.getCharsSequence(),\n                    startOffset, endOffset, mySettings, nodeAfter);\n        }\n        \n        final PsiElement element = myFile.findElementAt(startOffset);\n        if (element == null) {\n            return whiteSpaceText;\n        } else {\n            return myWhiteSpaceStrategy.adjustWhiteSpaceIfNecessary(whiteSpaceText, element, startOffset, endOffset,\n                    mySettings);\n        }\n    }\n    \n    // @Override\n    // public boolean isWhiteSpaceSymbol(char symbol) {\n    // myBuffer.put(0, symbol);\n    // return myWhiteSpaceStrategy.check(myBuffer, 0, 1) > 0;\n    // }\n    \n    public static boolean canUseDocumentModel(@NotNull Document document, @NotNull PsiFile file) {\n        PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());\n        return !psiDocumentManager.isUncommited(document) && !psiDocumentManager.isDocumentBlockedByPsi(document)\n                && file.getText().equals(document.getText());\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/KotlinBlock.kt",
    "content": "package org.jetbrains.kotlin.ui.formatter\n\nimport org.jetbrains.kotlin.idea.formatter.CommonAlignmentStrategy\nimport com.intellij.formatting.Indent\nimport com.intellij.formatting.Wrap\nimport com.intellij.psi.codeStyle.CodeStyleSettings\nimport org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilder\nimport com.intellij.lang.ASTNode\nimport com.intellij.formatting.Block\nimport com.intellij.formatting.Alignment\nimport com.intellij.formatting.Spacing\nimport org.jetbrains.kotlin.idea.formatter.KotlinCommonBlock\nimport com.intellij.formatting.ChildAttributes\nimport com.intellij.formatting.ASTBlock\nimport com.intellij.psi.tree.IElementType\nimport org.jetbrains.kotlin.lexer.KtTokens.ARROW\nimport org.jetbrains.kotlin.KtNodeTypes.WHEN_ENTRY\n\nclass KotlinBlock(\n        node: ASTNode,\n        private val myAlignmentStrategy: CommonAlignmentStrategy,\n        private val myIndent: Indent?,\n        wrap: Wrap?,\n        private val mySettings: CodeStyleSettings,\n        private val mySpacingBuilder: KotlinSpacingBuilder) : AbstractBlock(node, wrap, myAlignmentStrategy.getAlignment(node)) {\n            \n        private val kotlinDelegationBlock = object : KotlinCommonBlock(node, mySettings, mySpacingBuilder, myAlignmentStrategy) {\n            \n            override fun getNullAlignmentStrategy(): CommonAlignmentStrategy = NULL_ALIGNMENT_STRATEGY\n    \n            override fun createAlignmentStrategy(alignOption: Boolean, defaultAlignment: Alignment?): CommonAlignmentStrategy {\n                return NodeAlignmentStrategy.fromTypes(KotlinAlignmentStrategy.wrap(createAlignment(alignOption, defaultAlignment)))\n            }\n    \n            override fun getAlignmentForCaseBranch(shouldAlignInColumns: Boolean): CommonAlignmentStrategy {\n                return if (shouldAlignInColumns) {\n                    NodeAlignmentStrategy.fromTypes(\n                            KotlinAlignmentStrategy.createAlignmentPerTypeStrategy(listOf(ARROW as IElementType), WHEN_ENTRY, true))\n                }\n                else {\n                    NodeAlignmentStrategy.nullStrategy\n                }\n            }\n    \n            override fun getAlignment(): Alignment? = alignment\n    \n            override fun isIncompleteInSuper(): Boolean = isIncomplete\n    \n            override fun getSuperChildAttributes(newChildIndex: Int): ChildAttributes = super@KotlinBlock.getChildAttributes(newChildIndex)\n    \n            override fun getSubBlocks(): List<Block> = subBlocks\n\n            override fun createBlock(node: ASTNode, alignmentStrategy: CommonAlignmentStrategy, indent: Indent?, wrap: Wrap?, settings: CodeStyleSettings, spacingBuilder: KotlinSpacingBuilder, overrideChildren: Sequence<ASTNode>?): ASTBlock {\n                return KotlinBlock(\n                        node,\n                        alignmentStrategy,\n                        indent,\n                        wrap,\n                        mySettings,\n                        mySpacingBuilder)\n            }\n    \n            override fun createSyntheticSpacingNodeBlock(node: ASTNode): ASTBlock {\n                return object : AbstractBlock(node, null, null) {\n                    override fun isLeaf(): Boolean = false\n                    override fun getSpacing(child1: Block?, child2: Block): Spacing? = null\n                    override fun buildChildren(): List<Block> = emptyList()\n                }\n            }\n        }\n    \n    override fun getIndent(): Indent? = myIndent\n    \n    override fun buildChildren(): List<Block> = kotlinDelegationBlock.buildChildren()\n    \n    override fun getSpacing(child1: Block?, child2: Block): Spacing? = mySpacingBuilder.getSpacing(this, child1, child2)\n    \n    override fun getChildAttributes(newChildIndex: Int): ChildAttributes = kotlinDelegationBlock.getChildAttributes(newChildIndex)\n    \n    override fun isLeaf(): Boolean = kotlinDelegationBlock.isLeaf()\n}\n\nprivate fun createAlignment(alignOption: Boolean, defaultAlignment: Alignment?): Alignment? {\n    return if (alignOption) createAlignmentOrDefault(null, defaultAlignment) else defaultAlignment\n}\n\nprivate fun createAlignmentOrDefault(base: Alignment?, defaultAlignment: Alignment?): Alignment? {\n    return defaultAlignment ?: if (base == null) Alignment.createAlignment() else Alignment.createChildAlignment(base)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/NodeAlignmentStrategy.kt",
    "content": "package org.jetbrains.kotlin.ui.formatter\n\nimport org.jetbrains.kotlin.idea.formatter.CommonAlignmentStrategy\nimport com.intellij.formatting.Alignment\nimport com.intellij.lang.ASTNode\n\nabstract class NodeAlignmentStrategy : CommonAlignmentStrategy() {\n    companion object {\n        val nullStrategy = fromTypes(KotlinAlignmentStrategy.wrap(null))\n        \n        fun fromTypes(strategy: KotlinAlignmentStrategy): NodeAlignmentStrategy = AlignmentStrategyWrapper(strategy)\n    }\n    \n    private class AlignmentStrategyWrapper(val internalStrategy: KotlinAlignmentStrategy) : NodeAlignmentStrategy() {\n        override fun getAlignment(node: ASTNode): Alignment? {\n            val parent = node.getTreeParent()\n            if (parent != null) {\n                return internalStrategy.getAlignment(parent.getElementType(), node.getElementType())\n            }\n            \n            return internalStrategy.getAlignment(node.getElementType())\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/formatter/kotlinFormatter.kt",
    "content": "package org.jetbrains.kotlin.ui.formatter\n\nimport com.intellij.formatting.*\nimport com.intellij.lang.ASTNode\nimport com.intellij.openapi.editor.impl.DocumentImpl\nimport com.intellij.openapi.util.TextRange\nimport com.intellij.openapi.util.text.StringUtil\nimport com.intellij.psi.codeStyle.CodeStyleSettings\nimport com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptions\nimport com.intellij.psi.formatter.FormatterUtil\nimport com.intellij.util.text.CharArrayUtil\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jface.text.Document\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.core.model.getEnvironment\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilderUtil\nimport org.jetbrains.kotlin.idea.formatter.createSpacingBuilder\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.psi.KtPsiFactory\nimport com.intellij.openapi.editor.Document as IdeaDocument\n\nfun formatCode(\n\t\tsource: String,\n        fileName: String,\n        psiFactory: KtPsiFactory,\n        settings: CodeStyleSettings\n) = KotlinFormatter(source, fileName, psiFactory, settings).formatCode()\n\n\nfun reformatAll(\n        containingFile: KtFile,\n        rootBlock: Block,\n        settings: CodeStyleSettings,\n        document: IDocument\n) {\n\tformatRange(containingFile, rootBlock, settings, document, containingFile.textRange)\n}\n\nfun formatRange(\n        document: IDocument,\n        range: EclipseDocumentRange,\n        psiFactory: KtPsiFactory,\n        fileName: String,\n        settings: CodeStyleSettings\n) {\n\tformatRange(document, range.toPsiRange(document), psiFactory, fileName, settings)\n}\n\nfun formatRange(\n        document: IDocument,\n        range: TextRange,\n        psiFactory: KtPsiFactory,\n        fileName: String,\n        settings: CodeStyleSettings\n) {\n\tval ktFile = createKtFile(document.get(), psiFactory, fileName)\n\tval rootBlock = KotlinBlock(ktFile.node,\n\t\t\tNULL_ALIGNMENT_STRATEGY,\n\t\t\tIndent.getNoneIndent(),\n\t\t\tnull,\n\t\t\tsettings,\n\t\t\tcreateSpacingBuilder(settings, KotlinSpacingBuilderUtilImpl))\n\n\tformatRange(ktFile, rootBlock, settings, document, range)\n}\n\nprivate fun formatRange(\n\t\tcontainingFile: KtFile,\n\t\trootBlock: Block,\n\t\tsettings: CodeStyleSettings,\n\t\tdocument: IDocument,\n\t\trange: TextRange\n) {\n\tval formattingModel = buildModel(containingFile, rootBlock, settings, document, false)\n\n\tval ranges = FormatTextRanges(range, true)\n\tFormatterImpl().format(formattingModel, settings, settings.indentOptions, ranges)\n}\n\nfun adjustIndent(containingFile: KtFile, rootBlock: Block,\n\t\t\t\t settings: CodeStyleSettings, offset: Int, document: IDocument) {\n\tval formattingModel = buildModel(containingFile, rootBlock, settings, document, true)\n\tFormatterImpl().adjustLineIndent(\n\t\t\tformattingModel, settings, settings.indentOptions, offset, getSignificantRange(containingFile, offset))\n}\n\nfun getMockDocument(document: IdeaDocument): IdeaDocument {\n\treturn object : IdeaDocument by document {\n\t}\n}\n\nfun initializaSettings(options: IndentOptions) {\n\twith(options) {\n\t\tUSE_TAB_CHARACTER = !IndenterUtil.isSpacesForTabs()\n\t\tINDENT_SIZE = IndenterUtil.getDefaultIndent()\n\t\tTAB_SIZE = IndenterUtil.getDefaultIndent()\n\t}\n}\n\ndata class EclipseDocumentRange(val startOffset: Int, val endOffset: Int)\n\nprivate fun EclipseDocumentRange.toPsiRange(document: IDocument): TextRange {\n\tval startPsiOffset = LineEndUtil.convertCrToDocumentOffset(document, startOffset)\n\tval endPsiOffset = LineEndUtil.convertCrToDocumentOffset(document, endOffset)\n\treturn TextRange(startPsiOffset, endPsiOffset)\n}\n\nval NULL_ALIGNMENT_STRATEGY = NodeAlignmentStrategy.fromTypes(KotlinAlignmentStrategy.wrap(null))\n\nprivate fun buildModel(\n\t\tcontainingFile: KtFile,\n\t\trootBlock: Block,\n\t\tsettings: CodeStyleSettings,\n\t\tdocument: IDocument,\n\t\tforLineIndentation: Boolean): EclipseDocumentFormattingModel {\n\tinitializaSettings(settings.indentOptions!!)\n\tval formattingDocumentModel =\n\t\t\tEclipseFormattingModel(\n\t\t\t\t\tDocumentImpl(containingFile.viewProvider.contents, true),\n\t\t\t\t\tcontainingFile,\n\t\t\t\t\tsettings,\n\t\t\t\t\tforLineIndentation)\n\n\treturn EclipseDocumentFormattingModel(containingFile, rootBlock, formattingDocumentModel, document, settings)\n}\n\n\nprivate fun getSignificantRange(file: KtFile, offset: Int): TextRange {\n\tval elementAtOffset = file.findElementAt(offset)\n\tif (elementAtOffset == null) {\n\t\tval significantRangeStart = CharArrayUtil.shiftBackward(file.text, offset - 1, \"\\r\\t \")\n\t\treturn TextRange(Math.max(significantRangeStart, 0), offset)\n\t}\n\n\treturn elementAtOffset.textRange\n}\n\n\nprivate class KotlinFormatter(\n        source: String,\n        fileName: String,\n        psiFactory: KtPsiFactory,\n        val settings: CodeStyleSettings\n) {\n\tval ktFile = createKtFile(source, psiFactory, fileName)\n\n    val sourceDocument = Document(source)\n\n    fun formatCode(): String {\n        FormatterImpl()\n        val rootBlock = KotlinBlock(ktFile.node,\n                NULL_ALIGNMENT_STRATEGY,\n                Indent.getNoneIndent(),\n                null,\n                settings,\n                createSpacingBuilder(settings, KotlinSpacingBuilderUtilImpl))\n\n\t\treformatAll(ktFile, rootBlock, settings, sourceDocument)\n\n\t\treturn sourceDocument.get()\n\t}\n}\n\nfun createPsiFactory(eclipseFile: IFile): KtPsiFactory {\n\tval environment = getEnvironment(eclipseFile)\n\treturn KtPsiFactory(environment.project)\n}\n\nfun createKtFile(source: String, psiFactory: KtPsiFactory, fileName: String): KtFile {\n\treturn psiFactory.createFile(fileName, StringUtil.convertLineSeparators(source))\n}\n\nprivate fun createWhitespaces(countSpaces: Int) = IndenterUtil.SPACE_STRING.repeat(countSpaces)\n\nobject KotlinSpacingBuilderUtilImpl : KotlinSpacingBuilderUtil {\n\toverride fun createLineFeedDependentSpacing(minSpaces: Int,\n\t\t\t\t\t\t\t\t\t\t\t\tmaxSpaces: Int,\n\t\t\t\t\t\t\t\t\t\t\t\tminimumLineFeeds: Int,\n\t\t\t\t\t\t\t\t\t\t\t\tkeepLineBreaks: Boolean,\n\t\t\t\t\t\t\t\t\t\t\t\tkeepBlankLines: Int,\n\t\t\t\t\t\t\t\t\t\t\t\tdependency: TextRange,\n\t\t\t\t\t\t\t\t\t\t\t\trule: DependentSpacingRule): Spacing {\n\t\treturn object : DependantSpacingImpl(minSpaces, maxSpaces, dependency, keepLineBreaks, keepBlankLines, rule) {\n\t\t}\n\t}\n\n\toverride fun getPreviousNonWhitespaceLeaf(node: ASTNode?): ASTNode? {\n\t\treturn FormatterUtil.getPreviousNonWhitespaceLeaf(node)\n\t}\n\n\toverride fun isWhitespaceOrEmpty(node: ASTNode?): Boolean {\n\t\treturn FormatterUtil.isWhitespaceOrEmpty(node)\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/CompilerStatusHandler.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.IStatus\nimport org.eclipse.debug.core.IStatusHandler\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.swt.graphics.Color\nimport org.eclipse.swt.graphics.RGB\nimport org.eclipse.ui.console.ConsolePlugin\nimport org.eclipse.ui.console.MessageConsole\nimport org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity\nimport org.jetbrains.kotlin.core.compiler.KotlinCompilerUtils\nimport org.jetbrains.kotlin.core.launch.CompilerOutputElement\n\nclass CompilerStatusHandler : IStatusHandler {\n\n    @Throws(CoreException::class)\n    override fun handleStatus(status: IStatus, source: Any): Any? {\n        if (source !is KotlinCompilerUtils.CompilerOutputWithProject) {\n            return null\n        }\n        val javaProject: IJavaProject = source.project\n        val outputDataList: List<CompilerOutputElement> = source.data.list\n        val sortedOutput = groupOutputByPath(outputDataList)\n        val msgConsole = createCleanKotlinConsole(javaProject)\n        for (outputList in sortedOutput.values) {\n            printCompilerOutputList(outputList, msgConsole)\n        }\n        if (status.severity == IStatus.ERROR) {\n            ConsolePlugin.getDefault().consoleManager.showConsoleView(msgConsole)\n        }\n        return null\n    }\n\n    private fun printCompilerOutputList(outputList: List<CompilerOutputElement>, msgConsole: MessageConsole) {\n        val path = outputList[0].messageLocation?.path\n        msgConsole.println(path ?: \"No Location\", CONSOLE_BLACK)\n        for (dataElement in outputList) {\n            val color = dataElement.messageSeverity.color\n            val message = StringBuilder()\n            message.append(\"\\t\")\n            message.append(dataElement.messageSeverity.toString() + \": \" + dataElement.message)\n            if (dataElement.messageLocation != null) {\n                message.append(\" (\" + dataElement.messageLocation.line + \", \" + dataElement.messageLocation.column + \")\")\n            }\n            msgConsole.println(message.toString(), color)\n        }\n    }\n\n    private val CompilerMessageSeverity.color: RGB\n        get() = when (this) {\n            CompilerMessageSeverity.ERROR -> CONSOLE_RED\n            CompilerMessageSeverity.WARNING -> CONSOLE_YELLOW\n            else -> CONSOLE_BLACK\n        }\n\n    private fun MessageConsole.println(message: String, color: RGB?) = newMessageStream().apply {\n        this.color = Color(null, color)\n        println(message)\n    }\n\n    private fun groupOutputByPath(outputData: List<CompilerOutputElement>): Map<String, MutableList<CompilerOutputElement>> {\n        val res: MutableMap<String, MutableList<CompilerOutputElement>> = HashMap()\n        val emptyPath = \"\"\n        for (dataElement in outputData) {\n            val path = dataElement.messageLocation?.path ?: emptyPath\n            if (!res.containsKey(path)) {\n                res[path] = ArrayList()\n            }\n            res[path]!!.add(dataElement)\n        }\n        return res\n    }\n\n    companion object {\n        private val CONSOLE_RED = RGB(229, 43, 80)\n        private val CONSOLE_YELLOW = RGB(218, 165, 32)\n        private val CONSOLE_BLACK = RGB(0, 0, 0)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinLaunchShortcut.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.core.resources.IContainer\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.debug.core.DebugPlugin\nimport org.eclipse.debug.core.ILaunchConfiguration\nimport org.eclipse.debug.core.ILaunchConfigurationType\nimport org.eclipse.debug.ui.DebugUITools\nimport org.eclipse.debug.ui.ILaunchShortcut\nimport org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.ui.IEditorPart\nimport org.jetbrains.kotlin.core.KOTLIN_CLASSPATH_PROVIDER_ID\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\nimport org.jetbrains.kotlin.idea.KotlinFileType\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport java.util.*\n\n\nclass KotlinLaunchShortcut : ILaunchShortcut {\n    companion object {\n        fun createConfiguration(entryPoint: KtDeclaration, project: IProject): ILaunchConfiguration? {\n            val classFqName = getStartClassFqName(entryPoint)\n            if (classFqName == null) return null\n\n            val configWC = getLaunchConfigurationType().newInstance(null, \"Config - \" + entryPoint.containingKtFile.name).apply {\n                setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, classFqName.asString())\n                setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.name)\n                setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, KOTLIN_CLASSPATH_PROVIDER_ID)\n            }\n\n            return configWC.doSave()\n        }\n        \n        fun getFileClassName(mainFile: IFile): FqName {\n            val ktFile = KotlinPsiManager.getParsedFile(mainFile)\n            return JvmFileClassUtil.getFileClassInfoNoResolve(ktFile).fileClassFqName\n        }\n        \n        private fun getLaunchConfigurationType(): ILaunchConfigurationType {\n            return DebugPlugin.getDefault().launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION)\n        }\n    }\n    \n    override fun launch(selection: ISelection, mode: String) {\n        val mainFile = findFileToLaunch(selection) ?: return\n        \n        val ktFile = KotlinPsiManager.getParsedFile(mainFile)\n\n        val entryPoint = getEntryPoint(ktFile, languageVersionFor(mainFile))\n\n        if (entryPoint != null) {\n            launchWithMainClass(entryPoint, mainFile.project, mode)\n        }\n    }\n    \n    override fun launch(editor: IEditorPart, mode: String) {\n        if (editor !is KotlinFileEditor) return\n        \n        val file = editor.eclipseFile\n        if (file == null) {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null)\n            return\n        }\n        \n        val parsedFile = editor.parsedFile\n        if (parsedFile == null) return\n\n        val entryPoint = getEntryPoint(parsedFile, languageVersionFor(file))\n        if (entryPoint != null) {\n            launchWithMainClass(entryPoint, file.project, mode)\n            return\n        }\n    }\n    \n    private fun launchWithMainClass(entryPoint: KtDeclaration, project: IProject, mode: String) {\n        val configuration = findLaunchConfiguration(getLaunchConfigurationType(), entryPoint, project)\n                ?: createConfiguration(entryPoint, project)\n\n        if (configuration != null) {\n            DebugUITools.launch(configuration, mode)\n        }\n    }\n    \n    private fun findLaunchConfiguration(\n            configurationType: ILaunchConfigurationType, \n            entryPoint: KtDeclaration,\n            project: IProject): ILaunchConfiguration? {\n        val configs = DebugPlugin.getDefault().launchManager.getLaunchConfigurations(configurationType)\n        val mainClassName = getStartClassFqName(entryPoint)?.asString()\n        if (mainClassName == null) return null\n        \n        for (config in configs) {\n            if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, null as String?) == mainClassName && \n                config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, null as String?) == project.name) {\n                return config\n            }\n        }\n        \n        return null\n    }\n    \n    private fun addFiles(files: ArrayList<IFile>, resource: IResource) {\n        when (resource.type) {\n            IResource.FILE -> {\n                val file = resource as IFile\n                if (resource.getFileExtension() == KotlinFileType.INSTANCE.defaultExtension) {\n                    files.add(file)\n                }\n            }\n            \n            IResource.FOLDER, IResource.PROJECT -> {\n                val container = resource as IContainer\n                for (child in container.members()) {\n                    addFiles(files, child)\n                }\n            }\n        }\n    }\n}\n\nprivate fun languageVersionFor(file: IFile) =\n        KotlinEnvironment.getEnvironment(file.project).compilerProperties.languageVersionSettings"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinLaunchableTester.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.expressions.PropertyTester\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.IAdaptable\nimport org.jetbrains.kotlin.config.LanguageVersionSettings\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.core.preferences.languageVersionSettings\nimport org.jetbrains.kotlin.fileClasses.JvmFileClassUtil\nimport org.jetbrains.kotlin.idea.MainFunctionDetector\nimport org.jetbrains.kotlin.name.FqName\nimport org.jetbrains.kotlin.psi.*\n\nclass KotlinLaunchableTester : PropertyTester() {\n    override fun test(receiver: Any?, property: String?, args: Array<Any>?, expectedValue: Any?): Boolean {\n        if (receiver !is IAdaptable) return false\n\n        val file = receiver.getAdapter(IFile::class.java) ?: return false\n\n        val ktFile = KotlinPsiManager.getKotlinParsedFile(file) ?: return false\n\n        return checkFileHasMain(\n                ktFile,\n                KotlinEnvironment.getEnvironment(file.project).compilerProperties.languageVersionSettings)\n    }\n}\n\nfun checkFileHasMain(ktFile: KtFile, languageVersion: LanguageVersionSettings): Boolean {\n    return getEntryPoint(ktFile, languageVersion) != null\n}\n\nfun getStartClassFqName(mainFunctionDeclaration: KtDeclaration): FqName? {\n    val container = mainFunctionDeclaration.declarationContainer()\n    return when (container) {\n        is KtFile -> JvmFileClassUtil.getFileClassInfoNoResolve(container).facadeClassFqName\n\n        is KtClassOrObject -> {\n            if (container is KtObjectDeclaration && container.isCompanion()) {\n                val containerClass = PsiTreeUtil.getParentOfType(container, KtClass::class.java)\n                containerClass?.fqName\n            } else {\n                container.fqName\n            }\n        }\n\n        else -> null\n    }\n}\n\nfun getEntryPoint(ktFile: KtFile, languageVersion: LanguageVersionSettings): KtDeclaration? {\n    val bindingContext = KotlinAnalysisFileCache.getAnalysisResult(ktFile).analysisResult.bindingContext\n    val mainFunctionDetector = MainFunctionDetector(bindingContext, languageVersion)\n\n    val topLevelDeclarations = ktFile.declarations\n    for (declaration in topLevelDeclarations) {\n        val mainFunction = when (declaration) {\n            is KtNamedFunction -> if (mainFunctionDetector.isMain(declaration)) declaration else null\n\n            is KtClass -> {\n                mainFunctionDetector.findMainFunction(declaration.companionObjects.flatMap { it.declarations })\n            }\n\n            is KtObjectDeclaration -> mainFunctionDetector.findMainFunction(declaration.declarations)\n\n            else -> null\n        }\n\n        if (mainFunction != null) return mainFunction\n    }\n\n    return null\n}\n\nprivate fun KtDeclaration.declarationContainer(): KtDeclarationContainer? {\n    return PsiTreeUtil.getParentOfType(this, KtClassOrObject::class.java, KtFile::class.java) as KtDeclarationContainer?\n}\n\nprivate fun MainFunctionDetector.findMainFunction(declarations: List<KtDeclaration>): KtNamedFunction? {\n    return declarations.filterIsInstance(KtNamedFunction::class.java).find { isMain(it) }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinRuntimeConfigurator.kt",
    "content": "/*******************************************************************************\r\n * Copyright 2000-2016 JetBrains s.r.o.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n *\r\n *******************************************************************************/\r\npackage org.jetbrains.kotlin.ui.launch\r\n\r\nimport org.eclipse.core.resources.IProject\r\nimport org.eclipse.jface.dialogs.MessageDialog\r\nimport org.eclipse.jface.window.Window\r\nimport org.eclipse.swt.SWT\r\nimport org.eclipse.swt.custom.StyleRange\r\nimport org.eclipse.swt.custom.StyledText\r\nimport org.eclipse.swt.graphics.Image\r\nimport org.eclipse.swt.layout.GridLayout\r\nimport org.eclipse.swt.widgets.Composite\r\nimport org.eclipse.swt.widgets.Display\r\nimport org.eclipse.swt.widgets.Shell\r\nimport org.eclipse.ui.ISharedImages\r\nimport org.eclipse.ui.PlatformUI\r\nimport org.jetbrains.kotlin.core.KotlinClasspathContainer\r\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\r\nimport org.jetbrains.kotlin.ui.gridData\r\n\r\nclass KotlinRuntimeConfigurator(private val project: IProject) : Runnable {\r\n    companion object {\r\n        @JvmStatic fun suggestForProject(project: IProject) {\r\n            Display.getDefault().asyncExec(KotlinRuntimeConfigurator(project))\r\n        }\r\n    }\r\n\r\n    override fun run() {\r\n        if (ProjectUtils.hasKotlinRuntime(project)) return\r\n\r\n        ProjectUtils.addKotlinRuntime(project)\r\n        \r\n        MessageDialog.openInformation(Shell(Display.getDefault()), \"Configure Kotlin in Project\",\r\n            KotlinClasspathContainer.LIB_RUNTIME_NAME + \".jar, \" + KotlinClasspathContainer.LIB_REFLECT_NAME + \".jar were added\\nto the project classpath.\")\r\n    }\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinScriptLaunchConfigurationDelegate.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.ResourcesPlugin\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.debug.core.ILaunch\nimport org.eclipse.debug.core.ILaunchConfiguration\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate\nimport org.eclipse.jdt.launching.ExecutionArguments\nimport org.eclipse.jdt.launching.VMRunnerConfiguration\nimport org.jetbrains.kotlin.cli.jvm.K2JVMCompiler\nimport org.jetbrains.kotlin.core.compiler.KotlinCompiler\nimport org.jetbrains.kotlin.core.model.EclipseScriptDefinitionProvider\nimport org.jetbrains.kotlin.core.model.KOTLIN_COMPILER_PATH\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.core.utils.asFile\nimport java.io.File\nimport kotlin.script.experimental.api.ScriptCompilationConfiguration\nimport kotlin.script.experimental.api.baseClass\n\nclass KotlinScriptLaunchConfigurationDelegate : AbstractJavaLaunchConfigurationDelegate() {\n    companion object {\n        private val ideDepenedneciesPath = ProjectUtils.buildLibPath(\"ide-dependencies\")\n        private val compilerMainClass = K2JVMCompiler::class.java.name\n\n        private val classpathForCompiler =\n            listOf(KOTLIN_COMPILER_PATH, ideDepenedneciesPath)\n                .map { File(it).absolutePath }\n                .toTypedArray()\n    }\n\n    override fun launch(configuration: ILaunchConfiguration, mode: String, launch: ILaunch, monitor: IProgressMonitor) {\n        monitor.beginTask(\"${configuration.name}...\", 5)\n        try {\n            monitor.subTask(\"Verifying launch attributes...\")\n\n            val scriptFile = getScriptFile(configuration) ?: return\n            if (!scriptFile.exists()) return\n\n            monitor.subTask(\"Building project...\")\n            val javaProject = JavaCore.create(scriptFile.project)\n            KotlinCompiler.compileKotlinFiles(javaProject)\n\n            if (monitor.isCanceled) return\n            monitor.worked(3)\n\n            val runConfig = createRunnerConfiguration(configuration, scriptFile, javaProject)\n\n            if (monitor.isCanceled) return\n            monitor.worked(1)\n\n            val runner = getVMRunner(configuration, mode)\n            runner.run(runConfig, launch, monitor)\n\n            if (monitor.isCanceled) return\n        } finally {\n            monitor.done()\n        }\n    }\n\n    private fun createRunnerConfiguration(\n        configuration: ILaunchConfiguration,\n        scriptFile: IFile,\n        javaProject: IJavaProject\n    ): VMRunnerConfiguration {\n        val workingDir = verifyWorkingDirectory(configuration)?.absolutePath\n\n        val programArgs = getProgramArguments(configuration)\n        val vmArgs = getVMArguments(configuration)\n        val executionArgs = ExecutionArguments(vmArgs, programArgs)\n\n        val environmentVars = getEnvironment(configuration)\n\n        val vmAttributesMap: MutableMap<String, Any>? = getVMSpecificAttributesMap(configuration)\n\n        return VMRunnerConfiguration(compilerMainClass, classpathForCompiler + templateClasspath(scriptFile)).apply {\n            programArguments = buildCompilerArguments(\n                scriptFile,\n                javaProject,\n                executionArgs.programArgumentsArray\n            ).toTypedArray()\n\n            environment = environmentVars\n            vmArguments = executionArgs.vmArgumentsArray\n            workingDirectory = workingDir\n            vmSpecificAttributesMap = vmAttributesMap\n\n            bootClassPath = getBootpath(configuration)\n        }\n    }\n\n    private fun templateClasspath(scriptFile: IFile): Array<String> =\n        KotlinScriptEnvironment.getEnvironment(scriptFile).definitionClasspath.map { it.absolutePath }.toTypedArray()\n\n    private fun getScriptFile(configuration: ILaunchConfiguration): IFile? =\n        configuration.getAttribute(SCRIPT_FILE_PATH, null as String?)?.let { scriptFilePath ->\n            ResourcesPlugin.getWorkspace().root.getFile(Path(scriptFilePath))\n        }\n\n    private fun buildCompilerArguments(\n        scriptFile: IFile,\n        javaProject: IJavaProject,\n        programArguments: Array<String>\n    ): List<String> =\n        arrayListOf<String>().apply {\n            val environment = KotlinScriptEnvironment.getEnvironment(scriptFile)\n\n            val classpathEntries = environment.dependencies?.classpath?.toList().orEmpty()\n\n            val pathSeparator = System.getProperty(\"path.separator\")\n\n            add(\"-kotlin-home\")\n            add(ProjectUtils.ktHome)\n\n            add(\"-classpath\")\n            add(classpathEntries.joinToString(separator = pathSeparator))\n            add(\"-script\")\n            add(scriptFile.location.toOSString())\n\n            environment.definition\n                ?.compilationConfiguration\n                ?.get(ScriptCompilationConfiguration.baseClass)\n                ?.typeName\n                ?.also {\n                    add(\"-script-templates\")\n                    add(it)\n                }\n\n            val formattedEnvironment = EclipseScriptDefinitionProvider.getEnvironment(scriptFile.asFile)\n                ?.entries\n                ?.joinToString(separator = \",\") { (k, v) -> \"$k=$v\" }\n            if (formattedEnvironment != null) {\n                add(\"-Xscript-resolver-environment=$formattedEnvironment\")\n            }\n\n            addAll(programArguments)\n        }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinScriptLaunchConfigurationTabGroup.kt",
    "content": "package org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup\nimport org.eclipse.debug.ui.ILaunchConfigurationDialog\nimport org.eclipse.debug.ui.CommonTab\nimport org.eclipse.debug.ui.ILaunchConfigurationTab\nimport org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab\n\nclass KotlinScriptLaunchConfigurationTabGroup : AbstractLaunchConfigurationTabGroup() {\n    override fun createTabs(dialog: ILaunchConfigurationDialog, mode: String) {\n        val arr = arrayOf(CommonTab())\n        setTabs(*arr)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinScriptLaunchShortcut.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.IAdaptable\nimport org.eclipse.debug.core.DebugPlugin\nimport org.eclipse.debug.core.ILaunchConfiguration\nimport org.eclipse.debug.core.ILaunchConfigurationType\nimport org.eclipse.debug.ui.DebugUITools\nimport org.eclipse.debug.ui.ILaunchShortcut\nimport org.eclipse.jface.viewers.ISelection\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.eclipse.ui.IEditorPart\nimport org.jetbrains.kotlin.ui.editors.KotlinScriptEditor\nimport java.util.ArrayList\n\nconst val SCRIPT_FILE_PATH = \"org.jetbrains.kotlin.ui.scrpitFilePathAttribute\"\nprivate const val SCRIPT_LAUNCH_CONFIGURATION_TYPE = \"org.jetbrains.kotlin.ui.scriptLaunchConfiguration\"\n\nclass KotlinScriptLaunchShortcut : ILaunchShortcut {\n    override fun launch(selection: ISelection, mode: String) {\n        val scriptFile = findFileToLaunch(selection) ?: return\n        launch(scriptFile, mode)\n    }\n\n    override fun launch(editor: IEditorPart, mode: String) {\n        if (editor !is KotlinScriptEditor) return\n        \n        val scriptFile = editor.eclipseFile ?: return\n        \n        launch(scriptFile, mode)\n    }\n    \n    private fun launch(scriptFile: IFile, mode: String) {\n        val configuration = getLaunchConfigurationType().let {\n            findLaunchConfiguration(scriptFile, it) ?: createLaunchConfiguration(scriptFile, it)\n        }\n        \n        DebugUITools.launch(configuration, mode)\n    }\n    \n    private fun findLaunchConfiguration(scriptFile: IFile, configurationType: ILaunchConfigurationType): ILaunchConfiguration? {\n        return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configurationType).find {\n            it.getAttribute(SCRIPT_FILE_PATH, \"\") == scriptFile.fullPath.toPortableString()\n        }\n    }\n    \n    private fun createLaunchConfiguration(scriptFile: IFile,\n            configurationType: ILaunchConfigurationType): ILaunchConfiguration {\n        \n        return configurationType.newInstance(null,  \"Script - ${scriptFile.name}\").apply {\n            setAttribute(SCRIPT_FILE_PATH, scriptFile.fullPath.toPortableString())\n        }.doSave()\n    }\n}\n\nfun findFileToLaunch(selection: ISelection): IFile? {\n    if (selection !is IStructuredSelection) return null\n    \n    return selection.toList()\n            .filterIsInstance(IAdaptable::class.java)\n            .mapNotNull { it.getAdapter(IFile::class.java) }\n            .firstOrNull()\n\n}\n\nprivate fun getLaunchConfigurationType(): ILaunchConfigurationType {\n    return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SCRIPT_LAUNCH_CONFIGURATION_TYPE)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/KotlinScriptLaunchableTester.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.core.expressions.PropertyTester\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.IAdaptable\nimport org.jetbrains.kotlin.core.model.KotlinScriptEnvironment\n\nclass KotlinScriptLaunchableTester : PropertyTester() {\n    override fun test(receiver: Any?, property: String?, args: Array<out Any>?, expectedValue: Any?): Boolean {\n        if (receiver !is IAdaptable) return false\n\n        val file = receiver.getAdapter(IFile::class.java)\n        if (file == null) return false\n\n        return KotlinScriptEnvironment.isScript(file)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/junit/KotlinJUnitLaunchShortcut.java",
    "content": "/*******************************************************************************\n * Copyright 2010-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch.junit;\n\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.debug.core.ILaunchConfiguration;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.internal.junit.ui.JUnitMessages;\nimport org.eclipse.jdt.internal.junit.ui.JUnitPlugin;\nimport org.eclipse.jdt.junit.launcher.JUnitLaunchShortcut;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.ui.IEditorPart;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\n\npublic class KotlinJUnitLaunchShortcut extends JUnitLaunchShortcut {\n    public static final String KOTLIN_JUNIT_LAUNCH_ID = \"org.jetbrains.kotlin.ui.launch.junit\";\n    \n    @Override\n    public void launch(IEditorPart editor, String mode) {\n        IJavaElement eclipseElement = resolveToEclipseElement(editor);\n        if (eclipseElement != null) {\n            launch(eclipseElement, mode);\n        } else {\n            showNoTestsFoundDialog();\n        }\n    }\n    \n    @Override\n    public void launch(ISelection selection, String mode) {\n        IJavaElement eclipseElement = resolveToEclipseElement(selection);\n        if (eclipseElement != null) {\n            launch(eclipseElement, mode);\n        } else {\n            showNoTestsFoundDialog();\n        }\n    }\n    \n    @Nullable\n    private IJavaElement resolveToEclipseElement(@NotNull IEditorPart editor) {\n        IFile file = EditorUtil.getFile(editor);\n\n        if (file != null) {\n            IType eclipseType = KotlinJUnitLaunchUtils.getEclipseTypeForSingleClass(file);\n            return eclipseType != null ? eclipseType : null;\n        } else {\n            KotlinLogger.logError(\"Failed to retrieve IFile from editor \" + editor, null);\n        }\n\n        return null;\n    }\n    \n    @Nullable\n    private IJavaElement resolveToEclipseElement(@NotNull ISelection selection) {\n        if (selection instanceof IStructuredSelection) {\n            Object[] elements = ((IStructuredSelection) selection).toArray();\n            if (elements.length == 1) {\n                Object element = elements[0];\n                if (element instanceof IFile) {\n                    IFile file = (IFile) element;\n                    return KotlinJUnitLaunchUtils.getEclipseTypeForSingleClass(file);\n                }\n            }\n        }\n        \n        return null;\n    }\n    \n    private void launch(@NotNull IJavaElement eclipseElement, @NotNull String mode) {\n        try {\n            Method method = this.getClass().getSuperclass().getDeclaredMethod(\"performLaunch\", IJavaElement.class, String.class);\n            method.setAccessible(true);\n            method.invoke(this, eclipseElement, mode);\n        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    @Override\n    public ILaunchConfiguration[] getLaunchConfigurations(final IEditorPart editor) {\n        try {\n            IJavaElement eclipseType = resolveToEclipseElement(editor);\n            if (eclipseType != null) {\n                return new ILaunchConfiguration[] { createLaunchConfiguration(eclipseType) };\n            } \n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    private void showNoTestsFoundDialog() {\n        MessageDialog.openInformation(JUnitPlugin.getActiveWorkbenchShell(), \n                JUnitMessages.JUnitLaunchShortcut_dialog_title, JUnitMessages.JUnitLaunchShortcut_message_notests);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/junit/KotlinJUnitLaunchUtils.java",
    "content": "/*******************************************************************************\n * Copyright 2010-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch.junit;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.model.KotlinJavaManager;\nimport org.jetbrains.kotlin.psi.KtClass;\nimport org.jetbrains.kotlin.psi.KtDeclaration;\nimport org.jetbrains.kotlin.psi.KtFile;\n\npublic class KotlinJUnitLaunchUtils {\n    @Nullable\n    public static KtClass getSingleJetClass(@NotNull IFile file) {\n        if (!KotlinPsiManager.INSTANCE.existsSourceFile(file)) return null;\n        \n        KtFile jetFile = KotlinPsiManager.INSTANCE.getParsedFile(file);\n        \n        KtClass jetClass = null;\n        for (KtDeclaration declaration : jetFile.getDeclarations()) {\n            if (declaration instanceof KtClass) {\n                if (jetClass != null) {\n                    return null;\n                } else {\n                    jetClass = (KtClass) declaration;\n                }\n            }\n        }\n        \n        return jetClass;\n    }\n    \n    @Nullable\n    public static IType getEclipseTypeForSingleClass(@NotNull IFile file) {\n        KtClass jetClass = getSingleJetClass(file);\n        return jetClass != null ? KotlinJavaManager.INSTANCE.findEclipseType(jetClass, JavaCore.create(file.getProject())) : null;\n    }    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/junit/KotlinJUnitLaunchableTester.java",
    "content": "/*******************************************************************************\n * Copyright 2010-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch.junit;\n\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport org.eclipse.core.expressions.PropertyTester;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IType;\nimport org.eclipse.jdt.internal.junit.launcher.ITestKind;\nimport org.eclipse.jdt.internal.junit.launcher.TestKindRegistry;\nimport org.eclipse.ui.IFileEditorInput;\nimport org.jetbrains.annotations.NotNull;\n\npublic class KotlinJUnitLaunchableTester extends PropertyTester {\n\n    @Override\n    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {\n        if (receiver instanceof IFile) {\n            return checkFileHasTests((IFile) receiver);\n        } else if (receiver instanceof IFileEditorInput) {\n            IFile file = ((IFileEditorInput) receiver).getFile();\n            return checkFileHasTests(file);\n        }\n        \n        return false;\n    }\n    \n    private boolean checkFileHasTests(@NotNull IFile file) {\n        IType type = KotlinJUnitLaunchUtils.getEclipseTypeForSingleClass(file);\n        return type != null ? checkElementHasTests(type) : false;\n    }\n    \n    private boolean checkElementHasTests(@NotNull IJavaElement element) {\n        ITestKind testKind = TestKindRegistry.getDefault().getKind(TestKindRegistry.getContainerTestKindId(element));\n        \n        Set<IType> tests = new HashSet<>();\n        try {\n            testKind.getFinder().findTestsInContainer(element, tests, null);\n        } catch (CoreException e) {\n//            Exception throws when tests can not be found\n            return false;\n        }\n            \n        return !tests.isEmpty();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/launch/kotlinConsole.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.launch\n\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.ui.console.ConsolePlugin\nimport org.eclipse.ui.console.MessageConsole\n\nprivate const val KOTLIN_CONSOLE_ID = \"org.jetbrains.kotlin.ui.console\"\n\nprivate val manager get() = ConsolePlugin.getDefault().consoleManager\n\nprivate val IJavaProject.consoleName get() = \"$KOTLIN_CONSOLE_ID.${project.name}\"\n\nfun createCleanKotlinConsole(javaProject: IJavaProject): MessageConsole {\n    removeKotlinConsoles(javaProject)\n\n    return createNewKotlinConsole(javaProject)\n}\n\nprivate fun createNewKotlinConsole(javaProject: IJavaProject): MessageConsole {\n    val messageConsole = MessageConsole(javaProject.consoleName, null)\n    manager.addConsoles(arrayOf(messageConsole))\n\n    return messageConsole\n}\n\nfun removeKotlinConsoles(javaProject: IJavaProject) {\n    manager.removeConsoles(manager.consoles\n            .filter { it.name == javaProject.consoleName }\n            .toTypedArray())\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/navigation/KotlinOpenEditor.java",
    "content": "package org.jetbrains.kotlin.ui.navigation;\n\nimport java.io.File;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.jdt.core.IClassFile;\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.ISourceReference;\nimport org.eclipse.jdt.internal.core.BinaryType;\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IReusableEditor;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.ide.IDE;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil;\nimport org.jetbrains.kotlin.psi.KtElement;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor;\nimport org.jetbrains.kotlin.ui.editors.KotlinClassFileEditorInput;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\n// Seeks Kotlin editor by IJavaElement\n@SuppressWarnings(\"restriction\")\npublic class KotlinOpenEditor {\n    private static final String CLASS_WITHOUT_SOURCE = \"*.class without source\";\n\n\t@Nullable\n    public static IEditorPart openKotlinEditor(@NotNull IJavaElement element, boolean activate) {\n        List<KtFile> sourceFiles = findSourceFiles(element);\n        \n        IFile kotlinFile;\n        if (sourceFiles.size() == 1) {\n            kotlinFile = KotlinPsiManager.getEclipseFile(sourceFiles.get(0));\n        } else {\n            kotlinFile = KotlinOpenEditorUtilsKt.chooseSourceFile(sourceFiles);\n        }\n        \n        try {\n            if (kotlinFile != null && kotlinFile.exists()) {\n                IEditorPart kotlinEditor = EditorUtility.openInEditor(kotlinFile, activate);\n                if (activate && kotlinEditor instanceof KotlinEditor) {\n                    revealKotlinElement((KotlinEditor) kotlinEditor, element);\n                }\n                \n                return kotlinEditor;\n            }\n        } catch (PartInitException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        \n        return null;\n    }\n    \n    @NotNull\n    public static List<KtFile> findSourceFiles(@NotNull IJavaElement element) {\n        IResource resource = element.getResource();\n        if (resource == null) {\n            return Collections.emptyList();\n        }\n        \n        File lightClass = resource.getFullPath().toFile();\n        List<KtFile> sourceFiles = KotlinLightClassManager.Companion\n                .getInstance(element.getJavaProject().getProject()).getSourceFiles(lightClass);\n        KtFile navigationFile = KotlinOpenEditorUtilsKt.findNavigationFileFromSources(element, sourceFiles);\n        \n        if (navigationFile != null) {\n            return Collections.singletonList(navigationFile);\n        } else {\n            return sourceFiles;\n        }\n    }\n    \n    public static void revealKotlinElement(@NotNull KotlinEditor kotlinEditor, @NotNull IJavaElement javaElement) {\n        KtFile jetFile = kotlinEditor.getParsedFile();\n        \n        if (jetFile == null) {\n            return;\n        }\n        \n        KtElement jetElement = KotlinOpenEditorUtilsKt.findKotlinDeclaration(javaElement, jetFile);\n        if (jetElement == null) {\n            jetElement = jetFile;\n        }\n        \n        int offset = LineEndUtil.convertLfToDocumentOffset(jetFile.getText(), jetElement.getTextOffset(),\n                kotlinEditor.getDocument());\n        kotlinEditor.getJavaEditor().selectAndReveal(offset, 0);\n    }\n    \n    @Nullable\n    public static IEditorPart openKotlinClassFileEditor(@NotNull IJavaElement element, boolean activate) {\n        IClassFile classFile;\n        if (element instanceof IClassFile) {\n            classFile = (IClassFile) element;\n        } else if (element instanceof BinaryType) {\n            classFile = ((BinaryType) element).getClassFile();\n        } else {\n            return null;\n        }\n        \n        KotlinClassFileEditorInput editorInput = new KotlinClassFileEditorInput(classFile, classFile.getJavaProject());\n        \n        IWorkbench wb = PlatformUI.getWorkbench();\n        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();\n        IWorkbenchPage page = win.getActivePage();\n        \n        try {\n            IEditorPart reusedEditor = page.openEditor(editorInput, resolveEditorID((ISourceReference)element), activate);\n            if (reusedEditor != null) {\n                // the input is compared by a source path, but corresponding\n                // classes may be different\n                // so if editor is reused, the input should be changed for the\n                // purpose of inner navigation\n                page.reuseEditor((IReusableEditor) reusedEditor, editorInput);\n            }\n            return reusedEditor;\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n        return null;\n    }\n    \n\tprivate static String resolveEditorID(@NotNull ISourceReference reference) throws CoreException {\n\t\t// if no source let the java decompiler handle it.\n\t\tif(reference.getSourceRange() != null && reference.getSourceRange().getLength() > 0) {\n    \t\treturn KotlinClassFileEditor.Companion.getEDITOR_ID();\n\t\t}\n\t\treturn IDE.getEditorDescriptor(CLASS_WITHOUT_SOURCE, true, false).getId();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/navigation/KotlinOpenEditorUtils.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.navigation\n\nimport org.jetbrains.kotlin.psi.KtVisitorVoid\nimport com.intellij.psi.PsiElement\nimport org.eclipse.jdt.core.IJavaElement\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.eclipse.jdt.core.IType\nimport org.jetbrains.kotlin.psi.KtClass\nimport org.eclipse.jdt.core.IMethod\nimport org.jetbrains.kotlin.psi.KtNamedFunction\nimport org.jetbrains.kotlin.psi.KtFile\nimport java.util.ArrayList\nimport org.jetbrains.kotlin.psi.KtClassBody\nimport org.jetbrains.kotlin.psi.KtObjectDeclaration\nimport org.jetbrains.kotlin.name.FqName\nimport org.eclipse.jdt.core.IField\nimport org.jetbrains.kotlin.psi.KtProperty\nimport org.jetbrains.kotlin.core.asJava.LightClassBuilderFactory\nimport org.jetbrains.kotlin.psi.KtPropertyAccessor\nimport org.jetbrains.kotlin.psi.KtSecondaryConstructor\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.eclipse.jdt.core.IMember\nimport org.jetbrains.kotlin.psi.KtDeclaration\nimport org.jetbrains.kotlin.psi.KtEnumEntry\nimport org.jetbrains.kotlin.psi.KtPrimaryConstructor\nimport org.jetbrains.kotlin.core.asJava.equalsJvmSignature\nimport org.jetbrains.kotlin.core.asJava.getDeclaringTypeFqName\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.eclipse.ui.dialogs.ListDialog\nimport org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider\nimport org.eclipse.compare.internal.ListContentProvider\nimport org.eclipse.jface.window.Window\nimport org.eclipse.ui.PlatformUI\n\nfun chooseSourceFile(sourceFiles: List<KtFile>): IFile? {\n    return when {\n        sourceFiles.isEmpty() -> null\n        sourceFiles.size == 1 -> KotlinPsiManager.getEclipseFile(sourceFiles.first())\n        else -> chooseFile(sourceFiles)\n    }\n}\n\nfun chooseFile(jetFiles: List<KtFile>): IFile? {\n    val eclipseFiles = jetFiles.map { KotlinPsiManager.getEclipseFile(it) }\n    \n    val dialog = ListDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell())\n    dialog.setBlockOnOpen(true)\n    dialog.setMessage(\"Select a Kotlin file to navigate\")\n    dialog.setTitle(\"Choose Kotlin file\")\n    dialog.setContentProvider(ListContentProvider())\n    dialog.setLabelProvider(JavaUILabelProvider())\n    \n    dialog.setInput(eclipseFiles)\n    \n    if (dialog.open() != Window.OK) {\n        return null\n    }\n    \n    return dialog.getResult().firstOrNull() as? IFile\n}\n\nfun findNavigationFileFromSources(element: IJavaElement, sourceFiles: List<KtFile>): KtFile? {\n    return sourceFiles.firstOrNull { findKotlinDeclaration(element, it) != null }\n}\n\nfun findKotlinDeclaration(element: IJavaElement, jetFile: KtFile): KtElement? {\n    val result = ArrayList<KtElement>()\n    val visitor = makeVisitor(element, result)\n    if (visitor != null) {\n        jetFile.acceptChildren(visitor)\n    }\n\n    return result.firstOrNull()\n}\n\nfun makeVisitor(element: IJavaElement, result: ArrayList<KtElement>): KtVisitorVoid? {\n    return when (element) {\n        is IType -> object : JetAllVisitor() {\n            override fun visitClassOrObject(jetClassOrObject: KtClassOrObject) {\n                if (jetClassOrObject.getFqName() == element.getFqName()) {\n                    result.add(jetClassOrObject)\n                    return\n                }\n\n                jetClassOrObject.acceptChildren(this)\n            }\n        }\n        \n        is IField -> object: JetAllVisitor() {\n            override fun visitObjectDeclaration(declaration: KtObjectDeclaration) {\n                visitExplicitDeclaration(declaration)\n                declaration.acceptChildren(this)\n            }\n\n            override fun visitEnumEntry(enumEntry: KtEnumEntry) {\n                visitExplicitDeclaration(enumEntry)\n            }\n\n            override fun visitProperty(property: KtProperty) {\n                visitExplicitDeclaration(property)\n            }\n\n            fun visitExplicitDeclaration(declaration: KtDeclaration) {\n                if (equalsJvmSignature(declaration, element)) {\n                    result.add(declaration)\n                }\n            }\n        }\n        \n        is IMethod -> object : JetAllVisitor() {\n            override fun visitNamedFunction(function: KtNamedFunction) {\n                visitExplicitDeclaration(function)\n            }\n\n            override fun visitProperty(property: KtProperty) {\n                visitExplicitDeclaration(property)\n                property.acceptChildren(this)\n            }\n\n            override fun visitPropertyAccessor(accessor: KtPropertyAccessor) {\n                visitExplicitDeclaration(accessor)\n            }\n\n            override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) {\n                visitExplicitDeclaration(constructor)\n            }\n\n            override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor) {\n                visitExplicitDeclaration(constructor)\n            }\n\n//          Check primary constructor when there are no secondary constructors\n            override fun visitClass(jetClass: KtClass) {\n                if (equalsJvmSignature(jetClass, element) && (jetClass.getFqName() == element.getDeclaringType().getFqName())) {\n                    result.add(jetClass)\n                    return\n                }\n\n                jetClass.acceptChildren(this)\n            }\n\n            fun visitExplicitDeclaration(declaration: KtDeclaration) {\n                if (equalsJvmSignature(declaration, element) && equalsDeclaringTypes(declaration, element)) {\n                    result.add(declaration)\n                }\n            }\n        }\n        else -> null\n    }\n}\n\nfun IType.getFqName(): FqName {\n    return FqName(this.getFullyQualifiedName('.'))\n}\n\nfun equalsDeclaringTypes(jetElement: KtElement, javaMember: IMember): Boolean  {\n    val typeNameInfo = getDeclaringTypeFqName(jetElement)\n    val javaTypeFqName = javaMember.getDeclaringType().getFqName() \n    return typeNameInfo == javaTypeFqName \n}\n\nopen class JetAllVisitor() : KtVisitorVoid() {\n    override fun visitElement(element: PsiElement) {\n        element.acceptChildren(this)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/overrideImplement/KotlinCallableLabelProvider.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.overrideImplement\n\nimport org.eclipse.jface.viewers.LabelProvider\nimport org.eclipse.jface.viewers.ITreeContentProvider\nimport org.eclipse.jface.viewers.Viewer\nimport org.jetbrains.kotlin.descriptors.CallableMemberDescriptor\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.DescriptorUtils\nimport org.jetbrains.kotlin.renderer.render\nimport org.jetbrains.kotlin.descriptors.ClassDescriptor\nimport org.eclipse.swt.graphics.Image\nimport org.jetbrains.kotlin.ui.editors.completion.KotlinCompletionUtils\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinImageProvider\nimport org.jetbrains.kotlin.renderer.ClassifierNamePolicy\n\nclass KotlinCallableLabelProvider : LabelProvider() {\n    private val MEMBER_RENDERER = DescriptorRenderer.withOptions { \n        withDefinedIn = false\n        modifiers = emptySet()\n        startFromName = true\n        classifierNamePolicy = ClassifierNamePolicy.SHORT\n    }\n    \n    override fun getText(element: Any): String {\n        return when (element) {\n            is ClassDescriptor -> DescriptorUtils.getFqNameSafe(element).toUnsafe().render()\n            is CallableMemberDescriptor -> MEMBER_RENDERER.render(element)\n            else -> throw IllegalArgumentException(\"$element occurred in override/implement dialog\")\n        }\n    }\n    \n    override fun getImage(element: Any): Image? {\n        return if (element is DeclarationDescriptor) KotlinImageProvider.getImage(element) else null\n    }\n}\n\nclass KotlinCallableContentProvider(val descriptors: Set<CallableMemberDescriptor>, val types: Set<ClassDescriptor>) : ITreeContentProvider {\n    override fun dispose() {\n    }\n    \n    override fun inputChanged(viewer: Viewer?, oldInput: Any?, newInput: Any?) {\n    }\n    \n    override fun getParent(element: Any): Any? {\n        return null\n    }\n    \n    override fun getElements(inputElement: Any?): Array<out Any>? {\n        return types.toTypedArray()\n    }\n    \n    override fun hasChildren(element: Any?): Boolean {\n        return element is ClassDescriptor\n    }\n    \n    override fun getChildren(parentElement: Any): Array<out Any>? {\n        return if (parentElement is ClassDescriptor) {\n            descriptors.filter { it.getContainingDeclaration() == parentElement }.toTypedArray()\n        } else {\n            return null\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/overrideImplement/KotlinOverrideMembersAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.overrideImplement\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport com.intellij.util.SmartList\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.window.Window\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.dialogs.CheckedTreeSelectionDialog\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.psi.KtClassOrObject\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinImplementMethodsProposal\nimport org.jetbrains.kotlin.ui.editors.quickassist.resolveToDescriptor\nimport java.util.LinkedHashMap\nimport java.util.LinkedHashSet\n\npublic class KotlinOverrideMembersAction(\n        val editor: KotlinCommonEditor, \n        val filterMembersFromAny: Boolean = false) : SelectionDispatchAction(editor.getSite()) {\n    init {\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS)\n        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ADD_UNIMPLEMENTED_METHODS_ACTION)\n        \n        val overrideImplementText = \"Override/Implement Members\"\n        setText(overrideImplementText)\n        setDescription(\"Override or implement members declared in supertypes\")\n        setToolTipText(overrideImplementText)\n        \n    }\n    \n    val membersFromAny = listOf(\"equals\", \"hashCode\", \"toString\")\n    \n    companion object {\n        val ACTION_ID = \"OverrideMethods\"\n    }\n    \n    override fun run(selection: ITextSelection) {\n        val jetClassOrObject = getKtClassOrObject(selection)\n        if (jetClassOrObject == null) return\n        \n        val generatedMembers = collectMembersToGenerate(jetClassOrObject)\n        val selectedMembers = if (filterMembersFromAny) {\n            generatedMembers.filterNot { it.getName().asString() in membersFromAny }\n        } else {\n            showDialog(generatedMembers)\n        }\n        \n        if (selectedMembers.isEmpty()) return\n        \n        KotlinImplementMethodsProposal(editor).generateMethods(editor.document, jetClassOrObject, selectedMembers.toSet())\n    }\n    \n    private fun getKtClassOrObject(selection: ITextSelection): KtClassOrObject? {\n        val psiElement = EditorUtil.getPsiElement(editor, selection.getOffset())\n        return if (psiElement != null) {\n                PsiTreeUtil.getNonStrictParentOfType(psiElement, KtClassOrObject::class.java)\n            } else {\n                null\n            }\n    }\n    \n    private fun showDialog(descriptors: Set<CallableMemberDescriptor>): Set<CallableMemberDescriptor> {\n        val shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()\n        \n        val types = descriptors.map { it.getContainingDeclaration() as ClassDescriptor }.toSet()\n        val dialog = CheckedTreeSelectionDialog(shell,\n                KotlinCallableLabelProvider(),\n                KotlinCallableContentProvider(descriptors, types))\n        \n        dialog.setTitle(\"Override/Implement members\")\n        dialog.setContainerMode(true)\n        dialog.setExpandedElements(types.toTypedArray())\n        dialog.setInput(Any()) // Initialize input\n        \n        if (dialog.open() != Window.OK) {\n            return emptySet()\n        }\n        \n        val selected = dialog.getResult()?.filterIsInstance(CallableMemberDescriptor::class.java)\n        return selected?.toSet() ?: emptySet()\n    }\n    \n    private fun collectMembersToGenerate(classOrObject: KtClassOrObject): Set<CallableMemberDescriptor> {\n        val descriptor = classOrObject.resolveToDescriptor()\n        if (descriptor !is ClassDescriptor) return emptySet()\n        \n        val result = LinkedHashSet<CallableMemberDescriptor>()\n        for (member in descriptor.unsubstitutedMemberScope.getContributedDescriptors()) {\n            if (member is CallableMemberDescriptor\n                && (member.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || member.kind == CallableMemberDescriptor.Kind.DELEGATION)) {\n                val overridden = member.overriddenDescriptors\n                if (overridden.any { it.modality == Modality.FINAL || DescriptorVisibilities.isPrivate(it.visibility.normalize()) }) continue\n\n                class Data(\n                        val realSuper: CallableMemberDescriptor,\n                        val immediateSupers: MutableList<CallableMemberDescriptor> = SmartList()\n                )\n\n                val byOriginalRealSupers = LinkedHashMap<CallableMemberDescriptor, Data>()\n                for (immediateSuper in overridden) {\n                    for (realSuper in toRealSupers(immediateSuper)) {\n                        byOriginalRealSupers.getOrPut(realSuper.original) { Data(realSuper) }.immediateSupers.add(immediateSuper)\n                    }\n                }\n\n                val realSupers = byOriginalRealSupers.values.map { it.realSuper }\n                val nonAbstractRealSupers = realSupers.filter { it.modality != Modality.ABSTRACT }\n                val realSupersToUse = if (nonAbstractRealSupers.isNotEmpty()) {\n                    nonAbstractRealSupers\n                }\n                else {\n                    listOf(realSupers.first())\n                }\n\n                for (realSuper in realSupersToUse) {\n                    val immediateSupers = byOriginalRealSupers[realSuper.original]!!.immediateSupers\n                    assert(immediateSupers.isNotEmpty())\n\n                    val immediateSuperToUse = if (immediateSupers.size == 1) {\n                        immediateSupers.single()\n                    }\n                    else {\n                        immediateSupers.singleOrNull { (it.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.CLASS } ?: immediateSupers.first()\n                    }\n\n                    result.add(immediateSuperToUse)\n                }\n            }\n        }\n        \n        return result\n    }\n    \n    private fun toRealSupers(immediateSuper: CallableMemberDescriptor): Collection<CallableMemberDescriptor> {\n        if (immediateSuper.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {\n            return listOf(immediateSuper)\n        }\n\n        val overridden = immediateSuper.overriddenDescriptors\n        assert(overridden.isNotEmpty())\n        return overridden.flatMap { toRealSupers(it) }.distinctBy { it.original }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/extract/KotlinExtractVariableAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.extract\n\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages\nimport org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\n\npublic class KotlinExtractVariableAction(val editor: KotlinCommonEditor) : SelectionDispatchAction(editor.getSite()) {\n    init {\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE)\n        setText(RefactoringMessages.ExtractTempAction_label)\n        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.EXTRACT_TEMP_ACTION)\n    }\n    \n    companion object {\n        val ACTION_ID = \"ExtractLocalVariable\"\n    }\n    \n    override fun run(selection: ITextSelection) {\n        RefactoringStarter().activate(\n                KotlinExtractVariableWizard(KotlinExtractVariableRefactoring(selection, editor)), \n                getShell(), \n                RefactoringMessages.ExtractTempAction_extract_temp, \n                RefactoringSaveHelper.SAVE_NOTHING)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/extract/KotlinExtractVariableRefactoring.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.extract\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.PsiFile\nimport com.intellij.psi.PsiWhiteSpace\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages\nimport org.eclipse.jdt.internal.corext.refactoring.changes.TextChangeCompatibility\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.text.TextUtilities\nimport org.eclipse.ltk.core.refactoring.Change\nimport org.eclipse.ltk.core.refactoring.Refactoring\nimport org.eclipse.ltk.core.refactoring.RefactoringStatus\nimport org.eclipse.ltk.core.refactoring.TextFileChange\nimport org.eclipse.text.edits.ReplaceEdit\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.eclipse.ui.utils.IndenterUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getOffsetByDocument\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiUnifier\nimport org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.canPlaceAfterSimpleNameEntry\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.formatter.AlignmentStrategy\nimport org.jetbrains.kotlin.ui.refactorings.rename.FileEdit\n\npublic class KotlinExtractVariableRefactoring(val selection: ITextSelection, val editor: KotlinCommonEditor) : Refactoring() {\n    public var newName: String = \"temp\"\n    public var replaceAllOccurrences = true\n    private lateinit var expression: KtExpression\n    override fun checkFinalConditions(pm: IProgressMonitor?): RefactoringStatus = RefactoringStatus()\n    \n    override fun checkInitialConditions(pm: IProgressMonitor?): RefactoringStatus {\n        val startOffset = LineEndUtil.convertCrToDocumentOffset(editor.document, selection.getOffset())\n        val selectedExpression = PsiTreeUtil.findElementOfClassAtRange(editor.parsedFile!!, startOffset, \n            startOffset + selection.getLength(), KtExpression::class.java)\n        return if (selectedExpression != null) {\n            expression = selectedExpression\n            RefactoringStatus()\n        } else {\n            RefactoringStatus.createErrorStatus(\"Could not extract variable\")\n        }\n    }\n    \n    override fun getName(): String = RefactoringCoreMessages.ExtractTempRefactoring_name\n    \n    override fun createChange(pm: IProgressMonitor?): Change {\n        val edits = introduceVariable()\n        val fileChange = TextFileChange(\"Introduce variable\", editor.eclipseFile!!)\n        edits.forEach { TextChangeCompatibility.addTextEdit(fileChange, \"Kotlin change\", it.edit) }\n        \n        return fileChange\n    }\n    \n    private fun introduceVariable(): List<FileEdit> {\n        val occurrenceContainer = expression.getOccurrenceContainer()\n        if (occurrenceContainer == null) return emptyList()\n        val allReplaces = if (replaceAllOccurrences) expression.findOccurrences(occurrenceContainer) else listOf(expression)\n        val commonParent = PsiTreeUtil.findCommonParent(allReplaces) as KtElement\n        val commonContainer = getContainer(commonParent)\n        if (commonContainer == null) return emptyList()\n        \n        val anchor = calculateAnchor(commonParent, commonContainer, allReplaces)\n        if (anchor == null) return emptyList()\n        \n        val indent = run {\n            val indentNode = commonContainer.getFirstChild().getNode()\n            val nodeIndent = AlignmentStrategy.computeIndent(indentNode)\n            if (AlignmentStrategy.isBlockElement(indentNode)) nodeIndent - 1 else nodeIndent\n        }\n        val variableDeclarationText = \"val $newName = ${expression.getText()}\"\n        \n        val bindingContext = expression.getBindingContext()\n        \n        return createEdits(\n                commonContainer,\n                expression.isUsedAsStatement(bindingContext),\n                commonContainer !is KtBlockExpression,\n                variableDeclarationText,\n                indent,\n                anchor,\n                allReplaces)\n    }\n    \n    private fun shouldReplaceInitialExpression(context: BindingContext): Boolean {\n        return expression.isUsedAsStatement(context)\n    }\n    \n    private fun replaceExpressionWithVariableDeclaration(variableText: String, firstOccurrence: KtExpression): FileEdit {\n        val offset = firstOccurrence.getTextDocumentOffset(editor.document)\n        return FileEdit(editor.eclipseFile!!, ReplaceEdit(offset, firstOccurrence.getTextLength(), variableText))\n    }\n    \n    private fun createEdits(\n            container: PsiElement,\n            isUsedAsStatement: Boolean, \n            needBraces: Boolean, \n            variableDeclarationText: String,\n            indent: Int,\n            anchor: PsiElement,\n            replaces: List<KtExpression>): List<FileEdit> {\n        val lineDelimiter = TextUtilities.getDefaultLineDelimiter(editor.document)\n        val newLineWithShift = IndenterUtil.createWhiteSpace(indent, 1, lineDelimiter)\n        \n        val newLineBeforeBrace = IndenterUtil.createWhiteSpace(indent - 1, 1, lineDelimiter)\n        \n        val sortedReplaces = replaces.sortedBy { it.getTextOffset() }\n        if (isUsedAsStatement && sortedReplaces.first() == anchor) {\n            val variableText = if (needBraces) {\n                \"{${newLineWithShift}${variableDeclarationText}${newLineBeforeBrace}}\"\n            } else {\n                variableDeclarationText\n            }\n            \n            val replacesList = sortedReplaces.drop(1).map { replaceOccurrence(newName, it, editor) }\n            \n            return listOf(replaceExpressionWithVariableDeclaration(variableText, sortedReplaces.first())) + replacesList\n        } else {\n            val replacesList = replaces.map { replaceOccurrence(newName, it, editor) }\n            if (needBraces) {\n                val variableText = \"{${newLineWithShift}${variableDeclarationText}${newLineWithShift}\"\n                val removeNewLineIfNeeded = if (isElseAfterContainer(container)) \n                    removeNewLineAfter(container, editor)\n                else \n                    null\n                \n                return listOf(\n                        insertBefore(anchor, variableText, editor), \n                        addBraceAfter(expression, newLineBeforeBrace, editor),\n                        removeNewLineIfNeeded).filterNotNull() + replacesList\n            } else {\n                val variableText = \"${variableDeclarationText}${newLineWithShift}\"\n                return replacesList + insertBefore(anchor, variableText, editor)\n            }\n        }\n    }\n}\n\nprivate fun KtExpression.findOccurrences(occurrenceContainer: PsiElement): List<KtExpression> {\n    return toRange()\n            .match(occurrenceContainer, KotlinPsiUnifier.DEFAULT)\n            .map {\n                val candidate = it.range.elements.first()\n                when (candidate) {\n                    is KtExpression -> candidate\n                    is KtStringTemplateEntryWithExpression -> candidate.expression\n                    else -> throw AssertionError(\"Unexpected candidate element: \" + candidate.text)\n                } as? KtExpression\n            }\n            .filterNotNull()\n}\n\nprivate fun addBraceAfter(expr: KtExpression, newLineBeforeBrace: String, editor: KotlinCommonEditor): FileEdit {\n    val parent = expr.getParent()\n    var endOffset = parent.getTextRange().getEndOffset()\n    val text = editor.document.get()\n    while (endOffset > 0 && text[endOffset] == ' ') {\n        endOffset--\n    }\n    \n    val offset = expr.getParent().let { it.getOffsetByDocument(editor.document, endOffset + 1) }\n    return FileEdit(editor.eclipseFile!!, ReplaceEdit(offset, 0, \"$newLineBeforeBrace}\"))\n}\n\nprivate fun removeNewLineAfter(container: PsiElement, editor: KotlinCommonEditor): FileEdit? {\n    val next = container.nextSibling\n    if (next is PsiWhiteSpace) {\n        return FileEdit(\n                editor.eclipseFile!!, \n                ReplaceEdit(next.getTextDocumentOffset(editor.document), next.getTextLength(), \" \"))\n    }\n    \n    return null\n}\n\nprivate fun replaceOccurrence(newName: String, replaceExpression: KtExpression, editor: KotlinCommonEditor): FileEdit {\n    val (offset, length) = replaceExpression.getReplacementRange(editor)\n    return FileEdit(editor.eclipseFile!!, ReplaceEdit(offset, length, newName))\n}\n\nprivate fun KtExpression.getReplacementRange(editor: KotlinCommonEditor): ReplacementRange {\n    val p = getParent()\n    if (p is KtBlockStringTemplateEntry) {\n        if (canPlaceAfterSimpleNameEntry(p.nextSibling)) {\n            return ReplacementRange(p.getTextDocumentOffset(editor.document) + 1, p.getTextLength() - 1) // '+- 1' is for '$' sign\n        }\n    }\n    \n    return ReplacementRange(getTextDocumentOffset(editor.document), getTextLength())\n}\n\nprivate data class ReplacementRange(val offset: Int, val length: Int)\n\nprivate fun isElseAfterContainer(container: PsiElement): Boolean {\n    val next = container.nextSibling\n    if (next != null) {\n        val nextnext = next.nextSibling\n        if (nextnext != null && nextnext.node.elementType == KtTokens.ELSE_KEYWORD) {\n            return true\n        }\n    }\n    \n    return false\n}\n\nprivate fun insertBefore(psiElement: PsiElement, text: String, editor: KotlinCommonEditor): FileEdit {\n    val startOffset = psiElement.getOffsetByDocument(editor.document, psiElement.getTextRange().getStartOffset())\n    return FileEdit(editor.eclipseFile!!, ReplaceEdit(startOffset, 0, text))\n}\n\nprivate fun calculateAnchor(commonParent: PsiElement, commonContainer: PsiElement, allReplaces: List<KtExpression>): PsiElement? {\n    var anchor = commonParent\n    if (anchor != commonContainer) {\n        while (anchor.getParent() != commonContainer) {\n            anchor = anchor.getParent()\n        }\n    } else {\n        anchor = commonContainer.getFirstChild()\n        var startOffset = commonContainer.getTextRange().getEndOffset()\n        for (expr in allReplaces) {\n            val offset = expr.getTextRange().getStartOffset()\n            if (offset < startOffset) startOffset = offset\n        }\n        \n        while (anchor != null && !anchor.getTextRange().contains(startOffset)) {\n            anchor = anchor.getNextSibling()\n        }\n    }\n    \n    return anchor\n    \n}\n\nprivate fun getContainer(place: PsiElement): PsiElement? {\n    if (place is KtBlockExpression) return place\n    \n    var container = place\n    while (container != null) {\n        val parent = container.getParent()\n        if (parent is KtContainerNode) {\n            if (!isBadContainerNode(parent, container)) {\n                return parent\n            }\n        }\n        \n        if (parent is KtBlockExpression || (parent is KtWhenEntry && container == parent.getExpression())) {\n            return parent\n        }\n        \n        if (parent is KtDeclarationWithBody && parent.getBodyExpression() == container) {\n            return parent\n        }\n        \n        container = parent\n    }\n    \n    return null\n}\n\nprivate fun KtExpression.getOccurrenceContainer(): KtElement? {\n    var result: KtElement? = null\n    for ((place, parent) in parentsWithSelf.zip(parents)) {\n        when {\n            parent is KtContainerNode && place !is KtBlockExpression && !isBadContainerNode(parent, place) -> result = parent\n            parent is KtClassBody || parent is KtFile -> return result\n            parent is KtBlockExpression -> result = parent\n            parent is KtWhenEntry && place !is KtBlockExpression -> result = parent\n            parent is KtDeclarationWithBody && parent.bodyExpression == place && place !is KtBlockExpression -> result = parent\n        }\n    }\n\n    return null\n}\n\npublic val PsiElement.parentsWithSelf: Sequence<PsiElement>\n    get() = generateSequence(this) { if (it is PsiFile) null else it.getParent() }\n\npublic val PsiElement.parents: Sequence<PsiElement>\n    get() = parentsWithSelf.drop(1)\n\nprivate fun isBadContainerNode(parent: KtContainerNode, place: PsiElement): Boolean {\n    if (parent.getParent() is KtIfExpression && (parent.getParent() as KtIfExpression).getCondition() == place) {\n        return true\n    } else if (parent.getParent() is KtLoopExpression && (parent.getParent() as KtLoopExpression).getBody() != place) {\n        return true\n    } else if (parent.getParent() is KtArrayAccessExpression) {\n        return true\n    }\n    \n    return false\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/extract/KotlinExtractVariableWizard.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.extract\n\nimport org.eclipse.ltk.ui.refactoring.RefactoringWizard\nimport org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages\nimport org.eclipse.jdt.internal.ui.refactoring.TextInputWizardPage\nimport org.eclipse.swt.widgets.Composite\nimport org.eclipse.swt.SWT\nimport org.eclipse.swt.layout.GridLayout\nimport org.eclipse.jdt.internal.ui.util.RowLayouter\nimport org.eclipse.swt.widgets.Label\nimport org.eclipse.swt.layout.GridData\nimport org.eclipse.jface.dialogs.Dialog\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.jdt.internal.ui.IJavaHelpContextIds\nimport org.eclipse.swt.widgets.Button\nimport org.eclipse.swt.events.SelectionAdapter\nimport org.eclipse.swt.events.SelectionEvent\n\nclass KotlinExtractVariableWizard(val refactoring: KotlinExtractVariableRefactoring) : \n        RefactoringWizard(refactoring, RefactoringWizard.DIALOG_BASED_USER_INTERFACE) {\n    init {\n        setDefaultPageTitle(RefactoringMessages.ExtractTempWizard_defaultPageTitle)\n    }\n    \n    override fun addUserInputPages() {\n        addPage(ExtractVariableInputPage())\n    }\n    \n    private class ExtractVariableInputPage : \n            TextInputWizardPage(RefactoringMessages.ExtractTempInputPage_enter_name, true, \"\") {\n        val kotlinRefactoring by lazy { getRefactoring() as KotlinExtractVariableRefactoring }\n        \n        override fun textModified(text: String) {\n            kotlinRefactoring.newName = text\n            super.textModified(text)\n        }\n    \n        override fun createControl(parent: Composite) {\n            val result = Composite(parent, SWT.NONE)\n            setControl(result)\n            \n            val layout = GridLayout()\n            layout.numColumns = 2\n            layout.verticalSpacing = 8\n            result.setLayout(layout)\n            val layouter = RowLayouter(2)\n            \n            val label= Label(result, SWT.NONE)\n            label.setText(RefactoringMessages.ExtractTempInputPage_variable_name)\n            \n            val text = createTextInputField(result)\n            text.selectAll()\n            text.setLayoutData(GridData(GridData.FILL_HORIZONTAL))\n            \n            layouter.perform(label, text, 1)\n            \n            addReplaceAllCheckbox(result, layouter)\n            \n            Dialog.applyDialogFont(result)\n            PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_TEMP_WIZARD_PAGE)\n        }\n        \n        private fun addReplaceAllCheckbox(result: Composite, layouter: RowLayouter) {\n            val title = RefactoringMessages.ExtractConstantInputPage_replace_all\n            val defaultValue = true\n            \n            val checkBox= Button(result, SWT.CHECK)\n            checkBox.setText(title)\n            checkBox.setSelection(defaultValue)\n            layouter.perform(checkBox)\n            \n            checkBox.addSelectionListener(object : SelectionAdapter() {\n                override fun widgetSelected(e: SelectionEvent) {\n                    kotlinRefactoring.replaceAllOccurrences = checkBox.getSelection()\n                }\n            })\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/KotlinLightElementsFactory.java",
    "content": "package org.jetbrains.kotlin.ui.refactorings.rename;\n\nimport org.eclipse.jdt.core.IJavaElement;\nimport org.eclipse.jdt.core.IMethod;\nimport org.eclipse.jdt.core.IType;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class KotlinLightElementsFactory {\n    @Nullable\n    public static IJavaElement createLightElement(@NotNull IJavaElement javaElement) {\n        if (javaElement instanceof IType) {\n            return new KotlinLightType((IType) javaElement);\n        } else if (javaElement instanceof IMethod) {\n            return new KotlinLightFunction((IMethod) javaElement);\n        } else {\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/KotlinRenameAction.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.eclipse.core.commands.operations.IUndoableOperation\nimport org.eclipse.core.commands.operations.OperationHistoryFactory\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.IMethod\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorHighlightingSynchronizer\nimport org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper\nimport org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages\nimport org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal.DeleteBlockingExitPolicy\nimport org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds\nimport org.eclipse.jdt.ui.actions.SelectionDispatchAction\nimport org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper\nimport org.eclipse.jdt.ui.refactoring.RenameSupport\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.text.ITextViewerExtension6\nimport org.eclipse.jface.text.IUndoManager\nimport org.eclipse.jface.text.IUndoManagerExtension\nimport org.eclipse.jface.text.link.ILinkedModeListener\nimport org.eclipse.jface.text.link.LinkedModeModel\nimport org.eclipse.jface.text.link.LinkedPosition\nimport org.eclipse.jface.text.link.LinkedPositionGroup\nimport org.eclipse.ltk.core.refactoring.RefactoringCore\nimport org.eclipse.ltk.core.refactoring.participants.RenameRefactoring\nimport org.eclipse.ui.texteditor.link.EditorLinkedModeUI\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.model.sourceElementsToLightElements\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.eclipse.jdt.internal.compiler.env.ICompilationUnit as ContentProviderCompilationUnit\n\npublic class KotlinRenameAction(val editor: KotlinCommonEditor) : SelectionDispatchAction(editor.getSite()) {\n    init {\n        setActionDefinitionId(IJavaEditorActionDefinitionIds.RENAME_ELEMENT)\n        setText(RefactoringMessages.RenameAction_text)\n    }\n    \n    companion object {\n        val ACTION_ID = \"RenameElement\"\n    }\n    \n    override fun run(selection: ITextSelection) {\n        beginRenameRefactoring(selection, editor)\n    }\n    \n    fun undo(editor: KotlinCommonEditor, startingUndoOperation: IUndoableOperation?) {\n        editor.getSite().getWorkbenchWindow().run(false, true) {\n            val undoManager = getUndoManager(editor)\n            if (undoManager is IUndoManagerExtension) {\n                val undoContext = undoManager.getUndoContext()\n                val operationHistory = OperationHistoryFactory.getOperationHistory()\n                while (undoManager.undoable()) {\n                    if (startingUndoOperation != null && startingUndoOperation == operationHistory.getUndoOperation(undoContext)) {\n                        return@run\n                    }\n                    undoManager.undo()\n                }\n                \n            }\n        }\n    }\n    \n    fun getCurrentUndoOperation(editor: KotlinCommonEditor): IUndoableOperation? {\n        val undoManager = getUndoManager(editor)\n        if (undoManager is IUndoManagerExtension) {\n            val undoContext = undoManager.getUndoContext()\n            val operationHistory = OperationHistoryFactory.getOperationHistory()\n            return operationHistory.getUndoOperation(undoContext)\n        }\n        \n        return null\n    }\n    \n    fun getUndoManager(editor: KotlinCommonEditor): IUndoManager? {\n        val viewer = editor.getViewer()\n        return if (viewer is ITextViewerExtension6) viewer.getUndoManager() else null\n    }\n    \n    fun beginRenameRefactoring(selection: ITextSelection, editor: KotlinCommonEditor) {\n        val selectedElement = EditorUtil.getJetElement(editor, selection.getOffset()) ?: return\n        val offsetInDocument = selectedElement.getTextDocumentOffset(editor.document)\n        \n        val textLength = getLengthOfIdentifier(selectedElement) ?: return\n        \n        val position = LinkedPosition(editor.document, offsetInDocument, textLength)\n        val linkedPositionGroup = LinkedPositionGroup().apply { addPosition(position) }\n        \n        val startindUndoOperation = getCurrentUndoOperation(editor)\n        \n        val linkedModeModel = LinkedModeModel().apply {\n            addGroup(linkedPositionGroup)\n            forceInstall()\n            addLinkingListener(EditorHighlightingSynchronizer(editor))\n            \n            addLinkingListener(object : ILinkedModeListener {\n                override fun left(model: LinkedModeModel, flags: Int) {\n                    if ((flags and ILinkedModeListener.UPDATE_CARET) == 0) return\n                    \n                    val newName = position.getContent()\n                    undo(editor, startindUndoOperation)\n\n                    val file = editor.eclipseFile ?: return\n                    KotlinPsiManager.commitFile(file, editor.document)\n                    \n                    val sourceElements = computeSourceElements(selection, editor)\n                    if (sourceElements.isEmpty()) return\n\n                    doRename(sourceElements, newName, editor)\n                }\n\n                override fun resume(model: LinkedModeModel?, flags: Int) {\n                }\n\n                override fun suspend(model: LinkedModeModel?) {\n                }\n            })\n        } \n        \n        EditorLinkedModeUI(linkedModeModel, editor.getViewer()).apply {\n            setExitPosition(editor.getViewer(), offsetInDocument, 0, Integer.MAX_VALUE)\n            setExitPolicy(DeleteBlockingExitPolicy(editor.document))\n            enter()\n        }\n    }\n}\n\nprivate fun computeSourceElements(selection: ITextSelection, editor: KotlinCommonEditor): List<SourceElement> {\n    val jetElement = EditorUtil.getJetElement(editor, selection.getOffset()) ?: return emptyList()\n    return jetElement.resolveToSourceDeclaration()\n}\n\nprivate inline fun <T : IJavaElement> wrapIntoLightElementForKotlin(element: T, wrap: (T) -> T): T {\n    return if (EclipseJavaElementUtil.isKotlinLightClass(element)) wrap(element) else element\n}\n\nfun createRenameSupport(javaElement: IJavaElement, newName: String): RenameSupport {\n    val updateStrategy = RenameSupport.UPDATE_REFERENCES\n    return when (javaElement) {\n        is IType -> {\n            val element = wrapIntoLightElementForKotlin(javaElement, ::KotlinLightType)\n            RenameSupport.create(element, newName, updateStrategy)\n        }\n        is IMethod -> {\n            if (javaElement.isConstructor) {\n                createRenameSupport(javaElement.getDeclaringType(), newName)\n            } else {\n                val element = wrapIntoLightElementForKotlin(javaElement, ::KotlinLightFunction)\n                RenameSupport.create(element, newName, updateStrategy)\n            }\n        }\n        else -> throw UnsupportedOperationException(\"Rename refactoring for ${javaElement} is not supported\")\n    }\n}\n\nfun doRename(sourceElements: List<SourceElement>, newName: String, editor: KotlinCommonEditor) {\n    fun renameByJavaElement(javaElements: List<IJavaElement>) {\n        val javaElement = javaElements[0]\n        val renameSupport = createRenameSupport(javaElement, newName)\n        with(editor.getSite()) {\n            renameSupport.perform(getShell(), getWorkbenchWindow())\n        }\n    }\n    \n    fun renameLocalKotlinElement(sourceElement: KotlinSourceElement) {\n        val helper = RefactoringExecutionHelper(\n                RenameRefactoring(KotlinRenameProcessor(sourceElement, newName, editor.isScript)), \n                RefactoringCore.getConditionCheckingFailedSeverity(),\n                RefactoringSaveHelper.SAVE_REFACTORING,\n                editor.getSite().getShell(),\n                editor.getSite().getWorkbenchWindow())\n        try {\n            helper.perform(true, true)\n        } catch (e: InterruptedException) {\n            // skip\n        }\n    }\n    \n    val lightElements = sourceElementsToLightElements(sourceElements)\n    if (lightElements.isNotEmpty()) {\n        renameByJavaElement(lightElements)\n        editor.eclipseFile!!.getProject().refreshLocal(IResource.DEPTH_INFINITE, NullProgressMonitor())\n    } else {\n        if (sourceElements.isNotEmpty()) {\n            val element = sourceElements.first()\n            if (element is KotlinSourceElement) {\n                renameLocalKotlinElement(element)\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/KotlinRenameParticipant.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.eclipse.ltk.core.refactoring.participants.RenameParticipant\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext\nimport org.eclipse.ltk.core.refactoring.RefactoringStatus\nimport org.eclipse.ltk.core.refactoring.Change\nimport kotlin.properties.Delegates\nimport org.eclipse.jdt.core.IType\nimport java.util.ArrayList\nimport org.eclipse.ltk.core.refactoring.CompositeChange\nimport org.jetbrains.kotlin.ui.search.KotlinQueryParticipant\nimport org.eclipse.search.ui.text.Match\nimport org.eclipse.jdt.ui.search.ElementQuerySpecification\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.jetbrains.kotlin.ui.search.KotlinElementMatch\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.eclipse.ltk.core.refactoring.TextFileChange\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.eclipse.text.edits.ReplaceEdit\nimport org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor\nimport org.eclipse.ltk.core.refactoring.participants.RefactoringArguments\nimport org.eclipse.ltk.core.refactoring.participants.RenameArguments\nimport org.eclipse.text.edits.TextEdit\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.corext.refactoring.changes.TextChangeCompatibility\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.ui.search.QuerySpecification\n\nopen class KotlinRenameParticipant : RenameParticipant() {\n    lateinit var element: Any\n    lateinit var newName: String\n    \n    override fun initialize(element: Any): Boolean {\n        this.element = element\n        return true\n    }\n    \n    override fun initialize(processor: RefactoringProcessor?, element: Any?, arguments: RefactoringArguments): Boolean {\n        if (arguments is RenameArguments) {\n            newName = arguments.getNewName()\n        }\n        \n        return super.initialize(processor, element, arguments)\n    }\n    \n    override fun checkConditions(pm: IProgressMonitor?, context: CheckConditionsContext?): RefactoringStatus? {\n        return RefactoringStatus() // TODO: add corresponding refactoring status\n    }\n    \n    override fun getName() = \"Kotlin Type Rename Participant\"\n    \n    override fun createChange(pm: IProgressMonitor?): Change {\n        val kotlinQueryParticipant = KotlinQueryParticipant()\n        val matches = arrayListOf<Match>()\n        val querySpecification = createSearchQuery()\n        \n        kotlinQueryParticipant.search({ matches.add(it) }, querySpecification, pm)\n        \n        val groupedEdits = matches\n            .map { createTextChange(it) }\n            .filterNotNull()\n            .groupBy { it.file }\n        \n        val changes = arrayListOf<Change>()\n        \n        for ((file, edits) in groupedEdits) {\n            val fileChange = TextFileChange(\"Kotlin change\", file)\n            edits.forEach { TextChangeCompatibility.addTextEdit(fileChange, \"Kotlin change\", it.edit) }\n            \n            changes.add(fileChange)\n        }\n        \n        return CompositeChange(\"Changes in Kotlin\", changes.toTypedArray())\n    }\n    \n    protected open fun createSearchQuery(): QuerySpecification {\n        val factory = JavaSearchScopeFactory.getInstance()\n        return ElementQuerySpecification(\n                obtainOriginElement(element as IJavaElement), \n                IJavaSearchConstants.ALL_OCCURRENCES,\n                factory.createWorkspaceScope(false),\n                factory.getWorkspaceScopeDescription(false))\n    }\n    \n    private fun createTextChange(match: Match): FileEdit? {\n        if (match !is KotlinElementMatch) return null\n        \n        val jetElement = match.jetElement\n        \n        val eclipseFile = KotlinPsiManager.getEclipseFile(jetElement.containingKtFile) ?: return null\n\n        val document = EditorUtil.getDocument(eclipseFile) // TODO: make workaround here later\n        \n        val textLength = getLengthOfIdentifier(jetElement) ?: return null\n\n        return FileEdit(\n            eclipseFile,\n            ReplaceEdit(jetElement.getTextDocumentOffset(document), textLength, newName))\n    }\n    \n    private fun obtainOriginElement(javaElement: IJavaElement): IJavaElement {\n        return when (javaElement) {\n            is KotlinLightType -> javaElement.originElement\n            is KotlinLightFunction -> javaElement.originMethod\n            else -> javaElement\n        }\n    }\n}\n\ndata class FileEdit(val file: IFile, val edit: TextEdit)\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/KotlinRenameProcessor.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.eclipse.ltk.core.refactoring.participants.RenameProcessor\nimport org.eclipse.ltk.core.refactoring.RefactoringStatus\nimport org.eclipse.ltk.core.refactoring.participants.SharableParticipants\nimport org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext\nimport org.eclipse.ltk.core.refactoring.Change\nimport org.eclipse.ltk.core.refactoring.participants.RenameArguments\nimport org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating\nimport org.eclipse.ltk.core.refactoring.participants.ParticipantManager\nimport org.eclipse.jdt.internal.corext.refactoring.participants.JavaProcessors\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.core.model.KotlinNature\n\npublic class KotlinRenameProcessor(\n        element: KotlinSourceElement,\n        val newName: String,\n        val isFromScript: Boolean) : RenameProcessor() {\n    val jetElement = element.psi\n    \n    override fun isApplicable(): Boolean = true\n    \n    override fun loadParticipants(status: RefactoringStatus?, sharedParticipants: SharableParticipants?): Array<out RefactoringParticipant> {\n        val affectedNatures = if (isFromScript) {\n            arrayOf(KotlinNature.KOTLIN_NATURE)\n        } else {\n            val project = KotlinPsiManager.getJavaProject(jetElement)\n            if (project != null) JavaProcessors.computeAffectedNatures(project) else emptyArray()\n        }\n        \n        return ParticipantManager.loadRenameParticipants(\n                status, \n                this, \n                jetElement, \n                RenameArguments(newName, true), \n                affectedNatures,\n                sharedParticipants)\n    }\n    \n    override fun checkFinalConditions(pm: IProgressMonitor?, context: CheckConditionsContext?): RefactoringStatus? {\n        return RefactoringStatus()\n    }\n    \n    override fun checkInitialConditions(pm: IProgressMonitor?): RefactoringStatus = RefactoringStatus()\n    \n    override fun getIdentifier(): String = \"org.jetbrains.kotlin.ui.refactoring.renameProcessor\"\n    \n    override fun getProcessorName(): String = \"Kotlin Rename Processor\"\n    \n    override fun createChange(pm: IProgressMonitor?): Change? = null\n    \n    override fun getElements(): Array<Any> = arrayOf(jetElement)\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/lightEclipseElements.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.jobs.ISchedulingRule\nimport org.eclipse.jdt.core.CompletionRequestor\nimport org.eclipse.jdt.core.IAnnotation\nimport org.eclipse.jdt.core.IClassFile\nimport org.eclipse.jdt.core.ICompilationUnit\nimport org.eclipse.jdt.core.ICompletionRequestor\nimport org.eclipse.jdt.core.IField\nimport org.eclipse.jdt.core.IImportDeclaration\nimport org.eclipse.jdt.core.IInitializer\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.IJavaModel\nimport org.eclipse.jdt.internal.core.JavaModel\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.jdt.internal.core.JavaProject\nimport org.eclipse.jdt.core.IMethod\nimport org.eclipse.jdt.core.IOpenable\nimport org.eclipse.jdt.core.IPackageFragment\nimport org.eclipse.jdt.core.ISourceRange\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.jdt.core.ITypeHierarchy\nimport org.eclipse.jdt.core.ITypeParameter\nimport org.eclipse.jdt.core.ITypeRoot\nimport org.eclipse.jdt.core.IWorkingCopy\nimport org.eclipse.jdt.core.WorkingCopyOwner\nimport org.eclipse.jdt.core.compiler.CharOperation\nimport org.eclipse.jdt.internal.core.CompilationUnit\nimport org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner\nimport org.eclipse.jdt.internal.core.JavaElement\nimport org.eclipse.jdt.internal.core.JavaModelManager\nimport org.eclipse.jdt.internal.core.PackageFragment\nimport org.eclipse.jdt.internal.core.SourceType\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\nimport java.io.InputStream\nimport org.eclipse.jdt.internal.compiler.env.ICompilationUnit as ContentProviderCompilationUnit\n\nprivate val DUMMY_NAME_RANGE = object : ISourceRange {\n    override fun getLength(): Int = 0\n    \n    override fun getOffset(): Int = 1\n}\n\nopen class Testt(val originElement: IType) : IType by originElement\n\nclass KotlinLightType(val originElement: IType) :\n        SourceType(originElement.getParent() as JavaElement, originElement.getElementName()),\n        IType by originElement {\n    override fun findMethods(method: IMethod): Array<out IMethod>? {\n        val methods = originElement.findMethods(method)\n        return methods\n                ?.map { KotlinLightFunction(it) }\n                ?.toTypedArray()\n    }\n\n    override fun getCompilationUnit(): ICompilationUnit? = getLightCompilationUnit(originElement)\n    \n    override fun getMethods(): Array<IMethod> = emptyArray()\n\n    override fun getNameRange(): ISourceRange = DUMMY_NAME_RANGE\n\n    override fun getPrimaryElement(): JavaElement = this as JavaElement\n\n    override fun isBinary(): Boolean = false\n\n    override fun isReadOnly(): Boolean = false\n    \n    override fun exists(): Boolean = originElement.exists()\n    \n    override fun <T : Any?> getAdapter(adapter: Class<T>?): T {\n        return originElement.getAdapter(adapter)\n    }\n\n    override fun isAnnotation(): Boolean = originElement.isAnnotation()\n\n    override fun getOccurrenceCount(): Int = originElement.getOccurrenceCount()\n\n    override fun getInitializers(): Array<out IInitializer>? = originElement.getInitializers()\n\n    override fun getSuperInterfaceTypeSignatures(): Array<out String>? = originElement.getSuperInterfaceTypeSignatures()\n    \n    override fun getSourceRange(): ISourceRange = originElement.sourceRange\n\n    override fun getSuperclassName(): String? = originElement.getSuperclassName()\n\n    override fun getOpenable(): IOpenable? = originElement.getOpenable()\n\n    override fun getFlags(): Int = originElement.getFlags()\n\n    override fun copy(container: IJavaElement?, sibling: IJavaElement?, rename: String?, replace: Boolean, monitor: IProgressMonitor?) {\n        originElement.copy(container, sibling, rename, replace, monitor)\n    }\n\n    override fun getSchedulingRule(): ISchedulingRule? = originElement.getSchedulingRule()\n\n    override fun getAttachedJavadoc(monitor: IProgressMonitor?): String? = originElement.getAttachedJavadoc(monitor)\n\n    override fun isInterface(): Boolean = originElement.isInterface()\n\n    override fun getTypeParameters(): Array<out ITypeParameter>? = originElement.getTypeParameters()\n\n    override fun createType(contents: String?, sibling: IJavaElement?, force: Boolean, monitor: IProgressMonitor?): IType? {\n        return originElement.createType(contents, sibling, force, monitor)\n    }\n\n    override fun createInitializer(contents: String?, sibling: IJavaElement?, monitor: IProgressMonitor?): IInitializer? {\n        return originElement.createInitializer(contents, sibling, monitor)\n    }\n\n    override fun isAnonymous(): Boolean = originElement.isAnonymous()\n\n    override fun rename(name: String?, replace: Boolean, monitor: IProgressMonitor?) {\n        originElement.rename(name, replace, monitor)\n    }\n\n    override fun isMember(): Boolean = originElement.isMember()\n\n    override fun getField(name: String?): IField? = originElement.getField(name)\n\n    override fun hashCode(): Int = originElement.hashCode()\n\n    override fun getAnnotations(): Array<out IAnnotation>? = originElement.getAnnotations()\n\n    override fun toString(): String = originElement.toString()\n\n    override fun getTypeRoot(): ITypeRoot? = originElement.getTypeRoot()\n\n    override fun getFullyQualifiedParameterizedName(): String? = originElement.getFullyQualifiedParameterizedName()\n\n    override fun resolveType(typeName: String?): Array<out Array<String>>? = originElement.resolveType(typeName)\n\n    override fun resolveType(typeName: String?, owner: WorkingCopyOwner?): Array<out Array<String>>? {\n        return originElement.resolveType(typeName, owner)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: CompletionRequestor?, monitor: IProgressMonitor?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor, monitor)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: ICompletionRequestor?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: ICompletionRequestor?, owner: WorkingCopyOwner?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor, owner)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: CompletionRequestor?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: CompletionRequestor?, owner: WorkingCopyOwner?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor, owner)\n    }\n\n    override fun codeComplete(snippet: CharArray?, insertion: Int, position: Int, localVariableTypeNames: Array<out CharArray>?, localVariableNames: Array<out CharArray>?, localVariableModifiers: IntArray?, isStatic: Boolean, requestor: CompletionRequestor?, owner: WorkingCopyOwner?, monitor: IProgressMonitor?) {\n        originElement.codeComplete(snippet, insertion, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic, requestor, owner, monitor)\n    }\n\n    override fun getJavadocRange(): ISourceRange? = originElement.getJavadocRange()\n\n    override fun getPath(): IPath? = originElement.getPath()\n\n    override fun loadTypeHierachy(input: InputStream?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.loadTypeHierachy(input, monitor)\n    }\n\n    override fun getCorrespondingResource(): IResource? = originElement.getCorrespondingResource()\n\n    override fun newSupertypeHierarchy(monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newSupertypeHierarchy(monitor)\n    }\n\n    override fun newSupertypeHierarchy(workingCopies: Array<out ICompilationUnit>?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newSupertypeHierarchy(workingCopies, monitor)\n    }\n\n    override fun newSupertypeHierarchy(owner: WorkingCopyOwner?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newSupertypeHierarchy(owner, monitor)\n    }\n\n    override fun newSupertypeHierarchy(workingCopies: Array<out IWorkingCopy>?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newSupertypeHierarchy(workingCopies, monitor)\n    }\n\n    override fun getSuperclassTypeSignature(): String? = originElement.getSuperclassTypeSignature()\n\n    override fun isEnum(): Boolean = originElement.isEnum()\n\n    override fun getHandleIdentifier(): String? = originElement.getHandleIdentifier()\n\n    override fun getChildrenForCategory(category: String?): Array<out IJavaElement>? {\n        return originElement.getChildrenForCategory(category)\n    }\n\n    override fun hasChildren(): Boolean = originElement.hasChildren()\n\n    override fun newTypeHierarchy(monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(monitor)\n    }\n\n    override fun newTypeHierarchy(project: IJavaProject?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(project, monitor)\n    }\n\n    override fun newTypeHierarchy(workingCopies: Array<out IWorkingCopy>?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(workingCopies, monitor)\n    }\n\n    override fun newTypeHierarchy(owner: WorkingCopyOwner?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(owner, monitor)\n    }\n\n    override fun newTypeHierarchy(project: IJavaProject?, owner: WorkingCopyOwner?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(project, owner, monitor)\n    }\n\n    override fun newTypeHierarchy(workingCopies: Array<out ICompilationUnit>?, monitor: IProgressMonitor?): ITypeHierarchy? {\n        return originElement.newTypeHierarchy(workingCopies, monitor)\n    }\n\n    override fun getResource(): IResource? = originElement.getResource()\n\n    override fun getSource(): String? = originElement.getSource()\n\n    override fun getFields(): Array<out IField>? = originElement.getFields()\n\n    override fun getTypeQualifiedName(): String? = originElement.getTypeQualifiedName()\n\n    override fun getTypeQualifiedName(enclosingTypeSeparator: Char): String? = originElement.getTypeQualifiedName(enclosingTypeSeparator)\n\n    override fun getMethod(name: String?, parameterTypeSignatures: Array<out String>?): IMethod? {\n        return originElement.getMethod(name, parameterTypeSignatures)\n    }\n\n    override fun isLambda(): Boolean = originElement.isLambda()\n\n    override fun getInitializer(occurrenceCount: Int): IInitializer? = originElement.getInitializer(occurrenceCount)\n\n    override fun getPackageFragment(): IPackageFragment? = originElement.getPackageFragment()\n\n    override fun getElementType(): Int = originElement.getElementType()\n\n    override fun isStructureKnown(): Boolean = originElement.isStructureKnown()\n\n    override fun createField(contents: String?, sibling: IJavaElement?, force: Boolean, monitor: IProgressMonitor?): IField? {\n        return originElement.createField(contents, sibling, force, monitor)\n    }\n\n    override fun getUnderlyingResource(): IResource? = originElement.getUnderlyingResource()\n\n    override fun getCategories(): Array<out String>? = originElement.getCategories()\n\n    override fun getDeclaringType(): IType? = originElement.getDeclaringType()\n\n    override fun getAncestor(ancestorType: Int): IJavaElement? = originElement.getAncestor(ancestorType)\n\n    override fun delete(force: Boolean, monitor: IProgressMonitor?) {\n        originElement.delete(force, monitor)\n    }\n\n    override fun getSuperInterfaceNames(): Array<out String>? = originElement.getSuperInterfaceNames()\n\n    override fun getJavaModel(): JavaModel = originElement.getJavaModel() as JavaModel\n\n    override fun getParent(): JavaElement = originElement.getParent() as JavaElement\n\n    override fun getChildren(): Array<out IJavaElement>? = originElement.getChildren()\n\n    override fun equals(other: Any?): Boolean = originElement.equals(other)\n\n    override fun getTypeParameter(name: String?): ITypeParameter? = originElement.getTypeParameter(name)\n\n    override fun getType(name: String?, occurrenceCount: Int): IType? = originElement.getType(name, occurrenceCount)\n\n    override fun getType(name: String?): IType? = originElement.getType(name)\n\n    override fun getClassFile() = originElement.getClassFile()\n\n    override fun getTypeParameterSignatures(): Array<out String>? = originElement.getTypeParameterSignatures()\n\n    override fun isClass(): Boolean = originElement.isClass()\n\n    override fun isResolved(): Boolean = originElement.isResolved()\n\n    override fun getKey(): String? = originElement.getKey()\n\n    override fun getAnnotation(name: String?): IAnnotation? = originElement.getAnnotation(name)\n\n    override fun createMethod(contents: String?, sibling: IJavaElement?, force: Boolean, monitor: IProgressMonitor?): IMethod? {\n        return originElement.createMethod(contents, sibling, force, monitor)\n    }\n\n    override fun getJavaProject(): JavaProject = originElement.getJavaProject() as JavaProject\n\n    override fun move(container: IJavaElement?, sibling: IJavaElement?, rename: String?, replace: Boolean, monitor: IProgressMonitor?) {\n        originElement.move(container, sibling, rename, replace, monitor)\n    }\n\n    override fun getTypes(): Array<out IType>? = originElement.getTypes()\n\n    override fun isLocal(): Boolean = originElement.isLocal()\n\n    override fun getFullyQualifiedName(enclosingTypeSeparator: Char): String? {\n        return originElement.getFullyQualifiedName(enclosingTypeSeparator)\n    }\n\n    override fun getFullyQualifiedName(): String? = originElement.getFullyQualifiedName()\n\n    override fun getElementName(): String? = originElement.getElementName()\n}\n\nclass KotlinLightFunction(val originMethod: IMethod) : IMethod by originMethod {\n    override fun getDeclaringType(): IType? {\n        val declaringType = originMethod.getDeclaringType()\n        return KotlinLightType(declaringType)\n    }\n    \n    override fun getCompilationUnit(): ICompilationUnit? = getLightCompilationUnit(originMethod)\n    \n    override fun getNameRange(): ISourceRange = DUMMY_NAME_RANGE\n\n    override fun getPrimaryElement(): IJavaElement? = originMethod\n\n    override fun isBinary(): Boolean = false\n\n    override fun isReadOnly(): Boolean = false\n}\n\nclass KotlinLightCompilationUnit(val file: IFile, compilationUnit: ICompilationUnit) : ICompilationUnit by compilationUnit,\n       ContentProviderCompilationUnit {\n    override fun getImports(): Array<out IImportDeclaration> = emptyArray()\n\n    override fun getFileName(): CharArray? = CharOperation.NO_CHAR\n    \n    override fun getContents(): CharArray? = CharOperation.NO_CHAR\n    \n    override fun ignoreOptionalProblems(): Boolean = true\n    \n    override fun getMainTypeName(): CharArray? = CharOperation.NO_CHAR\n    \n    override fun getPackageName(): Array<out CharArray>? = null\n\n    override fun getResource(): IResource = file\n}\n\nprivate fun getLightCompilationUnit(origin: IJavaElement): ICompilationUnit? {\n    val sourceFiles = KotlinOpenEditor.findSourceFiles(origin)\n    val sourceFile = sourceFiles.firstOrNull()\n    if (sourceFile == null) return null\n    \n    val file = KotlinPsiManager.getEclipseFile(sourceFile)\n    if (file == null) return null\n    \n    val filePackage = JavaModelManager.determineIfOnClasspath(file, origin.getJavaProject())\n    return if (filePackage is PackageFragment) {\n        val compilationUnit = CompilationUnit(filePackage, file.getName(), DefaultWorkingCopyOwner.PRIMARY)\n        KotlinLightCompilationUnit(file, compilationUnit)\n    } else null\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/refactoringUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.psi.KtNamedDeclaration\nimport org.jetbrains.kotlin.psi.KtReferenceExpression\n\nfun getLengthOfIdentifier(jetElement: KtElement): Int? {\n    return when (jetElement) {\n        is KtNamedDeclaration -> jetElement.nameIdentifier!!.textLength\n        is KtReferenceExpression -> jetElement.getTextLength()\n        else -> null\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/refactorings/rename/renameParticipants.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.refactorings.rename\n\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinOnlyQuerySpecification\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\n\npublic class KotlinTypeRenameParticipant : KotlinRenameParticipant()\n\npublic class KotlinFunctionRenameParticipant : KotlinRenameParticipant()\n\npublic class KotlinLocalRenameParticipant : KotlinRenameParticipant() {\n    override fun createSearchQuery(): QuerySpecification {\n        val jetElement = element as KtElement\n        return KotlinOnlyQuerySpecification(\n                jetElement,\n                listOf(KotlinPsiManager.getEclipseFile(jetElement.getContainingKtFile())!!), \n                IJavaSearchConstants.ALL_OCCURRENCES,\n                JavaSearchScopeFactory.getInstance().getWorkspaceScopeDescription(false))\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/search/KotlinElementMatchCreator.kt",
    "content": "package org.jetbrains.kotlin.ui.search\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.eclipse.search.ui.text.Match\nimport org.jetbrains.kotlin.core.utils.getBindingContext\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor\nimport org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.calls.util.getCall\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectAction\n\ninterface KotlinElementMatchCreator {\n\n    fun createMatch(element: KtElement): Match?\n\n    companion object {\n        fun getMatchCreator(querySpecification: QuerySpecification) = when (querySpecification.limitTo) {\n            KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO -> InheritorsSearchMatchCreator\n            else -> BasicSearchMatchCreator\n        }\n    }\n}\n\nobject InheritorsSearchMatchCreator : KotlinElementMatchCreator {\n    override fun createMatch(element: KtElement): Match? {\n        val (descriptor: DeclarationDescriptor?, nameIdentifier) = when (element) {\n            is KtNamedFunction -> element.resolveToDescriptorIfAny() to element.nameIdentifier\n            is KtClass -> element.resolveToDescriptorIfAny() to element.nameIdentifier\n            is KtProperty -> element.resolveToDescriptorIfAny() to element.nameIdentifier\n            is KtObjectDeclaration -> element.resolveToDescriptorIfAny() to element.nameIdentifier\n            else -> return null\n        }\n        val tempLabel =\n            descriptor?.let { DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(it) } ?: BasicSearchMatchCreator.render(\n                element\n            )\n\n        return KotlinElementMatch(element, tempLabel, nameIdentifier ?: element)\n    }\n\n}\n\nobject BasicSearchMatchCreator : KotlinElementMatchCreator {\n\n    override fun createMatch(element: KtElement): Match {\n        return KotlinElementMatch(element, render(element), element)\n    }\n\n    fun render(element: KtElement): String {\n        val tempElement = element.getCall(element.getBindingContext())?.toString() ?: element.text\n\n        val tempParentDescriptor =\n            PsiTreeUtil.getParentOfType(element, KtDeclaration::class.java)?.resolveToDescriptorIfAny()\n\n        return buildString {\n            append(tempElement.lines().first())\n            if (tempParentDescriptor != null) {\n                append(\" in \")\n                append(DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions {\n                    modifiers = emptySet()\n                    includeAdditionalModifiers = false\n                }.render(tempParentDescriptor))\n            }\n        }\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/search/KotlinQueryParticipant.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.search\n\nimport com.intellij.psi.PsiElement\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IProject\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.IAdaptable\nimport org.eclipse.core.runtime.IProgressMonitor\nimport org.eclipse.core.runtime.ISafeRunnable\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.IType\nimport org.eclipse.jdt.core.search.IJavaSearchScope\nimport org.eclipse.jdt.internal.core.JavaModel\nimport org.eclipse.jdt.internal.ui.search.AbstractJavaSearchResult\nimport org.eclipse.jdt.internal.ui.search.JavaSearchQuery\nimport org.eclipse.jdt.ui.search.ElementQuerySpecification\nimport org.eclipse.jdt.ui.search.IQueryParticipant\nimport org.eclipse.jdt.ui.search.ISearchRequestor\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.eclipse.jface.resource.ImageDescriptor\nimport org.eclipse.jface.util.SafeRunnable\nimport org.eclipse.search.internal.ui.text.FileSearchResult\nimport org.eclipse.search.ui.ISearchResult\nimport org.eclipse.search.ui.text.FileTextSearchScope\nimport org.eclipse.search.ui.text.Match\nimport org.eclipse.search.ui.text.TextSearchQueryProvider.TextSearchInput\nimport org.eclipse.search2.internal.ui.text2.DefaultTextSearchQueryProvider\nimport org.eclipse.ui.model.IWorkbenchAdapter\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.log.KotlinLogger\nimport org.jetbrains.kotlin.core.model.sourceElementsToLightElements\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.core.resolve.lang.java.structure.EclipseJavaElementUtil\nimport org.jetbrains.kotlin.descriptors.FunctionDescriptor\nimport org.jetbrains.kotlin.descriptors.SourceElement\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.findElementByDocumentOffset\nimport org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny\nimport org.jetbrains.kotlin.lexer.KtSingleValueToken\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.name.Name\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.getParentOfType\nimport org.jetbrains.kotlin.resolve.source.KotlinSourceElement\nimport org.jetbrains.kotlin.types.expressions.OperatorConventions\nimport org.jetbrains.kotlin.ui.commands.findReferences.*\n\nclass KotlinQueryParticipant : IQueryParticipant {\n\n    private inner class DelegatedUniqueMatchSearchRequestor(\n        private val delegate: ISearchRequestor,\n        private val querySpecification: QuerySpecification\n    ) : ISearchRequestor {\n\n        private val seenMatches: MutableSet<Any> = mutableSetOf()\n        override fun reportMatch(match: Match) {\n            val tempElement = match.element\n            if ((match is KotlinElementMatch && !seenMatches.add(match.jetElement)) || (tempElement is IJavaElement && !seenMatches.add(tempElement))) return\n\n            delegate.reportMatch(match)\n\n            if (querySpecification.limitTo == KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO && match is KotlinElementMatch && match.jetElement is KtClass) {\n                val tempNewSpec = KotlinOnlyQuerySpecification(\n                    match.jetElement,\n                    querySpecification.getFilesInScope(),\n                    KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO,\n                    querySpecification.scopeDescription\n                )\n                search(this, tempNewSpec, null)\n            }\n        }\n    }\n\n    override fun search(\n        requestor: ISearchRequestor,\n        querySpecification: QuerySpecification,\n        monitor: IProgressMonitor?\n    ) {\n        SafeRunnable.run(object : ISafeRunnable {\n            override fun run() {\n                val tempRequestor =\n                    requestor as? DelegatedUniqueMatchSearchRequestor ?: DelegatedUniqueMatchSearchRequestor(\n                        requestor,\n                        querySpecification\n                    )\n                val searchElements = getSearchElements(querySpecification)\n                if (searchElements.isEmpty()) return\n\n                if (querySpecification is KotlinAndJavaSearchable) {\n                    runCompositeSearch(searchElements, tempRequestor, querySpecification, monitor)\n                    return\n                }\n\n                val kotlinFiles = getKotlinFilesByScope(querySpecification)\n                if (kotlinFiles.isEmpty()) return\n                if (monitor?.isCanceled == true) return\n\n                if (searchElements.size > 1) {\n                    KotlinLogger.logWarning(\"There are more than one elements to search: $searchElements\")\n                }\n\n                // We assume that there is only one search element, it could be IJavaElement or KtElement\n                val searchElement = searchElements.first()\n                val searchResult = searchTextOccurrences(searchElement, kotlinFiles) ?: return\n                if (monitor?.isCanceled == true) return\n\n                val elements = obtainElements(searchResult as FileSearchResult, kotlinFiles).flatMap {\n                    val tempImportAlias = it.getParentOfType<KtImportDirective>(false)?.alias\n\n                    if (tempImportAlias != null) {\n                        val tempEclipseFile = KotlinPsiManager.getEclipseFile(tempImportAlias.containingKtFile)!!\n                        val tempResult = searchTextOccurrences(\n                            SearchElement.KotlinSearchElement(tempImportAlias),\n                            listOf(tempEclipseFile)\n                        )\n                        return@flatMap obtainElements(tempResult as FileSearchResult, listOf(tempEclipseFile)) + it\n                    }\n\n                    listOf(it)\n                }\n\n                if (monitor?.isCanceled == true) return\n                val matchedReferences = resolveElementsAndMatch(elements, searchElement, querySpecification)\n                if (monitor?.isCanceled == true) return\n                matchedReferences.forEach { ktElement ->\n                    val tempCreator = KotlinElementMatchCreator.getMatchCreator(querySpecification)\n                    tempCreator.createMatch(ktElement)?.let { tempRequestor.reportMatch(it) }\n                }\n            }\n\n            override fun handleException(exception: Throwable) {\n                KotlinLogger.logError(exception)\n            }\n        })\n    }\n\n    override fun estimateTicks(specification: QuerySpecification): Int = 500\n\n    override fun getUIParticipant() = KotlinReferenceMatchPresentation()\n\n    private fun runCompositeSearch(\n        elements: List<SearchElement>, requestor: ISearchRequestor, originSpecification: QuerySpecification,\n        monitor: IProgressMonitor?\n    ) {\n\n        fun reportMatch(match: Match) {\n            val tempElement = match.element\n            if (tempElement is IJavaElement && EclipseJavaElementUtil.isFromKotlinBinFolder(tempElement)) {\n                return\n            }\n            requestor.reportMatch(match)\n        }\n\n        fun reportSearchResults(result: AbstractJavaSearchResult) {\n            for (searchElement in result.elements) {\n                result.getMatches(searchElement).forEach { match ->\n                    reportMatch(match)\n                }\n            }\n        }\n\n        val specifications = elements.map { searchElement ->\n            when (searchElement) {\n                is SearchElement.JavaSearchElement ->\n                    ElementQuerySpecification(\n                        searchElement.javaElement,\n                        originSpecification.limitTo,\n                        originSpecification.scope,\n                        originSpecification.scopeDescription\n                    )\n\n                is SearchElement.KotlinSearchElement ->\n                    KotlinOnlyQuerySpecification(\n                        searchElement.kotlinElement,\n                        originSpecification.getFilesInScope(),\n                        originSpecification.limitTo,\n                        originSpecification.scopeDescription\n                    )\n            }\n        }\n\n        for (specification in specifications) {\n            if (specification is KotlinScoped) {\n                search(requestor, specification, monitor)\n            } else if (specification is ElementQuerySpecification && specification.limitTo == KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO && specification.element is IType) {\n                //We need this workaround to find java subclasses!\n                val tempElement = specification.element as IType\n                val tempSubTypes = tempElement.newTypeHierarchy(monitor).getAllSubtypes(tempElement)\n                for (tempMatch in tempSubTypes.map { Match(it, it.nameRange.offset, it.nameRange.length) }) {\n                    reportMatch(tempMatch)\n                }\n            } else {\n                val searchQuery = JavaSearchQuery(specification)\n                searchQuery.run(monitor)\n                reportSearchResults(searchQuery.searchResult as AbstractJavaSearchResult)\n            }\n        }\n    }\n\n    sealed class SearchElement private constructor() {\n        abstract fun getSearchText(): String?\n\n        class JavaSearchElement(val javaElement: IJavaElement) : SearchElement() {\n            override fun getSearchText(): String = javaElement.elementName\n        }\n\n        class KotlinSearchElement(val kotlinElement: KtElement) : SearchElement() {\n            override fun getSearchText(): String? = kotlinElement.name\n        }\n    }\n\n\n    private fun getSearchElements(querySpecification: QuerySpecification): List<SearchElement> {\n        fun obtainSearchElements(sourceElements: List<SourceElement>): List<SearchElement> {\n            val (javaElements, kotlinElements) = getJavaAndKotlinElements(sourceElements)\n            return javaElements.map { SearchElement.JavaSearchElement(it) } +\n                    kotlinElements.map { SearchElement.KotlinSearchElement(it) }\n\n        }\n\n        return when (querySpecification) {\n            is ElementQuerySpecification -> listOf(SearchElement.JavaSearchElement(querySpecification.element))\n            is KotlinOnlyQuerySpecification -> listOf(SearchElement.KotlinSearchElement(querySpecification.kotlinElement))\n            is KotlinAndJavaSearchable -> obtainSearchElements(querySpecification.sourceElements)\n            else -> emptyList()\n        }\n    }\n\n    private fun searchTextOccurrences(searchElement: SearchElement, filesScope: List<IFile>): ISearchResult? {\n        var searchText = searchElement.getSearchText() ?: return null\n        var asRegex = false\n\n        if (searchElement is SearchElement.KotlinSearchElement) {\n            if (searchElement.kotlinElement is KtFunction) {\n                //Either it has an operator keyword directly, or it overrides something. In this case we could look in the overridden element, or we could just try to search for it!\n                if (searchElement.kotlinElement.hasModifier(KtTokens.OPERATOR_KEYWORD)) {\n                    val pair = getSearchTextAsRegex(searchText)\n                    asRegex = pair.first\n                    searchText = pair.second\n                } else if (searchElement.kotlinElement.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {\n                    val tempDescriptor = searchElement.kotlinElement.resolveToDescriptorIfAny() as? FunctionDescriptor\n                    if (tempDescriptor?.isOperator == true) {\n                        val pair = getSearchTextAsRegex(searchText)\n                        asRegex = pair.first\n                        searchText = pair.second\n                    }\n                }\n            }\n        }\n\n        val scope = FileTextSearchScope.newSearchScope(filesScope.toTypedArray(), null as Array<String?>?, false)\n\n        val query = DefaultTextSearchQueryProvider().createQuery(object : TextSearchInput() {\n            override fun isWholeWordSearch(): Boolean = !asRegex\n\n            override fun getSearchText(): String = searchText\n\n            override fun isCaseSensitiveSearch(): Boolean = true\n\n            override fun isRegExSearch(): Boolean = asRegex\n\n            override fun getScope(): FileTextSearchScope = scope\n        })\n\n        query.run(null)\n\n        return query.searchResult\n    }\n\n    private fun getSearchTextAsRegex(\n        searchText: String\n    ): Pair<Boolean, String> {\n        val tempOperationSymbol =\n            (OperatorConventions.getOperationSymbolForName(Name.identifier(searchText)) as? KtSingleValueToken)?.value?.let { \"\\\\Q$it\\\\E\" }\n                ?: when (searchText) {\n                    \"get\" -> \"\\\\[.*?]\"\n                    \"set\" -> \"\\\\[.*?]\\\\s*?=\"\n                    \"invoke\" -> \"\\\\(.*?\\\\)\"\n                    \"contains\" -> \"in|!in\"\n                    \"getValue\", \"setValue\", \"provideDelegate\" -> \"by\"\n                    else -> null\n                }\n        if (tempOperationSymbol != null) {\n            return Pair(true, \"(\\\\b$searchText\\\\b|$tempOperationSymbol)\")\n        }\n        return Pair(false, searchText)\n    }\n\n    private fun resolveElementsAndMatch(\n        elements: List<KtElement>, searchElement: SearchElement,\n        querySpecification: QuerySpecification\n    ): List<KtElement> {\n        val beforeResolveFilters = getBeforeResolveFilters(querySpecification)\n        val afterResolveFilters = getAfterResolveFilters(querySpecification)\n        val mapper = SearchParentObjectMapper.getMapper(querySpecification)\n\n        // This is important for optimization: \n        // we will consequentially cache files one by one which do contain these references\n        val sortedByFileNameElements = elements.sortedBy { it.containingKtFile.name }\n\n        return sortedByFileNameElements.flatMap { element ->\n            val tempElement = findApplicableElement(element, beforeResolveFilters, mapper) ?: return@flatMap emptyList()\n\n            val sourceElements = tempElement.resolveToSourceDeclaration()\n            if (sourceElements.isEmpty()) return@flatMap emptyList()\n\n            val additionalElements = getContainingClassOrObjectForConstructor(sourceElements)\n\n            if (afterResolveFilters.all { it.isApplicable(sourceElements, searchElement) } ||\n                afterResolveFilters.all { it.isApplicable(additionalElements, searchElement) }) {\n                return@flatMap listOf(tempElement)\n            }\n            emptyList()\n        }\n    }\n\n    private fun findApplicableElement(\n        element: KtElement, beforeResolveFilters: List<SearchFilter>, mapper: SearchParentObjectMapper\n    ): KtElement? {\n        if (beforeResolveFilters.all { it.isApplicable(element) }) return element\n        return mapper.map(element)?.takeIf { refExp ->\n            beforeResolveFilters.all { it.isApplicable(refExp) }\n        }\n    }\n\n    private fun obtainElements(searchResult: FileSearchResult, files: List<IFile>): List<KtElement> {\n        val elements = ArrayList<KtElement>()\n        for (file in files) {\n            val matches = searchResult.getMatches(file)\n            val jetFile = KotlinPsiManager.getParsedFile(file)\n            val document = EditorUtil.getDocument(file)\n\n            matches\n                .map { match ->\n                    val element = jetFile.findElementByDocumentOffset(match.offset, document)\n                    element?.let { PsiTreeUtil.getNonStrictParentOfType(it, KtElement::class.java) }\n                }\n                .filterNotNullTo(elements)\n        }\n\n        return elements\n    }\n\n    private fun getKotlinFilesByScope(querySpecification: QuerySpecification): List<IFile> {\n        return when (querySpecification) {\n            is ElementQuerySpecification,\n            is KotlinJavaQuerySpecification -> querySpecification.scope.getKotlinFiles()\n            is KotlinScoped -> querySpecification.searchScope\n            else -> emptyList()\n        }\n    }\n}\n\nfun getContainingClassOrObjectForConstructor(sourceElements: List<SourceElement>): List<SourceElement> {\n    return sourceElements.mapNotNull {\n        if (it is KotlinSourceElement) {\n            val psi = it.psi\n            if (psi is KtConstructor<*>) {\n                return@mapNotNull KotlinSourceElement(psi.getContainingClassOrObject())\n            }\n        }\n\n        null\n    }\n}\n\nfun getJavaAndKotlinElements(\n    sourceElements: List<SourceElement>\n): Pair<List<IJavaElement>, List<KtElement>> {\n    val javaElements = sourceElementsToLightElements(sourceElements)\n    val kotlinElements = sourceElementsToKotlinElements(sourceElements)\n    return Pair(javaElements, kotlinElements)\n}\n\nprivate fun sourceElementsToKotlinElements(sourceElements: List<SourceElement>): List<KtElement> {\n    return sourceElements\n        .filterIsInstance(KotlinSourceElement::class.java)\n        .map { it.psi }\n}\n\nfun IJavaSearchScope.getKotlinFiles(): List<IFile> {\n    return enclosingProjectsAndJars()\n        .map { JavaModel.getTarget(it, true) }\n        .filterIsInstance(IProject::class.java)\n        .flatMap { KotlinPsiManager.getFilesByProject(it) }\n}\n\nfun QuerySpecification.getFilesInScope(): List<IFile> {\n    return when (this) {\n        is KotlinScoped -> this.searchScope\n        else -> this.scope.getKotlinFiles()\n    }\n}\n\nclass KotlinElementMatch(val jetElement: KtElement, val label: String, val identifier: PsiElement) :\n    Match(KotlinAdaptableElement(jetElement, label), identifier.textOffset, identifier.textLength)\n\nclass KotlinAdaptableElement(val jetElement: KtElement, val label: String) : IAdaptable {\n    @Suppress(\"UNCHECKED_CAST\")\n    override fun <T> getAdapter(adapter: Class<T>?): T? {\n        return when {\n            IResource::class.java == adapter ->\n                KotlinPsiManager.getEclipseFile(jetElement.containingKtFile) as T\n            IWorkbenchAdapter::class.java == adapter ->\n                object : IWorkbenchAdapter {\n                    override fun getChildren(p0: Any?): Array<Any> = emptyArray()\n\n                    override fun getImageDescriptor(p0: Any?): ImageDescriptor? = null\n\n                    override fun getLabel(p0: Any?): String = label\n\n                    override fun getParent(p0: Any?): Any? =\n                        KotlinPsiManager.getEclipseFile(jetElement.containingKtFile)\n\n                } as T\n            else -> null\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/search/KotlinReferenceMatchPresentation.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.search\n\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.eclipse.jdt.ui.search.IMatchPresentation\nimport org.eclipse.jface.viewers.ILabelProvider\nimport org.eclipse.jface.viewers.LabelProvider\nimport org.eclipse.search.internal.ui.text.EditorOpener\nimport org.eclipse.search.ui.text.Match\nimport org.eclipse.swt.graphics.Image\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.core.asJava.getTypeFqName\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.KotlinImageProvider\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport org.jetbrains.kotlin.psi.*\n\nclass KotlinReferenceMatchPresentation : IMatchPresentation {\n    private val editorOpener = EditorOpener()\n    \n    override fun createLabelProvider(): ILabelProvider = KotlinReferenceLabelProvider()\n    \n    override fun showMatch(match: Match, currentOffset: Int, currentLength: Int, activate: Boolean) {\n        if (match !is KotlinElementMatch) return \n        \n        val identifier = match.identifier\n        val element = match.jetElement\n        val eclipseFile = KotlinPsiManager.getEclipseFile(element.containingKtFile)\n        if (eclipseFile != null) {\n            val document = EditorUtil.getDocument(eclipseFile)\n            editorOpener.openAndSelect(\n                PlatformUI.getWorkbench().activeWorkbenchWindow.activePage,\n                eclipseFile,\n                identifier.getTextDocumentOffset(document),\n                identifier.textLength,\n                activate\n            )\n        }\n    }\n}\n\nclass KotlinReferenceLabelProvider : LabelProvider() {\n    override fun getText(element: Any): String {\n        if (element !is KotlinAdaptableElement) {\n            throw IllegalArgumentException(\"KotlinReferenceLabelProvider asked for non-reference expression: $element\")\n        }\n\n        return when (val declaration = getContainingDeclaration(element.jetElement)) {\n            is KtNamedDeclaration -> with (declaration) {\n                fqName?.asString() ?: nameAsSafeName.asString()\n            }\n            is KtFile -> getTypeFqName(declaration)?.asString() ?: \"\"\n            else -> \"\"\n        }\n    }\n    \n    override fun getImage(element: Any): Image? {\n        val jetElement = (element as KotlinAdaptableElement).jetElement\n        val containingDeclaration = getContainingDeclaration(jetElement)\n        return containingDeclaration?.let { KotlinImageProvider.getImage(it) }\n    }\n    \n    private fun getContainingDeclaration(jetElement: KtElement): KtElement? {\n        return PsiTreeUtil.getNonStrictParentOfType(jetElement, \n                KtNamedFunction::class.java,\n                KtProperty::class.java,\n                KtClassOrObject::class.java,\n                KtFile::class.java)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/search/SearchParentObjectMapper.kt",
    "content": "package org.jetbrains.kotlin.ui.search\n\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.getParentOfType\nimport org.jetbrains.kotlin.psi.psiUtil.getParentOfTypes\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectAction\n\nfun interface SearchParentObjectMapper {\n\n    fun map(element: KtElement): KtElement?\n\n    companion object {\n        fun getMapper(querySpecification: QuerySpecification): SearchParentObjectMapper =\n            when (querySpecification.limitTo) {\n                IJavaSearchConstants.REFERENCES -> ReferencesParentObjectMapper\n                KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO -> ImplementationsParentObjectMapper\n                else -> NO_MAPPING\n            }\n\n        private val NO_MAPPING = SearchParentObjectMapper { null }\n    }\n}\n\nobject ReferencesParentObjectMapper : SearchParentObjectMapper {\n    override fun map(element: KtElement): KtElement? = element.getParentOfType<KtReferenceExpression>(false)\n}\n\nobject ImplementationsParentObjectMapper : SearchParentObjectMapper {\n    override fun map(element: KtElement): KtElement? =\n        element.getParentOfTypes(\n            false,\n            KtClass::class.java,\n            KtObjectDeclaration::class.java,\n            KtProperty::class.java,\n            KtNamedFunction::class.java\n        )\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/search/searchFilters.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.search\n\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.IMethod\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.psi.*\nimport org.jetbrains.kotlin.psi.psiUtil.isImportDirectiveExpression\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.resolve.descriptorUtil.isSubclassOf\nimport org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence\nimport org.jetbrains.kotlin.ui.commands.findReferences.KotlinFindImplementationsInProjectAction\nimport org.jetbrains.kotlin.ui.search.KotlinQueryParticipant.SearchElement\nimport org.jetbrains.kotlin.ui.search.KotlinQueryParticipant.SearchElement.JavaSearchElement\nimport org.jetbrains.kotlin.ui.search.KotlinQueryParticipant.SearchElement.KotlinSearchElement\nimport org.jetbrains.kotlin.utils.findCurrentDescriptor\n\ninterface SearchFilter {\n    fun isApplicable(jetElement: KtElement): Boolean\n}\n\ninterface SearchFilterAfterResolve {\n    fun isApplicable(sourceElement: KtElement, originElement: KtElement): Boolean\n\n    fun isApplicable(sourceElement: IJavaElement, originElement: IJavaElement): Boolean\n\n    fun isApplicable(\n        sourceElements: List<SourceElement>,\n        originElement: SearchElement\n    ): Boolean {\n        val (javaElements, kotlinElements) = getJavaAndKotlinElements(sourceElements)\n        return when (originElement) {\n            is JavaSearchElement -> javaElements.any { isApplicable(it, originElement.javaElement) }\n            is KotlinSearchElement -> kotlinElements.any { isApplicable(it, originElement.kotlinElement) }\n        }\n    }\n}\n\nfun getBeforeResolveFilters(querySpecification: QuerySpecification): List<SearchFilter> =\n    when (querySpecification.limitTo) {\n        IJavaSearchConstants.REFERENCES -> listOf(NonImportFilter, ElementWithPossibleReferencesFilter)\n        KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO -> listOf(\n            NonImportFilter,\n            PossibleOverridingMemberFilter\n        )\n        else -> emptyList()\n    }\n\nfun getAfterResolveFilters(querySpecification: QuerySpecification): List<SearchFilterAfterResolve> =\n    when (querySpecification.limitTo) {\n        KotlinFindImplementationsInProjectAction.IMPLEMENTORS_LIMIT_TO -> listOf(InheritorsFilter)\n        else -> listOf(ResolvedReferenceFilter)\n    }\n\nobject ElementWithPossibleReferencesFilter : SearchFilter {\n    override fun isApplicable(jetElement: KtElement): Boolean =\n        jetElement is KtReferenceExpression || (jetElement is KtPropertyDelegate)\n}\n\nobject PossibleOverridingMemberFilter : SearchFilter {\n\n    override fun isApplicable(jetElement: KtElement): Boolean {\n        return jetElement is KtClass || jetElement is KtNamedFunction || jetElement is KtProperty || jetElement is KtObjectDeclaration\n    }\n}\n\nobject NonImportFilter : SearchFilter {\n    override fun isApplicable(jetElement: KtElement): Boolean {\n        return jetElement !is KtSimpleNameExpression || !jetElement.isImportDirectiveExpression()\n    }\n}\n\nobject InheritorsFilter : SearchFilterAfterResolve {\n    override fun isApplicable(sourceElement: KtElement, originElement: KtElement): Boolean {\n        if (originElement is KtClass && (sourceElement !is KtClass && sourceElement !is KtObjectDeclaration)) return false\n        if (originElement is KtProperty && sourceElement !is KtProperty) return false\n        if (originElement is KtNamedFunction && sourceElement !is KtNamedFunction) return false\n\n        val (tempSourceModuleDescriptor, tempSourceDescriptor) = sourceElement.tryGetDescriptor()\n        val (_, tempOriginDescriptor) = originElement.tryGetDescriptor()\n\n        if (tempSourceDescriptor == null || tempOriginDescriptor == null) return false\n\n        val tempCurrentOriginDescriptor =\n            tempSourceModuleDescriptor.findCurrentDescriptor(tempOriginDescriptor) ?: return false\n        val tempCurrentSourceDescriptor =\n            tempSourceModuleDescriptor.findCurrentDescriptor(tempSourceDescriptor) ?: return false\n\n        if (tempCurrentOriginDescriptor == tempCurrentSourceDescriptor) return false\n\n        return if (tempCurrentSourceDescriptor is ClassDescriptor && tempCurrentOriginDescriptor is ClassDescriptor) {\n            return tempCurrentSourceDescriptor.isSubclassOf(tempCurrentOriginDescriptor)\n        } else {\n            val tempOverriddenDescriptors = when (tempSourceDescriptor) {\n                is FunctionDescriptor -> tempSourceDescriptor.overriddenTreeUniqueAsSequence(false).toList()\n                is PropertyDescriptor -> tempSourceDescriptor.overriddenTreeUniqueAsSequence(false).toList()\n                else -> return false\n            }.mapNotNull {\n                tempSourceModuleDescriptor.findCurrentDescriptor(it)\n            }\n\n            tempSourceModuleDescriptor.findCurrentDescriptor(tempOriginDescriptor) in tempOverriddenDescriptors\n        }\n    }\n\n    private fun KtElement.tryGetDescriptor(): Pair<ModuleDescriptor, DeclarationDescriptor?> {\n        val (bindingContext, moduleDescriptor) = KotlinAnalyzer.analyzeFile(containingKtFile).analysisResult\n        return Pair(moduleDescriptor, bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this])\n    }\n\n    override fun isApplicable(sourceElement: IJavaElement, originElement: IJavaElement): Boolean = false\n}\n\nobject ResolvedReferenceFilter : SearchFilterAfterResolve {\n    override fun isApplicable(sourceElement: KtElement, originElement: KtElement): Boolean {\n        return sourceElement == originElement || InheritorsFilter.isApplicable(sourceElement, originElement)\n    }\n\n    override fun isApplicable(sourceElement: IJavaElement, originElement: IJavaElement): Boolean {\n        return referenceFilter(sourceElement, originElement)\n    }\n\n    private fun referenceFilter(potentialElement: IJavaElement, originElement: IJavaElement): Boolean {\n        return when {\n            originElement.isConstructorCall() && potentialElement.isConstructorCall() -> {\n                (originElement as IMethod).declaringType == (potentialElement as IMethod).declaringType\n            }\n\n            originElement.isConstructorCall() -> {\n                (originElement as IMethod).declaringType == potentialElement\n            }\n\n            potentialElement.isConstructorCall() -> {\n                originElement == (potentialElement as IMethod).declaringType\n            }\n\n            else -> potentialElement == originElement\n        }\n    }\n\n    private fun IJavaElement.isConstructorCall() = this is IMethod && isConstructor\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/utils/DescriptorUtils.kt",
    "content": "package org.jetbrains.kotlin.utils\n\nimport org.jetbrains.kotlin.descriptors.*\nimport org.jetbrains.kotlin.name.ClassId\nimport org.jetbrains.kotlin.renderer.DescriptorRenderer\nimport org.jetbrains.kotlin.resolve.descriptorUtil.classId\nimport org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter\nimport org.jetbrains.kotlin.resolve.scopes.MemberScope\nimport org.jetbrains.kotlin.resolve.scopes.MemberScope.Companion.ALL_NAME_FILTER\n\nprivate fun ModuleDescriptor.findCurrentDescriptorForMember(originalDescriptor: MemberDescriptor): DeclarationDescriptor? {\n    val containingDeclaration = findCurrentDescriptor(originalDescriptor.containingDeclaration)\n    val memberScope = containingDeclaration?.memberScope ?: return null\n\n    val renderedOriginal: String = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(originalDescriptor)\n    val descriptors: Collection<DeclarationDescriptor> =\n        if (originalDescriptor is ConstructorDescriptor && containingDeclaration is ClassDescriptor) {\n        containingDeclaration.constructors\n    } else {\n        memberScope.getContributedDescriptors(DescriptorKindFilter.ALL, ALL_NAME_FILTER)\n    }\n    for (member in descriptors) {\n        if (renderedOriginal == DescriptorRenderer.FQ_NAMES_IN_TYPES.render(member)) {\n            return member\n        }\n    }\n    return null\n}\n\nfun ModuleDescriptor.findCurrentDescriptor(originalDescriptor: DeclarationDescriptor): DeclarationDescriptor? {\n    if (originalDescriptor is ClassDescriptor) {\n        val classId: ClassId = originalDescriptor.classId ?: return null\n        return findClassAcrossModuleDependencies(classId)\n    }\n    if (originalDescriptor is PackageFragmentDescriptor) {\n        return getPackage(originalDescriptor.fqName)\n    }\n    return if (originalDescriptor is MemberDescriptor) {\n        findCurrentDescriptorForMember(originalDescriptor)\n    } else null\n}\n\nprivate val DeclarationDescriptor.memberScope: MemberScope? get() = when (this) {\n    is ClassDescriptor -> defaultType.memberScope\n    is PackageFragmentDescriptor -> getMemberScope()\n    else -> null\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/utils/LazyObservable.kt",
    "content": "package org.jetbrains.kotlin.utils\n\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KProperty\n\nclass LazyObservable<T>(\n        initialValueProvider: () -> T,\n        private val onChange: (KProperty<*>, T, T) -> Unit\n) : ReadWriteProperty<Any?, T> {\n    private var overridden: Boolean = false\n\n    private var container: Any? = lazy(LazyThreadSafetyMode.NONE, initialValueProvider)\n\n    @Suppress(\"UNCHECKED_CAST\")\n    override fun getValue(thisRef: Any?, property: KProperty<*>) =\n            if (!overridden)\n                (container as Lazy<T>).getValue(thisRef, property)\n            else\n                container as T\n\n    override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {\n        val oldValue = getValue(thisRef, property)\n        overridden = true\n        container = value\n        onChange(property, oldValue, value)\n    }\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/utils/ThrowableExtensions.kt",
    "content": "package org.jetbrains.kotlin.utils\n\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.core.runtime.MultiStatus\n\nval Throwable.errorTitleForMessageDialog: String\n    get() = localizedMessage\n\nval Throwable.errorDescriptionForMessageDialog: String\n    get() = when (this) {\n        is CoreException -> when (status) {\n            is MultiStatus -> join(status.children.filterNot { it.isOK }.map { it.message }, \"\\n\")\n            else -> status.message\n        }\n        else -> localizedMessage\n    }"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/AbstractWizard.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.wizard.Wizard;\nimport org.eclipse.ui.INewWizard;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;\n\npublic abstract class AbstractWizard<WP extends AbstractWizardPage> extends Wizard implements INewWizard {\n\n    public static final String ERROR_MESSAGE = \"Error\";\n\n    private IWorkbench workbench;\n    private IStructuredSelection selection;\n    private WP page;\n\n    public IWorkbench getWorkbench() {\n        return workbench;\n    }\n\n    public IStructuredSelection getStructuredSelection() {\n        return selection;\n    }\n\n    public WP getWizardPage() {\n        return page;\n    }\n\n    protected abstract String getPageTitle();\n\n    protected abstract WP createWizardPage();\n\n    @Override\n    public void init(IWorkbench workbench, IStructuredSelection selection) {\n        this.workbench = workbench;\n        this.selection = selection;\n\n        setWindowTitle(getPageTitle());\n    }\n\n    @Override\n    public void addPages() {\n        super.addPages();\n\n        if (page == null) {\n            page = createWizardPage();\n        }\n\n        addPage(page);\n    }\n\n    protected static void selectAndRevealResource(IResource resource) {\n        BasicNewResourceWizard.selectAndReveal(resource, PlatformUI.getWorkbench().getActiveWorkbenchWindow());\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/AbstractWizardPage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createComposite;\n\nimport org.eclipse.core.resources.IWorkspaceRoot;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.jface.wizard.IWizardPage;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.widgets.Composite;\n\npublic abstract class AbstractWizardPage extends WizardPage implements IWizardPage {\n    \n    protected static final String BROWSE_BUTTON_TITLE = \"Browse...\";\n\n    protected AbstractWizardPage(String title, String description) {\n        super(title);\n        super.setTitle(title);\n        super.setDescription(description);\n    }\n\n    @Override\n    public void createControl(Composite parent) {\n        initializeDialogUnits(parent);\n\n        Composite composite = createComposite(parent);\n        createControls(composite);\n        setControl(composite);\n\n        setPageComplete(false);\n    }\n\n    protected abstract void createControls(Composite composite);\n\n    protected abstract String createErrorMessage();\n\n    protected final void validate() {\n        String errorMessage = createErrorMessage();\n\n        setErrorMessage(errorMessage);\n        setPageComplete(errorMessage == null);\n    }\n\n    protected abstract boolean resourceAlreadyExists();\n\n    protected static IWorkspaceRoot getWorkspaceRoot() {\n        return ResourcesPlugin.getWorkspace().getRoot();\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/FileCreationOp.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport static org.eclipse.ui.ide.undo.WorkspaceUndoUtil.getUIInfoAdapter;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.File;\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jface.operation.IRunnableWithProgress;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.ide.undo.CreateFileOperation;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.idea.KotlinFileType;\n\npublic class FileCreationOp implements IRunnableWithProgress {\n    \n    private final static String EXT = \".\" + KotlinFileType.INSTANCE.getDefaultExtension();\n    \n    private final IPackageFragmentRoot sourceDir;\n    private final IPackageFragment packageFragment;\n    private final String unitName;\n    private final String contents;\n    private final Shell shell;\n    \n    private IFile result;\n    \n    public FileCreationOp(IPackageFragmentRoot sourceDir, IPackageFragment packageFragment, String unitName, String contents,\n            Shell shell) {\n        this.sourceDir = sourceDir;\n        this.packageFragment = packageFragment;\n        this.contents = contents;\n        this.shell = shell;\n        this.unitName = unitName;\n    }\n    \n    public IFile getResult() {\n        return result;\n    }\n    \n    @Override\n    public void run(IProgressMonitor monitor) throws InvocationTargetException {\n        result = makeFile(packageFragment, sourceDir, unitName);\n        try {\n            if (!result.exists()) {\n                CreateFileOperation op = new CreateFileOperation(result, null, null, \"Create Kotlin Source File\");\n                PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor,\n                        getUIInfoAdapter(shell));\n                result.appendContents(new ByteArrayInputStream(contents.getBytes()), false, false, monitor);\n            } else {\n                result = null;\n            }\n        } catch (ExecutionException e) {\n            KotlinLogger.logAndThrow(e);\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    static String getCompilationUnitName(String name) {\n        if (name.endsWith(EXT)) {\n            return name;\n        }\n        \n        return name + EXT;\n    }\n    \n    static String getSimpleUnitName(String name) {\n        if (name.endsWith(EXT)) {\n            return name.substring(0, name.length() - EXT.length());\n        }\n        \n        return name;\n    }\n    \n    static String getExtensionRegexp() {\n        return \"(\\\\\" + EXT + \")?\";\n    }\n    \n    public static IFile makeFile(IPackageFragment packageFragment, IPackageFragmentRoot sourceDir, String unitName) {\n        IPath path = packageFragment.getPath().append(getCompilationUnitName(unitName));\n        IProject project = sourceDir.getJavaProject().getProject();\n        \n        return project.getFile(path.makeRelativeTo(project.getFullPath()));\n    }\n    \n    static boolean fileExists(IFile file) {\n        return new File(file.getRawLocation().toOSString()).exists();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/NewProjectWizard.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.jetbrains.kotlin.core.model.KotlinNature;\nimport org.jetbrains.kotlin.utils.ThrowableExtensionsKt;\n\npublic class NewProjectWizard extends AbstractWizard<NewProjectWizardPage> {\n\n    private static final String TITLE = \"Kotlin project\";\n    private static final String DESCRIPTION = \"Create a new Kotlin project\";\n\n    @Override\n    public boolean performFinish() {\n        NewProjectWizardPage page = getWizardPage();\n        \n        ProjectCreationOp op = new ProjectCreationOp(page.getProjectName(), page.getProjectLocation(), getShell());\n        try {\n            getContainer().run(true, true, op);\n        } catch (InvocationTargetException e) {\n            MessageDialog.openError(getShell(), AbstractWizard.ERROR_MESSAGE, e.getMessage());\n            return false;\n        } catch (InterruptedException e) {\n            return false;\n        }\n\n        ProjectCreationOp.OperationResult result = op.getResult();\n        if (result.isSuccess()) {\n            KotlinNature.Companion.addNature(result.getProject());\n            selectAndRevealResource(result.getProject());\n            return true;\n        } else {\n            MessageDialog.openError(getShell(),\n                    ThrowableExtensionsKt.getErrorTitleForMessageDialog(result.getException()),\n                    ThrowableExtensionsKt.getErrorDescriptionForMessageDialog(result.getException()));\n            return false;\n        }\n    }\n\n    @Override\n    protected String getPageTitle() {\n        return TITLE;\n    }\n\n    @Override\n    protected NewProjectWizardPage createWizardPage() {\n        return new NewProjectWizardPage(TITLE, DESCRIPTION);\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/NewProjectWizardPage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createButton;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createCheckbox;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createEmptySpace;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createGroup;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createLabel;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.createText;\n\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.DirectoryDialog;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Text;\n\npublic class NewProjectWizardPage extends AbstractWizardPage {\n\n    private static final String DEFAULT_PROJECT_NAME = \"\";\n    private static final String DEFAULT_PROJECT_LOCATION = \"\";\n\n    private static final String PROJECT_NAME_LABEL_TITLE = \"Project name\";\n    private static final String LOCATION_GROUP_TITLE = \"Location\";\n    private static final String PROJECT_LOCATION_CHECKBOX_TITLE = \"Use default location\";\n    private static final String PROJECT_LOCATION_LABEL_TITLE = \"Project location\";\n\n    private static final String EMPTY_PROJECT_NAME_MESSAGE = \"Please enter a project name\";\n    private static final String EMPTY_PROJECT_LOCATION_MESSAGE = \"Please enter a project location\";\n    private static final String PROJECT_EXISTS_MESSAGE = \"Project already exists\";\n\n    private String projectName;\n    private String projectLocation;\n\n    protected NewProjectWizardPage(String title, String description) {\n        super(title, description);\n\n        projectName = DEFAULT_PROJECT_NAME;\n        projectLocation = getOSWorkspaceLocation();\n    }\n\n    public String getProjectName() {\n        return projectName;\n    }\n\n    public String getProjectLocation() {\n        return projectLocation;\n    }\n\n    @Override\n    protected void createControls(Composite parent) {\n        Text projectName = createNameField(parent);\n        projectName.forceFocus();       \n\n        Group group = createGroup(parent, LOCATION_GROUP_TITLE);\n\n        final Button checkbox = createCheckbox(group, PROJECT_LOCATION_CHECKBOX_TITLE);\n        checkbox.setSelection(true);\n\n        final Text locationField = createLocationField(group);\n        locationField.setEnabled(false);\n\n        checkbox.addSelectionListener(new SelectionAdapter() {\n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                boolean selection = checkbox.getSelection();\n\n                locationField.setText(selection ? DEFAULT_PROJECT_LOCATION : projectLocation);\n                if (selection) {\n                    projectLocation = getOSWorkspaceLocation();\n                }\n\n                locationField.setEnabled(!selection);\n            }\n        });\n    }\n\n    private Text createNameField(Composite parent) {\n        createLabel(parent, PROJECT_NAME_LABEL_TITLE);\n\n        final Text nameText = createText(parent, DEFAULT_PROJECT_NAME);\n        nameText.addModifyListener(new ModifyListener() {\n            @Override\n            public void modifyText(ModifyEvent e) {\n                projectName = nameText.getText();\n                validate();\n            }\n        });\n\n        createEmptySpace(parent);\n\n        return nameText;\n    }\n\n    private Text createLocationField(Composite parent) {\n        createLabel(parent, PROJECT_LOCATION_LABEL_TITLE);\n\n        final Text locationText = createText(parent, DEFAULT_PROJECT_LOCATION);\n        locationText.addModifyListener(new ModifyListener() {\n            @Override\n            public void modifyText(ModifyEvent e) {\n                projectLocation = locationText.getText();\n                validate();\n            }\n        });\n\n        createButton(parent, BROWSE_BUTTON_TITLE, new SelectionAdapter() {\n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                DirectoryDialog dd = new DirectoryDialog(getShell(), SWT.OPEN);\n                dd.setFilterPath(locationText.getText());\n\n                String directoryPath = dd.open();\n                if (directoryPath != null) {\n                    projectLocation = directoryPath;\n                    locationText.setText(directoryPath);\n                }\n\n                validate();\n            }\n        });\n\n        return locationText;\n    }\n\n    @Override\n    protected String createErrorMessage() {\n        if (projectName.isEmpty()) {\n            return EMPTY_PROJECT_NAME_MESSAGE;\n        } else if (projectLocation.isEmpty()) {\n            return EMPTY_PROJECT_LOCATION_MESSAGE;\n        } else if (resourceAlreadyExists()) {\n            return PROJECT_EXISTS_MESSAGE;\n        } else {\n            return null;\n        }\n    }\n\n    @Override\n    protected boolean resourceAlreadyExists() {\n        for (IProject project : getWorkspaceRoot().getProjects()) {\n            if (project.getName().equals(projectName)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    private static String getOSWorkspaceLocation() {\n        return getWorkspaceRoot().getLocation().toOSString();\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/NewUnitWizard.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.jdt.core.IPackageFragment;\nimport org.eclipse.jdt.core.IPackageFragmentRoot;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.operation.IRunnableContext;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.ide.IDE;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.model.KotlinNature;\nimport org.jetbrains.kotlin.ui.launch.KotlinRuntimeConfigurator;\n\npublic class NewUnitWizard extends AbstractWizard<NewUnitWizardPage> {\n    \n    private static final String TITLE_FORMAT = \"Kotlin %s File\";\n    private static final String DESCRIPTION_FORMAT = \"Create a new Kotlin %s file\";\n    \n    private static final String DEFAULT_FILE_NAME = \"\";\n    private static final String DEFAULT_PACKAGE_NAME = \"\";\n    private static final String DEFAULT_TYPE_BODY = \"\";\n    private static final String PACKAGE_FORMAT = \"package %s\\n\\n\";\n    \n    private final WizardType type;\n\n    private boolean isDynamicType;\n    \n    public NewUnitWizard() {\n        this(WizardType.NONE);\n        isDynamicType = true;\n    }\n    \n    public NewUnitWizard(WizardType type) {\n        this.type = type;\n    }\n    \n    @Override\n    public boolean performFinish() {\n        NewUnitWizardPage wizardPage = getWizardPage();\n        WizardType finalType;\n        if(isDynamicType) {\n            finalType = wizardPage.getType();\n        } else {\n            finalType = type;\n        }\n        String contents = createPackageHeader() + createTypeBody(finalType);\n        \n        IFile kotlinSourceFile;\n        try {\n            kotlinSourceFile = createKotlinSourceFile(\n                    wizardPage.getSourceDir(), \n                    wizardPage.getPackageFragment(), \n                    wizardPage.getUnitName(), \n                    contents, \n                    getShell(), \n                    getContainer());\n        } catch (InvocationTargetException e) {\n            MessageDialog.openError(getShell(), AbstractWizard.ERROR_MESSAGE, e.getMessage());\n            return false;\n        } catch (InterruptedException e) {\n            return false;\n        }\n        \n        if (kotlinSourceFile != null) {\n            selectAndRevealResource(kotlinSourceFile);\n            openFile(kotlinSourceFile);\n        }\n        \n        return true;\n    }\n    \n    protected static void openFile(IFile file) {\n        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n        try {\n            if (window != null) {\n                IWorkbenchPage page = window.getActivePage();\n                \n                if (page != null) {\n                    IDE.openEditor(page, file, true);\n                }\n            }\n        } catch (PartInitException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    @Override\n    protected String getPageTitle() {\n        return String.format(TITLE_FORMAT, type.getWizardTypeName());\n    }\n    \n    @Override\n    protected NewUnitWizardPage createWizardPage() {\n        return new NewUnitWizardPage(getPageTitle(), String.format(DESCRIPTION_FORMAT,\n                type.getWizardTypeName().toLowerCase()), DEFAULT_FILE_NAME, getStructuredSelection(), isDynamicType);\n    }\n    \n    @Nullable\n    public static IFile createKotlinSourceFile(\n            @NotNull IPackageFragmentRoot root,\n            @NotNull IPackageFragment packageFragment,\n            @NotNull String fileName,\n            @NotNull String contents,\n            @NotNull Shell shell,\n            @NotNull IRunnableContext runnableContext) throws InvocationTargetException, InterruptedException {\n        FileCreationOp operation = new FileCreationOp(root, packageFragment, fileName, contents, shell);\n        runnableContext.run(true, true, operation);\n        \n        IProject project = root.getJavaProject().getProject();\n        \n        KotlinNature.Companion.addNature(project);\n        KotlinRuntimeConfigurator.Companion.suggestForProject(project);\n        \n        return operation.getResult();\n    }\n    \n    private String createTypeBody(WizardType finalType) {\n        if (finalType == WizardType.NONE) {\n            return DEFAULT_TYPE_BODY;\n        }\n        \n        return String.format(finalType.getFileBodyFormat(), FileCreationOp.getSimpleUnitName(getWizardPage().getUnitName()));\n    }\n    \n    private String createPackageHeader() {\n        String pckg = getWizardPage().getPackageFragment().getElementName();\n        if (pckg.isEmpty()) {\n            return DEFAULT_PACKAGE_NAME;\n        }\n        \n        return String.format(PACKAGE_FORMAT, pckg);\n    }\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/NewUnitWizardPage.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.jdt.core.*;\nimport org.eclipse.jdt.ui.JavaUI;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.widgets.Combo;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Text;\nimport org.eclipse.ui.dialogs.SelectionDialog;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\n\nimport java.util.Arrays;\n\nimport static org.eclipse.jdt.internal.ui.refactoring.nls.SourceContainerDialog.getSourceContainer;\nimport static org.jetbrains.kotlin.wizards.FileCreationOp.fileExists;\nimport static org.jetbrains.kotlin.wizards.FileCreationOp.makeFile;\nimport static org.jetbrains.kotlin.wizards.SWTWizardUtils.*;\n\npublic class NewUnitWizardPage extends AbstractWizardPage {\n\n    private static final String DEFAULT_SOURCE_FOLDER = \"\";\n    private static final String DEFAULT_PACKAGE = \"\";\n\n    private static final String NAME_LABEL_TITLE = \"Na&me\";\n    private static final String SOURCE_FOLDER_LABEL_TITLE = \"Source fol&der\";\n    private static final String PACKAGE_LABEL_TITLE = \"Pac&kage\";\n\n    private static final String ILLEGAL_UNIT_NAME_MESSAGE = \"Please enter a legal compilation unit name\";\n    private static final String SELECT_SOURCE_FOLDER_MESSAGE = \"Please select a source folder\";\n    private static final String ILLEGAL_PACKAGE_NAME_MESSAGE = \"Please enter a legal package name\";\n    private static final String UNIT_EXISTS_MESSAGE = \"File already exists\";\n\n    private static final String JAVA_IDENTIFIER_REGEXP = \"[a-zA-Z_]\\\\w*\";\n\n    private String unitName;\n    private String packageName;\n    private IPackageFragmentRoot sourceDir;\n    private IPackageFragment packageFragment;\n\n    private WizardType type = WizardType.NONE;\n\n    private final boolean isDynamicType;\n    private Text nameField = null;\n    private final IStructuredSelection selection;\n\n    protected NewUnitWizardPage(String title, String description, String unitName, IStructuredSelection selection, boolean isDynamicType) {\n        super(title, description);\n\n        this.selection = selection;\n        this.unitName = unitName;\n        this.isDynamicType = isDynamicType;\n    }\n\n    public IPackageFragment getPackageFragment() {\n        return packageFragment;\n    }\n\n    public IPackageFragmentRoot getSourceDir() {\n        return sourceDir;\n    }\n\n    public WizardType getType() {\n        return type;\n    }\n\n    public String getUnitName() {\n        return unitName;\n    }\n\n    public IProject getProject() {\n        if (sourceDir != null) {\n            return sourceDir.getJavaProject().getProject();\n        } else {\n            return null;\n        }\n    }\n\n    @Override\n    protected void createControls(Composite parent) {\n        createSourceFolderField(parent);\n        createPackageField(parent);\n\n        createSeparator(parent);\n\n        nameField = createNameField(parent);\n        if (isDynamicType) {\n            createDynamicTypeField(parent);\n        }\n    }\n\n    private void createDynamicTypeField(Composite parent) {\n        createLabel(parent, \"Type:\");\n        Combo tempCombo = new Combo(parent, SWT.READ_ONLY);\n        for (WizardType tempType : WizardType.values()) {\n            tempCombo.add(tempType.getWizardTypeName());\n        }\n        tempCombo.select(0);\n\n        tempCombo.addSelectionListener(new SelectionAdapter() {\n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                type = Arrays.stream(WizardType.values()).filter(it -> it.getWizardTypeName().equals(tempCombo.getText())).findFirst().orElse(WizardType.CLASS);\n            }\n        });\n    }\n\n    @Override\n    public void setVisible(boolean visible) {\n        super.setVisible(visible);\n        if (visible) {\n            if (nameField != null) {\n                nameField.setFocus();\n            }\n        }\n    }\n\n    private Text createNameField(Composite parent) {\n        createLabel(parent, NAME_LABEL_TITLE);\n        \n        final Text name = createText(parent, unitName);\n        name.addModifyListener(e -> {\n            unitName = name.getText();\n            validate();\n        });\n        \n        createEmptySpace(parent);\n        \n        return name;\n    }\n    \n    private void setSourceDirByFolderName(String srcFolder) {\n        try {\n            sourceDir = null;\n            for (IJavaProject jp : JavaCore.create(getWorkspaceRoot()).getJavaProjects()) {\n                for (IPackageFragmentRoot pfr : jp.getPackageFragmentRoots()) {\n                    if (pfr.getPath().toPortableString().equals(srcFolder)) {\n                        sourceDir = pfr;\n                        return;\n                    }\n                }\n            }\n        } catch (JavaModelException jme) {\n            KotlinLogger.logAndThrow(jme);\n        }\n    }\n    \n    private void createSourceFolderField(Composite parent) {\n        createLabel(parent, SOURCE_FOLDER_LABEL_TITLE);\n        \n        IPackageFragmentRoot srcFolder = WizardUtilsKt.getSourceFolderBySelection(selection);\n        String sourceFolderFromSelection = srcFolder != null ? srcFolder.getPath().toOSString() : DEFAULT_SOURCE_FOLDER;\n        sourceDir = srcFolder;\n        \n        final Text folder = createText(parent, sourceFolderFromSelection);\n        folder.addModifyListener(e -> {\n            setSourceDirByFolderName(folder.getText());\n            validate();\n        });\n        \n        createButton(parent, BROWSE_BUTTON_TITLE, new SelectionAdapter() {\n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                IPackageFragmentRoot pfr = getSourceContainer(getShell(), getWorkspaceRoot(), sourceDir);\n                if (pfr != null) {\n                    sourceDir = pfr;\n                    String folderName = sourceDir.getPath().toPortableString();\n                    folder.setText(folderName);\n                    packageFragment = sourceDir.getPackageFragment(packageName);\n                }\n                \n                validate();\n            }\n        });\n\n    }\n    \n    private void createPackageField(Composite parent) {\n        createLabel(parent, PACKAGE_LABEL_TITLE);\n        \n        IPackageFragment fragment = WizardUtilsKt.getPackageBySelection(selection);\n        String packageFromSelection = fragment != null ? fragment.getElementName() : DEFAULT_PACKAGE;\n        packageName = packageFromSelection;\n        \n        final Text pkg = createText(parent, packageFromSelection);\n        pkg.addModifyListener(e -> {\n            packageName = pkg.getText();\n            validate();\n        });\n        \n        createButton(parent, BROWSE_BUTTON_TITLE, new SelectionAdapter() {\n            @Override\n            public void widgetSelected(SelectionEvent e) {\n                if (sourceDir == null) {\n                    MessageDialog.openWarning(getShell(), \"No Source Folder\", SELECT_SOURCE_FOLDER_MESSAGE);\n                } else {\n                    SelectionDialog dialog;\n                    Object result = null;\n                    try {\n                        dialog = JavaUI.createPackageDialog(getShell(), sourceDir);\n                        dialog.setTitle(\"Package Selection\");\n                        dialog.setMessage(\"Select a package:\");\n                        dialog.open();\n                        if (dialog.getResult() != null) {\n                            result = dialog.getResult()[0];\n                        }\n                    } catch (JavaModelException jme) {\n                        KotlinLogger.logAndThrow(jme);\n                    }\n                    if (result != null) {\n                        packageName = ((IPackageFragment) result).getElementName();\n                        pkg.setText(packageName);\n                        if (sourceDir != null) {\n                            packageFragment = sourceDir.getPackageFragment(packageName);\n                        }\n                    }\n                    validate();\n                }\n            }\n        });\n\n    }\n    \n    @Override\n    protected String createErrorMessage() {\n        if (sourceDir != null && packageNameIsLegal()) {\n            packageFragment = sourceDir.getPackageFragment(packageName);\n        }\n        \n        if (sourceDir == null) {\n            return SELECT_SOURCE_FOLDER_MESSAGE;\n        } else if (!packageNameIsLegal()) {\n            return ILLEGAL_PACKAGE_NAME_MESSAGE;\n        } else if (!unitIsNameLegal()) {\n            return ILLEGAL_UNIT_NAME_MESSAGE;\n        } else if (resourceAlreadyExists()) {\n            return UNIT_EXISTS_MESSAGE;\n        } else {\n            return null;\n        }\n    }\n    \n    @Override\n    protected boolean resourceAlreadyExists() {\n        return fileExists(makeFile(packageFragment, sourceDir, unitName));\n    }\n    \n    private boolean packageNameIsLegal(String packageName) {\n        return packageName.matches(\"^(|\" + JAVA_IDENTIFIER_REGEXP + \"(\\\\.\" + JAVA_IDENTIFIER_REGEXP + \")*)$\");\n    }\n    \n    private boolean packageNameIsLegal() {\n        return packageName != null && packageNameIsLegal(packageName);\n    }\n    \n    private boolean unitIsNameLegal() {\n        return unitName != null && unitIsNameLegal(unitName);\n    }\n    \n    private boolean unitIsNameLegal(String unitName) {\n        return unitName.matches(\"^\" + JAVA_IDENTIFIER_REGEXP + FileCreationOp.getExtensionRegexp() + \"$\");\n    }\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/ProjectCreationOp.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport static org.eclipse.ui.ide.undo.WorkspaceUndoUtil.getUIInfoAdapter;\n\nimport java.io.FileNotFoundException;\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.resources.ICommand;\nimport org.eclipse.core.resources.IFolder;\nimport org.eclipse.core.resources.IProject;\nimport org.eclipse.core.resources.IProjectDescription;\nimport org.eclipse.core.resources.IWorkspace;\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.core.runtime.NullProgressMonitor;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.jdt.core.IClasspathEntry;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.launching.JavaRuntime;\nimport org.eclipse.jface.operation.IRunnableWithProgress;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.ide.undo.CreateProjectOperation;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\n\npublic class ProjectCreationOp implements IRunnableWithProgress {\n\n    private static final String SRC_FOLDER = \"src\";\n    private static final String BIN_FOLDER = \"bin\";\n\n    private final IProjectDescription projectDescription;\n    private final String projectName;\n    private final Shell shell;\n\n    private OperationResult result = new OperationResult();\n    private IJavaProject javaResult;\n\n    public ProjectCreationOp(String projectName, String projectLocation, Shell shell) {\n        projectDescription = buildProjectDescription(projectName, projectLocation);\n\n        this.projectName = projectName;\n        this.shell = shell;\n    }\n\n    public OperationResult getResult() {\n        return result;\n    }\n\n    private IJavaProject getJavaResult() {\n        if (javaResult == null) {\n            try {\n                javaResult = buildJavaProject(result.getProject());\n            } catch (CoreException e) {\n                KotlinLogger.logAndThrow(e);\n            } catch (FileNotFoundException e) {\n                KotlinLogger.logAndThrow(e);\n            }\n        }\n\n        return javaResult;\n    }\n\n    @Override\n    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {\n        CreateProjectOperation operation = new CreateProjectOperation(projectDescription, projectName);\n        try {\n            PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(operation, monitor,\n                    getUIInfoAdapter(shell));\n\n            result.project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);\n            result.project.setDescription(projectDescription, new NullProgressMonitor());\n            getJavaResult();\n        } catch (ExecutionException | CoreException e) {\n                KotlinLogger.logError(e);\n                result.exception = e.getCause();\n        }\n    }\n\n    private static IProjectDescription buildProjectDescription(String projectName, String projectLocation) {\n        IWorkspace workspace = ResourcesPlugin.getWorkspace();\n\n        IProjectDescription result = workspace.newProjectDescription(projectName);\n        result.setComment(projectName);\n        if (!workspace.getRoot().getLocation().toOSString().equals(projectLocation)) {\n            result.setLocation(new Path(projectLocation));\n        }\n\n        ICommand command = result.newCommand();\n        command.setBuilderName(JavaCore.BUILDER_ID);\n        result.setBuildSpec(new ICommand[] { command });\n\n        result.setNatureIds(new String[] { JavaCore.NATURE_ID });\n\n        return result;\n    }\n\n    private static IJavaProject buildJavaProject(@NotNull IProject project) throws CoreException, FileNotFoundException {\n        IJavaProject result = JavaCore.create(project);\n\n        IFolder binFolder = project.getFolder(BIN_FOLDER);\n        if (!binFolder.exists()) {\n            binFolder.create(false, true, null);\n        }\n        result.setOutputLocation(binFolder.getFullPath(), null);\n\n        IFolder srcFolder = project.getFolder(SRC_FOLDER);\n        if (!srcFolder.exists()) {\n            srcFolder.create(false, true, null);\n        }\n\n        result.setRawClasspath(new IClasspathEntry[] {\n                JavaCore.newContainerEntry(new Path(JavaRuntime.JRE_CONTAINER)),\n                JavaCore.newSourceEntry(result.getPackageFragmentRoot(srcFolder).getPath())\n                }, null);\n\n        ProjectUtils.addKotlinRuntime(project);\n\n        return result;\n    }\n\n    class OperationResult {\n        private IProject project = null;\n        private Throwable exception = null;\n\n        private OperationResult() {}\n\n        public boolean isSuccess() {\n            return exception == null;\n        }\n\n        IProject getProject() {\n            return project;\n        }\n\n        Throwable getException() {\n            return exception;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/SWTWizardUtils.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\npublic class SWTWizardUtils {\n\n    private static final int NUM_COLUMNS = 4;\n    private static final String LABEL_TEXT_SUFFIX = \": \";\n\n    private static GridData createGridData(int horizontalSpan, boolean grabExcessHorizontalSpace) {\n        GridData result = new GridData(GridData.HORIZONTAL_ALIGN_FILL);\n        result.horizontalSpan = horizontalSpan;\n        result.grabExcessHorizontalSpace = grabExcessHorizontalSpace;\n\n        return result;\n    }\n\n    private static Button createButton(Composite parent, String text, SelectionListener selectionListener, int style,\n            int horizontalSpan, boolean grabExcessHorizontalSpace) {\n        Button result = new Button(parent, style);\n        result.setText(text);\n        result.setLayoutData(createGridData(horizontalSpan, grabExcessHorizontalSpace));\n        if (selectionListener != null) {\n            result.addSelectionListener(selectionListener);\n        }\n\n        return result;\n    }\n\n    private static GridLayout createGridLayout() {\n        GridLayout result = new GridLayout();\n        result.numColumns = NUM_COLUMNS;\n\n        return result;\n    }\n\n    public static Composite createComposite(Composite parent) {\n        Composite result = new Composite(parent, SWT.NONE);\n        result.setFont(parent.getFont());\n        result.setLayout(createGridLayout());\n\n        return result;\n    }\n\n    public static Group createGroup(Composite parent, String text) {\n        Group result = new Group(parent, SWT.SHADOW_ETCHED_IN);\n        result.setText(text);\n        result.setLayout(createGridLayout());\n        result.setLayoutData(createGridData(NUM_COLUMNS, true));\n\n        return result;\n    }\n\n    public static Button createCheckbox(Composite parent, String text) {\n        return createButton(parent, text, null, SWT.CHECK, NUM_COLUMNS, true);\n    }\n\n    public static Label createLabel(Composite parent, String text) {\n        Label result = new Label(parent, SWT.LEFT | SWT.WRAP);\n        result.setText(text + LABEL_TEXT_SUFFIX);\n        result.setLayoutData(createGridData(1, false));\n\n        return result;\n    }\n\n    public static Text createText(Composite parent, String text) {\n        Text result = new Text(parent, SWT.SINGLE | SWT.BORDER);\n        result.setText(text);\n        result.setLayoutData(createGridData(2, true));\n\n        return result;\n    }\n\n    public static Button createButton(Composite parent, String text, SelectionListener selectionListener) {\n        return createButton(parent, text, selectionListener, SWT.PUSH, 1, false);\n    }\n\n    public static Label createSeparator(Composite parent) {\n        Label result = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);\n        result.setLayoutData(createGridData(NUM_COLUMNS, false));\n\n        return result;\n    }\n\n    public static Label createEmptySpace(Composite parent) {\n        return new Label(parent, SWT.NONE);\n    }\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/WizardType.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards\n\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.lexer.KtToken\n\nenum class WizardType(val wizardTypeName: String, val fileBodyFormat: String = \"\") {\n    NONE(\"Source\"),\n    CLASS(\"Class\", buildFileBody(KtTokens.CLASS_KEYWORD)),\n    SEALED_CLASS(\"Sealed Class\", buildFileBody(KtTokens.SEALED_KEYWORD, KtTokens.CLASS_KEYWORD)),\n    INTERFACE(\"Interface\", buildFileBody(KtTokens.INTERFACE_KEYWORD)),\n    SEALED_INTERFACE(\"Sealed Interface\", buildFileBody(KtTokens.SEALED_KEYWORD, KtTokens.INTERFACE_KEYWORD)),\n    OBJECT(\"Object\", buildFileBody(KtTokens.OBJECT_KEYWORD)),\n    ENUM(\"Enum\", buildFileBody(KtTokens.ENUM_KEYWORD, KtTokens.CLASS_KEYWORD)),\n    DATA(\"Data\", buildFileBody(KtTokens.DATA_KEYWORD, KtTokens.CLASS_KEYWORD)),\n    ANNOTATION(\"Annotation\", buildFileBody(KtTokens.ANNOTATION_KEYWORD, KtTokens.CLASS_KEYWORD)),\n}\n\nprivate const val NOT_EMPTY_BODY_FORMAT = \"%s {\\n}\"\n\nprivate fun buildFileBody(vararg modifiers: KtToken): String =\n    \"${modifiers.joinToString(separator = \" \")} $NOT_EMPTY_BODY_FORMAT\"\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/unitWizards.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\n@file:Suppress(\"unused\")\n\npackage org.jetbrains.kotlin.wizards\n\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.eclipse.ui.IWorkbench\nimport org.eclipse.ui.dialogs.WizardNewFileCreationPage\nimport org.eclipse.ui.ide.IDE\nimport org.eclipse.ui.wizards.newresource.BasicNewResourceWizard\nimport org.jetbrains.kotlin.parsing.KotlinParserDefinition\n\nclass NewClassWizard : NewUnitWizard(WizardType.CLASS)\nclass NewSealedClassWizard : NewUnitWizard(WizardType.SEALED_CLASS)\nclass NewEnumWizard : NewUnitWizard(WizardType.ENUM)\nclass NewDataClassWizard : NewUnitWizard(WizardType.DATA)\nclass NewAnnotationWizard : NewUnitWizard(WizardType.ANNOTATION)\nclass NewObjectWizard : NewUnitWizard(WizardType.OBJECT)\nclass NewInterfaceWizard : NewUnitWizard(WizardType.INTERFACE)\nclass NewSealedInterfaceWizard : NewUnitWizard(WizardType.SEALED_INTERFACE)\n\nclass NewScriptWizard : BasicNewResourceWizard() {\n    companion object {\n        private const val pageName = \"New Kotlin Script\"\n    }\n\n    private lateinit var mainPage: WizardNewFileCreationPage\n\n    override fun addPages() {\n        super.addPages()\n\n        mainPage = WizardNewFileCreationPage(pageName, getSelection()).apply {\n            fileExtension = KotlinParserDefinition.STD_SCRIPT_SUFFIX\n            title = \"Kotlin Script\"\n            description = \"Create a new Kotlin script\"\n        }\n\n        addPage(mainPage)\n    }\n\n    override fun init(workbench: IWorkbench, currentSelection: IStructuredSelection) {\n        super.init(workbench, currentSelection)\n        windowTitle = pageName\n    }\n\n    override fun performFinish(): Boolean {\n        val file = mainPage.createNewFile() ?: return false\n\n        selectAndReveal(file)\n        workbench.activeWorkbenchWindow?.let {\n            val page = it.activePage\n            if (page != null) {\n                IDE.openEditor(page, file, true)\n            }\n        }\n\n        return true\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/src/org/jetbrains/kotlin/wizards/wizardUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.wizards\n\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.jdt.core.*\nimport org.eclipse.jface.viewers.IStructuredSelection\nimport org.jetbrains.kotlin.core.utils.sourceFolders\n\nfun getSourceFolderBySelection(selection: IStructuredSelection): IPackageFragmentRoot? {\n    if (selection.isEmpty) return null\n\n    return when (val element = selection.firstElement) {\n        is IPackageFragmentRoot -> element\n        is IJavaProject -> element.sourceFolders.firstOrNull()\n        is IPackageFragment -> element.parent as IPackageFragmentRoot\n        is ICompilationUnit -> element.parent.parent as IPackageFragmentRoot\n        is IResource -> getPackageBySelection(selection)?.parent as? IPackageFragmentRoot\n        else -> null\n    }\n}\n\nfun getPackageBySelection(selection: IStructuredSelection): IPackageFragment? {\n    if (selection.isEmpty) return null\n\n    return when (val element = selection.firstElement) {\n        is IPackageFragment -> element\n        is ICompilationUnit -> element.parent as IPackageFragment\n        is IResource -> {\n            val javaProject = JavaCore.create(element.project)\n            javaProject.findPackageFragment(element.fullPath.removeLastSegments(1))\n        }\n        else -> null\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui/templates/default-templates.xml",
    "content": "<templates>\n\n<template name=\"main\" description=\"An entry point for Kotlin program\" id=\"org.jetbrains.kotlin.ui.editors.templates.main\" \n\tcontext=\"kotlin-top-level-declarations\" enabled=\"true\" autoinsert=\"true\">fun main(args: Array&lt;String&gt;) {\n\t${cursor}\n}</template>\n\n</templates>"
  },
  {
    "path": "kotlin-eclipse-ui-test/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: kotlin-eclipse-ui-test\nBundle-SymbolicName: org.jetbrains.kotlin.ui.tests;singleton:=true\nBundle-Version: 0.8.24.qualifier\nBundle-Vendor: JetBrains\nBundle-RequiredExecutionEnvironment: JavaSE-17\nBundle-ClassPath: .,\n lib/gson-2.3.1.jar\nRequire-Bundle: org.jetbrains.kotlin.bundled-compiler,\n org.jetbrains.kotlin.core,\n org.jetbrains.kotlin.ui,\n org.jetbrains.kotlin.testframework,\n org.junit,\n org.eclipse.jdt.ui,\n org.aspectj.runtime,\n org.aspectj.weaver,\n org.eclipse.equinox.weaving.aspectj,\n org.jetbrains.kotlin.aspects,\n org.eclipse.core.commands,\n org.eclipse.ui.workbench,\n org.eclipse.search,\n org.eclipse.jface,\n org.eclipse.ltk.core.refactoring,\n org.eclipse.jdt.core.manipulation,\n org.eclipse.osgi\nImport-Package: org.eclipse.core.expressions,\n org.eclipse.core.resources,\n org.eclipse.core.runtime,\n org.eclipse.core.runtime.jobs,\n org.eclipse.debug.core,\n org.eclipse.debug.core.model,\n org.eclipse.debug.internal.core,\n org.eclipse.debug.internal.ui,\n org.eclipse.debug.internal.ui.launchConfigurations,\n org.eclipse.debug.internal.ui.views.console,\n org.eclipse.debug.ui,\n org.eclipse.jdt.core,\n org.eclipse.jdt.core.search,\n org.eclipse.jdt.internal.junit,\n org.eclipse.jdt.internal.junit.buildpath,\n org.eclipse.jdt.internal.junit.launcher,\n org.eclipse.jdt.internal.junit.model,\n org.eclipse.jdt.junit,\n org.eclipse.jdt.junit.model,\n org.eclipse.jdt.launching,\n org.eclipse.jface.preference,\n org.eclipse.jface.text,\n org.eclipse.jface.text.contentassist,\n org.eclipse.jface.text.quickassist,\n org.eclipse.jface.text.rules,\n org.eclipse.jface.text.source,\n org.eclipse.jface.text.templates,\n org.eclipse.swt.custom,\n org.eclipse.swt.graphics,\n org.eclipse.ui,\n org.eclipse.ui.console,\n org.eclipse.ui.ide,\n org.jetbrains.kotlin.ui.commands.j2k\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/build.properties",
    "content": "###############################################################################\n# Copyright 2000-2014 JetBrains s.r.o.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n###############################################################################\nsource.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n</plugin>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.ui.tests</artifactId>\n\t<packaging>eclipse-test-plugin</packaging>\n\t\n\t<properties>\n\t\t<os-jvm-flags/>\n\t</properties>\n\n\t<dependencies>\n\t\t<dependency>\n\t\t\t<groupId>com.google.code.gson</groupId>\n\t\t\t<artifactId>gson</artifactId>\n\t\t\t<version>2.8.2</version>\n\t\t\t<scope>provided</scope>\n\t\t</dependency>\n\t</dependencies>\n\n\t<build>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t<artifactId>tycho-surefire-plugin</artifactId>\n\t\t\t\t<configuration>\n\t\t\t\t\t<useUIHarness>true</useUIHarness>\n\t\t\t\t\t<argLine>-Xmx1424m -XX:MaxPermSize=256m ${os-jvm-flags}</argLine>\n\t\t\t\t\t<dependencies>\n\t\t\t\t\t\t<dependency>\n\t\t\t\t\t\t\t<type>eclipse-feature</type>\n\t\t\t\t\t\t\t<artifactId>org.eclipse.rcp</artifactId>\n\t\t\t\t\t\t\t<version>0.0.0</version>\n\t\t\t\t\t\t</dependency>\n\t\t\t\t\t</dependencies>\n\t\t\t\t\t\n\t\t\t\t\t<frameworkExtensions>\n\t\t\t\t\t\t<frameworkExtension>\n\t\t\t\t\t\t\t<groupId>org.eclipse.platform</groupId>\n\t\t\t\t\t\t\t<artifactId>org.eclipse.equinox.weaving.hook</artifactId>\n\t\t\t\t\t\t\t<version>${weaving-hook.version}</version>\n\t\t\t\t\t\t</frameworkExtension>\n\t\t\t\t\t</frameworkExtensions>\n\t\t\t\t\t<bundleStartLevel>\n\t\t\t\t\t\t<bundle>\n\t\t\t\t\t\t\t<id>org.eclipse.equinox.weaving.aspectj</id>\n\t\t\t\t\t\t\t<level>2</level>\n\t\t\t\t\t\t\t<autoStart>true</autoStart>\n\t\t\t\t\t\t\t</bundle>\n\t\t\t\t\t\t</bundleStartLevel>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.jetbrains.kotlin</groupId>\n\t\t\t\t<artifactId>kotlin-maven-plugin</artifactId>\n\t\t\t\t<version>${kotlin.version}</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<jvmTarget>17</jvmTarget>\n\t\t\t\t</configuration>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>compile</id>\n\t\t\t\t\t\t<phase>process-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>compile</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n\n\t<profiles>\n\t\t<profile>\n\t\t\t<id>macosx-jvm-flags</id>\n\t\t\t<activation>\n\t\t\t\t<os><family>mac</family></os>\n\t\t\t</activation>\n\t\t\t<properties>\n\t\t\t\t<os-jvm-flags>-XstartOnFirstThread</os-jvm-flags>\n\t\t\t</properties>\n\t\t</profile>\n\t</profiles>\n</project>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/checkers/KotlinDiagnosticsTestCase.java",
    "content": "package org.jetbrains.kotlin.checkers;\n\n\nimport com.intellij.lang.java.JavaLanguage;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.Condition;\nimport com.intellij.openapi.util.TextRange;\nimport com.intellij.openapi.util.text.StringUtil;\nimport com.intellij.openapi.util.text.StringUtilRt;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiFileFactory;\nimport com.intellij.psi.search.GlobalSearchScope;\nimport com.intellij.psi.util.PsiTreeUtil;\nimport com.intellij.util.containers.ContainerUtil;\nimport junit.framework.TestCase;\nimport kotlin.Pair;\nimport kotlin.collections.CollectionsKt;\nimport kotlin.jvm.functions.Function1;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.analyzer.AnalysisResult;\nimport org.jetbrains.kotlin.asJava.DuplicateJvmSignatureUtilKt;\nimport org.jetbrains.kotlin.checkers.diagnostics.AbstractTestDiagnostic;\nimport org.jetbrains.kotlin.checkers.diagnostics.ActualDiagnostic;\nimport org.jetbrains.kotlin.checkers.diagnostics.TextDiagnostic;\nimport org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory0;\nimport org.jetbrains.kotlin.checkers.diagnostics.factories.SyntaxErrorDiagnosticFactory;\nimport org.jetbrains.kotlin.checkers.utils.CheckerTestUtil;\nimport org.jetbrains.kotlin.checkers.utils.DiagnosticsRenderingConfiguration;\nimport org.jetbrains.kotlin.config.ApiVersion;\nimport org.jetbrains.kotlin.config.LanguageVersion;\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.core.resolve.EclipseAnalyzerFacadeForJVM;\nimport org.jetbrains.kotlin.core.tests.diagnostics.AdditionalConditions;\nimport org.jetbrains.kotlin.core.tests.diagnostics.JetLightFixture;\nimport org.jetbrains.kotlin.core.tests.diagnostics.JetTestUtils;\nimport org.jetbrains.kotlin.descriptors.DeclarationDescriptor;\nimport org.jetbrains.kotlin.diagnostics.*;\nimport org.jetbrains.kotlin.diagnostics.PsiDiagnosticUtils.LineAndColumn;\nimport org.jetbrains.kotlin.platform.TargetPlatform;\nimport org.jetbrains.kotlin.psi.*;\nimport org.jetbrains.kotlin.resolve.AnalyzingUtils;\nimport org.jetbrains.kotlin.resolve.BindingContext;\nimport org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;\nimport org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;\nimport org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.junit.Assert;\nimport org.junit.Before;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.*;\nimport java.util.Map.Entry;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport static org.jetbrains.kotlin.diagnostics.Errors.*;\n\npublic class KotlinDiagnosticsTestCase extends KotlinProjectTestCase {\n    \n    public static final Pattern DIAGNOSTICS_PATTERN = Pattern.compile(\"([\\\\+\\\\-!])(\\\\w+)\\\\s*\");\n    public static final String DIAGNOSTICS_DIRECTIVE = \"DIAGNOSTICS\";\n    public static final Set<DiagnosticFactory<?>> DIAGNOSTICS_TO_INCLUDE_ANYWAY =\n        new HashSet<>(Arrays.asList(\n                Errors.UNRESOLVED_REFERENCE,\n                Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER,\n                SyntaxErrorDiagnosticFactory.Companion.getINSTANCE(),\n                DebugInfoDiagnosticFactory0.Companion.getELEMENT_WITH_ERROR_TYPE(),\n                DebugInfoDiagnosticFactory0.Companion.getMISSING_UNRESOLVED(),\n                DebugInfoDiagnosticFactory0.Companion.getUNRESOLVED_WITH_TARGET()\n        ));\n    public static final String CHECK_TYPE_DIRECTIVE = \"CHECK_TYPE\";\n    public static final String CHECK_TYPE_PACKAGE = \"tests._checkType\";\n    private static final String CHECK_TYPE_DECLARATIONS = \"\\npackage \" + CHECK_TYPE_PACKAGE +\n            \"\\nfun <T> checkSubtype(t: T) = t\" +\n            \"\\nclass Inv<T>\" +\n            \"\\nfun <E> Inv<E>._() {}\" +\n            \"\\ninfix fun <T> T.checkType(f: Inv<T>.() -> Unit) {}\";\n    \n    public static final String CHECK_TYPE_IMPORT = \"import \" + CHECK_TYPE_PACKAGE + \".*\";\n    \n    public static final String MARK_DYNAMIC_CALLS_DIRECTIVE = \"MARK_DYNAMIC_CALLS\";\n    \n    @Before\n    public void configure() {\n        configureProject();\n    }\n\n    protected void doTest(String filePath) throws IOException {\n        File file = new File(filePath);\n        \n        String expectedText = JetTestUtils.doLoadFile(file);\n        expectedText = StringUtilRt.convertLineSeparators(expectedText);\n\n        class ModuleAndDependencies {\n            final TestModule module;\n            final List<String> dependencies;\n\n            ModuleAndDependencies(TestModule module, List<String> dependencies) {\n                this.module = module;\n                this.dependencies = dependencies;\n            }\n        }\n        final Map<String, ModuleAndDependencies> modules = new HashMap<String, ModuleAndDependencies>();\n\n        List<TestFile> testFiles =\n                JetTestUtils.createTestFiles(file.getName(), expectedText, new JetTestUtils.TestFileFactory<TestModule, TestFile>() {\n\n                    @Override\n                    public TestFile createFile(@Nullable TestModule module, String fileName, String text, Map<String, String> directives) {\n                        if (fileName.endsWith(\".java\")) {\n                            writeJavaFile(fileName, text);\n                        }\n                        \n                        return new TestFile(module, fileName, text, directives);\n                    }\n\n                    @Override\n                    public TestModule createModule(String name, List<String> dependencies) {\n                        TestModule module = new TestModule(name);\n                        ModuleAndDependencies oldValue = modules.put(name, new ModuleAndDependencies(module, dependencies));\n                        assert oldValue == null : \"Module \" + name + \" declared more than once\";\n\n                        return module;\n                    }\n                });\n\n        for (final ModuleAndDependencies moduleAndDependencies : modules.values()) {\n            List<TestModule> dependencies = CollectionsKt.map(\n                    moduleAndDependencies.dependencies,\n                    new Function1<String, TestModule>() {\n                        @Override\n                        public TestModule invoke(String name) {\n                            ModuleAndDependencies dependency = modules.get(name);\n                            assert dependency != null : \"Dependency not found: \" + name + \" for module \" + moduleAndDependencies.module.getName();\n                            return dependency.module;\n                        }\n                    }\n            );\n            moduleAndDependencies.module.getDependencies().addAll(dependencies);\n        }\n\n        analyzeAndCheck(file, testFiles, \"<\" + file.getName().substring(0, file.getName().length() - \".kt\".length()));\n    }\n    \n    protected void analyzeAndCheck(File testDataFile, List<TestFile> testFiles, String moduleName) {\n        Map<TestModule, List<TestFile>> groupedByModule = CollectionsKt.groupByTo(\n                testFiles,\n                new LinkedHashMap<TestModule, List<TestFile>>(),\n                new Function1<TestFile, TestModule>() {\n                    @Override\n                    public TestModule invoke(TestFile file) {\n                        return file.getModule();\n                    }\n                }\n        );\n        \n        List<KtFile> allKtFiles = new ArrayList<KtFile>();\n        Map<TestModule, BindingContext> moduleBindings = new HashMap<TestModule, BindingContext>();\n\n        for (Map.Entry<TestModule, List<TestFile>> entry : groupedByModule.entrySet()) {\n            TestModule testModule = entry.getKey();\n            List<? extends TestFile> testFilesInModule = entry.getValue();\n\n            List<KtFile> jetFiles = getKtFiles(testFilesInModule, true);\n            allKtFiles.addAll(jetFiles);\n            \n            AnalysisResult analysisResult = EclipseAnalyzerFacadeForJVM.INSTANCE\n                    .analyzeSources(\n                            KotlinEnvironment.Companion.getEnvironment(getTestProject().getJavaProject().getProject()), jetFiles)\n                    .getAnalysisResult();\n            \n            moduleBindings.put(testModule, analysisResult.getBindingContext());\n            \n            checkAllResolvedCallsAreCompleted(jetFiles, analysisResult.getBindingContext());\n        }\n\n        boolean ok = true;\n\n        StringBuilder actualText = new StringBuilder();\n        for (TestFile testFile : testFiles) {\n            ok &= testFile.getActualText(moduleBindings.get(testFile.getModule()), actualText, true);\n        }\n\n        JetTestUtils.assertEqualsToFile(testDataFile, actualText.toString());\n\n        TestCase.assertTrue(\"Diagnostics mismatch. See the output above\", ok);\n    }\n    \n    private static void checkAllResolvedCallsAreCompleted(@NotNull List<KtFile> jetFiles, @NotNull BindingContext bindingContext) {\n        for (KtFile file : jetFiles) {\n            if (!AnalyzingUtils.getSyntaxErrorRanges(file).isEmpty()) {\n                return;\n            }\n        }\n\n        Map<Call,ResolvedCall<?>> resolvedCallsEntries = bindingContext.getSliceContents(BindingContext.RESOLVED_CALL);\n        checkResolvedCallsInDiagnostics(bindingContext);\n    }\n    \n    private static void checkResolvedCallsInDiagnostics(BindingContext bindingContext) {\n        Set<DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>>> diagnosticsStoringResolvedCalls1 = new HashSet<>(\n                Arrays.asList(OVERLOAD_RESOLUTION_AMBIGUITY, NONE_APPLICABLE, CANNOT_COMPLETE_RESOLVE, UNRESOLVED_REFERENCE_WRONG_RECEIVER,\n                ASSIGN_OPERATOR_AMBIGUITY, ITERATOR_AMBIGUITY));\n        Set<DiagnosticFactory2<KtExpression,? extends Comparable<?>,Collection<? extends ResolvedCall<?>>>>\n                diagnosticsStoringResolvedCalls2 = new HashSet<>(Arrays.asList(\n                COMPONENT_FUNCTION_AMBIGUITY, DELEGATE_SPECIAL_FUNCTION_AMBIGUITY, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE));\n        \n        Diagnostics diagnostics = bindingContext.getDiagnostics();\n        for (Diagnostic diagnostic : diagnostics) {\n            DiagnosticFactory<?> factory = diagnostic.getFactory();\n            //noinspection SuspiciousMethodCalls\n            if (diagnosticsStoringResolvedCalls1.contains(factory)) {\n                assertResolvedCallsAreCompleted(\n                        diagnostic, DiagnosticFactory.cast(diagnostic, diagnosticsStoringResolvedCalls1).getA());\n\n            }\n            //noinspection SuspiciousMethodCalls\n            if (diagnosticsStoringResolvedCalls2.contains(factory)) {\n                assertResolvedCallsAreCompleted(\n                        diagnostic,\n                        DiagnosticFactory.cast(diagnostic, diagnosticsStoringResolvedCalls2).getB());\n            }\n        }\n    }\n    \n    public static Condition<Diagnostic> parseDiagnosticFilterDirective(Map<String, String> directiveMap) {\n        String directives = directiveMap.get(DIAGNOSTICS_DIRECTIVE);\n        if (directives == null) {\n            return AdditionalConditions.alwaysTrue();\n        }\n        Condition<Diagnostic> condition = AdditionalConditions.alwaysTrue();\n        Matcher matcher = DIAGNOSTICS_PATTERN.matcher(directives);\n        if (!matcher.find()) {\n            Assert.fail(\"Wrong syntax in the '// !DIAGNOSTICS: ...' directive:\\n\" +\n                        \"found: '\" + directives + \"'\\n\" +\n                        \"Must be '([+-!]DIAGNOSTIC_FACTORY_NAME|ERROR|WARNING|INFO)+'\\n\" +\n                        \"where '+' means 'include'\\n\" +\n                        \"      '-' means 'exclude'\\n\" +\n                        \"      '!' means 'exclude everything but this'\\n\" +\n                        \"directives are applied in the order of appearance, i.e. !FOO +BAR means include only FOO and BAR\");\n        }\n        boolean first = true;\n        do {\n            String operation = matcher.group(1);\n            final String name = matcher.group(2);\n\n            Condition<Diagnostic> newCondition;\n            if (name.equals(\"ERROR\") || name.equals(\"WARNING\") || name.equals(\"INFO\")) {\n                final Severity severity = Severity.valueOf(name);\n                newCondition = new Condition<Diagnostic>() {\n                    @Override\n                    public boolean value(Diagnostic diagnostic) {\n                        return diagnostic.getSeverity() == severity;\n                    }\n                };\n            }\n            else {\n                newCondition = new Condition<Diagnostic>() {\n                    @Override\n                    public boolean value(Diagnostic diagnostic) {\n                        return name.equals(diagnostic.getFactory().getName());\n                    }\n                };\n            }\n            if (\"!\".equals(operation)) {\n                if (!first) {\n                    Assert.fail(\"'\" + operation + name + \"' appears in a position rather than the first one, \" +\n                                \"which effectively cancels all the previous filters in this directive\");\n                }\n                condition = newCondition;\n            }\n            else if (\"+\".equals(operation)) {\n                condition = AdditionalConditions.or(condition, newCondition);\n            }\n            else if (\"-\".equals(operation)) {\n                condition = AdditionalConditions.and(condition, AdditionalConditions.not(newCondition));\n            }\n            first = false;\n        }\n        while (matcher.find());\n        // We always include UNRESOLVED_REFERENCE and SYNTAX_ERROR because they are too likely to indicate erroneous test data\n        return AdditionalConditions.or(\n                condition,\n                new Condition<Diagnostic>() {\n                    @Override\n                    public boolean value(Diagnostic diagnostic) {\n                        return DIAGNOSTICS_TO_INCLUDE_ANYWAY.contains(diagnostic.getFactory());\n                    }\n                });\n    }\n    \n    private static void assertResolvedCallsAreCompleted(\n            @NotNull Diagnostic diagnostic, @NotNull Collection<? extends ResolvedCall<?>> resolvedCalls\n    ) {\n        boolean allCallsAreCompleted = true;\n        for (ResolvedCall<?> resolvedCall : resolvedCalls) {\n            if (!((MutableResolvedCall<?>) resolvedCall).isCompleted()) {\n                allCallsAreCompleted = false;\n            }\n        }\n\n        PsiElement element = diagnostic.getPsiElement();\n        LineAndColumn lineAndColumn =\n                DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange());\n\n        TestCase.assertTrue(\"Resolved calls stored in \" + diagnostic.getFactory().getName() + \"\\n\" +\n                   \"for '\" + element.getText() + \"'\" + lineAndColumn + \" are not completed\",\n                   allCallsAreCompleted);\n    }\n    \n    protected List<KtFile> getKtFiles(List<? extends TestFile> testFiles, boolean includeExtras) {\n        boolean declareCheckType = false;\n        List<KtFile> jetFiles = new ArrayList<>();\n        for (TestFile testFile : testFiles) {\n            if (testFile.getKtFile() != null) {\n                jetFiles.add(testFile.getKtFile());\n            }\n            declareCheckType |= testFile.declareCheckType;\n        }\n        \n        if (includeExtras) {\n            if (declareCheckType) {\n                jetFiles.add(JetLightFixture.createPsiFile(null, \"CHECK_TYPE.kt\", CHECK_TYPE_DECLARATIONS, getProject()));\n            }\n        }\n\n\n        return jetFiles;\n    }\n    \n    private boolean writeJavaFile(@NotNull String filePath, @NotNull String content) {\n        try {\n            File sourceFile = new File(filePath);\n            getTestProject().createSourceFile(\n                    sourceFile.getParent(), \n                    sourceFile.getName(), \n                    content);\n            return true;\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n    }\n    \n    protected static class TestModule {\n        private final String name;\n        private final List<TestModule> dependencies = new ArrayList<TestModule>();\n\n        public TestModule(String name) {\n            this.name = name;\n        }\n\n        public String getName() {\n            return name;\n        }\n\n        public List<TestModule> getDependencies() {\n            return dependencies;\n        }\n    }\n    \n    @NotNull\n    public Project getProject() {\n        return getTestProject().getKotlinEnvironment().getProject();\n    }\n    \n    protected class TestFile {\n        private final List<DiagnosedRange> diagnosedRanges = new ArrayList<>();\n        private final String expectedText;\n        private final TestModule module;\n        private final String clearText;\n        private final KtFile jetFile;\n        private final Condition<Diagnostic> whatDiagnosticsToConsider;\n        private final boolean markDynamicCalls;\n        private final boolean declareCheckType;\n        private final List<DeclarationDescriptor> dynamicCallDescriptors = new ArrayList<DeclarationDescriptor>();\n\n        public TestFile(\n                TestModule module,\n                String fileName,\n                String textWithMarkers,\n                Map<String, String> directives\n        ) {\n        \tthis.module = module;\n            this.whatDiagnosticsToConsider = parseDiagnosticFilterDirective(directives);\n            this.declareCheckType = directives.containsKey(CHECK_TYPE_DIRECTIVE);\n            this.markDynamicCalls = directives.containsKey(MARK_DYNAMIC_CALLS_DIRECTIVE);\n            if (fileName.endsWith(\".java\")) {\n                PsiFileFactory.getInstance(getProject()).createFileFromText(fileName, JavaLanguage.INSTANCE, textWithMarkers);\n                // TODO: check there's not syntax errors\n                this.jetFile = null;\n                this.expectedText = this.clearText = textWithMarkers;\n            }\n            else {\n                this.expectedText = textWithMarkers;\n                String textWithExtras = addExtras(expectedText);\n                this.clearText = CheckerTestUtil.INSTANCE.parseDiagnosedRanges(textWithExtras, diagnosedRanges, null);\n                this.jetFile = JetLightFixture.createCheckAndReturnPsiFile(null, fileName, clearText, getProject());\n            }\n        }\n        \n        private String addExtras(String text) {\n            return addImports(text, getExtras());\n        }\n        \n        private String getExtras() {\n            return \"/*extras*/\\n\" + getImports() + \"/*extras*/\\n\\n\";\n        }\n        \n        @NotNull\n        private String getImports() {\n            String imports = \"\";\n            if (declareCheckType) {\n                imports += CHECK_TYPE_IMPORT + \"\\n\";\n            }\n            return imports;\n        }\n        \n        private String addImports(String text, String imports) {\n            Pattern pattern = Pattern.compile(\"^package [\\\\.\\\\w\\\\d]*\\n\", Pattern.MULTILINE);\n            Matcher matcher = pattern.matcher(text);\n            if (matcher.find()) {\n                // add imports after the package directive\n                text = text.substring(0, matcher.end()) + imports + text.substring(matcher.end());\n            }\n            else {\n                // add imports at the beginning\n                text = imports + text;\n            }\n            return text;\n        }\n\n        public TestModule getModule() {\n            return module;\n        }\n\n        public KtFile getKtFile() {\n            return jetFile;\n        }\n        \n        private void stripExtras(StringBuilder actualText) {\n            String extras = getExtras();\n            int start = actualText.indexOf(extras);\n            if (start >= 0) {\n                actualText.delete(start, start + extras.length());\n            }\n        }\n        \n        public boolean getActualText(BindingContext bindingContext, StringBuilder actualText, boolean skipJvmSignatureDiagnostics) {\n            if (this.jetFile == null) {\n                // TODO: check java files too\n                actualText.append(this.clearText);\n                return true;\n            }\n\n            Set<ActualDiagnostic> jvmSignatureDiagnostics = skipJvmSignatureDiagnostics\n                                                            ? Collections.<ActualDiagnostic>emptySet()\n                                                            : computeJvmSignatureDiagnostics(bindingContext);\n\n            final boolean[] ok = { true };\n            List<Pair<TargetPlatform, BindingContext>> implementingModulesBinding = new ArrayList<>();\n            List<ActualDiagnostic> diagnostics = ContainerUtil.filter(\n                    CollectionsKt.plus(\n                    \t\tCheckerTestUtil.INSTANCE.getDiagnosticsIncludingSyntaxErrors(\n                    \t\t        bindingContext,\n                                    implementingModulesBinding,\n                                    jetFile.getOriginalElement(),\n                                    markDynamicCalls,\n                                    dynamicCallDescriptors,\n                                    new DiagnosticsRenderingConfiguration(null, false, new LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE)),\n                                    null,\n                                    null,\n                                    null),\n                    \t\tjvmSignatureDiagnostics),\n                    new Condition<ActualDiagnostic>() {\n                        @Override\n                        public boolean value(final ActualDiagnostic actualDiagnostic) {\n                            return whatDiagnosticsToConsider.value(actualDiagnostic.getDiagnostic());\n                        }\n                    });\n\n            Map<AbstractTestDiagnostic, TextDiagnostic> diagnosticToExpectedDiagnostic = CheckerTestUtil.INSTANCE.diagnosticsDiff(\n                    diagnosedRanges, diagnostics, new DiagnosticDiffCallbacks() {\n                @Override\n                public void missingDiagnostic(TextDiagnostic diagnostic, int expectedStart, int expectedEnd) {\n                    String message = \"Missing \" + diagnostic.getDescription() + PsiDiagnosticUtils.atLocation(jetFile, new TextRange(expectedStart, expectedEnd));\n                    System.err.println(message);\n                    ok[0] = false;\n                }\n\n                @Override\n                public void unexpectedDiagnostic(TextDiagnostic diagnostic, int actualStart, int actualEnd) {\n                    String message = \"Unexpected \" + diagnostic.getDescription() + PsiDiagnosticUtils.atLocation(jetFile, new TextRange(actualStart, actualEnd));\n                    System.err.println(message);\n                    ok[0] = false;\n                }\n\n\t\t\t\t@Override\n\t\t\t\tpublic void wrongParametersDiagnostic(\n\t\t\t\t\t\tTextDiagnostic expectedDiagnostic,\n\t\t\t\t\t\tTextDiagnostic actualDiagnostic, int start, int end) {\n\t\t\t\t\tString message = \"Parameters of diagnostic not equal at position \"\n                                     + PsiDiagnosticUtils.atLocation(jetFile, new TextRange(start, end))\n                                     + \". Expected: \" + expectedDiagnostic.asString(false, false) + \", actual: \" + actualDiagnostic.asString(false, false);\n\t\t            System.err.println(message);\n\t\t            ok[0] = false;\n\t\t\t\t}\n            });\n\n            actualText.append(CheckerTestUtil.INSTANCE.addDiagnosticMarkersToText(\n                    jetFile.getOriginalFile(),\n                    diagnostics,\n                    diagnosticToExpectedDiagnostic,\n                    file -> {\n                        String text = file.getText();\n                        return declareCheckType ? StringUtil.trimEnd(text, CHECK_TYPE_DECLARATIONS) : text;\n                    },\n                    Collections.emptyList(),\n                    true,\n                    false));\n\n            stripExtras(actualText);\n            \n            return ok[0];\n        }\n\n        private Set<ActualDiagnostic> computeJvmSignatureDiagnostics(BindingContext bindingContext) {\n            Set<ActualDiagnostic> jvmSignatureDiagnostics = new HashSet<ActualDiagnostic>();\n            Collection<KtDeclaration> declarations = PsiTreeUtil.findChildrenOfType(jetFile, KtDeclaration.class);\n            for (KtDeclaration declaration : declarations) {\n                Diagnostics diagnostics = DuplicateJvmSignatureUtilKt.getJvmSignatureDiagnostics(declaration, \n                        bindingContext.getDiagnostics(), GlobalSearchScope.allScope(getProject()));\n                if (diagnostics == null) continue;\n                jvmSignatureDiagnostics.addAll(CollectionsKt.map(diagnostics.forElement(declaration), new Function1<Diagnostic, ActualDiagnostic>() {\n                    @Override\n                    public ActualDiagnostic invoke(Diagnostic arg0) {\n                        return new ActualDiagnostic(arg0, null, false);\n                    }\n                }));\n                  \n            }\n            return jvmSignatureDiagnostics;\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/AdditionalConditions.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport com.intellij.openapi.util.Condition;\n\npublic class AdditionalConditions {\n\n\tpublic static Condition<Object> TRUE = new Condition<Object>() {\n\t\t@Override\n\t\tpublic boolean value(final Object object) {\n\t\t\treturn true;\n\t\t}\n\t};\n\t\n\tpublic static Condition<Object> FALSE = new Condition<Object>() {\n\t\t@Override\n\t\tpublic boolean value(final Object object) {\n\t\t\treturn false;\n\t\t}\n\t};\n\t\n\t@SuppressWarnings(\"unchecked\")\n\tpublic static <T> Condition<T> alwaysTrue() {\n\t\treturn (Condition<T>) TRUE;\n\t}\n\t\n\tprivate static class And<T> implements Condition<T>  {\n\t\tprivate final Condition<T> t1;\n\t\tprivate final Condition<T> t2;\n\n\t\tpublic And(final Condition<T> t1, final Condition<T> t2) {\n\t\t\tthis.t1 = t1;\n\t\t\tthis.t2 = t2;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean value(final T object) {\n\t\t\treturn t1.value(object) && t2.value(object);\n\t\t}\n\t}\n\t\n\tprivate static class Or<T> implements Condition<T>  {\n\t\tprivate final Condition<T> t1;\n\t\tprivate final Condition<T> t2;\n\n\t\tpublic Or(final Condition<T> t1, final Condition<T> t2) {\n\t\t\tthis.t1 = t1;\n\t\t\tthis.t2 = t2;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean value(final T object) {\n\t\t\treturn t1.value(object) || t2.value(object);\n\t\t}\n\t}\n\t\n\tprivate static class Not<T> implements Condition<T> {\n\t\tprivate final Condition<T> myCondition;\n\n\t\tpublic Not(Condition<T> condition) {\n\t\t\tmyCondition = condition;\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean value(T value) {\n\t\t\treturn !myCondition.value(value);\n\t\t}\n\t}\n\t\n\tpublic static <T> Condition<T> or(Condition<T> c1, Condition<T> c2) {\n\t\treturn new Or<T>(c1, c2);\n\t}\n\t\n\tpublic static <T> Condition<T> not(Condition<T> c) {\n\t\treturn new Not<T>(c);\n\t}\n\t\n\tpublic static <T> Condition<T> and(Condition<T> c1, Condition<T> c2) {\n\t\treturn new And<T>(c1, c2);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/AllDiagnosticsTests.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( {\n\tKotlinDiagnosticsJavaPlusKotlinTest.class,\n\tKotlinDiagnosticsTest.class,\n\tJavaAnnotationArgumentsInKotlinTest.class\n} )\npublic class AllDiagnosticsTests {\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/FileComparisonFailure.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport junit.framework.ComparisonFailure;\n\npublic class FileComparisonFailure extends ComparisonFailure {\n\tprivate static final long serialVersionUID = 1L;\n\tprivate final String myExpected;\n\t  private final String myActual;\n\t  private final String myFilePath;\n\n\t  public FileComparisonFailure(String message, String expected, String actual, String filePath) {\n\t    super(message, expected, actual);\n\t    myExpected = expected;\n\t    myActual = actual;\n\t    myFilePath = filePath;\n\t  }\n\n\t  public String getFilePath() {\n\t    return myFilePath;\n\t  }\n\n\t  @Override\n\tpublic String getExpected() {\n\t    return myExpected;\n\t  }\n\n\t  @Override\n\tpublic String getActual() {\n\t    return myActual;\n\t  }\n\t}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/JavaAnnotationArgumentsInKotlinTest.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport org.jetbrains.kotlin.checkers.KotlinDiagnosticsTestCase;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class JavaAnnotationArgumentsInKotlinTest extends KotlinDiagnosticsTestCase {\n    @Override\n    @Before\n    public void configure() {\n        configureProjectWithStdLib();\n    }\n\n    @Test\n    public void testAnnotationAsJavaAnnotationArgument() throws Exception {\n        // KE-266\n        doTest(\"testData/diagnostics/annotationAsJavaAnnotationArgument.kt\");\n    }\n\n    @Test\n    public void testConstAsJavaAnnotationArgument() throws Exception {\n        doTest(\"testData/diagnostics/constAsJavaAnnotationArgument.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/JetLightFixture.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport junit.framework.TestCase;\n\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.junit.Assert;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.text.StringUtilRt;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiElementVisitor;\nimport com.intellij.psi.PsiFile;\nimport com.intellij.testFramework.LightVirtualFile;\n\npublic class JetLightFixture {\n\n\tprotected static void ensureParsed(PsiFile file) {\n        file.accept(new PsiElementVisitor() {\n            @Override\n            public void visitElement(PsiElement element) {\n                element.acceptChildren(this);\n            }\n        });\n    }\n\t\n\tpublic static KtFile createCheckAndReturnPsiFile(String testName, String fileName, String text, Project project) {\n\t\ttext = StringUtilRt.convertLineSeparators(text);\n        KtFile myFile = createPsiFile(testName, fileName, text, project);\n        ensureParsed(myFile);\n        TestCase.assertEquals(\"light virtual file text mismatch\", text, ((LightVirtualFile) myFile.getVirtualFile()).getContent().toString());\n        TestCase.assertEquals(\"virtual file text mismatch\", text, ((LightVirtualFile) myFile.getVirtualFile()).getContent());\n//        TODO: Uncomment and fix error\n//        TestCase.assertEquals(\"doc text mismatch\", text, myFile.getViewProvider().getDocument().getText());\n        TestCase.assertEquals(\"psi text mismatch\", text, myFile.getText());\n        return myFile;\n    }\n\t\n\tpublic static KtFile createPsiFile(@Nullable String testName, @Nullable String fileName, String text, Project project) {\n        if (fileName == null) {\n            Assert.assertNotNull(testName);\n            fileName = testName + \".kt\";\n        }\n        \n        return JetTestUtils.createFile(fileName, text, project);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/JetTestUtils.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport org.jetbrains.annotations.NonNls;\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.kotlin.idea.KotlinLanguage;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.utils.ExceptionUtilsKt;\nimport org.junit.Assert;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.Comparing;\nimport com.intellij.openapi.util.io.FileUtil;\nimport com.intellij.openapi.util.text.StringUtil;\nimport com.intellij.openapi.vfs.CharsetToolkit;\nimport com.intellij.psi.PsiFileFactory;\nimport com.intellij.psi.impl.PsiFileFactoryImpl;\nimport com.intellij.testFramework.LightVirtualFile;\n\npublic class JetTestUtils {\n    \n    public static final Pattern FILE_OR_MODULE_PATTERN = Pattern.compile(\n            \"(?://\\\\s*MODULE:\\\\s*(\\\\w+)(\\\\(\\\\w+(?:, \\\\w+)*\\\\))?\\\\s*)?\" + \"//\\\\s*FILE:\\\\s*(.*)$\", Pattern.MULTILINE);\n            \n    public static final Pattern DIRECTIVE_PATTERN = Pattern.compile(\"^//\\\\s*!(\\\\w+)(:\\\\s*(.*)$)?\", Pattern.MULTILINE);\n    \n    public static void mkdirs(File file) throws IOException {\n        if (file.isDirectory()) {\n            return;\n        }\n        if (!file.mkdirs()) {\n            if (file.exists()) {\n                throw new IOException(\"failed to create \" + file + \" file exists and not a directory\");\n            }\n            throw new IOException();\n        }\n    }\n    \n    public static String doLoadFile(File file) throws IOException {\n        return FileUtil.loadFile(file).trim();\n    }\n    \n    public interface TestFileFactory<M, F> {\n        F createFile(@Nullable M module, String fileName, String text, Map<String, String> directives);\n        \n        M createModule(String name, List<String> dependencies);\n    }\n    \n    public static abstract class TestFileFactoryNoModules<F> implements TestFileFactory<Void, F> {\n        @Override\n        public final F createFile(\n                @Nullable Void module,\n                @NotNull String fileName,\n                @NotNull String text,\n                @NotNull Map<String, String> directives\n        ) {\n            return create(fileName, text, directives);\n        }\n\n        @NotNull\n        public abstract F create(@NotNull String fileName, @NotNull String text, @NotNull Map<String, String> directives);\n\n        @Override\n        public Void createModule(@NotNull String name, @NotNull List<String> dependencies) {\n            return null;\n        }\n    }\n    \n    @NotNull\n    public static KtFile createFile(@NotNull @NonNls String name, @NotNull String text, @NotNull Project project) {\n        LightVirtualFile virtualFile = new LightVirtualFile(name, KotlinLanguage.INSTANCE, text);\n        virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);\n        return (KtFile) ((PsiFileFactoryImpl) PsiFileFactory.getInstance(project)).trySetupPsiForFile(virtualFile,\n                KotlinLanguage.INSTANCE, true, false);\n    }\n    \n    private static List<String> parseDependencies(@Nullable String dependencies) {\n        if (dependencies == null)\n            return Collections.emptyList();\n            \n        Matcher matcher = Pattern.compile(\"\\\\w+\").matcher(dependencies);\n        List<String> result = new ArrayList<String>();\n        while (matcher.find()) {\n            result.add(matcher.group());\n        }\n        return result;\n    }\n    \n    public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull String actual) {\n        try {\n            String actualText = StringUtil.convertLineSeparators(actual.trim());\n            // TODO: add remove trailing whitespaces from expected and actual\n            // text\n            \n            if (!expectedFile.exists()) {\n                FileUtil.writeToFile(expectedFile, actualText.getBytes());\n                Assert.fail(\"Expected data file did not exist. Generating: \" + expectedFile);\n            }\n            String expected = FileUtil.loadFile(expectedFile, \"UTF-8\", true);\n            String expectedText = StringUtil.convertLineSeparators(expected.trim());\n            \n            if (!Comparing.equal(expectedText, actualText)) {\n                throw new FileComparisonFailure(\"Actual data differs from file content: \" + expectedFile.getName(),\n                        expected, actual, expectedFile.getAbsolutePath());\n            }\n        } catch (IOException e) {\n            throw ExceptionUtilsKt.rethrow(e);\n        }\n    }\n    \n    @NotNull\n    public static Map<String, String> parseDirectives(String expectedText) {\n        Map<String, String> directives = new HashMap<>();\n        Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);\n        int start = 0;\n        while (directiveMatcher.find()) {\n            if (directiveMatcher.start() != start) {\n                Assert.fail(\"Directives should only occur at the beginning of a file: \" + directiveMatcher.group());\n            }\n            String name = directiveMatcher.group(1);\n            String value = directiveMatcher.group(3);\n            String oldValue = directives.put(name, value);\n            Assert.assertNull(\"Directive overwritten: \" + name + \" old value: \" + oldValue + \" new value: \" + value,\n                    oldValue);\n            start = directiveMatcher.end() + 1;\n        }\n        return directives;\n    }\n    \n    public static <M, F> List<F> createTestFiles(String testFileName, String expectedText,\n            TestFileFactory<M, F> factory) {\n        Map<String, String> directives = parseDirectives(expectedText);\n        \n        List<F> testFiles = new ArrayList<>();\n        Matcher matcher = FILE_OR_MODULE_PATTERN.matcher(expectedText);\n        if (!matcher.find()) {\n            // One file\n            testFiles.add(factory.createFile(null, testFileName, expectedText, directives));\n        } else {\n            int processedChars = 0;\n            M module = null;\n            // Many files\n            while (true) {\n                String moduleName = matcher.group(1);\n                String moduleDependencies = matcher.group(2);\n                if (moduleName != null) {\n                    module = factory.createModule(moduleName, parseDependencies(moduleDependencies));\n                }\n                \n                String fileName = matcher.group(3);\n                int start = processedChars;\n                \n                boolean nextFileExists = matcher.find();\n                int end;\n                if (nextFileExists) {\n                    end = matcher.start();\n                } else {\n                    end = expectedText.length();\n                }\n                String fileText = expectedText.substring(start, end);\n                processedChars = end;\n                \n                testFiles.add(factory.createFile(module, fileName, fileText, directives));\n                \n                if (!nextFileExists)\n                    break;\n            }\n            assert processedChars == expectedText.length() : \"Characters skipped from \" + processedChars + \" to \"\n                    + (expectedText.length() - 1);\n        }\n        return testFiles;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/KotlinDiagnosticsJavaPlusKotlinTest.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport org.jetbrains.kotlin.checkers.KotlinDiagnosticsTestCase;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinDiagnosticsJavaPlusKotlinTest extends KotlinDiagnosticsTestCase {\n    @Override\n    @Before\n    public void configure() {\n        configureProjectWithStdLib();\n    }\n    \n    @Test\n    public void testAccessClassObjectFromJava() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/accessClassObjectFromJava.kt\");\n    }\n    \n    @Test\n    public void testAmbiguousSamAdapters() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/ambiguousSamAdapters.kt\");\n    }\n    \n    @Test\n    public void testAnnotationWithArgumentsMissingDependencies() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/annotationWithArgumentsMissingDependencies.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testArrayOfStarParametrized() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/arrayOfStarParametrized.kt\");\n    }\n    \n    @Test\n    public void testCanDeclareIfSamAdapterIsInherited() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/canDeclareIfSamAdapterIsInherited.kt\");\n    }\n    \n    @Test\n    public void testComputeIfAbsentConcurrent() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt\");\n    }\n    \n    @Test\n    public void testContravariantIterable() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/contravariantIterable.kt\");\n    }\n    \n    @Test\n    public void testEnumGetOrdinal() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/enumGetOrdinal.kt\");\n    }\n    \n    @Test\n    public void testFieldOverridesField() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/fieldOverridesField.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testFieldOverridesFieldOfDifferentType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/fieldOverridesFieldOfDifferentType.kt\");\n    }\n    \n    @Test\n    public void testFinalCollectionSize() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/finalCollectionSize.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testGenericConstructorWithMultipleBounds() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/genericConstructorWithMultipleBounds.kt\");\n    }\n    \n    @Test\n    public void testGenericsInSupertypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/GenericsInSupertypes.kt\");\n    }\n    \n    @Test\n    public void testInheritAbstractSamAdapter() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/inheritAbstractSamAdapter.kt\");\n    }\n    \n    @Test\n    public void testInheritedGenericFunction() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/InheritedGenericFunction.kt\");\n    }\n    \n    @Test\n    public void testInnerClassFromJava() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/InnerClassFromJava.kt\");\n    }\n    \n    @Test\n    public void testInnerNestedClassFromJava() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/innerNestedClassFromJava.kt\");\n    }\n    \n    @Test\n    public void testInvisiblePackagePrivateInheritedMember() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/invisiblePackagePrivateInheritedMember.kt\");\n    }\n    \n    @Test\n    @Ignore(\"Add when java-integration will be ready\")\n    public void testKJKInheritance() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/KJKInheritance.kt\");\n    }\n\n    @Test\n    @Ignore(\"Add when java-integration will be ready\")\n    public void testKJKInheritanceGeneric() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/KJKInheritanceGeneric.kt\");\n    }\n    \n    @Test\n    public void testJavaStaticImport() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/javaStaticImport.kt\");\n    }\n    \n    @Test\n    public void testKt1402() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt1402.kt\");\n    }\n    \n    @Test\n    public void testKt1431() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt1431.kt\");\n    }\n    \n    @Test\n    public void testKt1730_implementCharSequence() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt1730_implementCharSequence.kt\");\n    }\n    \n    @Test\n    public void testKt2152() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2152.kt\");\n    }\n    \n    @Test\n    public void testKt2394() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2394.kt\");\n    }\n    \n    @Test\n    public void testKt2606() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2606.kt\");\n    }\n    \n    @Test\n    public void testKt2619() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2619.kt\");\n    }\n    \n    @Test\n    public void testKt2641() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2641.kt\");\n    }\n    \n    @Test\n    public void testKt2890() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt2890.kt\");\n    }\n    \n    @Test\n    public void testKt3307() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt3307.kt\");\n    }\n    \n    @Test\n    public void testKt3311() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt3311.kt\");\n    }\n    \n    @Test\n    public void testKt7523() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/kt7523.kt\");\n    }\n    \n    @Test\n    public void testMatchers() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/matchers.kt\");\n    }\n    \n    @Test\n    public void testMutableIterator() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/mutableIterator.kt\");\n    }\n    \n    @Test\n    public void testOverrideRawType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/overrideRawType.kt\");\n    }\n    \n    @Test\n    public void testOverrideVararg() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/OverrideVararg.kt\");\n    }\n    \n    @Test\n    public void testOverrideWithSamAndTypeParameter() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testPackagePrivateClassStaticMember() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/packagePrivateClassStaticMember.kt\");\n    }\n    \n    @Test\n    public void testPackageVisibility() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/packageVisibility.kt\");\n    }\n    \n    @Test\n    public void testPrivateNestedClassStaticMember() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/privateNestedClassStaticMember.kt\");\n    }\n    \n    @Test\n    public void testProtectedStaticSamePackage() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/protectedStaticSamePackage.kt\");\n    }\n    \n    @Test\n    public void testRecursionWithJavaSyntheticProperty() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.kt\");\n    }\n    \n    @Test\n    public void testRecursiveRawUpperBound() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/recursiveRawUpperBound.kt\");\n    }\n    \n    @Test\n    public void testRecursiveRawUpperBound2() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/recursiveRawUpperBound2.kt\");\n    }\n    \n    @Test\n    public void testRecursiveRawUpperBound3() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/recursiveRawUpperBound3.kt\");\n    }\n    \n    @Test\n    public void testSamInConstructorWithGenerics() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/samInConstructorWithGenerics.kt\");\n    }\n    \n    @Test\n    public void testSerializable() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/serializable.kt\");\n    }\n    \n    @Test\n    public void testShadowingPrimitiveStaticField() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/shadowingPrimitiveStaticField.kt\");\n    }\n    \n    @Test\n    public void testSimple() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/Simple.kt\");\n    }\n    \n    @Test\n    public void testSpecialBridges() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/specialBridges.kt\");\n    }\n    \n    @Test\n    public void testStaticMembersFromSuperclasses() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/StaticMembersFromSuperclasses.kt\");\n    }\n    \n    @Test\n    public void testSupertypeArgumentsNullabilityNotNullSpecialTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt\");\n    }\n    \n    @Test\n    public void testSupertypeArgumentsNullabilityNotNullUserTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt\");\n    }\n    \n    @Test\n    public void testSupertypeArgumentsNullabilitySpecialTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/SupertypeArgumentsNullability-SpecialTypes.kt\");\n    }\n    \n    @Test\n    public void testSupertypeArgumentsNullabilityUserTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/SupertypeArgumentsNullability-UserTypes.kt\");\n    }\n    \n    @Test\n    public void testTraitDefaultCall() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/traitDefaultCall.kt\");\n    }\n    \n    @Test\n    public void testUnboxingNulls() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/j+k/UnboxingNulls.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/diagnostics/KotlinDiagnosticsTest.java",
    "content": "package org.jetbrains.kotlin.core.tests.diagnostics;\n\nimport org.jetbrains.kotlin.checkers.KotlinDiagnosticsTestCase;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinDiagnosticsTest extends KotlinDiagnosticsTestCase {\n    \n    @Test\n    public void testAbstract() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Abstract.kt\");\n    }\n    \n    @Test\n    public void testAbstractAccessor() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AbstractAccessor.kt\");\n    }\n    \n    @Test\n    public void testAbstractInAbstractClass() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AbstractInAbstractClass.kt\");\n    }\n    \n    @Test\n    public void testAbstractInClass() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AbstractInClass.kt\");\n    }\n    \n    @Test\n    public void testAbstractInTrait() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AbstractInTrait.kt\");\n    }\n    \n    @Test\n    public void testAnonymousInitializers() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AnonymousInitializers.kt\");\n    }\n    \n    @Test\n    public void testAnonymousInitializerVarAndConstructor() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AnonymousInitializerVarAndConstructor.kt\");\n    }\n    \n    @Test\n    public void testAssignToArrayElement() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AssignToArrayElement.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testAutoCreatedIt() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/AutoCreatedIt.kt\");\n    }\n    \n    @Test\n    public void testBacktickNames() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/BacktickNames.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testBasic() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Basic.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testBinaryCallsOnNullableValues() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/BinaryCallsOnNullableValues.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testBounds() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Bounds.kt\");\n    }\n    \n    @Test\n    public void testBreakContinue() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/BreakContinue.kt\");\n    }\n\n    @Test\n    public void testBuilders() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Builders.kt\");\n    }\n    \n    @Test\n    public void testCasts() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Casts.kt\");\n    }\n    \n    @Test\n    public void testCharacterLiterals() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/CharacterLiterals.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testcheckType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/checkType.kt\");\n    }\n    \n    @Test\n    public void testCompareToWithErrorType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/CompareToWithErrorType.kt\");\n    }\n    \n    @Test\n    public void testConstants() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Constants.kt\");\n    }\n    \n    @Test\n    public void testConstructors() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Constructors.kt\");\n    }\n    \n    @Test\n    public void testConstructorsOfPrimitives() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ConstructorsOfPrimitives.kt\");\n    }\n    \n    @Test\n    public void testCovariantOverrideType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/CovariantOverrideType.kt\");\n    }\n    \n    @Test\n    public void testDefaultValueForParameterInFunctionType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DefaultValueForParameterInFunctionType.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testDefaultValuesTypechecking() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DefaultValuesTypechecking.kt\");\n    }\n    \n    @Test\n    public void testDeferredTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DeferredTypes.kt\");\n    }\n    \n    @Test\n    public void testDeprecatedGetSetPropertyDelegateConvention() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testDeprecatedUnaryOperatorConventions() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DeprecatedUnaryOperatorConventions.kt\");\n    }\n    \n    @Test\n    public void testDiamondFunction() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DiamondFunction.kt\");\n    }\n    \n    @Test\n    public void testDiamondFunctionGeneric() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DiamondFunctionGeneric.kt\");\n    }\n    \n    @Test\n    public void testDiamondProperty() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/DiamondProperty.kt\");\n    }\n    \n    @Test\n    public void testDollar() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Dollar.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testEnumEntryAsType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/EnumEntryAsType.kt\");\n    }\n    \n    @Test\n    public void testExtensionCallInvoke() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ExtensionCallInvoke.kt\");\n    }\n    \n    @Test\n    public void testfileDependencyRecursion() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/fileDependencyRecursion.kt\");\n    }\n    \n    @Test\n    public void testForRangeConventions() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ForRangeConventions.kt\");\n    }\n    \n    @Test\n    public void testFreeFunctionCalledAsExtension() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/FreeFunctionCalledAsExtension.kt\");\n    }\n    \n    @Test\n    public void testFunctionCalleeExpressions() throws Exception {\n        doTest(\"testData/diagnostics/FunctionCalleeExpressions.kt\");\n    }\n    \n    @Test\n    public void testFunctionParameterWithoutType() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/FunctionParameterWithoutType.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testFunctionReturnTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/FunctionReturnTypes.kt\");\n    }\n    \n    @Test\n    public void testGenericArgumentConsistency() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/GenericArgumentConsistency.kt\");\n    }\n    \n    @Test\n    public void testGenericFunctionIsLessSpecific() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/GenericFunctionIsLessSpecific.kt\");\n    }\n    \n    @Test\n    public void testimplicitIntersection() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/implicitIntersection.kt\");\n    }\n    \n    @Test\n    public void testimplicitNestedIntersection() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/implicitNestedIntersection.kt\");\n    }\n    \n    @Test\n    public void testIncDec() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/IncDec.kt\");\n    }\n    \n    @Test\n    public void testIncorrectCharacterLiterals() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/IncorrectCharacterLiterals.kt\");\n    }\n    \n    @Test\n    public void testInferNullabilityInThenBlock() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/InferNullabilityInThenBlock.kt\");\n    }\n    \n    @Test\n    public void testInfix() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Infix.kt\");\n    }\n    \n    @Test\n    public void testInfixModifierApplicability() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/InfixModifierApplicability.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInvokeAndRecursiveResolve() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/InvokeAndRecursiveResolve.kt\");\n    }\n    \n    @Test\n    public void testIsExpressions() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/IsExpressions.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testkt310() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/kt310.kt\");\n    }\n    \n    @Test\n    public void testkt53() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/kt53.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testLateInit() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/LateInit.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testLateInitSetter() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/LateInitSetter.kt\");\n    }\n    \n    @Test\n    public void testLiteralAsResult() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/LiteralAsResult.kt\");\n    }\n    \n    @Test\n    public void testLocalClassAndShortSubpackageNames() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/LocalClassAndShortSubpackageNames.kt\");\n    }\n    \n    @Test\n    public void testlocalInterfaces() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/localInterfaces.kt\");\n    }\n    \n    @Test\n    public void testLValueAssignment() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/LValueAssignment.kt\");\n    }\n    \n    @Test\n    public void testMultilineStringTemplates() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/MultilineStringTemplates.kt\");\n    }\n    \n    @Test\n    public void testMultipleBounds() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/MultipleBounds.kt\");\n    }\n    \n    @Test\n    public void testNamedFunctionTypeParameterInSupertype() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/NamedFunctionTypeParameterInSupertype.kt\");\n    }\n    \n    @Test\n    public void testNullability() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Nullability.kt\");\n    }\n    \n    @Test\n    public void testNumberPrefixAndSuffix() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/NumberPrefixAndSuffix.kt\");\n    }\n    \n    @Test\n    public void testObjectWithConstructor() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ObjectWithConstructor.kt\");\n    }\n    \n    @Test\n    public void testOperatorChecks() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OperatorChecks.kt\");\n    }\n    \n    @Test\n    public void testOperators() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Operators.kt\");\n    }\n    \n    @Test\n    public void testOperatorsWithWrongNames() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OperatorsWithWrongNames.kt\");\n    }\n    \n    @Test\n    public void testOverrideFunctionWithParamDefaultValue() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OverrideFunctionWithParamDefaultValue.kt\");\n    }\n    \n    @Test\n    public void testOverridenFunctionAndSpecifiedTypeParameter() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OverridenFunctionAndSpecifiedTypeParameter.kt\");\n    }\n    \n    @Test\n    public void testOverridenSetterVisibility() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OverridenSetterVisibility.kt\");\n    }\n    \n    @Test\n    public void testOverridingVarByVal() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/OverridingVarByVal.kt\");\n    }\n    \n    @Test\n    public void testPackageInExpressionPosition() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PackageInExpressionPosition.kt\");\n    }\n    \n    @Test\n    public void testPackageInTypePosition() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PackageInTypePosition.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testPackageQualified() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PackageQualified.kt\");\n    }\n    \n    @Test\n    public void testPrimaryConstructors() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PrimaryConstructors.kt\");\n    }\n    \n    @Test\n    public void testPrivateFromOuterPackage() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PrivateFromOuterPackage.kt\");\n    }\n    \n    @Test\n    public void testPrivateSetterForOverridden() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PrivateSetterForOverridden.kt\");\n    }\n    \n    @Test\n    public void testProcessingEmptyImport() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ProcessingEmptyImport.kt\");\n    }\n    \n    @Test\n    public void testProjectionOnFunctionArgumentErrror() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ProjectionOnFunctionArgumentErrror.kt\");\n    }\n    \n    @Test\n    public void testProjectionsInSupertypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ProjectionsInSupertypes.kt\");\n    }\n    \n    @Test\n    public void testProperties() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Properties.kt\");\n    }\n    \n    @Test\n    public void testPropertyInitializers() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/PropertyInitializers.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testQualifiedExpressions() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/QualifiedExpressions.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRecursiveGetter() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/properties/inferenceFromGetters/RecursiveGetter.kt\");\n    }\n    \n    @Test\n    public void testRecursiveResolve() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/RecursiveResolve.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRecursiveTypeInference() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/RecursiveTypeInference.kt\");\n    }\n    \n    @Test\n    public void testResolveOfJavaGenerics() throws Exception {\n        doTest(\"testData/compiler/diagnostics/tests/ResolveOfJavaGenerics.kt\");\n    }\n    \n    @Test\n    public void testResolveToJava() throws Exception {\n        doTest(\"testData/compiler/diagnostics/tests/ResolveToJava.kt\");\n    }\n    \n    @Test\n    public void testReturn() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Return.kt\");\n    }\n    \n    @Test\n    public void testSafeCallInvoke() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SafeCallInvoke.kt\");\n    }\n    \n    @Test\n    public void testSafeCallNonNullReceiver() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SafeCallNonNullReceiver.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testSafeCallNonNullReceiverReturnNull() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt\");\n    }\n    \n    @Test\n    public void testSafeCallOnFakePackage() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SafeCallOnFakePackage.kt\");\n    }\n    \n    @Test\n    public void testSafeCallOnSuperReceiver() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SafeCallOnSuperReceiver.kt\");\n    }\n    \n    @Test\n    public void testSerializable() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Serializable.kt\");\n    }\n    \n    @Test\n    public void testSetterVisibility() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SetterVisibility.kt\");\n    }\n    \n    @Test\n    public void testShiftFunctionTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ShiftFunctionTypes.kt\");\n    }\n    \n    @Test\n    public void testStarsInFunctionCalls() throws Exception {\n        doTest(\"testData/compiler/diagnostics/tests/StarsInFunctionCalls.kt\");\n    }\n    \n    @Test\n    public void testStringPrefixAndSuffix() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/StringPrefixAndSuffix.kt\");\n    }\n    \n    @Test\n    public void testStringTemplates() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/StringTemplates.kt\");\n    }\n    \n    @Test\n    public void testSupertypeListChecks() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SupertypeListChecks.kt\");\n    }\n    \n    @Test\n    public void testSyntaxErrorInTestHighlighting() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SyntaxErrorInTestHighlighting.kt\");\n    }\n    \n    @Test\n    public void testSyntaxErrorInTestHighlightingEof() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/SyntaxErrorInTestHighlightingEof.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testTraitOverrideObjectMethods() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/TraitOverrideObjectMethods.kt\");\n    }\n    \n    @Test\n    public void testTraitWithConstructor() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/TraitWithConstructor.kt\");\n    }\n    \n    @Test\n    public void testTypeInference() throws Exception {\n        doTest(\"testData/compiler/diagnostics/tests/TypeInference.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchOnOverrideWithSyntaxErrors() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/TypeMismatchOnOverrideWithSyntaxErrors.kt\");\n    }\n    \n    @Test\n    public void testUnderscore() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Underscore.kt\");\n    }\n    \n    @Test\n    public void testUnitByDefaultForFunctionTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/UnitByDefaultForFunctionTypes.kt\");\n    }\n    \n    @Test\n    public void testUnitValue() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/UnitValue.kt\");\n    }\n    \n    @Test\n    public void testUnresolved() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Unresolved.kt\");\n    }\n    \n    @Test\n    public void testUnusedParameters() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/UnusedParameters.kt\");\n    }\n    \n    @Test\n    public void testUnusedVariables() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/UnusedVariables.kt\");\n    }\n    \n    @Test\n    public void testValAndFunOverrideCompatibilityClash() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/ValAndFunOverrideCompatibilityClash.kt\");\n    }\n    \n    @Test\n    public void testVarargs() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Varargs.kt\");\n    }\n    \n    @Test\n    public void testVarargTypes() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/VarargTypes.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testVariance() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/Variance.kt\");\n    }\n\n    @Ignore\n    @Test\n    public void testFeaturesOfKotlin_1_2() throws Exception {\n        doTest(\"common_testData/compiler/diagnostics/tests/featuresOf_1_2.kt\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/launch/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.tests.launch;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( {\n\tKotlinLaunchTest.class,\n\tKotlinJUnitLaunchTest.class\n} )\npublic class AllTests {\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/launch/KotlinJUnitLaunchTest.java",
    "content": "package org.jetbrains.kotlin.core.tests.launch;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n@Ignore\npublic class KotlinJUnitLaunchTest extends KotlinJUnitLaunchTestCase {\n\t@Test\n\tpublic void testSimpleJUnitTests() {\n\t\tdoTest(\"testData/launch/junit/SimpleJUnitTests.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testRunTestExtendingTestCase() {\n\t\tdoTest(\"testData/launch/junit/RunTestExtendingTestCase.kt\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/launch/KotlinJUnitLaunchTestCase.java",
    "content": "package org.jetbrains.kotlin.core.tests.launch;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\n\nimport java.util.List;\n\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.debug.core.ILaunchConfiguration;\nimport org.eclipse.debug.internal.ui.DebugUIPlugin;\nimport org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;\nimport org.eclipse.jdt.core.IClasspathEntry;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport;\nimport org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants;\nimport org.eclipse.jdt.internal.junit.launcher.TestKindRegistry;\nimport org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\nimport org.jetbrains.kotlin.psi.KtClass;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.ui.launch.junit.KotlinJUnitLaunchShortcut;\nimport org.jetbrains.kotlin.ui.launch.junit.KotlinJUnitLaunchUtils;\nimport org.junit.Before;\n\npublic class KotlinJUnitLaunchTestCase extends KotlinProjectTestCase {\n\t@Before\n    public void configure() throws CoreException {\n\t\tconfigureProject();\n\t\taddJUnitToClasspath();\n\t\tgetTestProject().addKotlinRuntime();\n    }\n\t\n\tpublic void doTest(String testPath) {\n\t\tString fileText = KotlinTestUtils.getText(testPath);\n\t\tfinal TextEditorTest testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText);\n\t\t\n\t\tKotlinEditorTestCase.joinBuildThread();\n\t\t\n\t\tfinal LaunchShortcutExtension launchShortcut = findKotlinJUnitLaunchShortcut();\n\t\tassertNotNull(\"Kotlin JUnit launch shortcut was not founded\", launchShortcut);\n\t\t\n\t\tILaunchConfiguration[] launchConfigurations = launchShortcut.getLaunchConfigurations(testEditor.getEditor());\n\t\tassertEquals(launchConfigurations.length, 1);\n\t\t\n\t\ttry {\n\t\t\tILaunchConfiguration launchConfiguration = launchConfigurations[0];\n\t\t\t\n\t\t\tString actualTestRunnerKind = launchConfiguration.getAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND, (String) null);\n\t\t\tString expectedTestRunnerKind = TestKindRegistry.getContainerTestKindId(KotlinJUnitLaunchUtils.getEclipseTypeForSingleClass(testEditor.getEditingFile()));\n\t\t\tassertEquals(expectedTestRunnerKind, actualTestRunnerKind);\n\t\t\t\n\t\t\tString actualFQName = launchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null);\n\t\t\tKtClass singleJetClass = KotlinJUnitLaunchUtils.getSingleJetClass(testEditor.getEditingFile());\n\t\t\tassertEquals(singleJetClass.getFqName().asString(), actualFQName);\n\t\t} catch (CoreException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\t\n\tprivate LaunchShortcutExtension findKotlinJUnitLaunchShortcut() {\n\t\tList<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();\n\t\tfor (LaunchShortcutExtension launchShortcutExtension : launchShortcuts) {\n\t\t\tif (KotlinJUnitLaunchShortcut.KOTLIN_JUNIT_LAUNCH_ID.equals(launchShortcutExtension.getId())) {\n\t\t\t\treturn launchShortcutExtension;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\tprivate void addJUnitToClasspath() {\n\t\tIClasspathEntry jUnit4ClasspathEntry = BuildPathSupport.getJUnit4ClasspathEntry();\n        ProjectUtils.addContainerEntryToClasspath(getTestProject().getJavaProject(), jUnit4ClasspathEntry);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/launch/KotlinLaunchTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.core.tests.launch;\n\nimport org.junit.Test;\n\npublic class KotlinLaunchTest extends KotlinLaunchTestCase {\n    \n    private static final String MAIN_FUNCTION = \"fun main(args : Array<String>) { print(\\\"ok\\\") }\";\n    \n    @Test\n    public void launchSimpleProject() {\n        doTest(MAIN_FUNCTION, \"test_project\", \"org.jet.pckg\", null);\n    }\n    \n    @Test\n    public void launchWhenProjectNameHaveSpace() {\n        doTest(MAIN_FUNCTION, \"test project\", \"pckg\", null);\n    }\n    \n    @Test\n    public void launchWithTwoSourceFolders() {\n        doTest(MAIN_FUNCTION, \"testProject\", \"pckg\", \"src2\");\n    }\n    \n    @Test\n    public void launchWhenSourceFolderHaveSpace() {\n        doTest(MAIN_FUNCTION, \"testProject\", \"pckg\", \"src directory\");\n    }\n    \n    @Test\n    public void launchFileWithJvmNameAnnotation() {\n        doTest(\"@file:JvmName(\\\"some\\\") \" + MAIN_FUNCTION, \"testProject\", \"some.pckg\", null);\n    }\n    \n    @Test\n    public void launchMainFromObject() {\n        doTest(\"object SomeObj { @JvmStatic \" + MAIN_FUNCTION + \" }\", \"testProject\", \"pckg\", null);\n    }\n    \n    @Test\n    public void launchMainFromCompanionObject() {\n        doTest(\"class SomeClass { companion object { @JvmStatic \" + MAIN_FUNCTION + \" } }\", \"testProject\", \"pckg\", null);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/core/tests/launch/KotlinLaunchTestCase.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.core.tests.launch\n\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.eclipse.debug.core.DebugPlugin\nimport org.eclipse.debug.core.ILaunch\nimport org.eclipse.debug.core.ILaunchListener\nimport org.eclipse.debug.internal.ui.DebugUIPlugin\nimport org.eclipse.debug.internal.ui.IInternalDebugUIConstants\nimport org.eclipse.jface.dialogs.MessageDialogWithToggle\nimport org.jetbrains.kotlin.config.LanguageVersionSettingsImpl\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.launch.KotlinLaunchShortcut\nimport org.jetbrains.kotlin.ui.launch.getEntryPoint\nimport org.junit.After\nimport org.junit.Assert\nimport org.junit.Before\n\nabstract class KotlinLaunchTestCase : KotlinEditorTestCase() {\n    val compileWithErrorPreference = DebugUIPlugin.getDefault().preferenceStore\n            .getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR)\n    \n    @Before\n    fun before() {\n        DebugUIPlugin.getDefault().preferenceStore.setValue(\n                IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, MessageDialogWithToggle.ALWAYS)\n    }\n    \n    @After\n    fun after() {\n        DebugUIPlugin.getDefault().preferenceStore.setValue(\n                IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, compileWithErrorPreference)\n    }\n    \n    fun doTest(input: String, projectName: String, packageName: String, additionalSrcFolderName: String?) {\n        testEditor = configureEditor(\"Test.kt\", input, projectName, packageName)\n        testEditor.testJavaProject.addKotlinRuntime()\n        if (additionalSrcFolderName != null) {\n            testEditor.testJavaProject.createSourceFolder(additionalSrcFolderName)\n        }\n        \n        KotlinTestUtils.joinBuildThread()\n        \n        val output = launchInForeground()\n        Assert.assertEquals(\"ok\", output)\n    }\n    \n    private fun launchInForeground(): String {\n        val stdout = StringBuilder()\n        val launchListener = object : ILaunchListener {\n            override fun launchRemoved(launch: ILaunch) {\n            }\n            \n            override fun launchChanged(launch: ILaunch) {\n                with(launch.processes[0].streamsProxy) {\n                    outputStreamMonitor.addListener { text, monitor -> stdout.append(text) }\n                    errorStreamMonitor.addListener { text, monitor -> stdout.append(text) }\n                }\n            }\n            \n            override fun launchAdded(launch: ILaunch) {\n            }\n        }\n\n        DebugPlugin.getDefault().launchManager.addLaunchListener(launchListener)\n        \n        var launch: ILaunch? = null\n        try {\n            val entryPoint = getEntryPoint(editor.parsedFile!!, LanguageVersionSettingsImpl.DEFAULT)\n            val launchConfiguration = KotlinLaunchShortcut.createConfiguration(entryPoint!!, testEditor.eclipseProject)\n            launch = DebugUIPlugin.buildAndLaunch(launchConfiguration, \"run\", NullProgressMonitor())\n            \n            synchronized (launch) {\n                for (attempt in 0..50) {\n                    if (launch!!.isTerminated) break\n                    (launch as java.lang.Object).wait(100)\n                }\n            }\n            \n            if (!launch.isTerminated) stdout.append(\"Launch not terminated\")\n        } finally {\n            launch?.terminate()\n            DebugPlugin.getDefault().launchManager.removeLaunchListener(launchListener)\n        }\n        \n        return stdout.toString()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n\torg.jetbrains.kotlin.ui.tests.editors.AllTests.class,\n\torg.jetbrains.kotlin.core.tests.launch.AllTests.class,\n\torg.jetbrains.kotlin.ui.tests.editors.completion.templates.KotlinTemplatesTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.completion.KotlinBasicCompletionTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.quickfix.intentions.KotlinReplaceGetIntentionTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.quickfix.intentions.KotlinSpecifyTypeTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport.KotlinAutoImportTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.quickfix.intentions.KotlinConvertToExpressionBodyTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.quickfix.intentions.KotlinConvertToBlockBodyTest.class,\n\torg.jetbrains.kotlin.ui.tests.editors.navigation.AllTests.class,\n\torg.jetbrains.kotlin.core.tests.diagnostics.AllDiagnosticsTests.class,\n\torg.jetbrains.kotlin.ui.tests.editors.completion.handlers.KotlinCompletionHandlerInsertTest.class,\n\torg.jetbrains.kotlin.ui.tests.search.KotlinFindReferencesTest.class} )\npublic class AllTests {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.jetbrains.kotlin.ui.tests.editors.formatter.KotlinFormatActionTest;\nimport org.jetbrains.kotlin.ui.tests.editors.highlighting.KotlinHighlightingTest;\nimport org.jetbrains.kotlin.ui.tests.editors.selection.KotlinSelectEnclosingTest;\nimport org.jetbrains.kotlin.ui.tests.editors.selection.KotlinSelectNextTest;\nimport org.jetbrains.kotlin.ui.tests.editors.selection.KotlinSelectPreviousTest;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n    KotlinEditorBaseTest.class, \n    KotlinBasicAutoIndentTest.class,\n    KotlinAnalyzerInIDETest.class,\n    KotlinHighlightingTest.class,\n    KotlinBracketInserterTest.class,\n    KotlinFormatActionTest.class,\n    KotlinCustomLocationBugTest.class,\n    PsiVisualizationCommandTest.class,\n    KotlinEditorClosedProjectInfluenceTest.class,\n    KotlinSelectEnclosingTest.class,\n    KotlinSelectNextTest.class,\n    KotlinSelectPreviousTest.class\n} )\npublic class AllTests {\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/CommandTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.eclipse.core.commands.Command;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.commands.ICommandService;\nimport org.junit.Assert;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\n\npublic class CommandTestCase extends KotlinEditorTestCase {\n\n\tpublic static void assertCommandEnabled(String commandId, boolean isEnabled) {\n\t\tIWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n\t\tICommandService commandService = (ICommandService) workbenchWindow.getService(ICommandService.class);\n\t\tCommand command = commandService.getCommand(commandId);\t\t\n\n\t\tAssert.assertEquals(isEnabled, command.isEnabled());\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinAnalyzerInIDETest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinAnalyzerInIDETest extends KotlinAnalyzerInIDETestCase {\n\t\n    @Ignore\n    @Test\n    public void unresolvedPackageType() {\n        doAutoTest();\n    }\n\t\n    @Test\n    public void analyzerHasKotlinRuntime() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void checkAnalyzerFoundError() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void analyzerHasKotlinAnnotations() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void javaFromKotlin() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void kotlinFromJava() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void kotlinInpackageFromJava() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void kotlinJavaKotlin() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void kotlinWithErrorsFromJava() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void checkTestsFoundJavaError() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void companionObjectFromJava() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void packageLevelFunctionsFromJava() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void packageLevelPropertiesFromJava() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void checkExistancePackageLevelFunctions() {\n    \tdoAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinAnalyzerInIDETestCase.kt",
    "content": "/*******************************************************************************\n* Copyright 2000-2015 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors\n\nimport java.io.File\nimport java.util.Arrays\nimport java.util.Collections\nimport kotlin.Pair\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.core.runtime.CoreException\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\nimport org.jetbrains.kotlin.resolve.BindingContext\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorAutoTestCase\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.testframework.utils.SourceFileData\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotation\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotationUtil\nimport org.junit.Assert\nimport org.junit.Before\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.eclipse.jdt.core.JavaCore\nimport org.eclipse.jdt.core.ICompilationUnit\n\nabstract class KotlinAnalyzerInIDETestCase : KotlinEditorAutoTestCase() {\n    @Before\n    fun before() {\n        configureProjectWithStdLib()\n    }\n    \n    private fun performTest(file: IFile, expectedFileText: String) {\n        val markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)\n        val actual = insertTagsForErrors(loadEclipseFile(file), markers)\n        Assert.assertEquals(expectedFileText, actual)\n    }\n    \n    override fun doSingleFileAutoTest(testPath: String) {\n        loadFilesToProjectAndDoTest(Collections.singletonList(File(testPath)))\n    }\n    \n    override fun doMultiFileAutoTest(testFolder: File) {\n        loadFilesToProjectAndDoTest(testFolder.listFiles().toList())\n    }\n    \n    private fun loadFilesToProjectAndDoTest(files: List<File>) {\n        val filesWithExpectedData = loadFilesToProject(files)\n        \n        KotlinTestUtils.joinBuildThread()\n        \n        for (fileAndExpectedData in filesWithExpectedData) {\n            val file = fileAndExpectedData.first\n            performTest(file, fileAndExpectedData.second)\n        }\n    }\n    \n    private fun loadFilesToProject(files: List<File>): List<Pair<IFile, String>> {\n        return files.map { file ->\n            val input = KotlinTestUtils.getText(file.getAbsolutePath())\n            val resolvedInput = KotlinTestUtils.resolveTestTags(input)\n            Pair(\n                createSourceFile(\n                    SourceFileData.getPackageFromContent(resolvedInput), \n                    file.getName(),\n                    KotlinTestUtils.resolveTestTags(resolvedInput)),\n                input)\n        }\n    }\n    \n    private fun loadEclipseFile(file: IFile): String = EditorUtil.getDocument(file).get()\n    \n    override fun getTestDataRelativePath() = ANALYZER_TEST_DATA_PATH_SEGMENT\n}\n\nprivate val ANALYZER_TEST_DATA_PATH_SEGMENT = \"ide_analyzer\"\n\nprivate fun insertTagsForErrors(fileText: String, markers: Array<IMarker>): String {\n    val result = StringBuilder(fileText)\n    var offset = 0\n    for (marker in markers) {\n        if (!(marker.getAttribute(IMarker.SEVERITY, 0) === IMarker.SEVERITY_ERROR)) {\n            continue\n        }\n        offset += insertTagByOffset(result, KotlinTestUtils.ERROR_TAG_OPEN, getTagStartOffset(marker, IMarker.CHAR_START), offset.toInt())\n        offset += insertTagByOffset(result, KotlinTestUtils.ERROR_TAG_CLOSE, getTagStartOffset(marker, IMarker.CHAR_END), offset.toInt())\n    }\n    \n    return result.toString()\n}\n\nprivate fun getTagStartOffset(marker: IMarker, type: String): Int = marker.getAttribute(type) as Int\n\nprivate fun insertTagByOffset(builder: StringBuilder, tag: String, tagStartOffset: Int, offset: Int): Int {\n    val tagOffset = tagStartOffset + offset\n    builder.insert(tagOffset, tag)\n    return tag.length\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinAutoIndentTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinAutoIndentTest extends KotlinAutoIndentTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/indentationOnNewline\";\n    }\n    \n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n    \n    @Test\n    public void AfterCatch() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void AfterFinally() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void AfterImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void AfterTry() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void AssignmentAfterEq() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void BinaryWithTypeExpressions() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ConsecutiveCallsAfterDot() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ConsecutiveCallsInSaeCallsMiddle() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ConsecutiveCallsInSafeCallsEnd() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DoInFun() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void For() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionBlock() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionWithInference() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void If() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InBinaryExpressionInMiddle() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InBinaryExpressionsBeforeCloseParenthesis() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InBinaryExpressionUnfinished() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InDelegationListAfterColon() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InDelegationListAfterComma() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InDelegationListNotEmpty() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InEnumAfterSemicolon() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InEnumInitializerListAfterComma() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InEnumInitializerListNotEmpty() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InExpressionsParenthesesBeforeOperand() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void InLambdaBeforeParams() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void InLambdaInsideChainCallSameLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void InLambdaInsideChainCallWithNewLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void InLambdaInsideChainCallWithNewLineWithSpaces() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void InMultilineLambdaAfterArrow() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void IsExpressionAfterIs() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void MultideclarationAfterEq() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void MultideclarationBeforeEq() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void NotFirstParameter() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void PropertyWithInference() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ReturnContinue() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void SettingAlignMultilineParametersInCalls() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void While() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinAutoIndentTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase\nimport org.junit.Before\nimport org.eclipse.jface.text.TextUtilities\nimport org.eclipse.ui.editors.text.EditorsUI\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.jetbrains.kotlin.ui.tests.editors.formatter.KotlinFormatActionTestCase\nimport com.intellij.psi.codeStyle.CodeStyleSettings\nimport org.jetbrains.kotlin.testframework.utils.CodeStyleConfigurator\nimport org.junit.After\n\nabstract class KotlinAutoIndentTestCase : KotlinEditorWithAfterFileTestCase() {\n    @Before\n    fun before() {\n        configureProject()\n    }\n    \n    @After\n    fun setDefaultSettings() {\n        CodeStyleConfigurator.deconfigure(testProject.project)\n    }\n    \n    override fun performTest(fileText: String, expectedFileText: String) {\n        CodeStyleConfigurator.configure(testProject.project, fileText)\n        \n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true)\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4)\n        \n        testEditor.typeEnter()\n        \n        EditorTestUtils.assertByEditor(testEditor.getEditor(), expectedFileText)\n    }\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinAutoIndenterTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase.Separator;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.junit.After;\nimport org.junit.Before;\n\npublic abstract class KotlinAutoIndenterTestCase extends KotlinProjectTestCase {\n    private int initialSpacesCount;\n    private Separator initialSeparator;\n    \n    @Before\n    public void configure() {\n        configureProject();\n        initialSeparator = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS) ? Separator.SPACE : Separator.TAB;\n        initialSpacesCount = EditorsUI.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);\n    }\n    \n    @Override\n    @After\n    public void afterTest() {\n        super.afterTest();\n        setStorePreference(Separator.SPACE == initialSeparator, initialSpacesCount);\n    }\n    \n    protected void doTest(String input, String expected) {\n        String resolvedInput = KotlinTestUtils.resolveTestTags(input);\n        TextEditorTest testEditor = configureEditor(\"Test.kt\", resolvedInput);\n        setStorePreference(false, 2);\n        \n        if (input.contains(KotlinEditorTestCase.CARET_TAG)) {\n            testEditor.typeEnter();\n        }\n        \n        EditorTestUtils.assertByEditor(testEditor.getEditor(), expected);\n    }\n    \n    protected IPreferenceStore getStore() {\n        return EditorsUI.getPreferenceStore();\n    }\n    \n    protected void setStorePreference(boolean isSpacesForTabs, int tabWidth) {\n        getStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, isSpacesForTabs);\n        getStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, tabWidth);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinBasicAutoIndentTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinBasicAutoIndentTest extends KotlinAutoIndentTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"format/autoIndent\";\n    }\n    \n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n\t\n\t@Test\n\tpublic void sampleTest() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesOnOneLine() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesOnDifferentLine() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void beforeCloseBrace() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void afterOneOpenBrace() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void lineBreakSaveIndent() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void afterOperatorIfWithoutBraces() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void afterOperatorWhileWithoutBraces() {\n\t    doAutoTest();\n\t}\n\t\n\t\n\t@Test\n\tpublic void breakLineAfterIfWithoutBraces() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void nestedOperatorsWithBraces() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void nestedOperatorsWithoutBraces() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void beforeFunctionStart() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void afterOpenBraceWithShift() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesWithSpacesAtStart() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesWithSpacesEnd1() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesWithSpacesEnd2() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void betweenBracesWithSpacesMiddle() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void newLineInParameters1() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n    public void newLineInParameters2() {\n        doAutoTest();\n    }\n\t\n\t@Test\n\tpublic void continuationBeforeFunName() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n    public void continuationAfterDotCall() {\n        doAutoTest();\n    }\n\t\n\t@Test\n\tpublic void indentBeforeWhile() {\n\t    doAutoTest();\n\t}\n\t\n\t@Ignore\n\t@Test\n\tpublic void afterFunCallInScript() {\n\t    doAutoTest();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinBracketInserterTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.junit.Test;\n\npublic class KotlinBracketInserterTest extends KotlinBracketInserterTestCase {\n    \n    @Test\n    public void simpleBracketAutoCompletion() {\n        doTest(\"<caret>\", '(', \"()\");\n    }\n    \n    @Test\n    public void insertBeforeOpenBracket() {\n        doTest(\"println<caret>()\", '(', \"println(()\");\n    }\n    \n    @Test\n    public void insertBeforeBetweenBracket() {\n        doTest(\"(<caret>)\", '(', \"(())\");\n    }\n    \n    @Test\n    public void insertAngleBracket() {\n        doTest(\"<caret>\", '<', \"<>\");\n    }\n    \n    @Test\n    public void insertBrace() {\n        doTest(\"<caret>\", '{', \"{}\");\n    }\n    \n    @Test\n    public void insertBracketInsideString() {\n        doTest(\"\\\"Hel<caret>lo\\\"\", '(', \"\\\"Hel(lo\\\"\");\n    }\n    \n    @Test\n    public void insertClosingBraceOnLastLine() {\n        doTest(\"fun foo() {\\n\\tFoo()\\n<caret>\", '}', \"fun foo() {\\n\\tFoo()\\n}\");\n    }\n    \n    @Test\n    public void insertClosingBraceAfterExpression() {\n        doTest(\"fun foo() {\\n\\tFoo() <caret>\", '}', \"fun foo() {\\n\\tFoo() }\");\n    }\n    \n    @Test\n    public void insertClosingBrace() {\n        doTest(\"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n<caret>\\n}\", '}', \"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n\\t}\\n}\");\n    }\n    \n    @Test\n    public void insertClosingBraceWithRemovingTabulation() {\n        doTest(\"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n\\t\\t\\t<caret>\\n}\", '}', \"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n\\t}\\n}\");\n    }\n    \n    @Test\n    public void insertClosingBraceWithoutRemovingTabulation() {\n        doTest(\"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n\\t<caret>\\n}\", '}', \"class Foo {\\n\\tfun foo() {\\n\\t\\tFoo()\\n\\t}\\n}\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinBracketInserterTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.junit.After;\nimport org.junit.Before;\n\npublic abstract class KotlinBracketInserterTestCase extends KotlinProjectTestCase {\n    \n    private boolean spacesForTabsInitialValue;\n    \n    @Before\n    public void setUp() {\n        configureProject();\n        \n        spacesForTabsInitialValue = EditorsUI.getPreferenceStore().getBoolean(\n                AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);\n    }\n    \n    @After\n    public void tearDown() {\n        EditorsUI.getPreferenceStore().setValue(\n                AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, spacesForTabsInitialValue);\n        \n        super.afterTest();\n    }\n    \n    protected void doTest(String input, char element, String expected) {\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);\n        \n        TextEditorTest testEditor = configureEditor(\"Test.kt\", input);\n        testEditor.type(element);\n        \n        EditorTestUtils.assertByEditor(testEditor.getEditor(), expected);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinCustomLocationBugTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport java.io.File;\nimport java.util.List;\n\nimport org.eclipse.core.resources.ResourcesPlugin;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.eclipse.jdt.core.JavaModelException;\nimport org.jetbrains.kotlin.core.utils.ProjectUtils;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class KotlinCustomLocationBugTest extends KotlinEditorTestCase {\n\n\tprivate static final String CUSTOM_LOCATION_TEST_PROJECT_NAME = \"Test Project\";\n\tprivate static final String CUSTOM_LOCATION_TEST_PROJECT_LOCATION = \"custom_location/custom_test_project\";\n\n\t@Test\n\tpublic void testGetSrcDirectories() throws JavaModelException {\n\t\tTestJavaProject testProject = new TestJavaProject(CUSTOM_LOCATION_TEST_PROJECT_NAME, CUSTOM_LOCATION_TEST_PROJECT_LOCATION);\n\t\t\n\t\tIJavaProject javaProject = testProject.getJavaProject();\n\t\tList<File> files =  ProjectUtils.getSrcDirectories(javaProject);\n\t\n\t\tIPath workspaceRootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();\n\t\tIPath expectedSourcePath = workspaceRootPath.append(CUSTOM_LOCATION_TEST_PROJECT_LOCATION).append(TestJavaProject.SRC_FOLDER);\n\t\t\n\t\tAssert.assertEquals(1, files.size());\n\t\tAssert.assertEquals(expectedSourcePath.toFile(), files.iterator().next());\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinEditorBaseTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class KotlinEditorBaseTest extends KotlinProjectTestCase {\n\t@Test\n\tpublic void openEditorTest() {\n\t\tTextEditorTest textEditor = new TextEditorTest();\n\t\tAssert.assertNotNull(textEditor.createEditor(\"Test.kt\", \"\"));\n\t}\n\t\n\t@Test\n\tpublic void getJavaProjectTest() {\n\t\tTextEditorTest textEditor = new TextEditorTest();\n\t\tAssert.assertNotNull(textEditor.getTestJavaProject());\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/KotlinEditorClosedProjectInfluenceTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport static org.junit.Assert.assertTrue;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.eclipse.ui.IEditorPart;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor;\nimport org.junit.Test;\n\n/**\n * Tests for bug <a href=\"https://youtrack.jetbrains.com/issue/KT-8193\">KT-8193</a>.\n */\npublic class KotlinEditorClosedProjectInfluenceTest extends KotlinEditorTestCase {\n\n\tprivate static final String PROJECT_NAME_FIRST = \"!FirstProject\";\n\tprivate static final String PROJECT_NAME_SECOND = \"SecondProject\";\n\n\t@Test\n\tpublic void testTwoProjectsBothOpen() throws CoreException {\n\t\tnew TestJavaProject(PROJECT_NAME_FIRST);\n\t\tTestJavaProject secondProject = new TestJavaProject(PROJECT_NAME_SECOND);\n\n\t\tIFile file = secondProject.createSourceFile(\n\t\t\tTextEditorTest.TEST_PACKAGE_NAME, \"Test.kt\", \"// Lorem ipsum\"\n\t\t);\n\t\tIEditorPart editor = EditorTestUtils.openInEditor(file);\n\n\t\tassertTrue(editor instanceof KotlinFileEditor);\n\t}\n\n\t@Test\n\tpublic void testTwoProjectsOneClosed() throws CoreException {\n\t\tTestJavaProject firstProject = new TestJavaProject(PROJECT_NAME_FIRST);\n\t\tTestJavaProject secondProject = new TestJavaProject(PROJECT_NAME_SECOND);\n\n\t\tfirstProject.getJavaProject().getProject().close(null);\n\n\t\tIFile file = secondProject.createSourceFile(\n\t\t\tTextEditorTest.TEST_PACKAGE_NAME, \"Test.kt\", \"// Lorem ipsum\"\n\t\t);\n\t\tIEditorPart editor = EditorTestUtils.openInEditor(file);\n\n\t\tassertTrue(editor instanceof KotlinFileEditor);\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/PsiVisualizationCommandTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.runtime.CoreException;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.junit.Test;\n\npublic class PsiVisualizationCommandTest extends CommandTestCase {\n\n\tpublic static final String COMMAND_ID_PSI_VISUALIZATION = \"org.jetbrains.kotlin.psi.visualization\";\t\n\n\t@Test\n\tpublic void testPsiVisualizationCommandWithoutEditor() {\n\t\tassertCommandEnabled(COMMAND_ID_PSI_VISUALIZATION, false);\n\t}\n\n\t@Test\n\tpublic void testPsiVisualizationCommandInKotlinEditor() {\n\t\tconfigureEditor(\"Test.kt\", \"// Lorem ipsum\");\n\n\t\tassertCommandEnabled(COMMAND_ID_PSI_VISUALIZATION, true);\n\t}\n\n\t@Test\n\tpublic void testPsiVisualizationCommandInJavaEditor() throws CoreException {\n\t\tTextEditorTest testEditor = new TextEditorTest();\n\n\t\tIFile file = testEditor.getTestJavaProject().createSourceFile(\n\t\t\tTextEditorTest.TEST_PACKAGE_NAME, \"Test.java\", \"// Lorem ipsum\"\n\t\t);\n\t\tEditorTestUtils.openInEditor(file);\n\n\t\tassertCommandEnabled(COMMAND_ID_PSI_VISUALIZATION, false);\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n\tKotlinBasicCompletionTest.class,\n\tKotlinFunctionParameterInfoTest.class\n} )\npublic class AllTests {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinBasicCompletionTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion;\n\nimport org.junit.Test;\n\npublic class KotlinBasicCompletionTest extends KotlinBasicCompletionTestCase {\n\t@Test\n\tpublic void testJavaConstructorsComletion() {\n\t\tdoTest(\"testData/completion/basic/java/JavaConstructorsCompletion.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testAfterFloatOnNewLine() {\n\t\tdoTest(\"testData/completion/basic/common/AfterFloatOnNewLine.kt\");\n\t}\n\n\t@Test\n\tpublic void testAfterIntSeparatedWithComments() {\n\t\tdoTest(\"common_testData/ide/completion/basic/common/AfterIntSeparatedWithComments.kt\");\n\t}\n\n\t@Test\n\tpublic void testAutoCastAfterIf() {\n\t\tdoTest(\"common_testData/ide/completion/basic/common/smartCast/SmartCastAfterIf.kt\");\n\t}\n\n\t@Test\n\tpublic void testAutoCastAfterIfMethod() {\n\t\tdoTest(\"testData/completion/basic/common/AutoCastAfterIfMethod.kt\");\n\t}\n\n\t@Test\n\tpublic void testAutoCastForThis() {\n\t\tdoTest(\"common_testData/ide/completion/basic/common/smartCast/SmartCastForThis.kt\");\n\t}\n\n\t@Test\n\tpublic void testAutoCastInWhen() {\n\t\tdoTest(\"common_testData/ide/completion/basic/common/smartCast/SmartCastInWhen.kt\");\n\t}\n\n\t@Test\n\tpublic void testBasicAny() {\n\t\tdoTest(\"testData/completion/basic/common/BasicAny.kt\");\n\t}\n\n\t@Test\n\tpublic void testBasicInt() {\n\t\tdoTest(\"testData/completion/basic/common/BasicInt.kt\");\n\t}\n\n\t@Test\n\tpublic void testBeforeDotInCall() {\n\t\tdoTest(\"testData/completion/basic/common/BeforeDotInCall.kt\");\n\t}\n\n\t@Test\n\tpublic void testCallLocalLambda() {\n\t\tdoTest(\"common_testData/ide/completion/basic/common/CallLocalLambda.kt\");\n\t}\n\n\t@Test\n\tpublic void testClassObjectElementsInClass() {\n\t\tdoTest(\"testData/completion/basic/common/ClassObjectElementsInClass.kt\");\n\t}\n\n\t@Test\n\tpublic void testClassRedeclaration1() {\n\t\tdoTest(\"testData/completion/basic/common/ClassRedeclaration1.kt\");\n\t}\n\n\t@Test\n\tpublic void testClassRedeclaration2() {\n\t\tdoTest(\"testData/completion/basic/common/ClassRedeclaration2.kt\");\n\t}\n\n\t@Test\n\tpublic void testExtendClassName() {\n\t\tdoTest(\"testData/completion/basic/common/ExtendClassName.kt\");\n\t}\n\n\t@Test\n\tpublic void testExtendQualifiedClassName() {\n\t\tdoTest(\"testData/completion/basic/common/ExtendQualifiedClassName.kt\");\n\t}\n\n//\t TODO: Add completion for extensions\n//\t@Test\n//\tpublic void testExtensionForProperty() {\n//\t\tdoTest(\"testData/completion/basic/common/ExtensionForProperty.kt\");\n//\t}\n\n//\t@Test\n//\tpublic void testExtensionFunReceiver() {\n//\t\tdoTest(\"testData/completion/basic/common/ExtensionFunReceiver.kt\");\n//\t}\n\n//\t@Test\n//\tpublic void testExtensionFunReceiverForce() {\n//\t\tdoTest(\"testData/completion/basic/common/ExtensionFunReceiverForce.kt\");\n//\t}\n\n//\t@Test\n//\tpublic void testExtensionInsideFunction() {\n//\t\tdoTest(\"testData/completion/basic/common/ExtensionInsideFunction.kt\");\n//\t}\n\n\t@Test\n\tpublic void testExtensionToIntInFloatStyle() {\n\t\tdoTest(\"testData/completion/basic/common/ExtensionToIntInFloatStyle.kt\");\n\t}\n\n\t@Test\n\tpublic void testFromImports() {\n\t\tdoTest(\"testData/completion/basic/common/FromImports.kt\");\n\t}\n\n//\t@Test\n//\tpublic void testFunctionCompletionFormatting() {\n//\t\tdoTest(\"testData/completion/basic/common/FunctionCompletionFormatting.kt\");\n//\t}\n\n\t@Test\n\tpublic void testInCallExpression() {\n\t\tdoTest(\"testData/completion/basic/common/InCallExpression.kt\");\n\t}\n\n\t@Test\n\tpublic void testInClassInitializer() {\n\t\tdoTest(\"testData/completion/basic/common/InClassInitializer.kt\");\n\t}\n\n\t@Test\n\tpublic void testInClassPropertyAccessor() {\n\t\tdoTest(\"testData/completion/basic/common/InClassPropertyAccessor.kt\");\n\t}\n\n\t@Test\n\tpublic void testInEmptyImport() {\n\t\tdoTest(\"testData/completion/basic/common/InEmptyImport.kt\");\n\t}\n\n\t@Test\n\tpublic void testInExpressionNoPrefix() {\n\t\tdoTest(\"testData/completion/basic/common/InExpressionNoPrefix.kt\");\n\t}\n\n\t@Test\n\tpublic void testInExtendTypeAnnotation() {\n\t\tdoTest(\"testData/completion/basic/common/InExtendTypeAnnotation.kt\");\n\t}\n\n\t@Test\n\tpublic void testInFileWithMultiDeclaration() {\n\t\tdoTest(\"testData/completion/basic/common/InFileWithMultiDeclaration.kt\");\n\t}\n\n\t@Test\n\tpublic void testInFileWithTypedef() {\n\t\tdoTest(\"testData/completion/basic/common/InFileWithTypedef.kt\");\n\t}\n\n\t@Test\n\tpublic void testInFunInClassInitializer() {\n\t\tdoTest(\"testData/completion/basic/common/InFunInClassInitializer.kt\");\n\t}\n\n\t@Test\n\tpublic void testInGlobalPropertyInitializer() {\n\t\tdoTest(\"testData/completion/basic/common/InGlobalPropertyInitializer.kt\");\n\t}\n\n\t@Test\n\tpublic void testInImport() {\n\t\tdoTest(\"testData/completion/basic/common/InImport.kt\");\n\t}\n\n\t@Test\n\tpublic void testInInitializerInPropertyAccessor() {\n\t\tdoTest(\"testData/completion/basic/common/InInitializerInPropertyAccessor.kt\");\n\t}\n\n\t@Test\n\tpublic void testInLocalObjectDeclaration() {\n\t\tdoTest(\"testData/completion/basic/common/InLocalObjectDeclaration.kt\");\n\t}\n\n\t@Test\n\tpublic void testInLongDotQualifiedExpression() {\n\t\tdoTest(\"testData/completion/basic/common/InLongDotQualifiedExpression.kt\");\n\t}\n\n\t@Test\n\tpublic void testInMiddleOfPackage() {\n\t\tdoTest(\"testData/completion/basic/common/InMiddleOfPackage.kt\");\n\t}\n\n\t@Test\n\tpublic void testInMiddleOfPackageDirective() {\n\t\tdoTest(\"testData/completion/basic/common/InMiddleOfPackageDirective.kt\");\n\t}\n\n\t@Test\n\tpublic void testInObjectInDelegationSpecifier() {\n\t\tdoTest(\"testData/completion/basic/common/InObjectInDelegationSpecifier.kt\");\n\t}\n\n\t@Test\n\tpublic void testInPackageBegin() {\n\t\tdoTest(\"testData/completion/basic/common/InPackageBegin.kt\");\n\t}\n\n\t@Test\n\tpublic void testInParametersTypes() {\n\t\tdoTest(\"testData/completion/basic/common/InParametersTypes.kt\");\n\t}\n\n\t@Test\n\tpublic void testInParametersTypesForce() {\n\t\tdoTest(\"testData/completion/basic/common/InParametersTypesForce.kt\");\n\t}\n\n\t@Test\n\tpublic void testInTypeAnnotation() {\n\t\tdoTest(\"testData/completion/basic/common/InTypeAnnotation.kt\");\n\t}\n\n\t@Test\n\tpublic void testJavaPackage() {\n\t\tdoTest(\"testData/completion/basic/common/JavaPackage.kt\");\n\t}\n\n\t@Test\n\tpublic void testLocalMultideclarationValues() {\n\t\tdoTest(\"testData/completion/basic/common/LocalMultideclarationValues.kt\");\n\t}\n\n\t@Test\n\tpublic void testNamedObject() {\n\t\tdoTest(\"testData/completion/basic/common/NamedObject.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoClassNameDuplication() {\n\t\tdoTest(\"testData/completion/basic/common/NoClassNameDuplication.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoCompletionAfterBigFloat() {\n\t\tdoTest(\"testData/completion/basic/common/NoCompletionAfterBigFloat.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoCompletionAfterFloat() {\n\t\tdoTest(\"testData/completion/basic/common/NoCompletionAfterFloat.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoCompletionAfterInt() {\n\t\tdoTest(\"testData/completion/basic/common/NoCompletionAfterInt.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoCompletionAfterLong() {\n\t\tdoTest(\"testData/completion/basic/common/NoCompletionAfterLong.kt\");\n\t}\n\n\t@Test\n\tpublic void testNoEmptyPackage() {\n\t\tdoTest(\"testData/completion/basic/common/NoEmptyPackage.kt\");\n\t}\n\n//\t@Test\n//\tpublic void testNoObjectInTypePosition() {\n//\t\tdoTest(\"testData/completion/basic/common/NoObjectInTypePosition.kt\");\n//\t}\n\n\t@Test\n\tpublic void testNoTopLevelCompletionInQualifiedUserTypes() {\n\t\tdoTest(\"testData/completion/basic/common/NoTopLevelCompletionInQualifiedUserTypes.kt\");\n\t}\n\n\t@Test\n\tpublic void testObjectRedeclaration1() {\n\t\tdoTest(\"testData/completion/basic/common/ObjectRedeclaration1.kt\");\n\t}\n\n\t@Test\n\tpublic void testObjectRedeclaration2() {\n\t\tdoTest(\"testData/completion/basic/common/ObjectRedeclaration2.kt\");\n\t}\n\n\t@Test\n\tpublic void testOnlyScopedClassesWithoutExplicit() {\n\t\tdoTest(\"testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt\");\n\t}\n\n\t@Test\n\tpublic void testOverloadFunctions() {\n\t\tdoTest(\"testData/completion/basic/common/OverloadFunctions.kt\");\n\t}\n\n\t@Test\n\tpublic void testShortClassNamesInTypePosition() {\n\t\tdoTest(\"testData/completion/basic/common/ShortClassNamesInTypePosition.kt\");\n\t}\n\n//\t@Test\n//\tpublic void testStandardJetArrayFirst() {\n//\t\tdoTest(\"testData/completion/basic/common/StandardJetArrayFirst.kt\");\n//\t}\n\n\t@Test\n\tpublic void testStandardJetDoubleFirst() {\n\t\tdoTest(\"testData/completion/basic/common/StandardJetDoubleFirst.kt\");\n\t}\n\n\t@Test\n\tpublic void testSubpackageInFun() {\n\t\tdoTest(\"testData/completion/basic/common/SubpackageInFun.kt\");\n\t}\n\n//\t@Test\n//\tpublic void testTopLevelClassCompletionInQualifiedCall() {\n//\t\tdoTest(\"testData/completion/basic/common/TopLevelClassCompletionInQualifiedCall.kt\");\n//\t}\n\n\t@Test\n\tpublic void testVariableClassName() {\n\t\tdoTest(\"testData/completion/basic/common/VariableClassName.kt\");\n\t}\n\t\n\t//visibility tests\n    @Test\n    public void testVisibilityClassMembersFromExternalForce() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityClassMembersFromExternalForce.kt\");\n    }\n\n    @Test\n    public void testVisibilityClassMembersFromExternal() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityClassMembersFromExternal.kt\");\n    }\n\n    @Test\n    public void testVisibilityInSubclassForce() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityInSubclassForce.kt\");\n    }\n\n    @Test\n    public void testVisibilityInSubclass() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityInSubclass.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisInConstructor() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisInConstructor.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisInConstructorWithThis() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisInConstructorWithThis.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisInSpecialScope() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisInSpecialScope.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThis() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThis.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisWithReceiver2() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisWithReceiver2.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisWithReceiver() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisWithReceiver.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisWithThis() throws Exception {\n        doTest(\"common_testData/ide/completion/basic/common/visibility/VisibilityPrivateToThisWithThis.kt\");\n    }\n\n    @Test\n    public void testVisibilityPrivateToThisWithWrongThis() throws Exception {\n        doTest(\"testData/completion/basic/common/visibility/VisibilityPrivateToThisWithWrongThis.kt\");\n    }\n    \n    //java tests\n\n    public void testAutoForceCompletion() throws Exception {\n        doTest(\"testData/completion/basic/java/AutoForceCompletion.kt\");\n    }\n    \n    public void testExtensionFromStandardLibrary() throws Exception {\n        doTest(\"testData/completion/basic/java/ExtensionFromStandardLibrary.kt\");\n    }\n    \n    public void testInPackage() throws Exception {\n        doTest(\"testData/completion/basic/java/InPackage.kt\");\n    }\n    \n    public void testJavaClassNames() throws Exception {\n        doTest(\"testData/completion/basic/java/JavaClassNames.kt\");\n    }\n    \n    public void testNoClassNameDuplicationForRuntimeClass() throws Exception {\n        doTest(\"testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt\");\n    }\n    \n    public void testNoImportedJavaClassDuplication() throws Exception {\n        doTest(\"testData/completion/basic/java/NoImportedJavaClassDuplication.kt\");\n    }\n    \n    public void testPropertyMetadata() throws Exception {\n        doTest(\"testData/completion/basic/java/PropertyMetadata.kt\");\n    }\n    \n    public void testTopLevelFromStandardLibrary() throws Exception {\n        doTest(\"testData/completion/basic/java/TopLevelFromStandardLibrary.kt\");\n    }\n    \n    public void testTopLevelFromStandardLibraryWithoutParam() throws Exception {\n        doTest(\"testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt\");\n    }\n    \n    @Test\n    public void testVariableWithLowerCase() {\n        doTest(\"testData/completion/basic/common/VariableWithLowerCase.kt\");\n    }\n    \n    @Test\n    public void testFunctionWithLowerCase() {\n        doTest(\"testData/completion/basic/common/FunctionWithLowerCase.kt\");\n    }\n    \n    @Test\n    public void testWithCompletedExpression() {\n        doTest(\"testData/completion/basic/common/WithCompletedExpression.kt\");\n    }\n    \n    @Test\n    public void testOneProposalWithExplicitImport() {\n        doTest(\"testData/completion/basic/common/OneProposalWithExplicitImport.kt\");\n    }\n    \n    @Test\n    public void testOneProposalWithStarImport() {\n        doTest(\"testData/completion/basic/common/OneWithStarImport.kt\");\n    }\n    \n    @Test\n    public void testNotImportedAnnotation() {\n        doTest(\"testData/completion/basic/common/notImportedAnnotation.kt\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinBasicCompletionTestCase.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin\nimport org.eclipse.jdt.ui.PreferenceConstants\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.jetbrains.kotlin.testframework.utils.ExpectedCompletionUtils\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.junit.Assert\nimport org.junit.Before\n\nabstract class KotlinBasicCompletionTestCase : KotlinProjectTestCase() {\n    @Before\n    fun configure() {\n        configureProject()\n    }\n\n    protected fun doTest(testPath: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        \n        val shouldHideNonVisible = ExpectedCompletionUtils.shouldHideNonVisibleMembers(fileText)\n        JavaPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, shouldHideNonVisible)\n        \n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        waitForEditorInitialization(testEditor)\n        \n        val actualProposals = getActualProposals(testEditor.getEditor() as KotlinEditor)\n        \n        val expectedNumber = ExpectedCompletionUtils.numberOfItemsShouldPresent(fileText)\n        if (expectedNumber != null) {\n            Assert.assertEquals(\"Different count of expected and actual proposals\", expectedNumber, actualProposals.size)\n        }\n        \n        val proposalSet = actualProposals.toSet()\n        \n        val expectedProposals = ExpectedCompletionUtils.itemsShouldExist(fileText).map { it.trim { it == '\"' } }\n        assertExists(expectedProposals, proposalSet)\n        \n        val expectedJavaOnlyProposals = ExpectedCompletionUtils.itemsJavaOnlyShouldExists(fileText)\n        assertExists(expectedJavaOnlyProposals, proposalSet)\n        \n        val unexpectedProposals = ExpectedCompletionUtils.itemsShouldAbsent(fileText)\n        assertNotExists(unexpectedProposals, proposalSet)\n        \n        val nothingElse = ExpectedCompletionUtils.isNothingElseExpected(fileText)\n        if (nothingElse) {\n            if (expectedProposals.size != proposalSet.size) {\n                Assert.fail(getErrorMessage(\n                        \"Items must be equal.\",\n                        expectedProposals,\n                        proposalSet,\n                        (expectedProposals - proposalSet).toSet(),\n                        (proposalSet - expectedProposals).toSet()))\n            }\n        }\n    }\n    \n    protected open fun getApplicableProposals(editor: KotlinEditor): Array<ICompletionProposal> {\n        return getCompletionProposals(editor)\n    }\n\n    private fun getActualProposals(javaEditor: KotlinEditor): List<String> {\n        return getApplicableProposals(javaEditor).map { it.stringToInsert() }\n    }\n\n    private fun assertExists(itemsShouldExist: List<String>, actualItems: Set<String>) {\n        val missing = itemsShouldExist.filter { !actualItems.contains(it) }.toSet()\n        \n        if (missing.isNotEmpty()) {\n            Assert.fail(getErrorMessage(\"Items not found.\", itemsShouldExist, actualItems, missing, emptySet()))\n        }\n    }\n\n    private fun assertNotExists(itemsShouldAbsent: List<String>, actualItems: Set<String>) {\n        val added = itemsShouldAbsent.filter { actualItems.contains(it) }.toSet()\n        \n        if (added.isNotEmpty()) {\n            Assert.fail(getErrorMessage(\"Items must be absent.\", itemsShouldAbsent, actualItems, emptySet(), added))\n        }\n    }\n\n    private fun getErrorMessage(message: String, expected: List<String>, actual: Set<String>, missing: Set<String>, added: Set<String>): String? {\n        return StringBuilder().apply {\n            append(\"$message\\n\")\n            append(\"Expected: <\\n\")\n            for (proposal in expected.sorted()) {\n                if (missing.contains(proposal)) {\n                    append(\"-\")\n                }\n                append(\"$proposal\\n\")\n            }\n            append(\"> \")\n            append(\"but was:<\\n\")\n            for (proposal in actual.sorted()) {\n                if (added.contains(proposal)) {\n                    append(\"+\")\n                }\n                append(\"$proposal\\n\")\n            }\n            append(\">\")\n        }.toString()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinCompletionRelevanceTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion;\n\nimport org.junit.Test;\n\npublic class KotlinCompletionRelevanceTest extends KotlinCompletionRelevanceTestCase {\n    @Test\n    public void testLocalBeforeNonImported() {\n        doTest(\"testData/completion/relevance/localBeforeNonImported.kt\");\n    }\n    \n    @Test\n    public void testSortingForLocal() {\n        doTest(\"testData/completion/relevance/sortingForLocal.kt\");\n    }\n    \n    @Test\n    public void testSortingForNonImported() {\n        doTest(\"testData/completion/relevance/sortingForNonImported.kt\");\n    }\n    \n    @Test\n    public void testByCamelCaseLocal() {\n        doTest(\"testData/completion/relevance/byCamelCaseLocal.kt\");\n    }\n    \n    @Test\n    public void testByPrefixMatchLocal() {\n        doTest(\"testData/completion/relevance/byPrefixMatchLocal.kt\");\n    }\n    \n    @Test\n    public void testByPrefixWithImported() {\n        doTest(\"testData/completion/relevance/byPrefixWithImported.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinCompletionRelevanceTestCase.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion\n\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.jetbrains.kotlin.testframework.utils.InTextDirectivesUtils\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.junit.Assert\nimport org.junit.Before\n\nabstract class KotlinCompletionRelevanceTestCase : KotlinProjectTestCase() {\n    @Before\n    fun before() {\n        configureProject()\n    }\n    \n    protected fun doTest(testPath: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        \n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        \n        KotlinTestUtils.joinBuildThread()\n        \n        val actualProposals = getCompletionProposals(testEditor.editor as KotlinFileEditor)\n        \n        val expectedItemsOrder = InTextDirectivesUtils.findListWithPrefixes(fileText, \"// ORDER:\")\n        Assert.assertTrue(\"There should be 'ORDER' items\", expectedItemsOrder.isNotEmpty())\n        \n        checkPreferredCompletionItems(actualProposals, expectedItemsOrder)\n    }\n    \n    private fun checkPreferredCompletionItems(actualProposals: Array<ICompletionProposal>, expectedOrder: List<String>) {\n        var expectedItemIndex = 0\n        for (proposal in actualProposals) {\n            val actualItem = proposal.stringToInsert()\n            if (actualItem == expectedOrder[expectedItemIndex]) {\n                expectedItemIndex++\n            }\n            \n            if (expectedItemIndex == expectedOrder.size) {\n                break\n            }\n        }\n        \n        if (expectedItemIndex != expectedOrder.size) {\n            Assert.fail(\"Order is not equal: actual - ${actualProposals.map { it.stringToInsert() }} and expected - ${expectedOrder}\")\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinFunctionParameterInfoTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n\npublic class KotlinFunctionParameterInfoTest extends KotlinFunctionParameterInfoTestCase {\n    @Test\n    public void testDeprecated() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/Deprecated.kt\");\n    }\n\n    @Test\n    public void testExtensionOnClassObject() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/ExtensionOnClassObject.kt\");\n    }\n\n    @Test\n    public void testInheritedFunctions() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/InheritedFunctions.kt\");\n    }\n\n    @Test\n    public void testInheritedWithCurrentFunctions() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/InheritedWithCurrentFunctions.kt\");\n    }\n\n    @Ignore\n    @Test\n    public void testNoAnnotations() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/NoAnnotations.kt\");\n    }\n\n    @Test\n    public void testNotAccessible() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/NotAccessible.kt\");\n    }\n\n    @Test\n    public void testNotGreen() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/NotGreen.kt\");\n    }\n\n    @Test\n    public void testNullableTypeCall() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/NullableTypeCall.kt\");\n    }\n\n    @Test\n    public void testPrintln() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/Println.kt\");\n    }\n\n    @Test\n    public void testSimple() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/Simple.kt\");\n    }\n\n    @Test\n    public void testSimpleConstructor() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/SimpleConstructor.kt\");\n    }\n\n    @Ignore(\"Unignore after fix bug with visibility\")\n    @Test\n    public void testSuperConstructorCall() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/SuperConstructorCall.kt\");\n    }\n\n    @Test\n    public void testTwoFunctions() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/TwoFunctions.kt\");\n    }\n\n    @Test\n    public void testTwoFunctionsGrey() throws Exception {\n        doTest(\"common_testData/ide/parameterInfo/functionCall/TwoFunctionsGrey.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinFunctionParameterInfoTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion\n\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.lexer.KtTokens\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinFunctionParameterInfoAssist\nimport org.junit.Assert\nimport org.junit.Before\n\nopen class KotlinFunctionParameterInfoTestCase : KotlinProjectTestCase() {\n    @Before\n    fun before() {\n        configureProject()\n    }\n\n    protected fun doTest(testPath: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n\n        val actualResult = getContextInformation(testEditor.editor as KotlinFileEditor)\n        val expectedResult = getExpectedResult(testEditor)\n\n        val agreement = actualResult.size == expectedResult.size &&\n                actualResult.all { actualResult ->\n                    expectedResult.any { expectedResult ->\n                        actualResult == expectedResult\n                    }\n                }\n\n        Assert.assertTrue(\"$expectedResult are not equals to $actualResult\", agreement)\n    }\n\n    private fun getExpectedResult(testEditor: TextEditorTest): List<String> {\n        val jetFile = KotlinPsiManager.getParsedFile(testEditor.editingFile)\n        val lastChild = jetFile.lastChild\n        val expectedText = if (lastChild.node.elementType == KtTokens.BLOCK_COMMENT) {\n            val lastChildText = lastChild.text\n            lastChildText.substring(2, lastChildText.length - 2).trim()\n        } else { // EOL_COMMENT\n            lastChild.text.substring(2).trim()\n        }\n\n        val regex = \"\\\\((.*)\\\\)\".toRegex()\n        val beginHighlightRegex = \"<highlight>\".toRegex()\n        val endHighlightRegex = \"</highlight>\".toRegex()\n        val noParametersRegex = \"<no parameters>\".toRegex()\n        return expectedText.split(\"\\n\")\n            .map { line ->\n                val match = regex.find(line)\n                val displayString = match!!.groups[1]!!.value\n                displayString\n                    .replace(beginHighlightRegex, \"\")\n                    .replace(endHighlightRegex, \"\")\n                    .replace(noParametersRegex, \"\")\n            }\n            .filter { it.isNotBlank() }\n    }\n\n    private fun getContextInformation(editor: KotlinFileEditor): List<String> {\n        val contextInformation = KotlinFunctionParameterInfoAssist.computeContextInformation(\n            editor,\n            KotlinTestUtils.getCaret(editor)\n        )\n        return contextInformation.map { it.informationDisplayString }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinKeywordCompletionTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinKeywordCompletionTest extends KotlinKeywordCompletionTestCase {\n    \n    @Ignore\n    @Test\n    public void testAfterClasses() {\n        doTest(\"common_testData/ide/completion/keywords/AfterClasses.kt\");\n    }\n    \n    @Test\n    public void testAfterDot() {\n        doTest(\"common_testData/ide/completion/keywords/AfterDot.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testAfterFuns() {\n        doTest(\"common_testData/ide/completion/keywords/AfterFuns.kt\");\n    }\n    \n    @Test\n    public void testAfterSafeDot() {\n        doTest(\"common_testData/ide/completion/keywords/AfterSafeDot.kt\");\n    }\n    \n    @Test\n    public void testAfterSpaceAndDot() {\n        doTest(\"common_testData/ide/completion/keywords/AfterSpaceAndDot.kt\");\n    }\n    \n    @Test\n    public void testBreakContinue() {\n        doTest(\"common_testData/ide/completion/keywords/BreakContinue.kt\");\n    }\n    \n    @Test\n    public void testBreakWithLabel() {\n        doTest(\"common_testData/ide/completion/keywords/BreakWithLabel.kt\");\n    }\n    \n    @Test\n    public void testCommaExpected() {\n        doTest(\"common_testData/ide/completion/keywords/CommaExpected.kt\");\n    }\n    \n    @Test\n    public void testCompanionObjectBeforeObject() {\n        doTest(\"common_testData/ide/completion/keywords/CompanionObjectBeforeObject.kt\");\n    }\n    \n    @Test\n    public void testContinueWithLabel() {\n        doTest(\"common_testData/ide/completion/keywords/ContinueWithLabel.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInAnnotationClassScope() {\n        doTest(\"common_testData/ide/completion/keywords/InAnnotationClassScope.kt\");\n    }\n    \n    @Test\n    public void testInBlockComment() {\n        doTest(\"common_testData/ide/completion/keywords/InBlockComment.kt\");\n    }\n    \n    @Test\n    public void testInChar() {\n        doTest(\"common_testData/ide/completion/keywords/InChar.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInClassBeforeFun() {\n        doTest(\"common_testData/ide/completion/keywords/InClassBeforeFun.kt\");\n    }\n    \n    @Test\n    public void testInClassNoCompletionInValName() {\n        doTest(\"common_testData/ide/completion/keywords/InClassNoCompletionInValName.kt\");\n    }\n    \n    @Test\n    public void testInClassProperty() {\n        doTest(\"common_testData/ide/completion/keywords/InClassProperty.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInClassScope() {\n        doTest(\"common_testData/ide/completion/keywords/InClassScope.kt\");\n    }\n    \n    @Test\n    public void testInClassTypeParameters() {\n        doTest(\"common_testData/ide/completion/keywords/InClassTypeParameters.kt\");\n    }\n    \n    @Test\n    public void testInEnumScope1() {\n        doTest(\"common_testData/ide/completion/keywords/InEnumScope1.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInEnumScope2() {\n        doTest(\"common_testData/ide/completion/keywords/InEnumScope2.kt\");\n    }\n    \n    @Test\n    public void testInFunctionExpressionBody() {\n        doTest(\"common_testData/ide/completion/keywords/InFunctionExpressionBody.kt\");\n    }\n    \n    @Test\n    public void testInFunctionName() {\n        doTest(\"common_testData/ide/completion/keywords/InFunctionName.kt\");\n    }\n    \n    @Test\n    public void testInFunctionRecieverType() {\n        doTest(\"common_testData/ide/completion/keywords/InFunctionRecieverType.kt\");\n    }\n    \n    @Test\n    public void testInFunctionTypePosition() {\n        doTest(\"testData/completion/keywords/InFunctionTypePosition.kt\");\n    }\n    \n    @Test\n    public void testInGetterExpressionBody() {\n        doTest(\"common_testData/ide/completion/keywords/InGetterExpressionBody.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInInterfaceScope() {\n        doTest(\"common_testData/ide/completion/keywords/InInterfaceScope.kt\");\n    }\n    \n    @Test\n    public void testInMemberFunParametersList() {\n        doTest(\"common_testData/ide/completion/keywords/InMemberFunParametersList.kt\");\n    }\n    \n    @Test\n    public void testInModifierListInsideClass() {\n        doTest(\"common_testData/ide/completion/keywords/InModifierListInsideClass.kt\");\n    }\n    \n    @Test\n    public void testInNotFinishedGenericWithFunAfter() {\n        doTest(\"common_testData/ide/completion/keywords/InNotFinishedGenericWithFunAfter.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInObjectScope() {\n        doTest(\"common_testData/ide/completion/keywords/InObjectScope.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInPrimaryConstructorParametersList() {\n        doTest(\"common_testData/ide/completion/keywords/InPrimaryConstructorParametersList.kt\");\n    }\n    \n    @Test\n    public void testInPropertyInitializer() {\n        doTest(\"common_testData/ide/completion/keywords/InPropertyInitializer.kt\");\n    }\n    \n    @Test\n    public void testInPropertyTypeReference() {\n        doTest(\"common_testData/ide/completion/keywords/InPropertyTypeReference.kt\");\n    }\n    \n    @Test\n    public void testInString() {\n        doTest(\"common_testData/ide/completion/keywords/InString.kt\");\n    }\n    \n    @Test\n    public void testInTopFunParametersList() {\n        doTest(\"common_testData/ide/completion/keywords/InTopFunParametersList.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testInTopScopeAfterPackage() {\n        doTest(\"common_testData/ide/completion/keywords/InTopScopeAfterPackage.kt\");\n    }\n    \n    @Test\n    public void testLabeledLambdaThis() {\n        doTest(\"common_testData/ide/completion/keywords/LabeledLambdaThis.kt\");\n    }\n    \n    @Test\n    public void testLineComment() {\n        doTest(\"common_testData/ide/completion/keywords/LineComment.kt\");\n    }\n    \n    @Test\n    public void testNoBreak1() {\n        doTest(\"common_testData/ide/completion/keywords/NoBreak1.kt\");\n    }\n    \n    @Test\n    public void testNoBreak2() {\n        doTest(\"common_testData/ide/completion/keywords/NoBreak2.kt\");\n    }\n    \n    @Test\n    public void testNoCompletionForCapitalPrefix() {\n        doTest(\"common_testData/ide/completion/keywords/NoCompletionForCapitalPrefix.kt\");\n    }\n    \n    @Test\n    public void testNoContinue() {\n        doTest(\"common_testData/ide/completion/keywords/NoContinue.kt\");\n    }\n    \n    @Test\n    public void testNoFinalInParameterList() {\n        doTest(\"common_testData/ide/completion/keywords/NoFinalInParameterList.kt\");\n    }\n    \n    @Test\n    public void testNotInNotIs() {\n        doTest(\"common_testData/ide/completion/keywords/NotInNotIs.kt\");\n    }\n    \n    @Test\n    public void testNotInNotIs2() {\n        doTest(\"common_testData/ide/completion/keywords/NotInNotIs2.kt\");\n    }\n    \n    @Test\n    public void testPrefixMatcher() {\n        doTest(\"common_testData/ide/completion/keywords/PrefixMatcher.kt\");\n    }\n    \n    @Test\n    public void testQualifiedThis() {\n        doTest(\"common_testData/ide/completion/keywords/QualifiedThis.kt\");\n    }\n    \n    @Test\n    public void testReturn1() {\n        doTest(\"common_testData/ide/completion/keywords/Return1.kt\");\n    }\n    \n    @Test\n    public void testReturn2() {\n        doTest(\"common_testData/ide/completion/keywords/Return2.kt\");\n    }\n    \n    @Test\n    public void testReturn3() {\n        doTest(\"common_testData/ide/completion/keywords/Return3.kt\");\n    }\n    \n    @Test\n    public void testReturn4() {\n        doTest(\"common_testData/ide/completion/keywords/Return4.kt\");\n    }\n    \n    @Test\n    public void testReturn5() {\n        doTest(\"common_testData/ide/completion/keywords/Return5.kt\");\n    }\n    \n    @Test\n    public void testReturn6() {\n        doTest(\"common_testData/ide/completion/keywords/Return6.kt\");\n    }\n    \n    @Test\n    public void testReturn8() {\n        doTest(\"common_testData/ide/completion/keywords/Return8.kt\");\n    }\n    \n    @Test\n    public void testReturn9() {\n        doTest(\"common_testData/ide/completion/keywords/Return9.kt\");\n    }\n    \n    @Test\n    public void testReturnBoolean() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnBoolean.kt\");\n    }\n    \n    @Test\n    public void testReturnCollection() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnCollection.kt\");\n    }\n    \n    @Test\n    public void testReturnIterable() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnIterable.kt\");\n    }\n    \n    @Test\n    public void testReturnKeywordName() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnKeywordName.kt\");\n    }\n    \n    @Test\n    public void testReturnList() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnList.kt\");\n    }\n    \n    @Test\n    public void testReturnNotNull() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnNotNull.kt\");\n    }\n    \n    @Test\n    public void testReturnNull() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnNull.kt\");\n    }\n    \n    @Test\n    public void testReturnNullableBoolean() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnNullableBoolean.kt\");\n    }\n    \n    @Test\n    public void testReturnSet() {\n        doTest(\"common_testData/ide/completion/keywords/ReturnSet.kt\");\n    }\n    \n    @Test\n    public void testThis() {\n        doTest(\"common_testData/ide/completion/keywords/This.kt\");\n    }\n    \n    @Test\n    public void testThisPrefixMatching() {\n        doTest(\"common_testData/ide/completion/keywords/ThisPrefixMatching.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testTopScope() {\n        doTest(\"common_testData/ide/completion/keywords/TopScope.kt\");\n    }\n    \n    @Test\n    public void testUseSiteTargetForPrimaryConstructorParameter() {\n        doTest(\"common_testData/ide/completion/keywords/UseSiteTargetForPrimaryConstructorParameter.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/KotlinKeywordCompletionTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion\n\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinKeywordCompletionProposal\n\nabstract class KotlinKeywordCompletionTestCase : KotlinBasicCompletionTestCase() {\n    override fun getApplicableProposals(editor: KotlinEditor): Array<ICompletionProposal> {\n        return getCompletionProposals(editor)\n                .filterIsInstance(KotlinKeywordCompletionProposal::class.java)\n                .toTypedArray()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/completionTestUtils.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2016 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion\n\nimport org.eclipse.jface.text.contentassist.ICompletionProposal\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinCompletionProcessor\nimport org.jetbrains.kotlin.ui.editors.codeassist.KotlinCompletionProposal\n\nfun getCompletionProposals(editor: KotlinEditor): Array<ICompletionProposal> =\n    KotlinCompletionProcessor.createKotlinCompletionProcessors(editor, null, needSorting = true).flatMap {\n        it.computeCompletionProposals(editor.javaEditor.viewer, KotlinTestUtils.getCaret(editor.javaEditor)).toList()\n    }.toTypedArray()\n\nfun ICompletionProposal.stringToInsert(): String {\n    return if (this is KotlinCompletionProposal) replacementString else additionalProposalInfo ?: displayString\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/handlers/KotlinCompletionHandlerInsertTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion.handlers;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinCompletionHandlerInsertTest extends KotlinCompletionHandlerInsertTestCase {\n\t@Override\n\tprotected String getTestDataRelativePath() {\n\t\treturn \"completion/handlers\";\n\t}\n\t\n\t@Test\n\tpublic void existingSingleBrackets() {\n\t\tdoAutoTest();\n\t}\n\n\t@Test\n\tpublic void functionLiteralInsertOnSpace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void higherOrderFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void higherOrderFunctionWithArgs1() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Ignore\n\t@Test\n \tpublic void insertFunctionWithBothParentheses() {\n \t\tdoAutoTest();\n \t}\n\t\n\t@Test\n\tpublic void insertFunctionWithSingleParameterWithBrace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void insertVoidJavaMethod() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void noParamsFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void paramsFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Ignore\n\t@Test\n\tpublic void singleBrackets() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void insertJavaMethodWithParam() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void functionWithParamOnBracket() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void paramFunctionOnBracket() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void unitFunctionOnBracket() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void unitFunctionOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void functionWithParamOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void paramFunctionOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void paramsFunctionOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void completeWithExistingBraces() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void completeWithExistingBracesOnBrace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void completeWithExistingBracesOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void withParamsAndBraces() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void withParamsAndBracesOnBrace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void withParamsAndBracesOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void withLambdaAndBraces() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void withLambdaAndBracesOnDot() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Ignore\n\t@Test\n    public void completeNonImported() {\n        doAutoTest();\n    }\n\t\n\t@Ignore\n\t@Test\n    public void nonImportedByCamelCase() {\n        doAutoTest();\n    }\n\t\n\t@Test\n\tpublic void filterTypesFromSamePackage() {\n\t    doAutoTest();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/handlers/KotlinCompletionHandlerInsertTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.completion.handlers;\n\nimport org.eclipse.jface.text.contentassist.ICompletionProposal;\nimport org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.ExpectedCompletionUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor;\nimport org.jetbrains.kotlin.ui.tests.editors.completion.CompletionTestUtilsKt;\nimport org.junit.Before;\n\npublic abstract class KotlinCompletionHandlerInsertTestCase extends KotlinEditorWithAfterFileTestCase {\n    @Before\n    public void before() {\n        configureProject();\n    }\n\n\t@Override\n\tprotected void performTest(String fileText, String expectedFileText) {\n\t\tICompletionProposal[] proposals = CompletionTestUtilsKt.getCompletionProposals(getEditor());\n\t\t\n\t\tString itemToComplete = ExpectedCompletionUtils.itemToComplete(fileText);\n\t\tassert itemToComplete == null && proposals.length == 1 : \"Completion proposal ambiguity\";\n\t\tif (itemToComplete == null) {\n\t\t\titemToComplete = \"\";\n\t\t}\n\n\t\tchar completionChar = ' ';\n\t\tCharacter completionCharacter = ExpectedCompletionUtils.getCompletionChar(fileText);\n\t\tif (completionCharacter != null) {\n\t\t\tcompletionChar = completionCharacter;\n\t\t}\n\t\t\n\t\tfor (ICompletionProposal proposal : proposals) {\n\t\t\tif (proposal.getDisplayString().startsWith(itemToComplete)) {\n\t\t\t\tif (proposal instanceof ICompletionProposalExtension2) {\n\t\t\t\t\tICompletionProposalExtension2 proposalExtension = (ICompletionProposalExtension2) proposal;\n\t\t\t\t\tproposalExtension.apply(getEditor().getViewer(), completionChar, 0, KotlinTestUtils.getCaret(getEditor()));\n\t\t\t\t} else {\n\t\t\t\t\tproposal.apply(getEditor().getViewer().getDocument());\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tEditorTestUtils.assertByEditor(getEditor(), expectedFileText);\n\t}\n\t\n\tprivate KotlinFileEditor getEditor() {\n\t    return (KotlinFileEditor) getTestEditor().getEditor();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/templates/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion.templates;\n\npublic class AllTests {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/templates/KotlinTemplatesTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion.templates;\n\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.junit.Test;\n\npublic class KotlinTemplatesTest extends KotlinTemplatesTestCase {\n\n\t@Test\n\tpublic void completeMainTemplate() {\n\t\tdoTest(\"main<caret>\", \n\t\t\t\t\"fun main(args: Array<String>) {<br>\" +\n\t\t\t\t\"\\t<caret><br>\" +\n\t\t\t\t\"}\");\n\t}\n\t\n\t@Test\n\tpublic void completeMainTemplateAfterText() {\n\t\tdoTest(\n\t\t\t\t\"// comment<br>\" +\n\t\t\t\t\"mai<caret>\",\n\t\t\t\t\n\t\t\t\t\"// comment<br>\" +\n\t\t\t\t\"fun main(args: Array<String>) {<br>\" +\n\t\t\t\t\"\\t<caret><br>\" +\n\t\t\t\t\"}\");\n\t}\n\t\n\t@Test\n\tpublic void doNotCompleteMainInClass() {\n\t\tdoTest(\n\t\t\t\t\"class Test {<br>\" +\n\t\t\t\t\"\\tmain<caret><br>\" +\n\t\t\t\t\"}\");\n\t}\n\t\n\t@Test\n\tpublic void doNotCompleteMainInDeclaration() {\n\t\tdoTest(\"fun test() = main<caret>\");\n\t}\n\t\n\t@Test\n\tpublic void doNotCompleteMainInExpression() {\n\t\tdoTest(\"fun test() = if (main<caret>) {}\");\n\t}\n\t\n\t@Test\n\tpublic void completeMainTemplateUsingSpacesInsteadTab() {\n\t\tdoTest(\n\t\t\t\t\"main<caret>\",\n\t\t\t\t\n\t\t\t\t\"fun main(args: Array<String>) {<br>\" +\n\t\t\t\t\"  <caret><br>\" +\n\t\t\t\t\"}\", \n\t\t\t\t\n\t\t\t\tKotlinTestUtils.Separator.SPACE, 2);\n\t\t\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/completion/templates/KotlinTemplatesTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.completion.templates;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.jface.text.contentassist.ICompletionProposal;\nimport org.eclipse.jface.text.templates.TemplateProposal;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils.Separator;\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor;\nimport org.jetbrains.kotlin.ui.tests.editors.completion.CompletionTestUtilsKt;\nimport org.junit.Assert;\nimport org.junit.Before;\n\npublic abstract class KotlinTemplatesTestCase extends KotlinProjectTestCase {\n\t@Before\n\tpublic void configure() {\n\t\tconfigureProject();\n\t}\n\n\tpublic void doTest(String input) {\n\t\tdoTest(input, input);\n\t}\n\t\n\tpublic void doTest(String input, String expected) {\n\t\tdoTest(input, expected, Separator.TAB, 4);\n\t}\n\t\n\tpublic void doTest(String input, String expected, Separator separator, int spacesCount) {\n\t\tconfigureIndents(separator, spacesCount);\n\n\t\tinput = KotlinTestUtils.resolveTestTags(input);\n\t\texpected = KotlinTestUtils.resolveTestTags(expected);\n\t\tTextEditorTest testEditor = configureEditor(\"Test.kt\", input);\n\t\t\n\t\tKotlinFileEditor editor = (KotlinFileEditor) testEditor.getEditor();\n\t\tICompletionProposal[] proposals = CompletionTestUtilsKt.getCompletionProposals(editor);\n\t\t\n\t\tif (!input.equals(expected)) {\n\t\t\tAssert.assertTrue(proposals.length > 0);\n\t\n\t\t\tapplyTemplateProposal((TemplateProposal)proposals[0], editor);\n\t\t} else {\n\t\t\tAssert.assertTrue(proposals.length == 0);\n\t\t}\n\t\t\t\n\t\tEditorTestUtils.assertByEditor(editor, expected);\n\t}\n\t\n\tprivate void applyTemplateProposal(TemplateProposal templateProposal, JavaEditor editor) {\n\t\ttemplateProposal.apply(editor.getViewer(), (char) 0, 0, KotlinTestUtils.getCaret(editor));\n\t\t\n\t\tPoint point = templateProposal.getSelection(null);\n\t\teditor.getViewer().getTextWidget().setCaretOffset(point.x);\n\t}\n\t\n\tprivate void configureIndents(Separator separator, int spacesCount) {\n\t\tEditorsUI.getPreferenceStore().setValue(\n\t\t\t\tAbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, \n\t\t\t\t(Separator.SPACE == separator));\n\t\tEditorsUI.getPreferenceStore().setValue(\n\t\t\t\tAbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, \n\t\t\t\tspacesCount);\t\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/AllFormatTests.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses({\n    KotlinFormatActionTest.class,\n    KotlinIdeaFormatActionTest.class,\n    KotlinFileAnnotationsFormatTest.class,\n    KotlinModifierListFormatTest.class,\n    KotlinParameterListFormatTest.class\n})\npublic class AllFormatTests {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinFileAnnotationsFormatTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.Test;\n\npublic class KotlinFileAnnotationsFormatTest extends KotlinFormatActionTestCase {\n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/formatter/fileAnnotations\";\n    }\n    \n    @Test\n    public void beforeDeclaration() {\n        doAutoTest();\n    }\n\n    @Test\n    public void beforeImportList() {\n        doAutoTest();\n    }\n\n    @Test\n    public void beforePackage() {\n        doAutoTest();\n    }\n\n    @Test\n    public void inEmptyFile() {\n        doAutoTest();\n    }\n\n    @Test\n    public void manyLinesFromFileBegin() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinFormatActionTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinFormatActionTest extends KotlinFormatActionTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"format\";\n    }\n    \n    @Test\n    public void classesAndPropertiesFormatTest() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void objectsAndLocalFunctionsFormatTest() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void packageFunctionsFormatTest() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void withBlockComments() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void withJavaDoc() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void withLineComments() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void withoutComments() {\n    \tdoAutoTest();\n    }\n        \n    @Test\n    public void initIndent() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void newLineAfterImportsAndPackage() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void withWhitespaceBeforeBrace() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void withMutableVariable() {\n    \tdoAutoTest();\n    }\n    \n    @Test\n    public void indentInWhenEntry() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void indentInDoWhile() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void indentInPropertyAccessor() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void indentInIfExpressionBlock() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void lambdaInBlock() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void formatSelection() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void respectCaretAfterFormatting() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void blockCommentBeforeDeclaration() {\n        doAutoTest();\n    }\n    \n    @Test\n    @Ignore\n    public void formatScriptFile() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void commentOnTheLastLineOfLambda() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinFormatActionTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextUtilities;\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase;\nimport org.jetbrains.kotlin.testframework.utils.CodeStyleConfigurator;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.junit.After;\nimport org.junit.Assert;\nimport org.junit.Before;\n\npublic abstract class KotlinFormatActionTestCase extends KotlinEditorWithAfterFileTestCase {\n    @Before\n    public void before() {\n        configureProject();\n    }\n    \n    @After\n    public void setDefaultSettings() {\n        CodeStyleConfigurator.INSTANCE.deconfigure(getTestProject().getProject());\n    }\n    \n    @Override\n    protected void performTest(String fileText, String content) {\n    \tString expectedLineDelimiter = TextUtilities.getDefaultLineDelimiter(getTestEditor().getDocument());\n    \t\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);\n        EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);\n\n        CodeStyleConfigurator.INSTANCE.configure(getTestProject().getProject(), fileText);\n        \n        getTestEditor().runFormatAction();\n        \n        EditorTestUtils.assertByEditor(getTestEditor().getEditor(), content);\n        assertLineDelimiters(expectedLineDelimiter, getTestEditor().getDocument());\n    }\n    \n    private void assertLineDelimiters(String expectedLineDelimiter, IDocument document) {\n    \ttry {\n    \t\tfor (int i = 0; i < document.getNumberOfLines() - 1; ++i) {\n    \t\t\tAssert.assertEquals(expectedLineDelimiter, document.getLineDelimiter(i));\n    \t\t}\n    \t} catch (BadLocationException e) {\n    \t\tthrow new RuntimeException(e);\n    \t}\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinIdeaFormatActionTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.Test;\n\npublic class KotlinIdeaFormatActionTest extends KotlinFormatActionTestCase {\n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n    \n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/formatter/\";\n    }\n    \n    @Test\n    public void AfterSemiColonInEnumClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void AnonymousInitializers() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void AnonymousInitializersLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ArrayAccess() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void BinaryExpressionAlignmentSpread() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void BinaryExpressions() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void BinaryExpressionsBoolean() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void BinaryExpressionsWithoutAlignment() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void BlockFor() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void CatchFinallyOnNewLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Class() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ClassInBody() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ClassLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ColonSpaces() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void CommentInFunctionLiteral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DelegationList() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DocComments() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DoWhileLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DoWhileSpacing() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ElseOnNewLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Elvis() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineAfterObjectDeclaration() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineAfterPackage() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweeAbstractFunctions() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenClassAndFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenClasses() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenEnumEntries() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenFunAndProperty() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenFunctions() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void EmptyLineBetweenProperties() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ForLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FormatFirstColumnComments() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FormatFirstColumnCommentsBeforeDeclaration() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ForNoBraces() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ForSpacing() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionalType() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionCallParametersAlign() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionDefParametersAlign() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionExpression() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FunctionLineBreak() {\n        doAutoTest();\n    }\n\n    @Test\n    public void FunctionWithInference() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void GetterAndSetter() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void If() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void IfElseRemoveLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void IfElseWithLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void IfElseWithTrickyComments() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void IfSpacing() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void KDoc() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void LambdaArrow() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void LoopParameterWithExplicitType() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Multideclaration() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void MultilineFunctionLiteral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void MultilineFunctionLiteralWithParams() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void NewLineForRBrace() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ObjectInBody() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ParameterDocComments() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Parameters() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void PrimaryConstructor() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void PropertyAccessors() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void PropertyTypeParameterList() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void PropertyWithInference() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ReferenceExpressionFunctionLiteral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void RemoveSpacesAroundOperations() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ReturnExpression() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void RightBracketOnNewLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SaveSpacesInDocComments() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SecondaryConstructors() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void secondaryCtorLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SingleLineFunctionLiteral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpaceAroundExtendColon() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpaceAroundExtendColonInObjects() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpaceAroundExtendColonInSecondaryCtr() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpaceBeforeFunctionLiteral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpacedInsideParans() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpacesAroundOperations() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpacesAroundUnaryOperations() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpacesInDeclarations() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SpacesInQualifiedExpressions() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void TryCatchLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void UnnecessarySpacesInParametersLists() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ValVarSpaces() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void When() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhenArrow() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhenEntryExpr() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhenLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhenLinesBeforeLbrace() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhileLineBreak() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhileOnNewLine() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WhileSpacing() {\n        doAutoTest();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinModifierListFormatTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.Test;\n\npublic class KotlinModifierListFormatTest extends KotlinFormatActionTestCase {\n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/formatter/modifierList\";\n    }\n    \n    @Test\n    public void funAnnotationBeforeAnnotation() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funAnnotationBeforeAnnotationEntry() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funAnnotationBeforeModifiers() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funAnnotationEntryBeforeAnnotation() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funAnnotationEntryBeforeAnnotationEntry() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funAnnotationEntryBeforeModifiers() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funModifierBeforeAnnotation() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funModifierBeforeAnnotationEntry() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funModifierBeforeModifiers() {\n        doAutoTest();\n    }\n\n    @Test\n    public void funTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void memberFunTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void memberValTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void memberVarTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void secondMemberFunTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void secondMemberValTheOnlyModifier() {\n        doAutoTest();\n    }\n\n    @Test\n    public void secondMemberVarTheOnlyModifier() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/formatter/KotlinParameterListFormatTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.formatter;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n@Ignore\npublic class KotlinParameterListFormatTest extends KotlinFormatActionTestCase {\n    @Override\n    protected AfterSuffixPosition getAfterPosition() {\n        return AfterSuffixPosition.BEFORE_DOT;\n    }\n\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/formatter/parameterList\";\n    }\n    \n    @Test\n    public void ArgumentListChopAsNeeded() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ArgumentListDoNotWrap() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ArgumentListWrapAlways() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ArgumentListWrapAsNeeded() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ParameterListChopAsNeeded() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ParameterListDoNotWrap() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ParameterListWrapAlways() {\n        doAutoTest();\n    }\n\n    @Test\n    public void ParameterListWrapAsNeeded() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/highlighting/KotlinHighlightingPositionUpdaterTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.highlighting;\n\nimport org.junit.Test;\n\npublic class KotlinHighlightingPositionUpdaterTest extends KotlinHighlightingPositionUpdaterTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"highlighting/positionUpdater\";\n    }\n    \n    @Test\n    public void afterFunctionName() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void beforeFunctionName() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void illegalCharactersAfter() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void insideHighlightedPosition() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void illegalCharactersBefore() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void beforeHighlightedPosition() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void afterHighlightedPosition() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void illegalCharactersBeforeHighlightedPosition() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/highlighting/KotlinHighlightingPositionUpdaterTestCase.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.highlighting\n\nimport java.io.File\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.utils.TypingUtils\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.ui.editors.highlighting.KotlinPositionUpdater\nimport org.junit.After\nimport org.junit.Assert\nimport org.jetbrains.kotlin.ui.editors.highlighting.KotlinSemanticHighlightingVisitor\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.ui.editors.highlighting.HighlightPosition.StyleAttributes\nimport org.eclipse.jface.text.IPositionUpdater\n\nabstract class KotlinHighlightingPositionUpdaterTestCase : KotlinEditorWithAfterFileTestCase() {\n    companion object {\n        private val testCategory = \"testPositionUpdater\"\n        private val posTag = \"<pos>\"\n        private val posCloseTag = \"</pos>\"\n    }\n    \n    @Before\n    fun before() {\n        configureProject();\n    }\n    \n    override fun performTest(fileText: String, expected: String) {\n        val positionUpdater = KotlinPositionUpdater(testCategory)\n        try {\n            val document = testEditor.document\n                    \n            configureDocument(document, positionUpdater)\n            addHighlightingPositions()\n            \n            val typedText = TypingUtils.typedText(fileText)\n            document.replace(testEditor.caretOffset, 0, typedText)\n            \n            val documentText = StringBuilder(document.get())\n            var shift = 0\n            for (position in document.getPositions(testCategory)) {\n                if (position.isDeleted()) continue\n                \n                documentText.insert(position.getOffset() + shift, posTag)\n                shift += posTag.length\n                \n                documentText.insert(position.getOffset() + position.getLength() + shift, posCloseTag)\n                shift += posCloseTag.length\n            }\n            \n            Assert.assertEquals(expected, documentText.toString())\n        } finally {\n            testEditor.document.removePositionUpdater(positionUpdater)\n            testEditor.document.removePositionCategory(testCategory)\n        }\n    }\n    \n    private fun addHighlightingPositions() {\n        val ktFile = (testEditor.editor as KotlinEditor).parsedFile!!\n        val document = testEditor.document\n        val highlightingVisitor = KotlinSemanticHighlightingVisitor(ktFile, document)\n        highlightingVisitor.computeHighlightingRanges().forEach { \n            if (it is StyleAttributes) document.addPosition(testCategory, it)\n        }\n    }\n    \n    private fun configureDocument(document: IDocument, positionUpdater: IPositionUpdater) {\n        document.addPositionCategory(testCategory)\n        document.addPositionUpdater(positionUpdater)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/highlighting/KotlinHighlightingTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.highlighting;\n\nimport org.junit.Test;\n\npublic class KotlinHighlightingTest extends KotlinHighlightingTestCase {\n\t\n\t@Override\n    protected String getTestDataRelativePath() {\n        return \"highlighting/basic\";\n    }\n\t\n\t@Test\n\tpublic void kdocBasic() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithParam() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithProperty() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithSee() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithThrows() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithEmptyLines() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithMyTag() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void kdocWithoutLeadingAsterisk() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void function() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void getterSetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void highlightCompanionObject() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void interfaceKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void blockComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void forKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void importKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void inKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void keywordWithText() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void openKeyword() {\n\t\tdoAutoTest();\n\t}\n\n\t@Test\n\tpublic void singleLineComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void softImportKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void softKeywords() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void stringInterpolation() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void textWithTokenBetween() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void textWithTokenInPrefix() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void textWithTokenInSuffix() {\n\t\tdoAutoTest();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/highlighting/KotlinHighlightingTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.highlighting;\n\nimport java.io.File;\n\nimport org.eclipse.jdt.internal.ui.JavaPlugin;\nimport org.eclipse.jdt.internal.ui.text.JavaColorManager;\nimport org.eclipse.jdt.ui.PreferenceConstants;\nimport org.eclipse.jdt.ui.text.IColorManager;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.preference.PreferenceConverter;\nimport org.eclipse.swt.custom.StyleRange;\nimport org.eclipse.swt.graphics.Color;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorAutoTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.junit.Assert;\nimport org.junit.Before;\n\npublic abstract class KotlinHighlightingTestCase extends KotlinEditorAutoTestCase {\n\t\n\tprivate static final IColorManager COLOR_MANAGER = new JavaColorManager();\n\tprivate static final IPreferenceStore preferenceStore = JavaPlugin.getDefault().getPreferenceStore();\n\tprivate static final Color KEYWORD = COLOR_MANAGER.getColor(PreferenceConverter.getColor(preferenceStore, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));\n\tprivate static final Color STRING = COLOR_MANAGER.getColor(PreferenceConverter.getColor(preferenceStore, PreferenceConstants.EDITOR_STRING_COLOR));\n\tprivate static final Color COMMENT = COLOR_MANAGER.getColor(PreferenceConverter.getColor(preferenceStore, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));\n\t\n\tprivate static final String KEYWORD_OPEN = \"<keyword>\";\n\tprivate static final String KEYWORD_CLOSE = \"</keyword>\";\n\tprivate static final String STRING_OPEN = \"<string>\";\n\tprivate static final String STRING_CLOSE = \"</string>\";\n\tprivate static final String COMMENT_OPEN = \"<comment>\";\n\tprivate static final String COMMENT_CLOSE = \"</comment>\";\n\t\n\t@Before\n\tpublic void before() {\n\t    configureProject();\n\t}\n\n    @Override\n    protected void doSingleFileAutoTest(String testPath) {\n    \tString fileText = KotlinTestUtils.getText(testPath);\n        TextEditorTest testEditor = configureEditor(\n                KotlinTestUtils.getNameByPath(testPath),\n                removeColorTags(fileText));\n        \n        StyleRange[] styleRanges = testEditor.getEditor().getViewer().getTextWidget().getStyleRanges();\n\t\tString actualText = insertTokenTags(testEditor.getEditorInput(), styleRanges);\n\t\t\n\t\tAssert.assertEquals(fileText, actualText);\n    }\n    \n\t@Override\n\tprotected void doMultiFileAutoTest(File testFolder) {\n\t\tthrow new UnsupportedOperationException(\"Multi-file tests are not supported for this case\");\n\t}\n\n\tprivate String insertTokenTags(String text, StyleRange[] styleRanges) {\n\t\tint tokenShift = 0;\n\t\tStringBuilder input = new StringBuilder(text);\n\t\tfor (StyleRange styleRange : styleRanges) {\n\t\t\tif (KEYWORD.equals(styleRange.foreground)) {\n\t\t\t\ttokenShift = insertTokenTag(input, KEYWORD_OPEN, styleRange.start, tokenShift);\n\t\t\t\ttokenShift = insertTokenTag(input, KEYWORD_CLOSE, styleRange.start + styleRange.length, tokenShift);\n\t\t\t}\n\t\t\t\n\t\t\tif (STRING.equals(styleRange.foreground)) {\n\t\t\t\ttokenShift = insertTokenTag(input, STRING_OPEN, styleRange.start, tokenShift);\n\t\t\t\ttokenShift = insertTokenTag(input, STRING_CLOSE, styleRange.start + styleRange.length, tokenShift);\n\t\t\t}\n\t\t\t\n\t\t\tif (COMMENT.equals(styleRange.foreground)) {\n\t\t\t\ttokenShift = insertTokenTag(input, COMMENT_OPEN, styleRange.start, tokenShift);\n\t\t\t\ttokenShift = insertTokenTag(input, COMMENT_CLOSE, styleRange.start + styleRange.length, tokenShift);\n\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn input.toString();\n\t}\n\t\n\tprivate int insertTokenTag(StringBuilder input, String insertText, int offset, int shift) {\n\t\tinput.insert(offset + shift, insertText);\n\t\treturn shift + insertText.length();\n\t}\n\t\n\tprivate String removeColorTags(String text) {\n\t\treturn text\n\t\t\t\t.replaceAll(KEYWORD_OPEN, \"\")\n\t\t\t\t.replaceAll(KEYWORD_CLOSE, \"\")\n\t\t\t\t.replaceAll(STRING_OPEN, \"\")\n\t\t\t\t.replaceAll(STRING_CLOSE, \"\")\n\t\t\t\t.replaceAll(COMMENT_OPEN, \"\")\n\t\t\t\t.replaceAll(COMMENT_CLOSE, \"\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/markers/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.markers;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n    KotlinParsingMarkersTest.class, MarkerAttributesTest.class\n} )\npublic class AllTests {\n    \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/markers/KotlinParsingMarkersTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.markers;\n\nimport org.junit.Test;\n\npublic class KotlinParsingMarkersTest extends KotlinParsingMarkersTestCase {\n\t@Override\n    protected String getTestDataRelativePath() {\n        return \"markers/parsing\";\n    }\n    \n    @Test\n    public void missingClosingBraceErrorTest() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void missingFunctionBodyErrorTest() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void excessBraceTypingErrorTest() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/markers/KotlinParsingMarkersTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.markers;\n\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.resources.IResource;\nimport org.eclipse.core.runtime.CoreException;\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.TypingUtils;\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager;\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotation;\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotationUtil;\nimport org.junit.Assert;\nimport org.junit.Before;\n\npublic abstract class KotlinParsingMarkersTestCase extends KotlinEditorWithAfterFileTestCase {\n    @Before\n    public void before() {\n        configureProject();\n    }\n    \n    @Override\n    protected void performTest(String fileText, String expected) {\n\n        try{\n            IMarker[] markers = generateAndGetProblemMarkers(fileText);\n            String actual = insertTagsForErrors(EditorUtil.getSourceCode(getTestEditor().getEditor()), markers);\n            \n            Assert.assertEquals(expected, actual);\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n\n    protected IMarker[] generateAndGetProblemMarkers(String fileText) throws CoreException {\n        IFile file = getTestEditor().getEditingFile();\n        \n        Character typedCharacter = TypingUtils.typedCharacter(fileText);\n        if (typedCharacter != null) {\n            getTestEditor().type(typedCharacter);\n        }\n        \n        KotlinPsiManager.getKotlinFileIfExist(file, EditorUtil.getSourceCode(getTestEditor().getEditor())); // We should update file because problem markers are adding manually\n        for (DiagnosticAnnotation annotation : DiagnosticAnnotationUtil.INSTANCE.createParsingDiagnosticAnnotations(file)) {\n            AnnotationManager.INSTANCE.addProblemMarker(annotation, file);\n        }\n        \n        return getTestEditor().getEditingFile().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);   \n    }\n    \n    private static String insertTagsForErrors(String fileText, IMarker[] markers) throws CoreException {\n        StringBuilder result = new StringBuilder(fileText);\n        \n        Integer offset = 0;\n        for (IMarker marker : markers) {\n            int openTagStartOffset = getOpenTagStartOffset(marker);\n            int closeTagStartOffset = getCloseTagStartOffset(marker);\n            \n            switch (marker.getAttribute(IMarker.SEVERITY, 0)) {\n            case IMarker.SEVERITY_ERROR:\n                offset += insertTagByOffset(result, KotlinTestUtils.ERROR_TAG_OPEN, openTagStartOffset, offset);\n                offset += insertTagByOffset(result, KotlinTestUtils.ERROR_TAG_CLOSE, closeTagStartOffset, offset);\n                break;\n            case IMarker.SEVERITY_WARNING:\n                offset += insertTagByOffset(result, KotlinEditorTestCase.WARNING_TAG_OPEN, openTagStartOffset, offset);\n                offset += insertTagByOffset(result, KotlinEditorTestCase.WARNING_TAG_CLOSE, closeTagStartOffset, offset);\n                break;\n            default:\n                break;\n            }\n        }\n        \n        return result.toString();\n    }\n    \n    private static int getOpenTagStartOffset(IMarker marker) throws CoreException {\n        return getTagStartOffset(marker, IMarker.CHAR_START);\n    }\n    \n    private static int getCloseTagStartOffset(IMarker marker) throws CoreException {\n        return getTagStartOffset(marker, IMarker.CHAR_END);\n    }\n    \n    private static int getTagStartOffset(IMarker marker, String type) throws CoreException {\n        return (int) marker.getAttribute(type);\n    }\n    \n    private static int insertTagByOffset(StringBuilder builder, String tag, int tagStartOffset, int offset) {\n    \tbuilder.insert(tagStartOffset + offset, tag);\n        return tag.length();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/markers/MarkerAttributesTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.markers;\n\nimport static org.hamcrest.CoreMatchers.equalTo;\nimport static org.junit.Assert.assertThat;\n\nimport org.eclipse.core.resources.IMarker;\nimport org.eclipse.core.runtime.CoreException;\nimport org.jetbrains.kotlin.core.log.KotlinLogger;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class MarkerAttributesTest extends KotlinParsingMarkersTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"markers/parsing\";\n    }\n    \n    @Override\n    protected void performTest(String fileText, String expected) {\n        try {\n            IMarker[] markers = generateAndGetProblemMarkers(fileText);\n            \n            for (IMarker marker : markers) {\n                assertThat(marker.getAttribute(IMarker.LOCATION), equalTo(\"line 3\"));\n                assertThat(marker.getAttribute(IMarker.LINE_NUMBER), equalTo(3));\n            }\n        } catch (CoreException e) {\n            KotlinLogger.logAndThrow(e);\n        }\n    }\n    \n    @Ignore\n    @Test\n    public void missingClosingBraceErrorTest() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n\tKotlinNavigationTest.class,\n\tJavaToKotlinNavigationTest.class,\n\tKotlinBuiltInsReferenceResolverTest.class,\n\tKotlinNavigationToLibraryTest.class,\n\tKotlinNavigationFromLibraryTest.class,\n\tKotlinNavigationToSuperTest.class\n} )\npublic class AllTests {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/JavaToKotlinNavigationTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n@Ignore(\"Navigation from java will be fixed in future releases\")\npublic class JavaToKotlinNavigationTest extends JavaToKotlinNavigationTestCase {\n\t@Override\n\tprotected String getTestDataRelativePath() {\n\t\treturn \"navigation/javaToKotlin\";\n\t}\n\t\n\t@Test\n\tpublic void toKotlinClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinClassInPackage() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toInnerKotlinClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinTopLevelFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinFunctionInCompanion() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toCompanionObject() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toNamedCompanionObject() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionInInnerClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionWithNameDuplicate() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionWithNameDuplicateInClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void specifiedPackageLevelFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunInBaseClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toNestedCompanionObject() {\n\t\tdoAutoTest();\n\t}\n\n\t@Test\n\tpublic void toKotlinSuperClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toBasicProperty() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toBasicTopLevelProperty() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toTopLevelPropertyWithGetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toTopLevelPropertyWithSetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toPropertyWithGetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toPropertyWithSetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toMutablePropertyFromGetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toMutablePropertyFromSetter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toMethodWithDefaultArg() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toPropertyInBaseClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toOverridenProperty() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toOverloadMethod1() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toOverloadMethod2() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinObject() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toSecondaryConstructor1() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toSecondaryConstructor2() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toPrimaryConstructor() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionInObject() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionWithPlatformName() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinEnumClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionWithExistingEqualSignature() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionWithExistingConstructorEqualSignature() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toKotlinEnumEntry() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toInnerKotlinEnumClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toInnerKotlinEnumEntry() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionInEnumClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toObjectInstance() {\n\t\tdoAutoTest();\n\t}\n\n\t@Test\n\tpublic void toParametrizedFunction() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toParametrizedFunctionWithOverload() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toParametrizedClass() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toMutablePropertyInCompanion() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toPropertyInCompanion() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFunctionInFilePart() {\n\t    doAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void toFilePart() {\n\t    doAutoTest();\n\t}\n\t\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/JavaToKotlinNavigationTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.jdt.ui.actions.OpenAction;\nimport org.eclipse.jface.text.TextSelection;\nimport org.eclipse.ui.PlatformUI;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.junit.Before;\n\npublic abstract class JavaToKotlinNavigationTestCase extends KotlinNavigationTestCase {\n    @Before\n    public void before() {\n        configureProjectWithStdLib();\n    }\n    \n\t@Override\n\tprotected void doSingleFileAutoTest(String testPath) {\n\t\tthrow new IllegalArgumentException(\"Tests with one file are not supported for this case\");\n\t}\n\n\t@Override\n\tprotected void performTest(String contentAfter) {\n\t\tKotlinTestUtils.joinBuildThread();\n\t\t\n\t\tJavaEditor editor = getTestEditor().getEditor();\n\t\tOpenAction openAction = new OpenAction(editor);\n\t\topenAction.run(new TextSelection(KotlinTestUtils.getCaret(editor), 0));\n        \n        JavaEditor activeEditor = (JavaEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\n        EditorTestUtils.assertByEditor(activeEditor, contentAfter);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinBuiltInsReferenceResolverTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.Test;\n\npublic class KotlinBuiltInsReferenceResolverTest extends KotlinBuiltInsReferenceResolverTestCase {\n    \n    @Test\n    public void testAny() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testInt() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testNothing() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testEquals() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testToString() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testTimes() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testUnit() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testEmptyRange() throws Exception {\n        doAutoTest();\n    }\n\n    @Test\n    public void testIntArrayConstructor() throws Exception {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinBuiltInsReferenceResolverTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.eclipse.jdt.core.IJavaProject;\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment;\nimport org.jetbrains.kotlin.psi.KtFile;\nimport org.jetbrains.kotlin.psi.KtPsiFactory;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\n\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.text.StringUtil;\n\npublic class KotlinBuiltInsReferenceResolverTestCase extends KotlinSourcesNavigationTestCase {\n    \n    private static final String TEST_DATA_PATH = \"common_testData/ide/resolve/builtins\";\n\n    @Override\n    public String getTestDataPath() {\n        return TEST_DATA_PATH;\n    }\n\n    @Override\n    public KtFile getParsedFile(KotlinEditor editor) {\n        IJavaProject javaProject = getTestProject().getJavaProject();\n        KotlinEnvironment environment = KotlinEnvironment.Companion.getEnvironment(javaProject.getProject());\n        Project ideaProject = environment.getProject();\n        KtFile jetFile = new KtPsiFactory(ideaProject).createFile(StringUtil.convertLineSeparators(editor.getJavaEditor().getViewer().getTextWidget().getText()));\n        return jetFile;\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationFromLibraryTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.KotlinNavigationFromLibraryTestCase;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinNavigationFromLibraryTest extends KotlinNavigationFromLibraryTestCase {\n    \n    private final static String TEST_CLASS_NAME = \"navtest.LibraryNavigationKt\";\n   \n    @Ignore\n    @Test\n    public void navigateToTheSameFile() {\n        doAutoTest(TEST_CLASS_NAME);\n    }\n    \n    @Ignore\n    @Test\n    public void navigateToAnotherFile() {\n        doAutoTest(TEST_CLASS_NAME);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationFromLibraryTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.rules.TestName\nimport org.junit.Rule\nimport org.junit.Before\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.JavaModelException\nimport org.junit.AfterClass\nimport org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.library.getTestLibrary;\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.library.clean;\nimport org.eclipse.jdt.core.IPackageFragment\nimport org.jetbrains.kotlin.ui.navigation.KotlinOpenEditor\nimport org.jetbrains.kotlin.psi.KtNamedFunction\nimport com.intellij.psi.PsiComment\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.junit.Assert\nimport org.eclipse.jdt.core.IMember\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\nimport com.intellij.psi.PsiNamedElement\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.eclipse.jdt.ui.JavaUI\nimport org.eclipse.ui.IEditorPart\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.library.TestLibraryData\n\nopen public class KotlinNavigationFromLibraryTestCase: KotlinProjectTestCase() {\n\n    private val name: TestName = TestName()\n\n    //TODO: remove this workaround when access to public fields will be implemented\n    @Rule\n    public fun getTestName(): TestName = name\n\n    @Before\n    fun configure() {\n        configureProject()\n        val testData = getTestLibrary()\n        val libPath = Path(testData.libPath)\n        val srcPath = Path(testData.srcPath)\n        try {\n            getTestProject().addLibrary(libPath, srcPath)\n        } catch (e: JavaModelException) {\n            throw RuntimeException(e)\n        }\n    }\n\n    public fun getEditor(testClassName: String): IEditorPart {\n        val cls = (getTestProject().getJavaProject().findType(testClassName) as IMember).getClassFile()\n        return JavaUI.openInEditor(cls, true, true) //activate = true, reveal = true\n    }\n\n    private fun configureEditor(editor: KotlinClassFileEditor, testData: TestData) {\n        val functionBody = testData.functionToTest.getBodyExpression()!!\n\n        val offset = functionBody.getTextOffset() + functionBody.getText().indexOf(testData.referenceText)\n        val start = LineEndUtil.convertLfToDocumentOffset(editor.parsedFile.getText(), offset, editor.document)\n\n        editor.selectAndReveal(start, 0)\n    }\n\n    public fun doAutoTest(testClassName: String) {\n        val editor = getEditor(testClassName)\n\n        Assert.assertNotNull(\"Editor must be not null\", editor)\n        Assert.assertTrue(\"Editor must be of KotlinClassFileEditor type\", editor is KotlinClassFileEditor)\n\n        val kotlinEditor = editor as KotlinClassFileEditor\n\n        val functionName = name.getMethodName()\n        val testData = getTestData(editor.parsedFile, functionName)\n\n        configureEditor(kotlinEditor, testData)\n\n        runOpenDeclarationAction(kotlinEditor)\n\n        val activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() as KotlinEditor\n\n        assertWithEditor(activeEditor, testData.targetFilePath, testData.targetSymbol)\n    }\n\n    private fun getTestData(parsedFile: KtFile, functionName: String): TestData {\n        val functionToTest = parsedFile.findChildrenByClass(KtNamedFunction::class.java)\n            .filter {functionName == it.name}.firstOrNull()\n        Assert.assertNotNull(\"Can't find a function to test: \"+functionName, functionName)\n\n        val comments = PsiTreeUtil.getChildrenOfType(functionToTest, PsiComment::class.java)\n            ?.map {it.getText().substring(2).trim()}\n        Assert.assertNotNull(\"Test function must provide comments with test info: \"+ functionName, comments)\n\n        val refText = comments!!.getOrNull(0)\n        Assert.assertNotNull(\"Expected a reference text in the function comments: \"+functionName, refText)\n        \n        val expectedTarget = comments.get(1).split(\":\")\n\n        val expectedFile = expectedTarget.getOrNull(0)\n        Assert.assertNotNull(\"Expected a file name in the function comments: \"+ functionName, expectedFile)\n\n        val expectedName = expectedTarget.getOrNull(1)\n        Assert.assertNotNull(\"Expected referenced name in the function comments: \"+ functionName, expectedName)\n\n        return TestData(functionToTest!!, refText!!, expectedFile!!, expectedName!!)\n    }\n\n    private fun assertWithEditor(editor: KotlinEditor, expectedFile: String, expectedName: String) {\n        val parsedFile = editor.parsedFile!!\n\n        val editorOffset = editor.javaEditor.getViewer().getTextWidget().getCaretOffset()\n\n        val expression = PsiTreeUtil.getNonStrictParentOfType(parsedFile.findElementAt(editorOffset)!!, PsiNamedElement::class.java)\n\n        Assert.assertEquals(expectedFile, editor.javaEditor.getTitleToolTip())\n        Assert.assertEquals(expectedName, expression?.getName())\n    }\n\n    private fun runOpenDeclarationAction(editor: KotlinClassFileEditor) {\n        editor.getAction(KotlinOpenDeclarationAction.OPEN_EDITOR_TEXT).run();\n    }\n\n    companion object {\n        @AfterClass\n        @JvmStatic\n        fun afterAllNavigationFromLibraryTests() {\n            getTestLibrary().clean()\n        }\n    }\n\n    private data class TestData(val functionToTest: KtNamedFunction,\n                                val referenceText: String,\n                                val targetFilePath: String,\n                                val targetSymbol: String)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class KotlinNavigationTest extends KotlinNavigationTestCase {\n    @Before\n    public void before() {\n        configureProjectWithStdLib();\n    }\n    \n\t@Override\n    protected String getTestDataRelativePath() {\n        return \"navigation\";\n    }\n\t\n    @Test\n    public void withinFileToClassNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void withinFileToMethodNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void withinFileFromConstructorToClassNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toKotlinClassNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toKotlinMethodNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toJavaClassNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toJavaMethodNavigation() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void fromSyntheticPropertyOnlyWithGetter() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void fromGetterSyntheticProperty() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void fromSetterSyntheticProperty() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toJavaGetterMethod() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.ui.PlatformUI;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorAutoTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.SourceFileData;\n\nimport com.intellij.openapi.util.Condition;\nimport com.intellij.util.containers.ContainerUtil;\n\npublic abstract class KotlinNavigationTestCase extends KotlinEditorAutoTestCase {\n    \n    public static class NavigationSourceFileData extends SourceFileData {\n        \n        public static final Condition<NavigationSourceFileData> IS_BEFORE_PREDICATE = new Condition<NavigationSourceFileData>() {\n            @Override\n            public boolean value(NavigationSourceFileData data) {\n                return data.isBefore;\n            }\n            \n        };\n        \n        public static final Condition<NavigationSourceFileData> IS_AFTER_PREDICATE = new Condition<NavigationSourceFileData>() {\n            @Override\n            public boolean value(NavigationSourceFileData data) {\n                return data.isAfter;\n            }\n            \n        };\n        \n        private boolean isBefore = false;\n        private boolean isAfter = false;\n        \n        public NavigationSourceFileData(File file) throws IOException {\n            super(file);\n        }\n        \n        public static List<NavigationSourceFileData> getTestFiles(File testFolder) {\n            List<NavigationSourceFileData> result = new ArrayList<NavigationSourceFileData>();\n            \n            for (File file : testFolder.listFiles()) {\n                String fileName = file.getName();\n                \n                NavigationSourceFileData data;\n                try {\n                    data = new NavigationSourceFileData(file);\n                } catch (IOException e) {\n                    throw new RuntimeException(e);\n                }\n                \n                result.add(data);\n                \n                if (fileName.endsWith(BEFORE_FILE_EXTENSION)) {\n                    data.isBefore = true;\n                }\n                if (fileName.endsWith(AFTER_FILE_EXTENSION)) {\n                    data.isAfter = true;\n                }\n            }\n            \n            return result;\n        }\n        \n        public static NavigationSourceFileData getFileByPredicate(Iterable<NavigationSourceFileData> files,\n                Condition<NavigationSourceFileData> predicate) {\n            return ContainerUtil.find(files, predicate);\n        }\n    }\n    \n    private TextEditorTest testEditor;\n    \n    protected TextEditorTest getTestEditor() {\n        return testEditor;\n    }\n    \n    protected void performTest(String contentAfter) {\n        KotlinTestUtils.joinBuildThread();\n        testEditor.runOpenDeclarationAction();\n        \n        JavaEditor activeEditor = (JavaEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\n        EditorTestUtils.assertByEditor(activeEditor, contentAfter);\n    }\n    \n    @Override\n    protected void doSingleFileAutoTest(String testPath) {\n        String fileText = KotlinTestUtils.getText(testPath);\n        testEditor = configureEditor(\n                KotlinTestUtils.getNameByPath(testPath),\n                fileText,\n                NavigationSourceFileData.getPackageFromContent(fileText));\n        \n        performTest(KotlinTestUtils.getText(testPath + AFTER_FILE_EXTENSION));\n    }\n    \n    @Override\n    protected void doMultiFileAutoTest(File testFolder) {\n        Collection<NavigationSourceFileData> files = NavigationSourceFileData.getTestFiles(testFolder);\n        \n        NavigationSourceFileData target = NavigationSourceFileData.getFileByPredicate(\n                files,\n                NavigationSourceFileData.IS_BEFORE_PREDICATE);\n        \n        NavigationSourceFileData targetAfter = NavigationSourceFileData.getFileByPredicate(\n                files,\n                NavigationSourceFileData.IS_AFTER_PREDICATE);\n        for (NavigationSourceFileData data : files) {\n            if (data != target) {\n                String fileName = data.getFileName();\n                \n                createSourceFile(\n                        data.getPackageName(),\n                        data != targetAfter ? fileName : fileName.replace(AFTER_FILE_EXTENSION, \"\"),\n                        data.getContent());\n            }\n        }\n        \n        testEditor = configureEditor(\n                target.getFileName().replace(BEFORE_FILE_EXTENSION, \"\"),\n                target.getContent(),\n                target.getPackageName());\n        \n        performTest(targetAfter.getContent());\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationToLibraryTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinNavigationToLibraryTest extends KotlinNavigationToLibraryTestCase {\n    \n    @Test\n    public void testClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void testFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void testPackageFunction() {\n        doAutoTest();\n    }\n\n    @Ignore\n    @Test\n    public void testClassWithMisplacedSource() {\n        doAutoTest();\n    }\n\n    @Ignore\n    @Test\n    public void testFunctionWithMisplacedSource() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void testClassWithIdenticalMisplacedSource() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void testConstructor() {\n        doAutoTest();\n    }  \n    \n    @Test\n    public void testPackageFacadeFunction() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationToLibraryTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation\n\nimport java.io.File\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.JavaModelException\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.Assert\nimport org.junit.Before\nimport org.junit.Test\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.library.getTestLibrary\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.library.clean\nimport org.junit.AfterClass\n\npublic open class KotlinNavigationToLibraryTestCase: KotlinSourcesNavigationTestCase() {\n    override fun getParsedFile(editor: KotlinEditor): KtFile =\n            editor.parsedFile!!\n\n    override val testDataPath: String =\n        \"testData/navigation/lib\"\n\n    @Before\n    override fun configure() {\n        super.configure()\n        try\n        {\n            val testData = getTestLibrary()\n            val libPath = Path(testData.libPath)\n            val srcPath = Path(testData.srcPath)\n            getTestProject().addLibrary(libPath, srcPath)\n        }\n        catch (e:JavaModelException) {\n            throw RuntimeException(e)\n        }\n    }\n    \n    companion object {\n        @AfterClass\n        @JvmStatic\n        fun afterAllNavigationTests() {\n            getTestLibrary().clean()\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationToSuperTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation;\n\nimport org.junit.Test;\n\npublic class KotlinNavigationToSuperTest extends KotlinNavigationToSuperTestCase {\n    @Test\n    public void testClassSimple() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/ClassSimple.test\");\n    }\n    \n    @Test\n    public void testDelegatedFun() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/DelegatedFun.test\");\n    }\n    \n    @Test\n    public void testDelegatedProperty() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/DelegatedProperty.test\");\n    }\n    \n    @Test\n    public void testFakeOverrideFun() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/FakeOverrideFun.test\");\n    }\n    \n    @Test\n    public void testFakeOverrideFunWithMostRelevantImplementation() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/FakeOverrideFunWithMostRelevantImplementation.test\");\n    }\n    \n    @Test\n    public void testFakeOverrideProperty() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/FakeOverrideProperty.test\");\n    }\n    \n    @Test\n    public void testFunctionSimple() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/FunctionSimple.test\");\n    }\n    \n    @Test\n    public void testObjectSimple() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/ObjectSimple.test\");\n    }\n    \n    @Test\n    public void testPropertySimple() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/PropertySimple.test\");\n    }\n    \n    @Test\n    public void testSuperWithNativeToGenericMapping() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/SuperWithNativeToGenericMapping.test\");\n    }\n    \n    @Test\n    public void testTraitSimple() throws Exception {\n        doTest(\"common_testData/ide/navigation/gotoSuper/TraitSimple.test\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinNavigationToSuperTestCase.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.navigation\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.Before\nimport java.io.File\nimport com.intellij.openapi.util.io.FileUtil\nimport org.jetbrains.kotlin.core.tests.diagnostics.JetTestUtils\nimport org.jetbrains.kotlin.core.tests.diagnostics.JetTestUtils.TestFileFactoryNoModules\nimport org.junit.Assert\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenSuperImplementationAction\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\n\nabstract class KotlinNavigationToSuperTestCase : KotlinProjectTestCase() {\n    @Before\n    fun confnigure() {\n        configureProject()\n    }\n    \n    fun doTest(filePath: String) {\n        val content = FileUtil.loadFile(File(filePath))\n        val (before, after) = loadBeforeAndAfterParts(content)\n        \n        val testEditor = configureEditor(\"before.kt\", before)\n        \n        testEditor.editor.getAction(KotlinOpenSuperImplementationAction.ACTION_ID).run()\n        \n        EditorTestUtils.assertByEditor(testEditor.editor, after);\n    }\n    \n    private fun loadBeforeAndAfterParts(content: String): NavigationTestData {\n        val files = JetTestUtils.createTestFiles(\"\", content, object : TestFileFactoryNoModules<String>() {\n            override fun create(fileName: String, text: String, directives: MutableMap<String, String>): String {\n                val firstLineEnd = text.indexOf('\\n')\n                return text.substring(firstLineEnd + 1).trim()\n            }\n        })\n        \n        Assert.assertTrue(\"Exactly two files expected: \", files.size == 2)\n        \n        return NavigationTestData(files[0], files[1])\n    }\n    \n    private data class NavigationTestData(val before: String, val after: String)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/KotlinSourcesNavigationTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.navigation.KotlinOpenDeclarationAction\nimport org.eclipse.jface.text.TextSelection\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.eclipse.ui.PlatformUI\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.eclipse.jdt.core.IJavaProject\nimport org.jetbrains.kotlin.psi.KtFile\nimport com.intellij.psi.util.PsiTreeUtil\nimport com.intellij.psi.PsiComment\nimport java.io.File\nimport org.junit.Assert\nimport org.jetbrains.kotlin.ui.editors.KotlinClassFileEditor\nimport org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType\nimport com.intellij.psi.PsiNamedElement\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.rules.TestName\nimport org.junit.Rule\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.jetbrains.kotlin.testframework.utils.InTextDirectivesUtils\nimport org.jetbrains.kotlin.psi.KtNamedDeclaration\nimport org.jetbrains.kotlin.psi.KtCallableDeclaration\nimport org.jetbrains.kotlin.psi.KtConstructor\nimport org.jetbrains.kotlin.psi.KtFunction\n\nabstract class KotlinSourcesNavigationTestCase: KotlinProjectTestCase() {\n    \n    abstract val testDataPath: String\n    \n    companion object {\n        private val KT_FILE_EXTENSION = \".kt\"\n        private val TEST_PREFIX = \"test\"\n    }\n    \n    private val name: TestName = TestName()\n    \n    //TODO: remove this workaround when access to public fields will be implemented\n    @Rule\n    public fun getTestName(): TestName = name\n    \n    private val testEditor: TextEditorTest by lazy {\n        val processedFileText = KotlinEditorTestCase.removeTags(fileText)\n        configureEditor(inputFileName, processedFileText)\n    }\n    \n    val inputFileName: String by lazy {\n        val inputFileName = name.getMethodName()\n        val filenameAsArray = inputFileName.substring(TEST_PREFIX.length).toCharArray()\n        filenameAsArray[0] = Character.toLowerCase(filenameAsArray[0])\n        String(filenameAsArray) + KT_FILE_EXTENSION\n    }\n    \n    val fileText: String by lazy {\n        KotlinEditorTestCase.getText(testDataPath  + File.separator + inputFileName)\n    }\n    \n    val processedFileText: String by lazy {\n        KotlinEditorTestCase.removeTags(fileText)\n    }\n    \n    @Before    \n    open fun configure() {\n        configureProject()\n        createSourceFile(inputFileName, processedFileText)\n    }\n\n    public fun doAutoTest() {\n        val testEditor = configureEditor(inputFileName, processedFileText)\n        val referenceOffset = getReferenceOffset(fileText)\n        val editorFile = testEditor.getEditingFile()\n        \n        val initialFile = KotlinPsiManager.getParsedFile(editorFile)\n        val editor = testEditor.getEditor()\n        testEditor.setCaret(referenceOffset)\n        \n        val openAction = KotlinOpenDeclarationAction(editor as KotlinFileEditor)\n        openAction.run(TextSelection(KotlinTestUtils.getCaret(editor), 0))\n        \n        val activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() as KotlinEditor\n        assertWithEditor(initialFile, activeEditor)\n    }\n\n    private fun assertWithEditor(initialFile: KtFile, editor: KotlinEditor) {\n        val fileText = initialFile.getText()\n        val expectedFile = InTextDirectivesUtils.findStringWithPrefixes(fileText, \"SRC:\");\n        val expectedTarget = InTextDirectivesUtils.findStringWithPrefixes(fileText, \"TARGET:\");\n        \n        Assert.assertEquals(expectedFile, editor.javaEditor.getTitleToolTip())\n        \n        val editorOffset = editor.javaEditor.getViewer().getTextWidget().getCaretOffset()\n        val offsetInPSI = LineEndUtil.convertCrToDocumentOffset(editor.document, editorOffset)\n        val psiElement = getParsedFile(editor).findElementAt(offsetInPSI)\n        val declaration = psiElement?.getNonStrictParentOfType(PsiNamedElement::class.java) as KtNamedDeclaration\n        \n        val expressionName = getPresentableString(declaration)\n        val locationString = if (declaration is KtConstructor<*>) {\n            val name = declaration.getContainingClassOrObject().fqName\n            \"(in $name)\"\n        } else {\n            getLocationString(declaration)\n        }\n        \n        Assert.assertEquals(expectedTarget, \"$locationString.$expressionName\")\n    }\n    \n    abstract fun getParsedFile(editor: KotlinEditor): KtFile\n    \n    private fun getReferenceOffset(fileText: String) = fileText.indexOf(KotlinEditorTestCase.CARET_TAG)\n    \n    private fun getPresentableString(declaration: KtNamedDeclaration): String {\n        if (declaration !is KtFunction) {\n            return declaration.name!!\n        }\n        \n        return buildString {\n            declaration.name?.let { append(it) }\n            \n            append(\"(\")\n            append(declaration.valueParameters.joinToString { it.typeReference?.text ?: \"\" })\n            append(\")\")\n        }\n    }\n    \n    private fun getLocationString(declaration: KtNamedDeclaration): String? {\n        val name = declaration.fqName ?: return null\n        val receiverTypeRef = (declaration as? KtCallableDeclaration)?.receiverTypeReference\n        if (receiverTypeRef != null) {\n            return \"(for \" + receiverTypeRef.text + \" in \" + name.parent() + \")\"\n        } else if (declaration.parent is KtFile) {\n            return \"(\" + name.parent() + \")\"\n        } else {\n            return \"(in \" + name.parent() + \")\"\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/navigation/library/NavigationTestLibrary.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.navigation.library\n\nimport org.eclipse.core.runtime.Path\nimport org.jetbrains.kotlin.cli.common.ExitCode\nimport org.jetbrains.kotlin.cli.jvm.K2JVMCompiler\nimport org.jetbrains.kotlin.core.launch.KotlinCLICompiler\nimport org.jetbrains.kotlin.core.utils.ProjectUtils\nimport org.jetbrains.kotlin.utils.PathUtil\nimport org.junit.Assert\nimport java.io.*\nimport java.util.zip.ZipEntry\nimport java.util.zip.ZipOutputStream\n\npublic data class TestLibraryData(val libPath: String, val srcPath: String)\n\npublic fun getTestLibrary() = \n        NavigationTestLibrary().let { \n            TestLibraryData(it.libraryPath, it.sourceArchivePath)\n         }\n\npublic fun TestLibraryData.clean() {\n    File(libPath).delete()\n    File(srcPath).delete()\n}\n\nprivate class NavigationTestLibrary {\n    private val srcFolderName = \"src\"\n    private val targetFolderName = \"target\"\n    \n    public val commonArtifactName: String = \"kotlin-navigation-test-lib\"\n    \n    private val testDataRootFolder = File(\"testData/navigation/lib/\")\n    private val srcPath = File(testDataRootFolder, srcFolderName)\n    \n    private val libraryFile: File\n    private val sourceArchiveFile: File\n    \n    public val libraryPath: String\n        get() {\n            return libraryFile.getAbsolutePath()\n        }\n    \n    public val sourceArchivePath: String\n        get() {\n            return sourceArchiveFile.getAbsolutePath()\n        }\n    \n    init {\n        val targetFolder = File(testDataRootFolder, targetFolderName)\n        if (!targetFolder.exists()) {\n            targetFolder.mkdir()\n        }\n        libraryFile = File(targetFolder, \"${commonArtifactName}.jar\")\n        if (!libraryFile.exists()) {\n            runCompiler(libraryFile)\n        }\n        \n        sourceArchiveFile = File(targetFolder, \"${commonArtifactName}-sources.zip\")\n        if (!sourceArchiveFile.exists()) {\n            createSourceArchive(sourceArchiveFile, srcPath)\n        }\n    }\n    \n    public fun clean() {\n        libraryFile.delete()\n        sourceArchiveFile.delete();\n    }\n    \n    private fun createSourceArchive(targetFile: File, contentsDir: File) {\n        val stream = ZipOutputStream(FileOutputStream(targetFile))\n        stream.use {\n            writeEntriesToJarRecursively(stream, contentsDir, \"\")\n        }\n    }\n    \n    private fun writeEntriesToJarRecursively(stream: ZipOutputStream, contentDir: File, pathPrefix: String) {\n        contentDir.listFiles().forEach {\n            val entryName = pathPrefix + it.getName() + if (it.isDirectory()) \"/\" else \"\"\n            when {\n                it.isDirectory() -> { \n                    stream.putNextEntry(ZipEntry(entryName))\n                    stream.closeEntry()\n                    writeEntriesToJarRecursively(stream, it, entryName) \n                }\n                it.isFile() -> {\n                    stream.putNextEntry(ZipEntry(entryName))\n                    val inStream = BufferedInputStream(FileInputStream(it));\n                    inStream.use { \n                        it.copyTo(stream)\n                    }\n                    stream.closeEntry()\n                }\n            }\n         }\n    }\n    \n    private fun runCompiler(targetFile: File) {\n        val targetPath: String = Path(targetFile.getAbsolutePath()).toOSString()\n        val outputStream = ByteArrayOutputStream();\n        val out = PrintStream(outputStream);\n        \n        val exitCode = KotlinCLICompiler.doMain(K2JVMCompiler(), out, \n                arrayOf(\"-d\", targetPath, \"-kotlin-home\", ProjectUtils.ktHome,\n                    \"-Xplugin=\" + ProjectUtils.buildLibPath(PathUtil.KOTLIN_SCRIPTING_COMPILER_PLUGIN_NAME),\n                    srcPath.getAbsolutePath()))\n        Assert.assertTrue(\n                \"Could not compile test library, exitCode = $exitCode\\n ${outputStream.toString()}\", \n                exitCode == ExitCode.OK)\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/organizeImports/KotlinCommonOptimizeImportsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.organizeImports;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinCommonOptimizeImportsTest extends KotlinOrganizeImportsTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/editor/optimizeImports/common\";\n    }\n    \n    @Ignore(\"Enable this test when autoimport for functions will be ready\")\n    @Test\n    public void ArrayAccessExpression() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void ClassMemberImported() {\n        doAutoTest();\n    }\n    \n    @Ignore(\"Enable this test when autoimport for functions will be ready\")\n    @Test\n    public void ComponentFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void CurrentPackage() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DefaultObjectReference() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void Enums() {\n        doAutoTest();\n    }\n    \n    @Ignore\n    @Test\n    public void InvokeFunction() {\n        doAutoTest();\n    }\n    \n    @Ignore(\"Enable this test when autoimport for functions will be ready\")\n    @Test\n    public void IteratorFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void KeywordNames() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Kt2488EnumEntry() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Kt2709() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void KT9875() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void MembersInScope() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void NestedClassReferenceOutsideClassBody() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/organizeImports/KotlinJvmOptimizeImportsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.organizeImports;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinJvmOptimizeImportsTest extends KotlinOrganizeImportsTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/editor/optimizeImports/jvm\";\n    }\n    \n    @Test\n    public void AlreadyOptimized() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void CallableReference() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ClassFromSameFileImportAddedBug() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DoNotTouchIfNoChanges() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void DuplicatedImports() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FromCompanionObject() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void FromCompanionObjectGeneric() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void KT10226() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Kt1850FullQualified() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void Kt1850InnerClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void NestedClassInObject() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void RemoveImportsIfGeneral() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void RemoveImportsIfGeneralBefore() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void SamConstructor() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void StaticMethodFromSuper() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void ThisAndSuper() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void TrivialAlias() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void UnusedImports() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void WithAliases() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/organizeImports/KotlinOrganizeImportsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.organizeImports;\n\nimport org.junit.Test;\n\npublic class KotlinOrganizeImportsTest extends KotlinOrganizeImportsTestCase {\n    @Override\n    public boolean getIncludeStdLib() {\n        return false;\n    }\n\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"organizeImports\";\n    }\n    \n    @Test\n    public void includeImportsOnlyfromActiveFile() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void doNotInsertLinesForNoErrors() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void importOneClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void importSeveralClasses() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void importSeveralClassesWithExistingPackage() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/organizeImports/KotlinOrganizeImportsTestCase.kt",
    "content": "/*******************************************************************************\n\n* Copyright 2000-2016 JetBrains s.r.o.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.organizeImports\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase\nimport org.junit.Before\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.editors.organizeImports.KotlinOrganizeImportsAction\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\n\nabstract class KotlinOrganizeImportsTestCase : KotlinEditorWithAfterFileTestCase() {\n\topen val includeStdLib: Boolean = true\n\t\n    @Before\n    fun before() {\n\t\tif (includeStdLib) {\n\t\t    configureProjectWithStdLib()\n\t\t} else {\n\t\t\tconfigureProject()\n\t\t}\n    }\n    \n    override fun performTest(fileText: String, expectedFileText: String) {\n        val editor = testEditor.getEditor() as KotlinFileEditor\n        \n        editor.getAction(KotlinOrganizeImportsAction.ACTION_ID).run()\n        \n        EditorTestUtils.assertByEditor(editor, expectedFileText)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/AllTests.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\n\n@RunWith(Suite.class)\n@Suite.SuiteClasses( { \n\tKotlinAutoImportTest.class,\n\tKotlinMakeClassOpenQuickFixTest.class,\n\tKotlinChangeModifiersQuickFixTest.class,\n\tKotlinAbstractModifierQuickFixTest.class,\n\tKotlinMakeOverridenMemberOpenQuickFixTest.class\n} )\npublic class AllTests {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinAbstractModifierQuickFixTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.Test;\n\npublic class KotlinAbstractModifierQuickFixTest extends KotlinQuickFixTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/quickfix/abstract/\";\n    }\n    \n    @Test\n    public void abstractFunctionInNonAbstractClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyInNonAbstractClass1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyInNonAbstractClass2() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyInNonAbstractClass3() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyInPrimaryConstructorParameters() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyNotInClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyWithGetter1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyWithInitializer1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void abstractPropertyWithSetter() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void mustBeInitializedOrBeAbstract() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void nonMemberAbstractFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void notImplementedMember() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void notImplementedMemberFromAbstractClass() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void replaceOpen() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinAutoImportTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.Test;\n\npublic class KotlinAutoImportTest extends KotlinAutoImportTestCase {\n\n\t@Test\n\tpublic void standardEnumMapAutoImport() {\n\t\tdoAutoTest();\n\t}\n\n\t@Test\n\tpublic void packageArrayListAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void sameProjectJavaClassAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void localJavaEnumAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void localJavaClassAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void localJavaInterfaceAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void importClassWithExistingPackageKeyword() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void importOnlyUnresolvedReferenceExpressions() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void importWithExtraBreakline() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void importWithExtraBreaklineWithoutPackage() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void oneStandardVectorAutoImport() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void packageLevelFunctionImport() {\n\t    doAutoTest();\n\t}  \n\t\n    @Test\n    public void packageLevelValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void packageLevelInvokableValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void packageLevelFunctionValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionFunctionImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void functionExtensionValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void invokableExtensionValImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionOperatorImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void unaryExtensionOperatorImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionInfixFunctionImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void functionReferenceImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void propertyReferenceImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionFunctionReferenceImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionValReferenceImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void classNestedInClassImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void classNestedInObjectImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionMethodInLambdaWithReceiverImport() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void extensionMethodInLambdaWithReceiverAmbigousImport() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinAutoImportTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisFileCache;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.ExpectedCompletionUtils;\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolution;\nimport org.junit.Assert;\nimport org.junit.Before;\n\npublic abstract class KotlinAutoImportTestCase extends KotlinEditorWithAfterFileTestCase {\n    \n    private static final String AUTOIMPORT_TEST_DATA_PATH_SEGMENT = \"completion/autoimport\";\n    \n    private static final String COUNT_ASSERTION_ERROR_MESSAGE = \"Number of actual proposals differs from the number of expected proposals\";\n    private static final String EXISTENCE_ASSERTION_ERROR_MESSAGE_FORMAT = \"List of actual proposals doesn't contain expected proposal: %s\";\n    \n    @Before\n    public void before() {\n        configureProjectWithStdLib();\n    }\n    \n    @Override\n    protected boolean loadFilesBeforeOpeningEditor() {\n        return true;\n    }\n    \n    private List<KotlinMarkerResolution> createProposals() {\n        // TODO: find better solution than this\n        try {\n            Thread.sleep(500);\n        } catch (InterruptedException ignored) {}\n        KotlinAnalysisFileCache.INSTANCE.resetCache();\n\n        return KotlinQuickFixTestCaseKt.getProposals(getTestEditor());\n    }\n    \n    @Override\n    protected void performTest(String fileText, String content) {\n        List<KotlinMarkerResolution> proposals = createProposals();\n        assertCount(proposals, fileText);\n        assertExistence(proposals, fileText);\n        \n        if (!proposals.isEmpty()) {\n            proposals.get(0).apply(getTestEditor().getEditingFile());;\n        }\n        \n        EditorTestUtils.assertByEditor(getEditor(), content);\n    }\n    \n    @Override\n    protected String getTestDataRelativePath() {\n        return AUTOIMPORT_TEST_DATA_PATH_SEGMENT;\n    }\n    \n    private static void assertCount(List<KotlinMarkerResolution> proposals, String fileText) {\n        Integer expectedNumber = ExpectedCompletionUtils.numberOfItemsShouldPresent(fileText);\n        \n        if (expectedNumber != null) {\n            Assert.assertEquals(COUNT_ASSERTION_ERROR_MESSAGE, expectedNumber.intValue(), proposals.size());\n        }\n    }\n    \n    private static void assertExistence(List<KotlinMarkerResolution> proposals, String fileText) {\n        List<String> expectedStrings = ExpectedCompletionUtils.itemsShouldExist(fileText);\n        List<String> actualStrings = getProposalsStrings(proposals);\n        \n        for (String string : expectedStrings) {\n            Assert.assertTrue(String.format(EXISTENCE_ASSERTION_ERROR_MESSAGE_FORMAT, string), actualStrings.contains(string));\n        }\n    }\n    \n    private static List<String> getProposalsStrings(List<KotlinMarkerResolution> proposals) {\n        List<String> result = new ArrayList<String>();\n        \n        for (KotlinMarkerResolution proposal : proposals) {\n            result.add(proposal.getLabel());\n        }\n        \n        return result;\n    }\n    \n    private JavaEditor getEditor() {\n        return getTestEditor().getEditor();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinChangeModifiersQuickFixTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinChangeModifiersQuickFixTest extends KotlinQuickFixTestCase {\n    \n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/quickfix/modifiers/\";\n    }\n    \n    @Test\n    public void abstractModifierInEnum() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void finalTrait() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void illegalEnumAnnotation1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void illegalEnumAnnotation2() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void infixModifier() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void kt10409() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void nestedClassNotAllowed() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void openMemberInFinalClass1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void openMemberInFinalClass2() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void openMemberInFinalClass3() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void openMemberInFinalClass4() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void openModifierInEnum() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void operatorModifier() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void operatorModifierCollection() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void operatorModifierComponent() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void operatorModifierGet() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void operatorModifierInherited() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void packageMemberCannotBeProtected() {\n        doAutoTest();\n    }\n    \n    @Ignore(\"Temporary ignore this\")\n    @Test\n    public void removeAbstractModifier() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeIncompatibleModifier() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeInnerForClassInTrait() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeProtectedModifier() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeRedundantModifier1() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeRedundantModifier2() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void removeRedundantModifier3() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinMakeClassOpenQuickFixTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.Test;\n\npublic class KotlinMakeClassOpenQuickFixTest extends KotlinQuickFixTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/quickfix/modifiers/addOpenToClassDeclaration\";\n    }\n    \n    @Test\n    public void explicitlyFinalSupertype() {\n        doAutoTest();\n    }\n\n    @Test\n    public void explicitlyFinalUpperBound() {\n        doAutoTest();\n    }\n\n    @Test\n    public void finalSupertype() {\n        doAutoTest();\n    }\n\n    @Test\n    public void finalUpperBound() {\n        doAutoTest();\n    }\n\n    @Test\n    public void implementTraitFinalSupertype() {\n        doAutoTest();\n    }\n\n    @Test\n    public void nestedFinalClass() {\n        doAutoTest();\n    }\n\n    @Test\n    public void secondaryCtrDelegationInHeader() {\n        doAutoTest();\n    }\n\n    @Test\n    public void secondaryCtrDelegationInSecondary() {\n        doAutoTest();\n    }\n\n    @Test\n    public void withConstructor() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinMakeOverridenMemberOpenQuickFixTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport;\n\nimport org.junit.Test;\n\npublic class KotlinMakeOverridenMemberOpenQuickFixTest extends KotlinQuickFixTestCase {\n    @Override\n    protected String getTestDataRelativePath() {\n        return \"../common_testData/ide/quickfix/override\";\n    }\n    \n    // TODO: Fix for several base methods\n//    @Test\n//    public void overriddingMultipleFinalMethods() {\n//        doAutoTest();\n//    }\n//    \n    \n    @Test\n    public void overridingDelegatedMethod() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void overridingFakeOverride() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void overridingFinalMethod() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void overridingFinalMethodInLocal() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void overridingFinalProperty() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/autoimport/KotlinQuickFixTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.autoimport\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.eclipse.ui.ide.IDE\nimport org.eclipse.core.resources.IMarker\nimport org.eclipse.core.resources.IResource\nimport org.eclipse.jface.text.source.ISourceViewer\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.ui.editors.annotations.DiagnosticAnnotation\nimport org.jetbrains.kotlin.ui.editors.annotations.endOffset\nimport org.eclipse.jface.text.source.IAnnotationModel\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolutionGenerator\nimport org.jetbrains.kotlin.ui.editors.annotations.AnnotationManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.getBindingContext\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.junit.Assert\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.jetbrains.kotlin.eclipse.ui.utils.LineEndUtil\nimport org.eclipse.jdt.core.IJavaProject\nimport org.eclipse.core.resources.IFile\nimport org.jetbrains.kotlin.psi.KtFile\nimport org.jetbrains.kotlin.ui.editors.quickfix.KotlinMarkerResolution\nimport org.eclipse.jface.text.IDocument\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest\nimport org.jetbrains.kotlin.ui.editors.findDiagnosticsBy\nimport org.eclipse.jface.text.source.TextInvocationContext\n\nprivate val expectedQuickFixRegex = \"\\\"(.*?)\\\"\".toRegex()\n\nabstract class KotlinQuickFixTestCase : KotlinEditorWithAfterFileTestCase() {\n    \n    @Before\n    fun before() {\n        configureProject();\n    }\n    \n    override fun performTest(fileText: String, expectedFileText: String) {\n        val firstLine = fileText.split(\"\\n\")[0]\n        val splittedLine = expectedQuickFixRegex.find(firstLine)\n        val expectedLabel = splittedLine!!.groups[1]!!.value\n        \n        val foundProposals = getProposals(testEditor)\n        val resolution = foundProposals.find { it.label == expectedLabel }\n        \n        Assert.assertNotNull(\n                \"Expected proposal with label \\\"$expectedLabel\\\" wasn't found. Found proposals:\\n${foundProposals.joinToString(\"\\n\") { it.label }}\",\n                resolution)\n        \n        resolution!!.apply(testEditor.getEditingFile())\n        \n        EditorTestUtils.assertByEditor(testEditor.getEditor(), expectedFileText);\n    }\n}\n\nfun getProposals(testEditor: TextEditorTest): List<KotlinMarkerResolution> {\n    val editor = testEditor.getEditor() as KotlinFileEditor\n    val diagnostics = findDiagnosticsBy(TextInvocationContext(editor.viewer, testEditor.caretOffset, 0), editor)\n    \n    return KotlinMarkerResolutionGenerator.getResolutions(diagnostics)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/AbstractKotlinQuickAssistTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport java.io.File;\nimport java.lang.reflect.InvocationTargetException;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest;\nimport org.jetbrains.kotlin.testframework.utils.InTextDirectivesUtils;\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\nimport org.junit.Assert;\nimport org.junit.Before;\n\nimport kotlin.jvm.functions.Function1;\n\npublic abstract class AbstractKotlinQuickAssistTestCase<Proposal extends KotlinQuickAssistProposal> extends KotlinProjectTestCase {\n\t@Before\n\tpublic void configure() {\n\t\tconfigureProject();\n\t}\n\t\n\tprotected void doTestFor(String testPath, Function1<KotlinEditor, KotlinQuickAssistProposal> createProposal) {\n\t\tdoTestFor(testPath, createProposal, false);\n\t}\n\t\n\tprotected void doTestFor(String testPath, \n\t        Function1<KotlinEditor, KotlinQuickAssistProposal> createProposal, \n\t        boolean joinBuildThread) {\n\t\tString fileText = KotlinTestUtils.getText(testPath);\n\t\tTextEditorTest testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText);\n\t\tKotlinQuickAssistProposal proposal = createProposal.invoke((KotlinEditor) testEditor.getEditor()); \n\t\t\n\t\tString isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, \"IS_APPLICABLE: \");\n        boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals(\"true\");\n        \n        String pathToExpectedFile = testPath + \".after\";\n        File expectedFile = new File(pathToExpectedFile);\n        if (!expectedFile.exists()) isApplicableExpected = false;\n        \n        if (joinBuildThread) {\n        \tKotlinTestUtils.joinBuildThread();\n        }\n\n        Assert.assertTrue(\n                \"isAvailable() for \" + proposal.getClass() + \" should return \" + isApplicableExpected,\n                isApplicableExpected == proposal.isApplicable());\n\t\t\n\t\tString shouldFailString = InTextDirectivesUtils.findStringWithPrefixes(fileText, \"SHOULD_FAIL_WITH: \");\n\t\t\n\t\tif (isApplicableExpected) {\n\t\t\tproposal.apply(testEditor.getEditor().getViewer().getDocument());\n\t\n\t\t\tif (shouldFailString == null) {\n\t\t\t\tassertByEditor(testEditor.getEditor(), KotlinTestUtils.getText(pathToExpectedFile));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprotected abstract void assertByEditor(JavaEditor editor, String expected);\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinChangeReturnTypeTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinChangeReturnTypeTest extends KotlinChangeReturnTypeTestCase {\n    @Test\n    public void testNonLocalReturnRuntime() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/nonLocalReturnRuntime.kt\");\n    }\n    \n    @Test\n    public void testChangeFunctionReturnTypeToFunctionType() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/changeFunctionReturnTypeToFunctionType.kt\");\n    }\n    \n    @Test\n    public void testNonLocalReturnWithLabelRuntime() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/nonLocalReturnWithLabelRuntime.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchInIfStatementReturnedByFunction() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/typeMismatchInIfStatementReturnedByFunction.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchInInitializer() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/typeMismatchInInitializer.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchInReturnStatement() {\n        doTest(\"common_testData/ide/quickfix/typeMismatch/typeMismatchOnReturnedExpression/typeMismatchInReturnStatement.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchInReturnLambda() {\n        doTest(\"testData/intentions/changeReturnType/typeMismatchInReturnLambda.kt\");\n    }\n    \n    @Test\n    public void testTypeMismatchInReturnLambdaWithLabel() {\n        doTest(\"testData/intentions/changeReturnType/typeMismatchInReturnLambdaWithLabel.kt\");\n    }\n    \n\n    @Ignore(\"Script support will be fixed in future releases\")\n    @Test\n    public void testChangeReturnTypeInScript() {\n        doTest(\"testData/intentions/changeReturnType/changeReturnTypeInScript.kts\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinChangeReturnTypeTestCase.kt",
    "content": "/*******************************************************************************\n * Copyright 2000-2015 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions\n\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinChangeReturnTypeProposal\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.junit.Before\n\n@Suppress(\"UPPER_BOUND_VIOLATED\")\nabstract class KotlinChangeReturnTypeTestCase : AbstractKotlinQuickAssistTestCase<KotlinChangeReturnTypeProposal>() {\n    @Before\n    override fun configure() {\n        configureProjectWithStdLib()\n    }\n\n    override fun assertByEditor(editor: JavaEditor, expected: String) {\n        EditorTestUtils.assertByEditor(editor, expected)\n    }\n    \n    protected fun doTest(testPath: String) {\n\t\t@Suppress(\"TYPE_MISMATCH\", \"MISSING_DEPENDENCY_CLASS\")\n        doTestFor(testPath) { KotlinChangeReturnTypeProposal(it) }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinConvertToBlockBodyTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinConvertToBlockBodyTest extends\n\t\tKotlinConvertToBlockBodyTestCase {\n\t@Test\n\tpublic void testAddSpace() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/addSpace.kt\");\n\t}\n\n\t@Test\n\tpublic void testAnnotatedExpr() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/annotatedExpr.kt\");\n\t}\n\t\n    @Ignore\n    @Test\n    public void testImplicitlyNonUnitFun() {\n        doTest(\"testData/intentions/convertToBlockBody/implicitlyNonUnitFun.kt\");\n    }\n\n\t@Test\n\tpublic void testExplicitlyNonUnitFun() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/explicitlyNonUnitFun.kt\");\n\t}\n\n\t@Test\n\tpublic void testExplicitlyTypedFunWithUnresolvedExpression() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/explicitlyTypedFunWithUnresolvedExpression.kt\");\n\t}\n\n\t@Test\n\tpublic void testExplicitlyTypedFunWithUnresolvedType() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/explicitlyTypedFunWithUnresolvedType.kt\");\n\t}\n\n\t@Test\n\tpublic void testExplicitlyUnitFun() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/explicitlyUnitFun.kt\");\n\t}\n\n\t@Test\n\tpublic void testExplicitlyUnitFunWithUnresolvedExpression() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/explicitlyUnitFunWithUnresolvedExpression.kt\");\n\t}\n\n\t@Test\n\tpublic void testFunWithThrow() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/funWithThrow.kt\");\n\t}\n\n\t@Test\n\tpublic void testGetter() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/getter.kt\");\n\t}\n\n\t@Test\n\tpublic void testGetterWithThrow() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/getterWithThrow.kt\");\n\t}\n\n\t@Test\n\tpublic void testImplicitlyTypedFunWithUnresolvedType() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/implicitlyTypedFunWithUnresolvedType.kt\");\n\t}\n\n\t@Test\n\tpublic void testImplicitlyUnitFun() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/implicitlyUnitFun.kt\");\n\t}\n\n\t@Test\n\tpublic void testLabeledExpr() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/labeledExpr.kt\");\n\t}\n\n\t@Test\n\tpublic void testNothingFun() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/nothingFun.kt\");\n\t}\n\n\t@Test\n\tpublic void testSetter() {\n\t\tdoTest(\"common_testData/ide/intentions/convertToBlockBody/setter.kt\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinConvertToBlockBodyTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinConvertToBlockBodyAssistProposal;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\n\nimport kotlin.jvm.functions.Function1;\n\npublic class KotlinConvertToBlockBodyTestCase extends\n\t\tKotlinSpacesForTabsQuickAssistTestCase<KotlinConvertToBlockBodyAssistProposal> {\n\n\tprotected void doTest(String testPath) {\n\t\tdoTestFor(testPath, new Function1<KotlinEditor, KotlinQuickAssistProposal>() {\n            @Override\n            public KotlinQuickAssistProposal invoke(KotlinEditor editor) {\n                return new KotlinConvertToBlockBodyAssistProposal(editor);\n            }\n        });\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinConvertToExpressionBodyTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Test;\n\npublic class KotlinConvertToExpressionBodyTest extends\n\t\tKotlinConvertToExpressionBodyTestCase {\n\t\n    @Test\n    public void testAnonymousObjectExpression() {\n//        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/anonymousObjectExpression.kt\");\n        doTest(\"testData/intentions/convertToExpressionBody/anonymousObjectExpression.kt\");\n    }\n\n    @Test\n    public void testAssignment() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/assignment.kt\");\n    }\n\n    @Test\n    public void testDeclaration() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/declaration.kt\");\n    }\n\n    @Test\n    public void testExpressionWithReturns1() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/expressionWithReturns1.kt\");\n    }\n\n    @Test\n    public void testExpressionWithReturns2() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/expressionWithReturns2.kt\");\n    }\n\n    @Test\n    public void testFunctionLiteral() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/functionLiteral.kt\");\n    }\n\n    @Test\n    public void testFunWithImplicitUnitTypeWithThrow() {\n        doTest(\"testData/intentions/convertToExpressionBody/funWithImplicitUnitTypeWithThrow.kt\");\n    }\n\n    @Test\n    public void testFunWithNoBlock() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/funWithNoBlock.kt\");\n    }\n\n    @Test\n    public void testFunWithNothingType() {\n        doTest(\"testData/intentions/convertToExpressionBody/funWithNothingType.kt\");\n    }\n\n    @Test\n    public void testFunWithReturn() {\n        doTest(\"testData/intentions/convertToExpressionBody/funWithReturn.kt\");\n    }\n\n    @Test\n    public void testFunWithUnitType2() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/funWithUnitType2.kt\");\n    }\n\n    @Test\n    public void testFunWithUnitType() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/funWithUnitType.kt\");\n    }\n\n    @Test\n    public void testFunWithUnitTypeWithThrow() {\n        doTest(\"testData/intentions/convertToExpressionBody/funWithUnitTypeWithThrow.kt\");\n    }\n\n    @Test\n    public void testGetWithReturn() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/getWithReturn.kt\");\n    }\n\n    @Test\n    public void testMultipleStatements() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/multipleStatements.kt\");\n    }\n\n    @Test\n    public void testOverridePublicFun() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/overridePublicFun.kt\");\n    }\n\n    @Test\n    public void testReturnWithNoValue() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/returnWithNoValue.kt\");\n    }\n\n    @Test\n    public void testWhile() {\n        doTest(\"common_testData/ide/inspectionsLocal/useExpressionBody/convertToExpressionBody/while.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinConvertToExpressionBodyTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinConvertToExpressionBodyAssistProposal;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\n\nimport kotlin.jvm.functions.Function1;\n\npublic class KotlinConvertToExpressionBodyTestCase extends KotlinSpacesForTabsQuickAssistTestCase<KotlinConvertToExpressionBodyAssistProposal> {\n\tprotected void doTest(String testPath) {\n\t\tdoTestFor(testPath, new Function1<KotlinEditor, KotlinQuickAssistProposal>() {\n            @Override\n            public KotlinQuickAssistProposal invoke(KotlinEditor editor) {\n                return new KotlinConvertToExpressionBodyAssistProposal(editor);\n            }\n        });\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinImplementMethodsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinImplementMethodsTest extends KotlinImplementMethodsTestCase {\n\t@Test\n\tpublic void testDefaultValues() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/defaultValues.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testEmptyClassBodyFunctionMethod() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/emptyClassBodyFunctionMethod.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testFunctionMethod() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/functionMethod.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testFunctionProperty() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/functionProperty.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testFunctionWithTypeParameters() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/functionWithTypeParameters.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testGenericMethod() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/genericMethod.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testGenericTypesSeveralMethods() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/genericTypesSeveralMethods.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testLocalClass() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/localClass.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testOverrideExplicitFunction() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/overrideExplicitFunction.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testOverrideExtensionProperty() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/overrideExtensionProperty.kt\");\n\t}\n\t\n\t@Ignore\n\t@Test\n\tpublic void testOverrideMutableExtensionProperty() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/overrideMutableExtensionProperty.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testProperty() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/property.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testTraitGenericImplement() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/traitGenericImplement.kt\");\n\t}\n\t\n\t@Test\n\tpublic void testTraitNullableFunction() {\n\t\tdoTest(\"common_testData/ide/codeInsight/overrideImplement/traitNullableFunction.kt\");\n\t}\n\t\n\t@Ignore\n\t@Test\n    public void testImplementMethodInScript() {\n        doTest(\"testData/intentions/implementMethods/implementMethodInScript.kts\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinImplementMethodsTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinImplementMethodsProposal;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\n\nimport kotlin.jvm.functions.Function1;\n\npublic class KotlinImplementMethodsTestCase\n        extends KotlinSpacesForTabsQuickAssistTestCase<KotlinImplementMethodsProposal> {\n    protected void doTest(String testPath) {\n        String functionBody = \"TODO(\\\"not implemented\\\") //To change body of created functions use File | Settings | File Templates.\";\n        String propertyBody = \"TODO(\\\"not implemented\\\") //To change initializer of created properties use File | Settings | File Templates.\";\n        doTestFor(testPath, new Function1<KotlinEditor, KotlinQuickAssistProposal>() {\n            @Override\n            public KotlinQuickAssistProposal invoke(KotlinEditor editor) {\n                return new KotlinImplementMethodsProposal(editor, functionBody, propertyBody);\n            }\n        });\n    }\n    \n    @Override\n    protected void assertByEditor(JavaEditor editor, String expected) {\n        EditorTestUtils.assertByEditor(editor, removeCaretAndSelection(expected));\n    }\n    \n    public static String removeCaretAndSelection(String text) {\n        return text.replaceAll(\"<caret>\", \"\").replaceAll(\"<selection>\", \"\").replaceAll(\"</selection>\", \"\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinOverrideMembersTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions\n\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.overrideImplement.KotlinOverrideMembersAction\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.eclipse.jface.text.TextSelection\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants\nimport org.eclipse.ui.editors.text.EditorsUI\n\nopen class KotlinOverrideMembersTestCase : KotlinProjectTestCase() {\n    @Before\n    fun configure() {\n        configureProject()\n    }\n    \n    fun doTest(testPath: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        \n        val action = KotlinOverrideMembersAction(testEditor.getEditor() as KotlinFileEditor, true)\n        \n        action.run(TextSelection(testEditor.getDocument(), testEditor.getCaretOffset(), 0))\n        \n        val expected = KotlinTestUtils.getText(\"${testPath}.after\")\n        EditorTestUtils.assertByEditor(testEditor.getEditor(), \n                KotlinImplementMethodsTestCase.removeCaretAndSelection(expected))\n    }\n    \n    private fun assertByEditor() {\n        \n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinOverrideMethodsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Test;\n\npublic class KotlinOverrideMethodsTest extends KotlinOverrideMembersTestCase {\n    @Test\n    public void testEscapeIdentifiers() {\n        doTest(\"common_testData/ide/codeInsight/overrideImplement/escapeIdentifiers.kt\");\n    }\n    \n    @Test\n    public void testOverrideNonUnitFunction() {\n        doTest(\"common_testData/ide/codeInsight/overrideImplement/overrideNonUnitFunction.kt\");\n    }\n    \n    @Test\n    public void testOverrideUnitFunction() {\n        doTest(\"common_testData/ide/codeInsight/overrideImplement/overrideUnitFunction.kt\");\n    }\n    \n    @Test\n    public void testVarArgs() {\n        doTest(\"common_testData/ide/codeInsight/overrideImplement/varArgs.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinRemoveExplicitTypeTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Test;\n\npublic class KotlinRemoveExplicitTypeTest extends KotlinRemoveExplicitTypeTestCase {\n    @Test\n    public void testNotOnParameterOfFunctionType() {\n        doTest(\"common_testData/ide/intentions/removeExplicitType/notOnParameterOfFunctionType.kt\");\n    }\n    \n    @Test\n    public void testOnOverride() {\n        doTest(\"common_testData/ide/intentions/removeExplicitType/onOverride.kt\");\n    }\n    \n    @Test\n    public void testOnOverrideInTrait() {\n        doTest(\"common_testData/ide/intentions/removeExplicitType/onOverrideInTrait.kt\");\n    }\n    \n    @Test\n    public void testOnType() {\n        doTest(\"common_testData/ide/intentions/removeExplicitType/onType.kt\");\n    }\n    \n    @Test\n    public void testRemoveUnresolvedType() {\n        doTest(\"common_testData/ide/intentions/removeExplicitType/removeUnresolvedType.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinRemoveExplicitTypeTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions\n\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinRemoveExplicitTypeAssistProposal\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\n\n@Suppress(\"UPPER_BOUND_VIOLATED\")\nabstract class KotlinRemoveExplicitTypeTestCase : AbstractKotlinQuickAssistTestCase<KotlinRemoveExplicitTypeAssistProposal>() {\n    fun doTest(testPath: String) {\n\t\t@Suppress(\"TYPE_MISMATCH\", \"MISSING_DEPENDENCY_CLASS\")\n        doTestFor(testPath) { KotlinRemoveExplicitTypeAssistProposal(it) }\n    }\n    \n    override fun assertByEditor(editor: JavaEditor, expected: String) {\n        EditorTestUtils.assertByEditor(editor, expected)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinReplaceGetIntentionTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n            \npublic class KotlinReplaceGetIntentionTest extends KotlinReplaceGetIntentionTestCase {\n    \n    private static final String PATH_PREFIX = \"common_testData/ide/inspectionsLocal/conventionNameCalls/replaceGetOrSet\";\n    \n\t@Test\n\tpublic void testAcceptableVararg() {\n\t\tdoTest(PATH_PREFIX + \"/acceptableVararg.kt\");\n\t}\n\n\t@Test\n    public void testArgumentAndFunction() throws Exception {\n        doTest(PATH_PREFIX + \"/argumentAndFunction.kt\");\n    }\n    \n\t@Test\n    public void testDuplicateArguments() throws Exception {\n        doTest(PATH_PREFIX + \"/duplicateArguments.kt\");\n    }\n    \n\t@Test\n    public void testExtensionFunction() throws Exception {\n        doTest(PATH_PREFIX + \"/extensionFunction.kt\");\n    }\n    \n\t@Test\n    public void testFunctionalArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/functionalArgument.kt\");\n    }\n    \n\t@Test\n    public void testInvalidArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/invalidArgument.kt\");\n    }\n    \n\t@Test\n    public void testMissingDefaultArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/missingDefaultArgument.kt\");\n    }\n    \n\t@Test\n    public void testMultiArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/multiArgument.kt\");\n    }\n    \n\t@Test\n    public void testNoArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/noArgument.kt\");\n    }\n\t\n\t@Test\n    public void testQualifier() throws Exception {\n        doTest(PATH_PREFIX + \"/qualifier.kt\");\n    }\n    \n\t@Test\n    public void testSanityCheck() throws Exception {\n        doTest(PATH_PREFIX + \"/sanityCheck.kt\");\n    }\n    \n\t@Test\n    public void testSingleArgument() throws Exception {\n        doTest(PATH_PREFIX + \"/singleArgument.kt\");\n    }\n    \n\t@Test\n    public void testSuper() throws Exception {\n        doTest(PATH_PREFIX + \"/super.kt\");\n    }\n\t\n\t@Test\n    public void testTopLevelFun() throws Exception {\n        doTest(PATH_PREFIX + \"/topLevelFun.kt\");\n    }\n    \n\t@Test\n    public void testUnacceptableVararg() throws Exception {\n        doTest(PATH_PREFIX + \"/unacceptableVararg.kt\");\n    }\n    \n\t@Test\n    public void testUnnamedAndNamed() throws Exception {\n        doTest(PATH_PREFIX + \"/unnamedAndNamed.kt\");\n    }\n\t\n\t@Ignore(\"Script support will be fixed in future releases\")\n\t@Test\n    public void testReplaceGetInScript() throws Exception {\n        doTest(\"testData/intentions/replaceGetOrSet/replaceGetInScript.kts\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinReplaceGetIntentionTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinReplaceGetAssistProposal;\n\nimport kotlin.jvm.functions.Function1;\n\npublic abstract class KotlinReplaceGetIntentionTestCase extends AbstractKotlinQuickAssistTestCase<KotlinReplaceGetAssistProposal> {\n\tprotected void doTest(String testPath) {\n\t\tdoTestFor(testPath, new Function1<KotlinEditor, KotlinQuickAssistProposal>() {\n            @Override\n            public KotlinQuickAssistProposal invoke(KotlinEditor editor) {\n                return new KotlinReplaceGetAssistProposal(editor);\n            }\n        });\t\n\t}\n\t\n\t@Override\n\tprotected void assertByEditor(JavaEditor editor, String expected) {\n\t\tEditorTestUtils.assertByEditor(editor, expected);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinSpacesForTabsQuickAssistTestCase.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.ui.editors.text.EditorsUI;\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\n\npublic class KotlinSpacesForTabsQuickAssistTestCase<Proposal extends KotlinQuickAssistProposal> extends\n\t\tAbstractKotlinQuickAssistTestCase<Proposal> {\n\tprivate boolean isSpacesForTab;\n\tprivate int initialSpacesCount;\n\t\n\t@Override\n\tprotected void assertByEditor(JavaEditor editor, String expected) {\n\t\tEditorTestUtils.assertByEditor(editor, expected);\n\t}\n\t\n\t@Override\n\tpublic void configure() {\n\t\tsuper.configure();\n\t\t\n\t\tisSpacesForTab = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);\n\t\tinitialSpacesCount = EditorsUI.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);\n\t\tEditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);\n\t\tEditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);\n\t}\n\n\t@Override\n\tpublic void afterTest() {\n\t\tsuper.afterTest();\n\t\tEditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, isSpacesForTab);\n\t\tEditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, initialSpacesCount);\n\t}\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinSpecifyTypeTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.junit.Test;\n\npublic class KotlinSpecifyTypeTest extends KotlinSpecifyTypeTestCase {\n    \n    @Test\n    public void testBadCaretPosition() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/badCaretPosition.kt\");\n    }\n    \n    @Test\n    public void testClassNameClashing() {\n        doTest(\"testData/intentions/specifyType/ClassNameClashing.kt\");\n    }\n    \n    @Test\n    public void testConstructor() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/constructor.kt\");\n    }\n    \n    @Test\n    public void testEnumType() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/enumType.kt\");\n    }\n    \n    @Test\n    public void testFunctionType() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/functionType.kt\");\n    }\n    \n    @Test\n    public void testLambdaParam() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/lambdaParam.kt\");\n    }\n    \n    @Test\n    public void testLoopParameter() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/loopParameter.kt\");\n    }\n    \n    @Test\n    public void testPublicMember() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/publicMember.kt\");\n    }\n    \n    @Test\n    public void testStringRedefined() {\n        doTest(\"testData/intentions/specifyType/StringRedefined.kt\");\n    }\n    \n    @Test\n    public void testTypeAlreadyProvided() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/typeAlreadyProvided.kt\");\n    }\n    \n    @Test\n    public void testUnitType() {\n        doTest(\"common_testData/ide/intentions/specifyTypeExplicitly/unitType.kt\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/quickfix/intentions/KotlinSpecifyTypeTestCase.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2014 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.editors.quickfix.intentions;\n\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinQuickAssistProposal;\nimport org.jetbrains.kotlin.ui.editors.quickassist.KotlinSpecifyTypeAssistProposal;\nimport org.junit.Before;\n\nimport kotlin.jvm.functions.Function1;\n\npublic abstract class KotlinSpecifyTypeTestCase extends AbstractKotlinQuickAssistTestCase<KotlinSpecifyTypeAssistProposal> {\n    private static final Function1<KotlinEditor, KotlinQuickAssistProposal> createProposal = \n            new Function1<KotlinEditor, KotlinQuickAssistProposal>() {\n                @Override\n                public KotlinQuickAssistProposal invoke(KotlinEditor editor) {\n                    return new KotlinSpecifyTypeAssistProposal(editor);\n                }\n            };\n    \n    @Override\n    @Before\n    public void configure() {\n        configureProjectWithStdLib();\n    }\n    \n\tprotected void doTest(String testPath) {\n\t\tdoTestFor(testPath, createProposal);\n\t}\n\t\n\tprotected void doTestWithBuildThreadJoin(String testPath) {\n\t\tdoTestFor(testPath, createProposal, true);\n\t}\n\t\n\t@Override\n\tprotected void assertByEditor(JavaEditor editor, String expected) {\n\t\tEditorTestUtils.assertByEditor(editor, expected);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinCommonSelectionTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection\n\nimport java.io.File;\nimport java.util.ArrayList;\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorSequentialAutoTestCase;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorAutoTestCase;\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorTestCase;\nimport org.junit.Before\n\npublic abstract class KotlinCommonSelectionTestCase: KotlinEditorSequentialAutoTestCase() {\n\tprivate val INITIAL_FILE_NAME = \"0.kt\";\n\tprotected val COMMON_DIR: String = \"wordSelection\"\n\tabstract protected val RELATIVE_DIR: String\n    \n    @Before\n    fun before() {\n        configureProject()\n    }\n\n\toverride fun getInitialFileName() = INITIAL_FILE_NAME\n\t\n\toverride fun getAfterFilesPaths(testFolder: File): ArrayList<String> {\n\t\tval afterFileContents = ArrayList<String>() \n\t\t\n\t\tvar fileIndex = 1\n\t\t\n\t\twhile (true) {\n\t\t\tval filePath = \"${testFolder.getAbsolutePath()}${File.separator}${fileIndex}.kt\"\n\t\t\tval afterFile = File(filePath)\n\t\t\tif (!afterFile.exists()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tafterFileContents.add(filePath)\n\t\t\tfileIndex++\n\t\t}\n\t\t\t\t\n\t\treturn afterFileContents;\n\t}\n\t\n\toverride fun getAfterFileContent(afterFilePath: String): String {\n\t\treturn KotlinEditorTestCase.getText(afterFilePath).replace(KotlinEditorTestCase.CARET_TAG.toRegex(), \"\")\n\t}\n\n\toverride fun getTestDataRelativePath() = COMMON_DIR + File.separator + RELATIVE_DIR\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectEnclosingTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection;\n\nimport org.junit.Test;\n\npublic class KotlinSelectEnclosingTest extends KotlinSelectEnclosingTestCase {\n\t\n\t@Test\n\tpublic void selectEnclosingFunctionNameWithoutSelection() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void DocComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ForRange() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void FunctionWithLineCommentAfter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void FunctionWithLineCommentBefore() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void IfBody() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void IfCondition() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void LineComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ShiftOnWhitespace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void SimpleComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void SimpleStringLiteral() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void SimpleStringLiteral2() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void Statements() {\n\t\tdoAutoTest();\n\t}\n\t\t\n\t@Test\n\tpublic void StatementsWithWindowsDelimiter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void TemplateStringLiteral1() {\n\t\tdoAutoTest();\n\t}\t\n\t\n\t@Test\n\tpublic void TemplateStringLiteral2() {\n\t\tdoAutoTest();\n\t}\t\n\t\n\t@Test\n\tpublic void TemplateStringLiteral3() {\n\t\tdoAutoTest();\n\t}\t\n\t\n\t@Test\n\tpublic void TypeArguments() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void TypeParameters() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ValueArguments() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ValueParameters() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void WhenEntries() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void WholeFileSelection() {\n\t\tdoAutoTest();\n\t}\t\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectEnclosingTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection\n\npublic abstract class KotlinSelectEnclosingTestCase: KotlinCommonSelectionTestCase() {\n\toverride val RELATIVE_DIR = \"selectEnclosing\"\n\toverride fun performSingleOperation() = testEditor.runSelectEnclosingAction()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectNextTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection;\r\n\r\nimport org.junit.Test;\r\n\r\npublic class KotlinSelectNextTest extends KotlinSelectNextTestCase {\r\n\t@Test\r\n\tpublic void BlockStatements() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void BlockStatementsWithWindowsDelimiter() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void Classes() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void DocComment() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void Functions() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void FunctionWithLineComments() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void Imports() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void NonTraversableElement() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void ShiftOnWhitespace() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void TemplateStringLiteral() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void TypeArguments() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void TypeParameters() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void ValueArguments() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void ValueParameters() {\r\n\t\tdoAutoTest();\r\n\t}\r\n\t\r\n\t@Test\r\n\tpublic void WholeFile() {\r\n\t\tdoAutoTest();\r\n\t}\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectNextTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection\n\npublic abstract class KotlinSelectNextTestCase: KotlinCommonSelectionTestCase() {\n\toverride val RELATIVE_DIR = \"selectNext\"\n\toverride fun performSingleOperation() = testEditor.runSelectNextAction()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectPreviousTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection;\n\nimport org.junit.Test;\n\npublic class KotlinSelectPreviousTest extends KotlinSelectPreviousTestCase {\n\t@Test\n\tpublic void BlockStatements() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void BlockStatementsWithWindowsDelimiter() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void Classes() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void DocComment() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void Functions() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void FunctionWithLineComments() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void Imports() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void NonTraversableElement() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ShiftOnWhitespace() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void TemplateStringLiteral() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void TypeArguments() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void TypeParameters() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ValueArguments() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void ValueParameters() {\n\t\tdoAutoTest();\n\t}\n\t\n\t@Test\n\tpublic void WholeFile() {\n\t\tdoAutoTest();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/editors/selection/KotlinSelectPreviousTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.editors.selection\n\npublic abstract class KotlinSelectPreviousTestCase: KotlinCommonSelectionTestCase() {\n\toverride val RELATIVE_DIR = \"selectPrevious\"\n\toverride fun performSingleOperation() = testEditor.runSelectPreviousAction()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/convert/JavaToKotlinEncodingBugTest.java",
    "content": "/*******************************************************************************\n * Copyright 2000-2017 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *******************************************************************************/\npackage org.jetbrains.kotlin.ui.tests.refactoring.convert;\n\nimport java.nio.charset.Charset;\nimport java.util.Collections;\n\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.expressions.EvaluationContext;\nimport org.eclipse.core.resources.IFile;\nimport org.eclipse.jdt.core.ICompilationUnit;\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.ui.ISources;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PlatformUI;\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase;\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils;\nimport org.jetbrains.kotlin.testframework.utils.TestJavaProject;\nimport org.jetbrains.kotlin.ui.commands.j2k.JavaToKotlinActionHandler;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n@Ignore\npublic class JavaToKotlinEncodingBugTest extends KotlinProjectTestCase {\n\n    private static final String CHARSET_UTF8 = \"UTF-8\";\n    private static final String CHARSET_WINDOWS1251 = \"Windows-1251\";\n    private static final String SOURCE_FILE_NAME = \"Test.java\";\n    private static final String PROBLEMATIC_TEXT =\n        \"/**\\n\" +\n        \" * FIXME: \\u0422\\u0435\\u0441\\u0442\\n\" + // \"Test\" in Russian.\n        \" */\\n\";\n    private static final String SOURCE_FILE_CONTENT =\n        PROBLEMATIC_TEXT +\n        \"public class Test {\\n\" +\n        \"\\n\" +\n        \"  public static void main(String... args) {\\n\" +\n        \"    System.out.println(\\\"Test\\\");\\n\" +\n        \"  }\\n\" +\n        \"\\n\" +\n        \"}\\n\";\n    private static final String EXPECTED_FILE_CONTENT =\n        PROBLEMATIC_TEXT +\n        \"object Test {\\n\" +\n        \"    fun main(vararg args: String) {\\n\" +\n        \"        System.out.println(\\\"Test\\\")\\n\" +\n        \"    }\\n\" +\n        \"}\";\n\n    public void testJavaToKotlinConversion(String projectDefaultEncoding, String sourceFileEncoding, String source, String expected) throws Exception {\n        TestJavaProject project = getTestProject();\n        project.getJavaProject().getProject().setDefaultCharset(projectDefaultEncoding, null);\n\n        IFile sourceFile = project.createSourceFile(\"\", SOURCE_FILE_NAME, source, Charset.forName(sourceFileEncoding));\n\n        EvaluationContext context = new EvaluationContext(null, new Object());\n        ICompilationUnit sourceCompilaitonUnit = JavaCore.createCompilationUnitFrom(sourceFile);\n        context.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, new StructuredSelection(sourceCompilaitonUnit));\n        ExecutionEvent event = new ExecutionEvent(null, Collections.emptyMap(), null, context);\n        JavaToKotlinActionHandler handler = new JavaToKotlinActionHandler();\n        handler.execute(event);\n\n        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n        JavaEditor activeEditor = (JavaEditor) workbenchWindow.getActivePage().getActiveEditor();\n        EditorTestUtils.assertByEditor(activeEditor, expected);\n    }\n\n    @Before\n    public void before() {\n        configureProjectWithStdLib();\n    }\n\n    @Test\n    public void test_UTF8_UTF8() throws Exception {\n        testJavaToKotlinConversion(CHARSET_UTF8, CHARSET_UTF8, SOURCE_FILE_CONTENT, EXPECTED_FILE_CONTENT);\n    }\n\n    @Test\n    public void test_UTF8_WIN1251() throws Exception {\n        testJavaToKotlinConversion(CHARSET_UTF8, CHARSET_WINDOWS1251, SOURCE_FILE_CONTENT, EXPECTED_FILE_CONTENT);\n    }\n\n    @Test\n    public void test_WIN1251_UTF8() throws Exception {\n        testJavaToKotlinConversion(CHARSET_WINDOWS1251, CHARSET_UTF8, SOURCE_FILE_CONTENT, EXPECTED_FILE_CONTENT);\n    }\n\n    @Test\n    public void test_WIN1251_WIN1251() throws Exception {\n        testJavaToKotlinConversion(CHARSET_WINDOWS1251, CHARSET_WINDOWS1251, SOURCE_FILE_CONTENT, EXPECTED_FILE_CONTENT);\n    }\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/extract/KotlinExtractVariableTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.extract;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinExtractVariableTest extends KotlinExtractVariableTestCase {\n    @Test\n    public void testIfCondition() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IfCondition.kt\", \"b\");\n    }\n    \n    @Test\n    public void testArrayAccess() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ArrayAccessExpr.kt\");\n    }\n    \n    @Test\n    public void testCallUnderSmartCast() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/callUnderSmartCast.kt\", \"foo\");\n    }\n    \n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testComplexCallee() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ComplexCallee.kt\", \"function\");\n    }\n    \n    @Test\n    public void testDelegatorByExpressionInDelegate() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/DelegatorByExpressionInDelegate.kt\", \"o\");\n    }\n    \n    @Test\n    public void testDelegatorToSuperCallInArgument() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/DelegatorToSuperCallInArgument.kt\", \"n\");\n    }\n    \n    @Test\n    public void testDoWhileAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/DoWhileAddBlock.kt\");\n    }\n    \n    @Test\n    public void testDoWhileAddBlockInner() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/DoWhileAddBlockInner.kt\");\n    }\n    \n    @Test\n    public void testFewOccurrences() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/FewOccurrences.kt\");\n    }\n\n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testFunctionAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/FunctionAddBlock.kt\");\n    }\n\n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testFunctionAddBlockInner() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/FunctionAddBlockInner.kt\");\n    }\n    \n    @Test\n    public void testIfElseAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IfElseAddBlock.kt\");\n    }\n    \n    @Test\n    public void testIfThenAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IfCondition.kt\", \"b\");\n    }\n    \n    @Test\n    public void testIfThenAddBlockInner() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IfThenAddBlockInner.kt\");\n    }\n    \n    @Test\n    public void testIfThenValuedAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IfThenValuedAddBlock.kt\");\n    }\n    \n    @Test\n    public void testIntroduceAndCreateBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/IntroduceAndCreateBlock.kt\");\n    }\n    \n    @Test\n    public void testManyInnerOccurences() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ManyInnerOccurences.kt\");\n    }\n    \n    @Test\n    public void testManyOccurrences() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ManyOccurrences.kt\");\n    }\n    \n    @Test\n    public void testNoNewLinesInBetween() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/NoNewLinesInBetween.kt\", \"bar\");\n    }\n    \n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testNoNewLinesInBetweenNoBraces() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/NoNewLinesInBetweenNoBraces.kt\", \"bar\");\n    }\n    \n    @Test\n    public void testNotNullAssertion() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/notNullAssertion.kt\", \"length\");\n    }\n    \n    @Test\n    public void testOccurrencesInStringTemplate() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/OccurrencesInStringTemplate.kt\");\n    }\n    \n    @Test\n    public void testOneExplicitReceiver() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/OneExplicitReceiver.kt\", \"prop\");\n    }\n    \n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testPropertyAccessorAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/PropertyAccessorAddBlock.kt\");\n    }\n    \n    @Ignore(\"Ignore because of formatter issues\")\n    @Test\n    public void testPropertyAccessorAddBlockInner() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/PropertyAccessorAddBlockInner.kt\");\n    }\n    \n    @Test\n    public void testReplaceOccurence() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ReplaceOccurence.kt\", \"x\");\n    }\n    \n    @Test\n    public void testSimple() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/Simple.kt\");\n    }\n    \n    @Test\n    public void testSimpleCreateValue() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/SimpleCreateValue.kt\");\n    }\n    \n    @Test\n    public void testLoopRange() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/LoopRange.kt\", \"intRange\");\n    }\n    \n    @Test\n    public void testThisReference() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/ThisReference.kt\", \"a\");\n    }\n    \n    @Test\n    public void testTwoExplicitReceivers() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/TwoExplicitReceivers.kt\", \"f1\");\n    }\n    \n    @Test\n    public void testWhenAddBlock() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/WhenAddBlock.kt\");\n    }\n    \n    @Test\n    public void testWhenAddBlockInner() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/WhenAddBlockInner.kt\");\n    }\n    \n    @Test\n    public void testWhileCondition() {\n        doTest(\"common_testData/ide/refactoring/introduceVariable/WhileCondition.kt\", \"b\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/extract/KotlinExtractVariableTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.extract\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinEditorWithAfterFileTestCase\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.refactorings.extract.KotlinExtractVariableAction\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.jetbrains.kotlin.ui.refactorings.extract.KotlinExtractVariableRefactoring\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport com.intellij.openapi.util.io.FileUtil\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\n\npublic abstract class KotlinExtractVariableTestCase : KotlinProjectTestCase() {\n    @Before\n    fun before() {\n        configureProject()\n    }\n    \n    @JvmOverloads\n    fun doTest(testPath: String, newName: String = \"i\") {\n        val fileText = KotlinTestUtils.getText(testPath)\n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        val editor = testEditor.getEditor() as KotlinFileEditor\n        \n        val refactoring = KotlinExtractVariableRefactoring(editor.getSelectionProvider().getSelection() as ITextSelection, editor)\n        val monitor = NullProgressMonitor()\n        \n        refactoring.checkInitialConditions(monitor)\n        refactoring.newName = newName\n        refactoring.createChange(monitor).perform(monitor)\n        \n        EditorTestUtils.assertByEditor(editor, KotlinTestUtils.getText(\"${testPath}.after\"))\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/rename/KotlinLocalRenameTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.rename;\n\nimport org.junit.Test;\n\npublic class KotlinLocalRenameTest extends KotlinLocalRenameTestCase {\n    @Test\n    public void testForLoop() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/ForLoop.kt\", \"j\");\n    }\n    \n    @Test\n    public void testFunctionLiteral() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/FunctionLiteral.kt\", \"y\");\n    }\n    \n    @Test\n    public void testFunctionLiteralParenthesis() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/FunctionLiteralParenthesis.kt\", \"y\");\n    }\n    \n    @Test\n    public void testLocalFunction() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/LocalFunction.kt\", \"bar\");\n    }\n    \n    @Test\n    public void testMultiDeclaration() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/MultiDeclaration.kt\", \"foo\");\n    }\n    \n    @Test\n    public void testTryCatch() {\n        doTest(\"common_testData/ide/refactoring/rename/inplace/TryCatch.kt\", \"e1\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/rename/KotlinLocalRenameTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.rename\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.Before\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.ui.editors.KotlinFileEditor\nimport org.jetbrains.kotlin.ui.refactorings.rename.doRename\nimport org.jetbrains.kotlin.testframework.utils.EditorTestUtils\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\n\nabstract class KotlinLocalRenameTestCase : KotlinProjectTestCase() {\n    @Before\n    fun before() {\n        configureProjectWithStdLib()\n    }\n    \n    protected fun doTest(testPath: String, newName: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        \n        val jetElement = EditorUtil.getJetElement(testEditor.getEditor() as KotlinFileEditor, \n                KotlinTestUtils.getCaret(testEditor.getEditor()))!!\n        val sourceElements = jetElement.resolveToSourceDeclaration()\n        doRename(sourceElements, newName, testEditor.getEditor() as KotlinFileEditor)\n        \n        val expected = KotlinTestUtils.getText(\"${testPath}.after\")\n        \n        EditorTestUtils.assertByEditor(testEditor.getEditor(), expected)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/rename/KotlinRenameTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.rename;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\npublic class KotlinRenameTest extends KotlinRenameTestCase {\n    \n    @Ignore\n    @Test\n    public void testSimple() {\n        doTest(\"testData/refactoring/rename/simple/info.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testAutomaticRenamer() {\n        doTest(\"testData/refactoring/rename/automaticRenamer/simple.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameJavaClass() {\n        doTest(\"testData/refactoring/rename/renameJavaClass/renameJavaClass.test\");\n    }\n    \n    @Test\n    public void testRenameJavaClassSamePackage() {\n        doTest(\"testData/refactoring/rename/renameJavaClassSamePackage/renameJavaClassSamePackage.test\");\n    }\n    \n    @Test\n    public void testRenameJavaInterface() {\n        doTest(\"testData/refactoring/rename/renameJavaInterface/renameJavaInterface.test\");\n    }\n    \n    @Ignore(\"Temporary disable as a bug\")\n    @Test\n    public void testRenameJavaKotlinOverridenMethod() {\n        doTest(\"testData/refactoring/rename/renameJavaMethod/kotlinOverridenMethod.test\");\n    }\n\n    @Ignore\n    @Test\n    public void testRenameKotlinClass() {\n        doTest(\"testData/refactoring/rename/renameKotlinClass/kotlinClass.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinMethod() {\n        doTest(\"testData/refactoring/rename/renameKotlinMethod/renameKotlinMethod.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinTopLevelFun() {\n        doTest(\"testData/refactoring/rename/renameKotlinTopLevelFun/renameKotlinTopLevelFun.test\");\n    }\n    \n    @Test\n    public void testRenameJavaStaticMethod() {\n        doTest(\"testData/refactoring/rename/renameJavaStaticMethod/renameJavaStaticMethod.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinClassByConstructorReference() {\n        doTest(\"testData/refactoring/rename/renameKotlinClassByConstructorRef/renameKotlinClassByConstructorRef.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinClassFromJava() {\n        doTest(\"testData/refactoring/rename/renameKotlinClassFromJava/renameKotlinClassFromJava.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinMethodFromJava() {\n        doTest(\"testData/refactoring/rename/renameKotlinMethodFromJava/renameKotlinMethodFromJava.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameKotlinTopLevelFunFromJava() {\n        doTest(\"testData/refactoring/rename/renameKotlinTopLevelFunFromJava/renameKotlinTopLevelFunFromJava.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameClassInScript() {\n        doTest(\"testData/refactoring/rename/scripts/renameClassInScript/info.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenameFunctionInScript() {\n        doTest(\"testData/refactoring/rename/scripts/renameFunctionInScript/info.test\");\n    }\n    \n    @Ignore\n    @Test\n    public void testRenamePropertyInScript() {\n        doTest(\"testData/refactoring/rename/scripts/renamePropertyInScript/info.test\");\n    }\n    \n    @Test\n    public void testRenameInScriptLocally() {\n        doTest(\"testData/refactoring/rename/scripts/renameInScriptLocally/info.test\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/refactoring/rename/KotlinRenameTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.refactoring.rename\n\nimport com.google.gson.JsonObject\nimport com.google.gson.JsonParser\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.IPath\nimport org.eclipse.core.runtime.Path\nimport org.eclipse.jdt.core.ICompilationUnit\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.eclipse.jface.text.ITextSelection\nimport org.eclipse.jface.text.TextSelection\nimport org.eclipse.ui.IEditorPart\nimport org.eclipse.ui.PlatformUI\nimport org.eclipse.ui.ide.IDE\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.core.references.resolveToSourceDeclaration\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinCommonEditor\nimport org.jetbrains.kotlin.ui.refactorings.rename.createRenameSupport\nimport org.jetbrains.kotlin.ui.refactorings.rename.doRename\nimport org.junit.Assert\nimport org.junit.Before\nimport java.io.File\n\nabstract class KotlinRenameTestCase : KotlinProjectTestCase() {\n    @Before\n    fun before() {\n        configureProjectWithStdLib()\n    }\n    \n    protected fun doTest(testInfo: String) {\n        val fileInfoText = KotlinTestUtils.getText(testInfo)\n        val jsonParser = JsonParser()\n        \n        val renameObject = jsonParser.parse(fileInfoText) as JsonObject\n        \n        val rootFolder = Path(testInfo).removeLastSegments(1)\n        val beforeSourceFolder = rootFolder.append(\"before\")\n        val loadedFiles = arrayListOf<IFile>()\n        loadFiles(beforeSourceFolder.toFile()) { loadedFiles.add(it) }\n        \n        KotlinTestUtils.joinBuildThread()\n        reconcileJavaFiles(beforeSourceFolder.toFile(), beforeSourceFolder)\n        KotlinTestUtils.joinBuildThread()\n        \n        val editor = openMainFile(renameObject, loadedFiles)\n        \n        val selection = findSelectionToRename(renameObject, editor)\n        Assert.assertTrue(\"Element to rename was not found\", selection.getOffset() > 0)\n        \n        val newName = renameObject[\"newName\"].asString\n        when (editor) {\n            is KotlinCommonEditor -> performRename(selection, newName, editor)\n            else -> performRenameFromJava(selection, newName, editor as JavaEditor)\n        }\n        \n        val base = rootFolder.append(\"after\")\n        checkResult(base.toFile(), base)\n    }\n    \n    fun performRename(selection: ITextSelection, newName: String, editor: KotlinCommonEditor) {\n        val selectedElement = EditorUtil.getJetElement(editor, selection.getOffset())\n        if (selectedElement == null) return\n        \n        val sourceDeclaration = selectedElement.resolveToSourceDeclaration()\n        doRename(sourceDeclaration, newName, editor)\n    }\n    \n    fun performRenameFromJava(selection: ITextSelection, newName: String, editor: JavaEditor) {\n        val root = EditorUtility.getEditorInputJavaElement(editor, false) as ICompilationUnit\n        val javaElement = root.codeSelect(selection.getOffset(), 0)[0]\n        \n        val renameSupport = createRenameSupport(javaElement, newName)\n        renameSupport.perform(editor.getSite().getShell(), editor.getSite().getWorkbenchWindow())\n    }\n    \n    private fun checkResult(sourceFolderAfter: File, base: IPath) {\n        val actualFiles = KotlinPsiManager.getFilesByProject(getTestProject().getJavaProject().getProject())\n        for (expectedFile in sourceFolderAfter.listFiles()) {\n            if (expectedFile.isFile()) {\n                val expectedSource = KotlinTestUtils.getText(expectedFile.getAbsolutePath())\n                val actualSource = if (expectedFile.extension == \"kt\") {\n                    val actualFile = actualFiles.find { it.getName() == expectedFile.getName() }!!\n                    EditorUtil.getDocument(actualFile).get()\n                } else if (expectedFile.extension == \"kts\") {\n                    val actualFile = getTestProject().getJavaProject().getProject().findMember(\"src/${expectedFile.getName()}\")\n                    EditorUtil.getDocument(actualFile as IFile).get()\n                } else {\n                    val relative = Path(expectedFile.getPath()).makeRelativeTo(base)\n                    val element = getTestProject().getJavaProject().findElement(relative)\n                    EditorUtil.getDocument(element.getResource() as IFile).get()\n                }\n                \n                Assert.assertEquals(\"Expected and actual files for ${expectedFile.getName()} are not equals\", expectedSource, actualSource)\n            } else if (expectedFile.isDirectory()) {\n                checkResult(expectedFile, base)\n            }\n        }\n    }\n    \n    private fun findSelectionToRename(renameObject: JsonObject, editor: IEditorPart): TextSelection {\n        val document = (editor as JavaEditor).getDocumentProvider().getDocument(editor.getEditorInput())\n        val position = document.get().indexOf(renameObject[\"oldName\"].asString) + 1\n        return TextSelection(document, position, 0)\n    }\n    \n    private fun openMainFile(renameObject: JsonObject, loadedFiles: List<IFile>): IEditorPart {\n        val mainFile = loadedFiles.find { \n            it.getName() == renameObject[\"mainFile\"].asString\n        }\n        val page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()\n        return IDE.openEditor(page, mainFile, false)\n    }\n    \n    private fun reconcileJavaFiles(sourceFolder: File, base: IPath) {\n        sourceFolder.listFiles().forEach { \n            when {\n                it.isFile -> {\n                    val relative = Path(it.getPath()).makeRelativeTo(base)\n                    val element = getTestProject().getJavaProject().findElement(relative)\n                    if (element is ICompilationUnit) {\n                        element.becomeWorkingCopy(null)\n                        element.reconcile(ICompilationUnit.NO_AST, true, null, null)\n                        element.commitWorkingCopy(true, null)\n                        element.discardWorkingCopy()\n                    }\n                }\n                \n                it.isDirectory -> reconcileJavaFiles(it, base)\n            }\n        }\n    }\n    \n    private fun loadFiles(sourceRoot: File, action: (IFile) -> Unit) {\n        for (file in sourceRoot.listFiles()) {\n            if (file.isFile()) {\n                val fileContent = KotlinTestUtils.getText(file.getAbsolutePath())\n                action(createSourceFile(file.getName(), fileContent))\n            } else if (file.isDirectory()) {\n                loadFiles(file, action)\n            }\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/completion/CompletionInScriptsTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.completion;\n\nimport org.jetbrains.kotlin.ui.tests.editors.completion.KotlinBasicCompletionTestCase;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n\n@Ignore(\"Script support will be fixed in future releases\")\npublic class CompletionInScriptsTest extends KotlinBasicCompletionTestCase {\n    @Test\n    public void testArgsCompletion() {\n        doTest(\"testData/completion/basic/scripts/argsCompletion.kts\");\n    }\n    \n    @Test\n    public void testFunctionFromStdlib() {\n        doTest(\"testData/completion/basic/scripts/functionFromStdlib.kts\");\n    }\n    \n    @Test\n    public void testTypeFromRuntime() {\n        doTest(\"testData/completion/basic/scripts/typeFromRuntime.kts\");\n    }\n    \n    @Test\n    public void testAbsentMainTemplate() {\n        doTest(\"testData/completion/basic/scripts/absentMainTemplate.kts\");\n    }\n    \n    @Test\n    public void testKeywordsCompletion() {\n        doTest(\"testData/completion/basic/scripts/keywordsCompletion.kts\");\n    }\n    \n    @Test\n    public void testLocalDeclarations() {\n        doTest(\"testData/completion/basic/scripts/localDeclarations.kts\");\n    }\n    \n    @Test\n    public void testClassFromJRE() {\n        doTest(\"testData/completion/basic/scripts/classFromJRE.kts\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/navigation/BasicNavigationInScripts.java",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.navigation;\n\nimport org.jetbrains.kotlin.ui.tests.editors.navigation.KotlinNavigationTestCase;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n@Ignore(\"Script support will be fixed in future releases\")\npublic class BasicNavigationInScripts extends KotlinNavigationTestCase {\n    @Before\n    public void before() {\n        configureProjectWithStdLib();\n    }\n    \n    @Override\n    protected String getTestDataRelativePath() {\n        return \"navigation/scripts/basic\";\n    }\n    \n    @Test\n    public void toFunction() {\n        doAutoTest();\n    }\n    \n    @Test\n    public void toVariable() {\n        doAutoTest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/KotlinScriptWithTemplateResolveTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates;\n\nimport org.junit.Test;\n\npublic class KotlinScriptWithTemplateResolveTest extends KotlinScriptWithTemplateResolveTestCase {\n    @Test\n    public void testSample() {\n        doTest(\"testData/scripts/templates/sample.testDef.kts\");\n    }\n    \n    @Test\n    public void testStandard() {\n        doTest(\"testData/scripts/templates/standard.kts\");\n    }\n    \n    @Test\n    public void testSampleEx() {\n        doTest(\"testData/scripts/templates/sampleEx.testDef.kts\");\n    }\n    \n    @Test\n    public void testCustomEPResolver() {\n        doTest(\"testData/scripts/templates/customEPResolver.kts\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/KotlinScriptWithTemplateResolveTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates\n\nimport org.jetbrains.kotlin.analyzer.AnalysisResult\nimport org.jetbrains.kotlin.core.resolve.KotlinAnalyzer\nimport org.jetbrains.kotlin.diagnostics.Diagnostic\nimport org.jetbrains.kotlin.diagnostics.Severity\nimport org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.jetbrains.kotlin.ui.editors.KotlinEditor\nimport org.junit.Assert\nimport org.junit.Before\n\nabstract class KotlinScriptWithTemplateResolveTestCase : KotlinProjectTestCase() {\n    @Before\n    fun configure() {\n        configureProject()\n    }\n    \n    protected fun doTest(testPath: String) {\n        val fileText = KotlinTestUtils.getText(testPath)\n        \n        val testEditor = configureEditor(KotlinTestUtils.getNameByPath(testPath), fileText)\n        val ktEditor = testEditor.editor as KotlinEditor\n        \n        val analysisResult = KotlinAnalyzer.analyzeFile(ktEditor.parsedFile!!).analysisResult\n        val errorMessages = renderErrors(analysisResult).joinToString(\"\\n\")\n        \n        Assert.assertFalse(errorMessages, hasErrors(analysisResult))\n    }\n    \n    private fun hasErrors(analysisResult: AnalysisResult): Boolean {\n        return getErrors(analysisResult).isNotEmpty()\n    }\n    \n    private fun renderErrors(analysisResult: AnalysisResult): List<String> {\n        return getErrors(analysisResult).map { DefaultErrorMessages.render(it) }\n    }\n    \n    private fun getErrors(analysisResult: AnalysisResult): List<Diagnostic> {\n        return analysisResult.bindingContext.diagnostics.filter { it.severity == Severity.ERROR }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/TestKtScriptTemplateProvider.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates\n\n//import org.jetbrains.kotlin.script.ScriptTemplatesProvider\nimport java.io.File\n\nclass TestKtScriptTemplateProvider/* : ScriptTemplatesProvider*/ {\n    /*override*/ val templateClasspath: List<File>\n        get() = listOf()\n\n    /*override*/ val environment: Map<String, Any?>?\n        get() = emptyMap()\n    \n    /*override*/ val id: String\n        get() = \"Test\"\n    \n    /*override*/ val isValid: Boolean\n        get() = true\n    \n    /*override*/ val templateClassNames: Iterable<String>\n        get() = listOf(\"org.jetbrains.kotlin.ui.tests.scripts.templates.TestScriptTemplateDefinition\")\n    \n    /*override*/ val version: Int\n        get() = 10\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/TestKtScriptTemplateProviderEx.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.IProgressMonitor\n\n//import org.jetbrains.kotlin.core.model.ScriptTemplateProviderEx\n//\n//class TestKtScriptTemplateProviderEx : ScriptTemplateProviderEx {\n//    override val templateClassName = \"org.jetbrains.kotlin.ui.tests.scripts.templates.TestScriptTemplateDefinitionEx\"\n//    \n//    override fun getTemplateClasspath(environment: Map<String, Any?>?, monitor: IProgressMonitor): Iterable<String> {\n//        return listOf(\"bin/\", \"target/classes/\")\n//    }\n//\n//    override fun getEnvironment(file: IFile): Map<String, Any?>? {\n//        return mapOf(\n//                \"projectName\" to file.project.name,\n//                \"additionalImports\" to arrayOf(\"java.util.Date\") \n//        )\n//    }\n//}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/TestScriptTemplateDefinition.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates\n\nimport java.io.File\nimport java.util.concurrent.Future\nimport kotlin.script.dependencies.KotlinScriptExternalDependencies\nimport kotlin.script.dependencies.ScriptContents\nimport kotlin.script.dependencies.ScriptDependenciesResolver\nimport kotlin.script.dependencies.asFuture\nimport kotlin.script.templates.ScriptTemplateDefinition\n\n@ScriptTemplateDefinition(\n        resolver = TestKotlinScriptResolver::class,\n        scriptFilePattern = \"sample.testDef.kts\"\n)\nopen class TestScriptTemplateDefinition(val testNameParam: String, val secondParam: Int, val thirdParam: Int = 10) {\n    fun doSomething() {\n    }\n\n    fun callFromBase(y: Int) {\n        println(y)\n    }\n}\n\n@ScriptTemplateDefinition(\n        resolver = TestKotlinScriptResolverEx::class,\n        scriptFilePattern = \"sampleEx.testDef.kts\"\n)\nopen class TestScriptTemplateDefinitionEx(val testNameParam: String, val secondParam: Int, val thirdParam: Int = 10)\n\nfun TestScriptTemplateDefinition.testExtension(x: Int): String {\n    return x.toString()\n}\n\nclass TestKotlinScriptResolver : ScriptDependenciesResolver {\n    override fun resolve(script: ScriptContents,\n                         environment: Map<String, Any?>?,\n                         report: (ScriptDependenciesResolver.ReportSeverity, String, ScriptContents.Position?) -> Unit,\n                         previousDependencies: KotlinScriptExternalDependencies?): Future<KotlinScriptExternalDependencies?> {\n        return TestScriptExternalDependencies.asFuture()\n    }\n}\n\nclass TestKotlinScriptResolverEx : ScriptDependenciesResolver {\n    override fun resolve(script: ScriptContents,\n                         environment: Map<String, Any?>?,\n                         report: (ScriptDependenciesResolver.ReportSeverity, String, ScriptContents.Position?) -> Unit,\n                         previousDependencies: KotlinScriptExternalDependencies?): Future<KotlinScriptExternalDependencies?> {\n        val additionalImports = if (environment != null) {\n            @Suppress(\"UNCHECKED_CAST\")\n            val importsArray = environment[\"additionalImports\"] as? Array<String> \n            importsArray?.toList()\n        } else {\n            null\n        }\n\n        val standardImports = listOf(\n                \"java.io.File\",\n                \"java.util.concurrent.*\",\n                \"org.jetbrains.kotlin.ui.tests.scripts.templates.*\") \n        \n        return object : KotlinScriptExternalDependencies {\n            override val imports: Iterable<String>\n                get() =  standardImports + (additionalImports ?: emptyList())\n        }.asFuture()\n    }\n}\n\nobject TestScriptExternalDependencies : KotlinScriptExternalDependencies {\n    override val classpath: Iterable<File>\n        get() = listOf()\n\n    override val sources: Iterable<File>\n        get() = listOf()\n\n    override val imports: Iterable<String>\n        get() = listOf(\n                \"java.io.File\",\n                \"java.util.concurrent.*\",\n                \"org.jetbrains.kotlin.ui.tests.scripts.templates.*\")\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/scripts/templates/testCustomEPResolver.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.scripts.templates\n\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.core.runtime.IProgressMonitor\n\n//import org.jetbrains.kotlin.core.model.ScriptTemplateProviderEx\n//import org.jetbrains.kotlin.script.KotlinScriptExternalDependencies\n//import org.jetbrains.kotlin.script.ScriptContents\n//import org.jetbrains.kotlin.script.ScriptDependenciesResolver\n//import org.jetbrains.kotlin.script.ScriptTemplateDefinition\n//import org.jetbrains.kotlin.script.asFuture\n//import java.util.concurrent.Future\n//\n//class CustomEPResolverScriptTemplateProvider : ScriptTemplateProviderEx {\n//    override val templateClassName = \"org.jetbrains.kotlin.ui.tests.scripts.templates.CustomReolverScriptTemplateDefinition\"\n//    \n//    override fun getTemplateClasspath(environment: Map<String, Any?>?, monitor: IProgressMonitor): Iterable<String> {\n//        return listOf(\"bin/\", \"target/classes/\")\n//    }\n//\n//    override fun getEnvironment(file: IFile): Map<String, Any?>? = null\n//}\n//\n//@ScriptTemplateDefinition(\n//        resolver = CustomScriptDependenciesResolver::class,\n//        scriptFilePattern = \"customEPResolver.kts\"\n//)\n//open class CustomReolverScriptTemplateDefinition\n//\n//class CustomScriptDependenciesResolver : ScriptDependenciesResolver {\n//    override fun resolve(\n//            script: ScriptContents,\n//            environment: Map<String, Any?>?,\n//            report: (ScriptDependenciesResolver.ReportSeverity, String, ScriptContents.Position?) -> Unit,\n//            previousDependencies: KotlinScriptExternalDependencies?): Future<KotlinScriptExternalDependencies?> {\n//        return object : KotlinScriptExternalDependencies {\n//            override val imports: Iterable<String> get() = listOf(\"java.util.Date\")\n//        }.asFuture()\n//    }\n//}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/search/KotlinFindReferencesTest.java",
    "content": "package org.jetbrains.kotlin.ui.tests.search;\n\nimport org.junit.Ignore;\nimport org.junit.Test;\n\n\npublic class KotlinFindReferencesTest extends KotlinFindReferencesTestCase {\n    @Test\n    public void testJKClassAllUsages() {\n        doTest(\"testData/findUsages/java/JKClassAllUsages.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedAnonymousObjects() {\n        doTest(\"testData/findUsages/java/JKClassDerivedAnonymousObjects.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedClasses() {\n        doTest(\"testData/findUsages/java/JKClassDerivedClasses.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedInnerClasses() {\n        doTest(\"testData/findUsages/java/JKClassDerivedInnerClasses.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedInnerObjects() {\n        doTest(\"testData/findUsages/java/JKClassDerivedInnerObjects.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedLocalClasses() {\n        doTest(\"testData/findUsages/java/JKClassDerivedLocalClasses.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedLocalObjects() {\n        doTest(\"testData/findUsages/java/JKClassDerivedLocalObjects.0.java\");\n    }\n    \n    @Test\n    public void testJKClassDerivedObjects() {\n        doTest(\"testData/findUsages/java/JKClassDerivedObjects.0.java\");\n    }\n    \n    @Test\n    public void testJKClassWithImplicitConstructorAllUsages() {\n        doTest(\"testData/findUsages/java/JKClassWithImplicitConstructorAllUsages.0.java\");\n    }\n    \n    @Test\n    public void testJKInnerClassAllUsages() {\n        doTest(\"common_testData/ide/findUsages/java/findJavaClassUsages/JKInnerClassAllUsages.0.java\");\n    }\n    \n    @Test\n    public void testJKNestedClassAllUsages() {\n        doTest(\"testData/findUsages/java/JKNestedClassAllUsages.0.java\");\n    }\n    \n    @Test\n    public void testJavaClassAllUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findClassUsages/javaClassAllUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalClassUsages1() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findClassUsages/kotlinLocalClassUsages1.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalClassUsages2() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findClassUsages/kotlinLocalClassUsages2.0.kt\");\n    }\n    \n    @Test\n    public void testJavaMethodUsages() {\n        doTest(\"testData/findUsages/kotlin/findFunctionUsages/javaMethodUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalMethodUsages1() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinLocalMethodUsages1.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalMethodUsages2() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinLocalMethodUsages2.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinMethodUsages() {\n        doTest(\"testData/findUsages/kotlin/findFunctionUsages/kotlinMethodUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinMultiRefInImport() {\n        doTest(\"testData/findUsages/kotlin/findFunctionUsages/kotlinMultiRefInImport.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinNestedClassMethodUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinNestedClassMethodUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinTopLevelMethodUsagesNoImport() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinTopLevelMethodUsagesNoImport.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinTraitImplThroughDelegate() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinTraitImplThroughDelegate.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinTraitNoImplThroughDelegate() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/kotlinTraitNoImplThroughDelegate.0.kt\");\n    }\n    \n    @Test\n    public void testLocalClassMember() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/localClassMember.0.kt\");\n    }\n    \n    @Test\n    public void testObjectExpressionDeepMember() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/objectExpressionDeepMember.0.kt\");\n    }\n    \n    @Test\n    public void testObjectExpressionMember() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/objectExpressionMember.0.kt\");\n    }\n    \n    @Test\n    public void testObjectExpressionMember2() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/objectExpressionMember2.0.kt\");\n    }\n    \n    @Test\n    public void testSynthesizedFunction() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findFunctionUsages/synthesizedFunction.0.kt\");\n    }\n    \n    @Test\n    public void testJavaObjectUsages() {\n        doTest(\"testData/findUsages/kotlin/findObjectUsages/javaObjectUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalObjectUsages1() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findObjectUsages/kotlinLocalObjectUsages1.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalObjectUsages2() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findObjectUsages/kotlinLocalObjectUsages2.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinNestedObjectUsages() {\n        doTest(\"testData/findUsages/kotlin/findObjectUsages/kotlinNestedObjectUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinObjectUsages() {\n        doTest(\"testData/findUsages/kotlin/findObjectUsages/kotlinObjectUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinConstructorParameterUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findParameterUsages/kotlinConstructorParameterUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinFunctionParameterUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findParameterUsages/kotlinFunctionParameterUsages.0.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testJavaClassObjectPropertyUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/javaClassObjectPropertyUsages.0.kt\");\n    }\n    \n    @Ignore\n    @Test\n    public void testKotlinClassObjectPropertyUsage() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/kotlinClassObjectPropertyUsage.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalPropertyUsages1() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/kotlinLocalPropertyUsages1.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinLocalPropertyUsages2() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/kotlinLocalPropertyUsages2.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinNestedClassPropertyUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/kotlinNestedClassPropertyUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinPrivatePropertyInClassObjectUsages() {\n        doTest(\"common_testData/ide/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyInClassObjectUsages.0.kt\");\n    }\n    \n    @Test\n    public void testKotlinTopLevelPropertyUsages() {\n        doTest(\"testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt\");\n    }\n    \n    @Test\n    public void testPrimaryConstructorByRef() {\n        doTest(\"testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorByRef.0.kt\");\n    }\n    \n    @Test\n    public void testPrimaryConstructorWithKeyword() {\n        doTest(\"testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorWithKeyword.0.kt\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/src/org/jetbrains/kotlin/ui/tests/search/KotlinFindReferencesTestCase.kt",
    "content": "package org.jetbrains.kotlin.ui.tests.search\n\nimport org.jetbrains.kotlin.testframework.editor.KotlinProjectTestCase\nimport org.junit.Before\nimport java.io.File\nimport com.intellij.openapi.util.io.FileUtil\nimport com.intellij.openapi.util.io.FileUtilRt\nimport org.eclipse.core.commands.ExecutionEvent\nimport org.eclipse.ui.ISources\nimport org.eclipse.jface.text.ITextSelection\nimport org.jetbrains.kotlin.core.references.*\nimport org.jetbrains.kotlin.core.builder.KotlinPsiManager\nimport org.jetbrains.kotlin.eclipse.ui.utils.*\nimport org.jetbrains.kotlin.testframework.editor.TextEditorTest\nimport org.eclipse.jdt.core.IJavaElement\nimport org.eclipse.jdt.core.search.SearchEngine\nimport org.eclipse.jdt.core.search.SearchPattern\nimport org.eclipse.jdt.core.search.IJavaSearchConstants\nimport org.eclipse.jdt.core.search.SearchRequestor\nimport org.eclipse.jdt.core.search.SearchMatch\nimport java.util.ArrayList\nimport org.jetbrains.kotlin.core.model.KotlinEnvironment\nimport org.jetbrains.kotlin.testframework.utils.KotlinTestUtils\nimport org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory\nimport org.eclipse.jdt.ui.search.ElementQuerySpecification\nimport org.eclipse.jdt.internal.ui.search.JavaSearchQuery\nimport org.eclipse.search.ui.ISearchResult\nimport org.eclipse.core.runtime.NullProgressMonitor\nimport org.jetbrains.kotlin.psi.KtElement\nimport org.eclipse.search.ui.text.AbstractTextSearchResult\nimport org.eclipse.search.ui.text.Match\nimport org.eclipse.jdt.internal.ui.search.JavaElementMatch\nimport org.jetbrains.kotlin.ui.search.KotlinElementMatch\nimport com.intellij.openapi.util.text.StringUtilRt\nimport org.junit.Assert\nimport com.intellij.openapi.util.text.StringUtil\nimport org.eclipse.jdt.core.ISourceReference\nimport org.eclipse.core.resources.IFile\nimport org.eclipse.jdt.internal.ui.javaeditor.JavaEditor\nimport org.eclipse.jdt.internal.ui.search.AbstractJavaSearchResult\nimport org.eclipse.core.resources.IResource\nimport org.jetbrains.kotlin.eclipse.ui.utils.EditorUtil\nimport org.eclipse.jface.text.AbstractDocument\nimport org.jetbrains.kotlin.core.references.createReferences\nimport com.intellij.psi.util.PsiTreeUtil\nimport org.jetbrains.kotlin.eclipse.ui.utils.getTextDocumentOffset\nimport kotlin.properties.Delegates\nimport org.eclipse.ui.editors.text.EditorsUI\nimport org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants\nimport java.util.regex.Pattern\nimport org.eclipse.jdt.internal.ui.javaeditor.EditorUtility\nimport org.eclipse.jdt.core.ICompilationUnit\nimport org.jetbrains.kotlin.core.model.KotlinAnalysisProjectCache\nimport org.eclipse.jdt.ui.search.QuerySpecification\nimport org.eclipse.jdt.core.search.IJavaSearchScope\nimport org.jetbrains.kotlin.ui.commands.findReferences.createQuerySpecification\n\nabstract class KotlinFindReferencesTestCase : KotlinProjectTestCase() {\n    @Before public fun configure() {\n        configureProjectWithStdLib()\n    }\n    \n    protected fun doTest(filePath: String) {\n        val (editor, sourceFiles, resultFile) = configureSourceFiles(filePath)\n        \n        KotlinTestUtils.joinBuildThread()\n        \n        val scope = SearchEngine.createWorkspaceScope()\n        \n        val querySpecification = createQuerySpecificationBy(editor, scope)\n        val searchQuery = JavaSearchQuery(querySpecification)\n        searchQuery.run(NullProgressMonitor())\n        \n        val searchResult = searchQuery.getSearchResult()\n        checkResults(searchResult, resultFile, sourceFiles)\n    }\n    \n    private fun createQuerySpecificationBy(editor: TextEditorTest, scope: IJavaSearchScope) = \n        if (editor.getEditingFile().getFileExtension() == \"java\") {\n            val root = EditorUtility.getEditorInputJavaElement(editor.getEditor(), false) as ICompilationUnit\n            val javaElement = root.getElementAt(editor.getCaretOffset())\n            \n            ElementQuerySpecification(javaElement, IJavaSearchConstants.REFERENCES, scope, null)\n        } else {\n            val jetFile = KotlinPsiManager.getParsedFile(editor.getEditingFile())\n            val element = jetFile.findElementByDocumentOffset(editor.getCaretOffset(), editor.getDocument())!!\n            val jetElement = PsiTreeUtil.getNonStrictParentOfType(element, KtElement::class.java)!!\n            \n            createQuerySpecification(jetElement, scope, \"\")\n        }\n    \n    private fun checkResults(searchResult: ISearchResult, resultFile: File, sourceFiles: List<TestFile>) {\n        if (searchResult !is AbstractJavaSearchResult) throw RuntimeException()\n        \n        val actualResults = searchResult.getElements().flatMap { searchElement ->\n            searchResult.getMatches(searchElement).map { match -> \n                when (match) {\n                    is JavaElementMatch -> {\n                        val file = searchResult.getFile(match.getElement())!!\n                        val testFile = sourceFiles.firstOrNull { it.file == file }\n                        if (testFile == null) return@map null\n                        renderReference(testFile, match.getOffset())\n                    }\n                    is KotlinElementMatch -> {\n                        val file = KotlinPsiManager.getEclipseFile(match.jetElement.getContainingKtFile())\n                        val testFile = sourceFiles.first { it.file == file }\n                        renderKotlinReference(testFile, match.jetElement)\n                    }\n                    else -> throw RuntimeException()\n                }\n            }.filterNotNull()\n        }\n        \n        val expectedResults = loadResultsFile(resultFile)\n        \n        val agreement = expectedResults.all { expectedResult ->\n            actualResults.any { actualResult ->\n                (expectedResult.fileName == null || expectedResult == actualResult) && \n                    expectedResult.lineNumber == actualResult.lineNumber \n            }\n        }\n        \n        Assert.assertTrue(\"$expectedResults are not equals to $actualResults\", agreement)\n    }\n    \n    private fun loadResultsFile(resultFile: File): List<TestResult> {\n        val fileNameRegex = \"\\\\[(.+)\\\\]\".toRegex()\n        val offsetRegex = \"([\\\\d]+\\\\s)\".toRegex()\n        return FileUtil.loadFile(resultFile).splitToSequence(\"\\n\")\n            .filter { it.isNotBlank() }\n            .map { line ->\n                val fileNameMatch = fileNameRegex.find(line)\n                val fileName = if (fileNameMatch != null) fileNameMatch.groups[1]?.value as String else null\n                \n                val offsetMatch= offsetRegex.find(line)!!\n\t            TestResult(\n\t                fileName, \n\t                offsetMatch.groups[1]!!.value.trim().toInt())\n        \t}.toList()\n    }\n    \n    private fun renderKotlinReference(testFile: TestFile, jetElement: KtElement): TestResult {\n        val document = EditorUtil.getDocument(testFile.file)\n        return renderReference(testFile, jetElement.getTextDocumentOffset(document))\n    }\n    \n    private fun renderReference(testFile: TestFile, offset: Int): TestResult {\n        val document = EditorUtil.getDocument(testFile.file)\n        if (document is AbstractDocument) {\n        \tval lineNumber = document.getLineOfOffset(offset) + 1\n            return TestResult(testFile.name, lineNumber)\n        }\n        \n        throw RuntimeException()\n    }\n    \n    private fun configureSourceFiles(filePath: String): TestConfiguration {\n        val mainFile = File(filePath)\n        val mainFileName = mainFile.getName()\n        val mainFileText = FileUtil.loadFile(mainFile)\n        \n        val editor = configureEditor(mainFileName, mainFileText)\n        \n        val prefix = mainFileName.substring(0, mainFileName.indexOf('.') + 1)\n        \n        val rootPath = filePath.substring(0, filePath.lastIndexOf(\"/\") + 1)\n        val rootDir = File(rootPath)\n        val extraFiles = rootDir.listFiles { dir, name ->\n        \tif (!name.startsWith(prefix) || name.equals(mainFileName)) return@listFiles false\n            \n            val ext = FileUtilRt.getExtension(name)\n\t\t\text == \"kt\" || ext == \"java\"\n        }\n        \n        val sourceFiles = ArrayList<TestFile>()\n        extraFiles.mapTo(sourceFiles) { TestFile(createSourceFile(it.getName(), FileUtil.loadFile(it)), it.getName()) }\n        sourceFiles.add(TestFile(editor.getEditingFile(), mainFileName))\n        \n        return TestConfiguration(editor, sourceFiles, File(rootPath, \"${prefix}results.txt\"))\n    }\n    \n    data class TestResult(val fileName: String?, val lineNumber: Int)\n    \n    data class TestConfiguration(val editor: TextEditorTest, val sourceFiles: List<TestFile>, val resultFile: File)\n    \n    data class TestFile(val file: IFile, val name: String)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/ResolveOfJavaGenerics.kt",
    "content": "// !WITH_NEW_INFERENCE\n// Fixpoint generic in Java: Enum<T extends Enum<T>>\nfun test(<!UNUSED_PARAMETER!>a<!> : java.lang.annotation.RetentionPolicy) {\n\n}\n\nfun test() {\n  java.util.Collections.<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()\n  val <!UNUSED_VARIABLE!>a<!> : Collection<String>? = java.util.Collections.emptyList()\n}\n\nfun test(<!UNUSED_PARAMETER!>a<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<Int><!>) {\n\n}\n\nfun test(<!UNUSED_PARAMETER!>a<!> : java.util.ArrayList<Int>) {\n\n}\n\nfun test(<!UNUSED_PARAMETER!>a<!> : java.lang.Class<Int>) {\n\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/ResolveOfJavaGenerics.txt",
    "content": "package\n\npublic fun test(): kotlin.Unit\npublic fun test(/*0*/ a: java.lang.Class<kotlin.Int>): kotlin.Unit\npublic fun test(/*0*/ a: java.lang.Comparable<kotlin.Int>): kotlin.Unit\npublic fun test(/*0*/ a: java.lang.annotation.RetentionPolicy): kotlin.Unit\npublic fun test(/*0*/ a: java.util.ArrayList<kotlin.Int>): kotlin.Unit\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/ResolveToJava.kt",
    "content": "// !WITH_NEW_INFERENCE\n// !CHECK_TYPE\n// JAVAC_SKIP\n\n// FILE: f.kt\n\nimport java.*\nimport java.util.*\nimport <!UNRESOLVED_REFERENCE!>utils<!>.*\n\nimport java.io.PrintStream\nimport <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<!> as Com\n\nval l : MutableList<in Int> = ArrayList<Int>()\n\nfun test(<!UNUSED_PARAMETER!>l<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.List<Int><!>) {\n  val <!UNUSED_VARIABLE!>x<!> : java.<!UNRESOLVED_REFERENCE!>List<!>\n  val <!UNUSED_VARIABLE!>y<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.List<Int><!>\n  val <!UNUSED_VARIABLE!>b<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Object<!>\n  val <!UNUSED_VARIABLE!>z<!> : java.<!UNRESOLVED_REFERENCE!>utils<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>List<!><Int>\n\n  val <!UNUSED_VARIABLE!>f<!> : java.io.File? = null\n\n  Collections.<!FUNCTION_CALL_EXPECTED, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>\n  Collections.<!FUNCTION_CALL_EXPECTED!>emptyList<Int><!>\n  Collections.emptyList<Int>()\n  Collections.<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()\n\n  checkSubtype<Set<Int>?>(Collections.singleton<Int>(1))\n  Collections.singleton<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!>)\n\n  <!RESOLUTION_TO_CLASSIFIER!>List<!><Int>\n\n\n  val <!UNUSED_VARIABLE!>o<!> = \"sdf\" as <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Object<!>\n\n  try {\n    // ...\n  }\n  catch(e: Exception) {\n    System.out.println(e.message)\n  }\n\n  PrintStream(\"sdf\")\n\n  val c : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Com<Int><!>? = null\n\n  checkSubtype<<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<Int><!>?>(c)\n\n//  Collections.sort<Integer>(ArrayList<Integer>())\n  xxx.<!UNRESOLVED_REFERENCE!>Class<!>()\n}\n\n\n// FILE: f.kt\npackage xxx\n  import java.lang.Class;\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/ResolveToJava.txt",
    "content": "package\n\npublic val l: kotlin.collections.MutableList<in kotlin.Int>\npublic fun test(/*0*/ l: java.util.List<kotlin.Int>): kotlin.Unit\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/StarsInFunctionCalls.kt",
    "content": "// !WITH_NEW_INFERENCE\n\nfun <T> getT() {}\nfun <A, B> getTT() {}\nfun <A, B, C> getTTT(<!UNUSED_PARAMETER!>x<!> : Any) {}\nfun foo(<!UNUSED_PARAMETER!>a<!> : Any?) {}\n\npublic fun main() {\n    getT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()\n    <!UNRESOLVED_REFERENCE!>ggetT<!><<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()\n    getTT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()\n    getTT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, Int>()\n    getTT<Int, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()\n    foo(getTTT<Int, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, Int>(1))\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/StarsInFunctionCalls.txt",
    "content": "package\n\npublic fun foo(/*0*/ a: kotlin.Any?): kotlin.Unit\npublic fun </*0*/ T> getT(): kotlin.Unit\npublic fun </*0*/ A, /*1*/ B> getTT(): kotlin.Unit\npublic fun </*0*/ A, /*1*/ B, /*2*/ C> getTTT(/*0*/ x: kotlin.Any): kotlin.Unit\npublic fun main(): kotlin.Unit\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/TypeInference.kt",
    "content": "// !WITH_NEW_INFERENCE\nclass C<T>() {\n  fun foo() : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>\n}\n\nfun foo(<!UNUSED_PARAMETER!>c<!>: C<Int>) {}\nfun <T> bar() : C<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>\n\nfun main() {\n  val <!UNUSED_VARIABLE!>a<!> : C<Int> = C();\n  val <!UNUSED_VARIABLE!>x<!> : C<in String> = C()\n  val <!UNUSED_VARIABLE!>y<!> : C<out String> = C()\n  val <!UNUSED_VARIABLE!>z<!> : C<*> = <!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>C<!>()\n\n  val <!UNUSED_VARIABLE!>ba<!> : C<Int> = bar();\n  val <!UNUSED_VARIABLE!>bx<!> : C<in String> = bar()\n  val <!UNUSED_VARIABLE!>by<!> : C<out String> = bar()\n  val <!UNUSED_VARIABLE!>bz<!> : C<*> = <!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/compiler/diagnostics/tests/TypeInference.txt",
    "content": "package\n\npublic fun </*0*/ T> bar(): C<T>\npublic fun foo(/*0*/ c: C<kotlin.Int>): kotlin.Unit\npublic fun main(): kotlin.Unit\n\npublic final class C</*0*/ T> {\n    public constructor C</*0*/ T>()\n    public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean\n    public final fun foo(): T\n    public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int\n    public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInClassImport/dependency.kt",
    "content": "package dependencies\n\nclass Foo {\n    class Bar\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInClassImport/test.kt",
    "content": "fun main() {\n    B<caret>ar()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInClassImport/test.kt.after",
    "content": "import dependencies.Foo.Bar\n\nfun main() {\n    Bar()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInObjectImport/dependency.kt",
    "content": "package dependencies\n\nobject Foo {\n    class Bar\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInObjectImport/test.kt",
    "content": "fun main() {\n    B<caret>ar()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/classNestedInObjectImport/test.kt.after",
    "content": "import dependencies.Foo.Bar\n\nfun main() {\n    Bar()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionImport/dependency.kt",
    "content": "package dependencies\n\nfun String.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionImport/other.kt",
    "content": "package other\n\noperator fun Int.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionImport/test.kt",
    "content": "fun main() {\n    \"\".fo<caret>o(27)\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    \"\".foo(27)\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionReferenceImport/dependency.kt",
    "content": "package dependencies\n\nfun String.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionReferenceImport/other.kt",
    "content": "package other\n\noperator fun Int.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionReferenceImport/test.kt",
    "content": "fun main() {\n    String::foo<caret>\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionFunctionReferenceImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    String::foo\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionInfixFunctionImport/dependency.kt",
    "content": "package dependencies\n\ninfix fun Int.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionInfixFunctionImport/other1.kt",
    "content": "package other1\n\nfun Int.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionInfixFunctionImport/other2.kt",
    "content": "package other2\n\ninfix fun String.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionInfixFunctionImport/test.kt",
    "content": "fun main() {\n    6 fo<caret>o \"bar\"\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionInfixFunctionImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    6 foo \"bar\"\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverAmbigousImport/dependency1.kt",
    "content": "package dependencies1\n\nfun String.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverAmbigousImport/dependency2.kt",
    "content": "package dependencies2\n\nfun foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverAmbigousImport/other.kt",
    "content": "package other\n\nfun Int.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverAmbigousImport/test.kt",
    "content": "fun main() {\n    with(\"\") {\n        fo<caret>o(27)\n    }\n}\n\n// NUMBER: 2\n// EXIST: Import 'foo' (dependencies1)\n// EXIST: Import 'foo' (dependencies2)\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverAmbigousImport/test.kt.after",
    "content": "import dependencies1.foo\n\nfun main() {\n    with(\"\") {\n        foo(27)\n    }\n}\n\n// NUMBER: 2\n// EXIST: Import 'foo' (dependencies1)\n// EXIST: Import 'foo' (dependencies2)\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverImport/dependency.kt",
    "content": "package dependencies\n\nfun String.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverImport/test.kt",
    "content": "fun main() {\n    with(\"\") {\n        fo<caret>o(27)\n    }\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionMethodInLambdaWithReceiverImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    with(\"\") {\n        fo<caret>o(27)\n    }\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionOperatorImport/dependency.kt",
    "content": "package dependencies\n\noperator fun String.div(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionOperatorImport/other1.kt",
    "content": "package other1\n\nfun String.div(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionOperatorImport/other2.kt",
    "content": "package other2\n\noperator fun Int.div(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionOperatorImport/test.kt",
    "content": "fun main() {\n\t\"\" /<caret> 27\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionOperatorImport/test.kt.after",
    "content": "import dependencies.div\n\nfun main() {\n\t\"\" / 27\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValImport/dependency.kt",
    "content": "package dependencies\n\nval String.foo = this\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValImport/other.kt",
    "content": "package other\n\nval Int.foo = this"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValImport/test.kt",
    "content": "fun main() {\n    \"\".f<caret>oo\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    \"\".foo\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValReferenceImport/dependency.kt",
    "content": "package dependencies\n\nfun String.foo(a: Int) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValReferenceImport/other.kt",
    "content": "package other\n\noperator fun Int.foo(a: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValReferenceImport/test.kt",
    "content": "fun main() {\n    String::foo<caret>\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/extensionValReferenceImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    String::foo\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionExtensionValImport/dependency.kt",
    "content": "package dependencies\n\nval String.foo: () -> Unit = {}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionExtensionValImport/other.kt",
    "content": "package other\n\nval Int.foo: () -> Unit = {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionExtensionValImport/test.kt",
    "content": "fun main() {\n    \"\".f<caret>oo()\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionExtensionValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    \"\".foo()\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionReferenceImport/dependency.kt",
    "content": "package dependencies\n\nfun foo() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionReferenceImport/test.kt",
    "content": "fun main() {\n\t::fo<caret>o\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/functionReferenceImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n\t::foo\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importClassWithExistingPackageKeyword.kt",
    "content": "package testing\n\nfun test() = Vec<caret>tor"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importClassWithExistingPackageKeyword.kt.after",
    "content": "package testing\n\nimport java.util.Vector\n\nfun test() = Vector"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importOnlyUnresolvedReferenceExpressions.kt",
    "content": "// NUMBER: 0\n\nfun test() = O<caret>bject"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importOnlyUnresolvedReferenceExpressions.kt.after",
    "content": "// NUMBER: 0\n\nfun test() = Object"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importWithExtraBreakline.kt",
    "content": "package testing\nfun test() = Vect<caret>or"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importWithExtraBreakline.kt.after",
    "content": "package testing\n\nimport java.util.Vector\n\nfun test() = Vector"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importWithExtraBreaklineWithoutPackage.kt",
    "content": "fun test() = <caret>Vector"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/importWithExtraBreaklineWithoutPackage.kt.after",
    "content": "import java.util.Vector\n\nfun test() = Vector"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/invokableExtensionValImport/dependency.kt",
    "content": "package dependencies\n\nval String.foo: () -> Unit = {}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/invokableExtensionValImport/other.kt",
    "content": "package other\n\nval Int.foo: () -> Unit = {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/invokableExtensionValImport/test.kt",
    "content": "fun main() {\n    \"\".f<caret>oo()\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/invokableExtensionValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    \"\".foo()\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaClassAutoImport/Bar.kt",
    "content": "fun test() = F<caret>oo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaClassAutoImport/Bar.kt.after",
    "content": "import testing.Foo\n\nfun test() = Foo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaClassAutoImport/Foo.java",
    "content": "package testing\n\npublic class Foo {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaEnumAutoImport/Bar.kt",
    "content": "fun test() = FooE<caret>num"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaEnumAutoImport/Bar.kt.after",
    "content": "import testing.FooEnum\n\nfun test() = FooEnum"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaEnumAutoImport/FooEnum.java",
    "content": "package testing\n\npublic enum FooEnum {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaInterfaceAutoImport/Bar.kt",
    "content": "fun test() = FooInt<caret>erface"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaInterfaceAutoImport/Bar.kt.after",
    "content": "import testing.FooInterface\n\nfun test() = FooInterface"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/localJavaInterfaceAutoImport/FooInterface.java",
    "content": "package testing\n\npublic interface FooInterface {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/oneStandardVectorAutoImport.kt",
    "content": "fun test() = Vect<caret>or\n\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/oneStandardVectorAutoImport.kt.after",
    "content": "import java.util.Vector\n\nfun test() = Vector\n\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageArrayListAutoImport.kt",
    "content": "public class ArrayList<T>\n\nfun main(args: Array<String>) {\n\tval list = ArrayList<caret><String>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageArrayListAutoImport.kt.after",
    "content": "public class ArrayList<T>\n\nfun main(args: Array<String>) {\n\tval list = ArrayList<String>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionImport/dependency.kt",
    "content": "package dependencies\n\nfun foo() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionImport/test.kt",
    "content": "fun main() {\n\tfo<caret>o()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n\tfoo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionValImport/dependency.kt",
    "content": "package dependencies\n\nval foo: () -> Unit = {}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionValImport/test.kt",
    "content": "fun main() {\n    f<caret>oo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelFunctionValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n    foo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelInvokableValImport/dependency.kt",
    "content": "package dependencies\n\nval foo = Invokable()\n\nclass Invokable {\n    operator fun invoke() {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelInvokableValImport/test.kt",
    "content": "fun main() {\n\tf<caret>oo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelInvokableValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n\tfoo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelValImport/dependency.kt",
    "content": "package dependencies\n\nval foo = 7"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelValImport/test.kt",
    "content": "fun main() {\n\tfo<caret>o\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/packageLevelValImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n\tfoo\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/propertyReferenceImport/dependency.kt",
    "content": "package dependencies\n\nval foo = null"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/propertyReferenceImport/test.kt",
    "content": "fun main() {\n\t::fo<caret>o\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/propertyReferenceImport/test.kt.after",
    "content": "import dependencies.foo\n\nfun main() {\n\t::foo\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/sameProjectJavaClassAutoImport/Bar.kt",
    "content": "package second\n\npublic class Bar : Fo<caret>o()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/sameProjectJavaClassAutoImport/Bar.kt.after",
    "content": "package second\n\nimport first.Foo\n\npublic class Bar : Foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/sameProjectJavaClassAutoImport/Foo.java",
    "content": "package first;\n\npublic class Foo {\n\tpublic int zero() {\n\t\treturn 0;\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/standardEnumMapAutoImport.kt",
    "content": "fun main(args : Array<String>) {\n\tval list = Enum<caret>Map\n\tprintln(list)\n}\n\n// EXIST: Import 'EnumMap' (java.util)\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/standardEnumMapAutoImport.kt.after",
    "content": "import java.util.EnumMap\n\nfun main(args : Array<String>) {\n\tval list = EnumMap\n\tprintln(list)\n}\n\n// EXIST: Import 'EnumMap' (java.util)\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/dependency.kt",
    "content": "package dependencies\n\noperator fun String.unaryMinus() {}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/other1.kt",
    "content": "package other1\n\nfun String.unaryMinus() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/other2.kt",
    "content": "package other2\n\noperator fun BooleanArray.unaryMinus() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/other3.kt",
    "content": "package other2\n\noperator fun String.minus(other: String) {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/test.kt",
    "content": "fun main() {\n\t-<caret> \"\"\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/autoimport/unaryExtensionOperatorImport/test.kt.after",
    "content": "import dependencies.unaryMinus\n\nfun main() {\n\t- \"\"\n}\n\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AfterFloatOnNewLine.kt",
    "content": "fun test() {\n    val some = 1\n    val f = 1.0f\n    som<caret>\n}\n\n// EXIST: some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AfterIntSeparatedWithComments.kt",
    "content": "fun Int.func(s: String): Int{}\n\nfun test() {\n    val floor = \"Floor\"\n    val a = 1/**/f<caret>\n}\n\n// EXIST: func"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AutoCastAfterIf.kt",
    "content": "trait Expr\nclass Num(val value : Int) : Expr\n\nfun eval(e : Expr) {\n    if (e is Num) {\n        return e.<caret>\n    }\n}\n\n// EXIST: value\n\n\n\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AutoCastAfterIfMethod.kt",
    "content": "class Expr {}\nclass Num : Expr() {\n    fun testing() {}\n}\n\nfun eval(e : Expr) {\n    if (e is Num) {\n        return e.<caret>()\n    }\n}\n\n// EXIST: testing"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AutoCastForThis.kt",
    "content": "trait Expr {\n    public fun testThis() {\n        if (this is Num) {\n            this.<caret>\n        }\n    }\n}\n\nclass Num(val toCheck : Int) : Expr\n\n// EXIST: toCheck"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/AutoCastInWhen.kt",
    "content": "trait Expr\nclass Sum(val left : Expr, val right : Expr) : Expr\n\nfun evalWhen(e : Expr) : Int = when (e) {\n    is Sum -> e.<caret>\n}\n\n// EXIST: left, right"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/BasicAny.kt",
    "content": "fun some() {\n    var a : A<caret>\n}\n\n// EXIST: Any"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/BasicInt.kt",
    "content": "fun some() {\n    var a : In<caret>\n}\n\n// EXIST: Int"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/BeforeDotInCall.kt",
    "content": "package testing\n\nfun testTop() {\n\n}\n\nclass TestSample() {\n    fun main(args : Array<String>) {\n        val testVar = \"\"\n        test<caret>.testFun()\n    }\n\n    fun testFun() {\n\n    }\n}\n\n// INVOCATION_COUNT: 2\n// EXIST: testVar, testFun, testTop"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/CallLocalLambda.kt",
    "content": "class TestClass {\n    public fun testMethod() {\n    }\n}\n\nfun testFun() {\n    val lambda = {() -> TestClass() }\n    lambda().<caret>\n}\n\n// EXIST: testMethod"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ClassObjectElementsInClass.kt",
    "content": "class Some {\n    companion object {\n        val coProp = 12\n\n        fun coFun = 12\n    }\n\n    fun some() {\n        val a = co<caret>\n    }\n}\n\n// EXIST: coProp, coFun"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ClassRedeclaration1.kt",
    "content": "class A {\n  fun f() : A<caret>\n}\n\nclass A {\n  fun f() : A\n}\n\n// EXIST: A"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ClassRedeclaration2.kt",
    "content": "class A {\n  fun f() : A\n}\n\nclass A {\n  fun f() : A<caret>\n}\n\n// EXIST: A"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtendClassName.kt",
    "content": "open class MySecondClass() {\n}\n\nopen class MyFirstClass<T> {\n\n}\n\nclass A() : My<caret> {\n    public fun test() {\n    }\n}\n\n// EXIST: MySecondClass, MyFirstClass\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtendQualifiedClassName.kt",
    "content": "package Test.SubTest.AnotherTest\n\nopen class TestClass {\n}\n\nclass A() : Test.SubTest.AnotherTest.Te<caret> {\n    public fun test() {\n    }\n}\n\n// EXIST: TestClass\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtensionForProperty.kt",
    "content": "class Test {\n    val St<caret>\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"String\", tailText:\" (jet)\" }\n// EXIST: IllegalStateException\n// EXIST: StringBuilder\n// EXIST_JAVA_ONLY: StringBuffer\n// ABSENT: HTMLStyleElement\n// ABSENT: Statement\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtensionFunReceiver.kt",
    "content": "fun testing() {}\n\nfun S<caret>\n\n// Should complete types for receiver after explicit basic completion call\n// INVOCATION_COUNT: 1\n// EXIST: String\n// EXIST_JAVA_ONLY: StringBuffer\n// EXIST: Set\n// ABSENT: testing\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtensionFunReceiverForce.kt",
    "content": "class Test {\n    val St<caret>\n}\n\n// INVOCATION_COUNT: 2\n// EXIST: { lookupString:\"String\", tailText:\" (jet)\" }\n// EXIST: IllegalStateException\n// EXIST: StringBuilder\n// EXIST_JAVA_ONLY: StringBuffer\n// EXIST_JS_ONLY: HTMLStyleElement\n// EXIST_JAVA_ONLY: { lookupString:\"Statement\", tailText:\" (java.sql)\" }\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtensionInsideFunction.kt",
    "content": "class StrSome {\n  class StrOther\n\n  fun more() {\n    class StrInFun\n\n    fun Str<caret>\n  }\n}\n\nclass StrMore {\n  class StrAbsent\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"String\", tailText:\" (jet)\" }\n// EXIST: StrSome\n// EXIST: StrMore\n// EXIST: StrInFun\n// EXIST: StringBuilder\n// EXIST_JAVA_ONLY: StringBuffer\n// ABSENT: StrAbsent"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ExtensionToIntInFloatStyle.kt",
    "content": "val Int.f: Float get() = this.toFloat()\n\nval test = 1.<caret>\n\n// EXIST: f"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/FromImports.kt",
    "content": "package Tests\n\nimport java.util.*\n\nfun hello() {\n    val a = So<caret>\n}\n\n// EXIST: SortedSet\n// EXIST_JAVA_ONLY: SortedMap\n// EXIST_JS_ONLY: JSON\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/FunctionCompletionFormatting.kt",
    "content": "fun test(a: Int) {}\n\nfun some() {\n    tes<caret>\n}\n\n// EXIST: { lookupString:\"test\", itemText:\"test(a: jet.Int)\" }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InCallExpression.kt",
    "content": "package something\n\nclass SomeTempClass {\n    fun helloWorld() {\n\n    }\n\n    fun test() {\n        hello<caret>()\n    }\n}\n\n// EXIST: helloWorld"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InClassInitializer.kt",
    "content": "val testExternal\n\nclass Some(testParam : Int) {\n  private val myVal : Int\n\n  init {\n    val testing = 12\n    myVal = test<caret>\n  }\n}\n\n// EXIST: testParam, testExternal, testing\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InClassPropertyAccessor.kt",
    "content": "class Test(val testParam : Int) {\n  val x : Int get() {\n      val test = 12\n      return te<caret>\n  }\n}\n\n// EXIST: test\n// EXIST: testParam\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InEmptyImport.kt",
    "content": "package Test\n\nimport <caret>\n\n// EXIST: java,\n// EXIST_JAVA_ONLY: javax\n// EXIST_JS_ONLY: js\n// ABSENT: Array, Integer"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InExpressionNoPrefix.kt",
    "content": "class Test {\n    fun test() {\n        val some : <caret>\n    }\n}\n\n// EXIST: Any, Nothing, Unit, Int, Number, Array\n// EXIST_JAVA_ONLY: Math, Thread"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InExtendTypeAnnotation.kt",
    "content": "class Test : <caret> {\n    fun test() {\n    }\n}\n\n// EXIST: Any, Nothing, Unit, Int, Number, Array\n// EXIST_JAVA_ONLY: Math, Thread"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InFileWithMultiDeclaration.kt",
    "content": "data class LocalData(val first : Int, val second : Int)\n\nval (localFirst, localSecond) = LocalData(11, 12)\n\nfun test() {\n  local<caret>\n}\n\n// Test that this test won't fail with exception\n// Regression for EA-39175\n\n// ABSENT: localFirst, localSecond\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InFileWithTypedef.kt",
    "content": "class TestClassName\ntype TestAlias = TestClassName\n\nval a: Tes<caret>\n\n// Regression for EA-38287 and KT-2758\n\n// EXIST: TestClassName\n// ABSENT: TestAlias"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InFunInClassInitializer.kt",
    "content": "val some = 12\nclass Some(someParam : Int) {\n  init {\n    fun internalFun(someInternal : Int) : Int {\n      return some<caret>\n    }\n  }\n}\n\n// EXIST: some, someInternal, someParam\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InGlobalPropertyInitializer.kt",
    "content": "val testing = 12\nval test = \"Hello\"\n\nval more = test<caret>\n\n// EXIST: test, testing\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InImport.kt",
    "content": "package Test\n\nimport java.util.<caret>\n\nclass Test {\n\n}\n\n// EXIST: AbstractList, Date\n// EXIST_JAVA_ONLY: Random, concurrent"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InInitializerInPropertyAccessor.kt",
    "content": "val testGlobal = 12\n\nval test : Int get() {\n    class SomeMore(testParam : Int) {\n        init {\n            tes<caret>\n        }\n    }\n}\n\n// EXIST: testGlobal, test, testParam\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InLocalObjectDeclaration.kt",
    "content": "fun hello(moParam : Int) : Int {\n    val more = 12\n\n    val test = object {\n        val sss = mo<caret>\n    }\n\n    return 12\n}\n\n// EXIST: more\n// EXIST: moParam"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InLongDotQualifiedExpression.kt",
    "content": "// For KT-2796\n\nfun test() {\n    val bVal = 1\n    b<caret>.app().app() // b is not there\n}\n\n// EXIST: bVal"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InMiddleOfPackage.kt",
    "content": "package java.ut<caret>il.\n\nimport java.util.AbstractList\n\nclass Test {\n\n}\n\n// TODO: Add completion in package directive\n// Add \"util\" to exists"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InMiddleOfPackageDirective.kt",
    "content": "package testdata.kotlin.data\n\nclass TestSample() {\n    fun main(args : Array<String>) {\n        testdata.kot<caret>lin.data.TestSample()\n    }\n}\n\n// EXIST: kotlin"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InObjectInDelegationSpecifier.kt",
    "content": "open class PageManager(a: Runnable)\nclass Tab\n\nclass ChromePageManager(): PageManager(object : Runnable {\n    public override fun run() {\n        val ab : Ta<caret> = null\n    }\n}) {\n}\n\n// EXIST: Tab"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InPackageBegin.kt",
    "content": "package kttesting<caret>.util\n\n// Test that there won't be package with completion fake suffix\n\n// NUMBER: 0"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InParametersTypes.kt",
    "content": "class SomeClass {\n  class SomeInternal\n\n  fun some(a : S<caret>)\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: SomeClass\n// EXIST: SomeInternal\n// EXIST: { lookupString:\"String\", tailText:\" (jet)\" }\n// EXIST: StringBuilder\n// EXIST_JAVA_ONLY: StringBuffer\n// ABSENT: HTMLStyleElement"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InParametersTypesForce.kt",
    "content": "class SomeClass {\n  class SomeInternal\n\n  fun some(a : S<caret>)\n}\n\n// INVOCATION_COUNT: 2\n// EXIST: SomeClass\n// EXIST: SomeInternal\n// EXIST: String \n// EXIST: StringBuilder\n// EXIST_JAVA_ONLY: StringBuffer\n// EXIST_JS_ONLY: HTMLStyleElement\n// EXIST_JAVA_ONLY: { lookupString:\"Statement\", tailText:\" (java.sql)\" }\n\n// TODO: json { lookupString:\"String\", tailText:\" (jet)\" }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/InTypeAnnotation.kt",
    "content": "public StringMethod() : String {\n\n}\n\nopen class StringMy() {\n}\n\npublic class Test : String<caret> {\n\n}\n\n// EXIST: StringMy\n// EXIST: String\n// ABSENT: StringMethod"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/JavaPackage.kt",
    "content": "package Tests\n\nclass A : java.<caret>\n\n// EXIST: lang, util, io\n// ABSENT: fun, val, var, package\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/LocalMultideclarationValues.kt",
    "content": "data class TestData(val first: Int, val second: String)\n\nfun f() : TestData = TestData(42, \"Second\")\n\nfun test() {\n  val (dataFirst, dataSecond) = f()\n  d<caret>\n}\n\n// EXIST: dataFirst, dataSecond"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NamedObject.kt",
    "content": "package testing\n\npublic object SimpleTestClass {\n\n}\n\nfun some() {\n    S<caret>\n}\n\n// EXIST: SimpleTestClass\n// EXIST: String"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoClassNameDuplication.kt",
    "content": "package testing\n\nclass Testing {\n}\n\nfun firstFun() {\n    Testin<caret>\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: Testing\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoCompletionAfterBigFloat.kt",
    "content": "val a = 1.0F<caret>\n\n// NUMBER: 0"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoCompletionAfterFloat.kt",
    "content": "val a = 1.0f<caret>\n\n// NUMBER: 0\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoCompletionAfterInt.kt",
    "content": "fun test() {\n    val a = 10<caret>\n}\n\n// NUMBER: 0\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoCompletionAfterLong.kt",
    "content": "val a = 1L<caret>\n\n// NUMBER: 0\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoEmptyPackage.kt",
    "content": "fun test() {\n    <caret>\n}\n\n// ABSENT: \"\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoObjectInTypePosition.kt",
    "content": "object NamedObject\n\nfun test() {\n  val a : Named<caret>\n}\n\n// INVOCATION_COUNT: 2\n// ABSENT: NamedObject\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/NoTopLevelCompletionInQualifiedUserTypes.kt",
    "content": "class Test : java.lang.A<caret>\n\n// ABSENT: Annotation"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ObjectRedeclaration1.kt",
    "content": "object A {\n  fun f() : S<caret>\n}\n\nobject A {\n  fun f() : S\n}\n\n// EXIST: String"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ObjectRedeclaration2.kt",
    "content": "object A {\n  fun f() : S\n}\n\nobject A {\n  fun f() : S<caret>\n}\n\n// EXIST: String"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/OneProposalWithExplicitImport.kt",
    "content": "import java.util.ArrayList\n\nval k: HashMap<caret>\n\n// EXIST: HashMap\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/OneWithStarImport.kt",
    "content": "import java.util.*\n\nval k: HashMap<caret>\n\n// EXIST: HashMap\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt",
    "content": "package first\n\nfun firstFun() {\n  val a = In<caret>\n}\n\n// EXIST: Int\n// INVOCATION_COUNT: 0\n\n// TODO absent: JSon { lookupString:\"Int\", tailText:\" (jet.runtime.SharedVar)\" }\n// TODO exist: JSon { lookupString:\"Int\", tailText:\" (jet)\" }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/OverloadFunctions.kt",
    "content": "package Test.MyTest\n\nclass A {\n    companion object {\n        public fun testOther() {\n\n        }\n\n        public fun testOther(a: Boolean) {\n\n        }\n\n        public fun testOther(a: Int) {\n\n        }\n    }\n}\n\nfun testMy() {\n    A.test<caret>\n}\n\n// EXIST: testOther\n// NUMBER: 3"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/ShortClassNamesInTypePosition.kt",
    "content": "package testing\n\nclass Hello() {\n   fun test() {\n       val a : S<caret>\n   }\n}\n\n// EXIST: Set, Short, ShortArray\n// ABSENT: toString\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/StandardJetArrayFirst.kt",
    "content": "fun main(args: Array<String>) {\n    Array<caret>\n}\n\n// INVOCATION_COUNT: 2\n// WITH_ORDER: 1\n// EXIST: { lookupString:\"Array\", tailText:\" (jet)\" }\n// EXIST_JAVA_ONLY: { lookupString:\"Array\", tailText:\" (java.sql)\" }\n// EXIST_JAVA_ONLY: { lookupString:\"ArrayList\", tailText:\"<E> (java.util)\" }\n// EXIST_JS_ONLY: { lookupString:\"ArrayList\", tailText:\" (java.util)\" }\n\n\n\n\n\n// Developer! Every ancient failure of this test is important!"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/StandardJetDoubleFirst.kt",
    "content": "fun some(a: Double<caret>) {\n}\n\n// INVOCATION_COUNT: 2\n// WITH_ORDER: 1\n// EXIST: { lookupString:\"Double\", tailText:\" (jet)\" }\n// EXIST_JAVA_ONLY: { lookupString:\"Double\", tailText:\" (java.lang)\" }\n// EXIST: { lookupString:\"DoubleArray\", tailText:\" (jet)\" }\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/SubpackageInFun.kt",
    "content": "package Test.MyTest\n\nfun test() {\n    Test.<caret>\n}\n\n// EXIST: MyTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/TopLevelClassCompletionInQualifiedCall.kt",
    "content": "class Test {\n    fun foo(a: Collection<String>) {\n\n    }\n}\n\nfun test() {\n    val t = Test()\n    t.foo(Array<caret>)\n}\n\n// EXIST: ArrayList\n// INVOCATION_COUNT: 2"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/VariableClassName.kt",
    "content": "package some;\n\nopen class MyClass() {\n}\n\nclass A() {\n    public fun test() {\n        val a : MyC<caret>\n    }\n}\n\n// EXIST: MyClass\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/VariableWithLowerCase.kt",
    "content": "package some;\n\npublic fun testSome() {\n    val smallBig = 10\n    smallbi<caret>\n}\n\n// EXIST: smallBig"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/VisibilityClassMembersFromExternal.kt",
    "content": "class Some() {\n    public val testPublic = 12\n    protected val testProtected = 12\n    private val testPrivate = 12\n    val testPackage = 12\n}\n\nfun test() {\n    Some().<caret>\n}\n\n// EXIST: testPublic, testPackage, testPrivate, testProtected\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/WithCompletedExpression.kt",
    "content": "fun some() {\n    some().<caret>hashCode()\n}\n\n// EXIST: equals, toString "
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/functionWithLowerCase.kt",
    "content": "fun someCase() {\n    someca<caret>\n}\n\n// EXIST: someCase"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/notImportedAnnotation.kt",
    "content": "class FXMLClass\n\nfun foo() {\n    @FX<caret>\n}\n\n// EXIST: FXML"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/common/visibility/VisibilityPrivateToThisWithWrongThis.kt",
    "content": "class A<in I> {\n    private val bar: I\n\n    private fun foo(): I = null!!\n\n\n    fun test() {\n        with(A()) {\n            this.<caret>\n        }\n    }\n}\npublic inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()\n\n// INVOCATION_COUNT: 1\n// ABSENT: bar, foo\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/AutoForceCompletion.kt",
    "content": "fun some(a : Statement<caret>)\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"Statement\", tailText:\" (java.sql)\" }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/ExtensionFromStandardLibrary.kt",
    "content": "package first\n\nimport java.util.ArrayList\n\nfun firstFun() {\n  val a = ArrayList<Int>()\n  a.toLinke<caret>\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"toLinkedList\", itemText:\"toLinkedList()\", tailText:\" for jet.Iterable<T> in kotlin\" }\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/InPackage.kt",
    "content": "package java.util.<caret>\n\n// EXIST: concurrent\n// ABSENT: AbstractList, Date, Random, import\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/JavaClassNames.kt",
    "content": "package testing\n\n// Should show java names by short name\nclass Hello() {\n   fun test() {\n       val a : S<caret>\n   }\n}\n\n// INVOCATION_COUNT: 2\n// EXIST: SortedMap, Short, Socket\n// ABSENT: hashSetOf"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/JavaConstructorsCompletion.kt",
    "content": "package sdf.sdf\n\nimport java.util.HashMap\n\nfun main(args : Array<String>) {\n\tval map = HashMap<Int, Int>()\n\tmap.<caret>\n}\n\n// EXIST: keys, get\n// Check that there is no exception "
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt",
    "content": "val x = LineIterator<caret>\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"LineIterator\", tailText:\" (kotlin.io)\" }\n// NUMBER: 1\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/NoImportedJavaClassDuplication.kt",
    "content": "import java.io.InputStreamReader\n\nval x = InputStreamReader<caret>\n\n// INVOCATION_COUNT: 1\n// EXIST: { lookupString:\"InputStreamReader\", tailText:\" (java.io)\" }\n// NUMBER: 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/PropertyMetadata.kt",
    "content": "/* Number of result in completion should be fixed after removing duplicates */\npackage first\n\nfun firstFun() {\n  val a = PropertyM<caret>\n}\n\n// INVOCATION_COUNT: 1\n// EXIST: PropertyMetadata, PropertyMetadataImpl\n// EXIST: { lookupString:\"PropertyMetadata\", itemText:\"PropertyMetadata\", tailText:\" (jet)\" }\n// EXIST: { lookupString:\"PropertyMetadataImpl\", itemText:\"PropertyMetadataImpl\", tailText:\" (jet)\" }\n// NUMBER: 2\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/TopLevelFromStandardLibrary.kt",
    "content": "package testing\n\nfun someFun() {\n  measureTime<caret>\n}\n\n// Important: This test checks that completion will find top level functions from jars.\n// If you going to update it make sure that methods are not auto-imported\n\n// EXIST: measureTimeNano, measureTimeMillis"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt",
    "content": "package testing\n\nfun someFun() {\n  defaultDocumentBuilderFa<caret>\n}\n\n// Important: This test checks that completion will find top level functions from jars.\n// If you going to update it make sure that methods are not auto-imported\n\n// EXIST: defaultDocumentBuilderFactory"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/absentMainTemplate.kts",
    "content": "mai<caret>\n\n// ABSENT: main"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/argsCompletion.kts",
    "content": "println(arg<caret>s.size)\n\n// EXIST: args"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/classFromJRE.kts",
    "content": "StringBuilder().toStr<caret>\n\n// EXIST: toString"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/functionFromStdlib.kts",
    "content": "println(args.ma<caret>)\n\n// EXIST: map, mapNotNull, mapTo, max"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/keywordsCompletion.kts",
    "content": "if (123 i<caret>\n\n// EXIST: in, is\n// NOTHING_ELSE"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/localDeclarations.kts",
    "content": "val foo = 123\nfun fooFun() {\n}\n\nclass fooClass\n\nprintln(fo<caret>)\n\n// EXIST: foo, fooFun, fooClass"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/basic/scripts/typeFromRuntime.kts",
    "content": "println(In<caret>)\n\n// EXIST: Int, IntArray, IntIterator, IntRange"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/ExistingSingleBrackets.kt",
    "content": "package Test.MyTest\n\nclass A {\n    companion object {\n        public fun testOther(a: Int) {\n\n        }\n    }\n}\n\nfun testMy() {\n    A.testOthe<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/ExistingSingleBrackets.kt.after",
    "content": "package Test.MyTest\n\nclass A {\n    companion object {\n        public fun testOther(a: Int) {\n\n        }\n    }\n}\n\nfun testMy() {\n    A.testOther(<caret>)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/FunctionWithParamOnBracket.kt",
    "content": "fun myFoo(x: Int, y: Int) {\n}\n\nfun main(args: Array<String>) {\n    myFo<caret>\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/FunctionWithParamOnBracket.kt.after",
    "content": "fun myFoo(x: Int, y: Int) {\n}\n\nfun main(args: Array<String>) {\n    myFoo(<caret>)\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeNonImported.kt",
    "content": "fun test(k: Vect<caret>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeNonImported.kt.after",
    "content": "import java.util.Vector\n\nfun test(k: Vector<caret>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBraces.kt",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutPa<caret>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBraces.kt.after",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutParam()<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBracesOnBrace.kt",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutPa<caret>()\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBracesOnBrace.kt.after",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutParam(<caret>)\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBracesOnDot.kt",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutPa<caret>()\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/completeWithExistingBracesOnDot.kt.after",
    "content": "fun withoutParam() {\t\n}\n\nfun main(args : Array<String>) {\n\twithoutParam().<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/filterTypesFromSamePackage.dependency.kt",
    "content": "package org.jet\n\nclass KotlinCompletionTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/filterTypesFromSamePackage.kt",
    "content": "package org.jet\n\nfun foo() {\n    KotlinCompletionTe<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/filterTypesFromSamePackage.kt.after",
    "content": "package org.jet\n\nfun foo() {\n    KotlinCompletionTest<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/functionLiteralInsertOnSpace.kt",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().fil<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/functionLiteralInsertOnSpace.kt.after",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().filter { <caret> }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/functionWithParamOnDot.kt",
    "content": "fun myFoo(x: Int, y: Int) {\n}\n\nfun main(args: Array<String>) {\n    myFo<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/functionWithParamOnDot.kt.after",
    "content": "fun myFoo(x: Int, y: Int) {\n}\n\nfun main(args: Array<String>) {\n    myFoo().<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/higherOrderFunction.kt",
    "content": "fun myFilter(predicate : (T) -> Boolean) : java.util.List<T> = throw UnsupportedOperationException()\n\nfun main(args: Array<String>) {\n    myFil<caret>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/higherOrderFunction.kt.after",
    "content": "fun myFilter(predicate : (T) -> Boolean) : java.util.List<T> = throw UnsupportedOperationException()\n\nfun main(args: Array<String>) {\n    myFilter { <caret> }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/higherOrderFunctionWithArgs1.kt",
    "content": "fun myfoo(p : (String, Char) -> Boolean){}\n\nfun main(args: Array<String>) {\n    myfo<caret>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/higherOrderFunctionWithArgs1.kt.after",
    "content": "fun myfoo(p : (String, Char) -> Boolean){}\n\nfun main(args: Array<String>) {\n    myfoo(<caret>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertFunctionWithBothParentheses.kt",
    "content": "// KT-1968 Double closing parentheses entered when completing unit function\npackage some\n\nfun test() = 12\nfun test1()\n\nval a = <caret>\n\n// ELEMENT: test1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertFunctionWithBothParentheses.kt.after",
    "content": "// KT-1968 Double closing parentheses entered when completing unit function\npackage some\n\nfun test() = 12\nfun test1()\n\nval a = test1()<caret>\n\n// ELEMENT: test1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertFunctionWithSingleParameterWithBrace.kt",
    "content": "fun some(f: () -> Unit) { f() }\n\nfun test() {\n    some<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertFunctionWithSingleParameterWithBrace.kt.after",
    "content": "fun some(f: () -> Unit) { f() }\n\nfun test() {\n    some { <caret> }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertJavaMethodWithParam.kt",
    "content": "import java.io.File\n\nfun test() {\n  val f = File(\"testFile\")\n  f.equal<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertJavaMethodWithParam.kt.after",
    "content": "import java.io.File\n\nfun test() {\n  val f = File(\"testFile\")\n  f.equals(<caret>)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertVoidJavaMethod.kt",
    "content": "import java.io.File\n\nfun test() {\n  val f = File(\"testFile\")\n  // Should be no ;\n  f.deleteOnExit<caret>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/insertVoidJavaMethod.kt.after",
    "content": "import java.io.File\n\nfun test() {\n  val f = File(\"testFile\")\n  // Should be no ;\n  f.deleteOnExit()<caret>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/noParamsFunction.kt",
    "content": "package testing.handlers\n\nfun testFun() {\n}\n\nfun other() {\n    testFu<caret>\n}\n\n// INSERT: test"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/noParamsFunction.kt.after",
    "content": "package testing.handlers\n\nfun testFun() {\n}\n\nfun other() {\n    testFun()<caret>\n}\n\n// INSERT: test"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/nonImportedByCamelCase.kt",
    "content": "val k: ArrList<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/nonImportedByCamelCase.kt.after",
    "content": "import java.util.ArrayList\n\nval k: ArrayList<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramFunctionOnBracket.kt",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().fil<caret>\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramFunctionOnBracket.kt.after",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().filter(<caret>)\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramFunctionOnDot.kt",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().fil<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramFunctionOnDot.kt.after",
    "content": "class Some {\n\tfun filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException()\n}\n\nfun main(args: Array<String>) {\n    Some().filter {  }.<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramsFunction.kt",
    "content": "package somefortest\n\nfun test(a: Int) {\n}\n\nfun other() {\n    tes<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramsFunction.kt.after",
    "content": "package somefortest\n\nfun test(a: Int) {\n}\n\nfun other() {\n    test(<caret>)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramsFunctionOnDot.kt",
    "content": "fun myfoo(p : (String, Char) -> Boolean){}\n\nfun main(args: Array<String>) {\n    myfo<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/paramsFunctionOnDot.kt.after",
    "content": "fun myfoo(p : (String, Char) -> Boolean){}\n\nfun main(args: Array<String>) {\n    myfoo().<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/singleBrackets.kt",
    "content": "package Test.MyTest\n\nclass A {\n    companion object {\n        public fun testOther(a: Boolean) {\n\n        }\n\n        public fun testOther(a: Int) {\n\n        }\n    }\n}\n\nfun testMy() {\n    A.testOther<caret>\n}\n\n// ELEMENT: testOther"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/singleBrackets.kt.after",
    "content": "package Test.MyTest\n\nclass A {\n    companion object {\n        public fun testOther(a: Boolean) {\n\n        }\n\n        public fun testOther(a: Int) {\n\n        }\n    }\n}\n\nfun testMy() {\n    A.testOther(<caret>)\n}\n\n// ELEMENT: testOther"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/unitFunctionOnBracket.kt",
    "content": "fun myFoo() {\n\t\n}\n\nfun main(args: Array<String>) {\n    myFo<caret>\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/unitFunctionOnBracket.kt.after",
    "content": "fun myFoo() {\n\t\n}\n\nfun main(args: Array<String>) {\n    myFoo(<caret>)\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/unitFunctionOnDot.kt",
    "content": "fun myFoo() {\n\t\n}\n\nfun main(args: Array<String>) {\n    myFo<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/unitFunctionOnDot.kt.after",
    "content": "fun myFoo() {\n\t\n}\n\nfun main(args: Array<String>) {\n    myFoo().<caret>\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withLambdaAndBraces.kt",
    "content": "fun someFun(f: () -> Unit) {\n\tf()\n}\n\nfun main(args : Array<String>) {\n\tsomeF<caret> {  }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withLambdaAndBraces.kt.after",
    "content": "fun someFun(f: () -> Unit) {\n\tf()\n}\n\nfun main(args : Array<String>) {\n\tsomeFun {<caret>  }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withLambdaAndBracesOnDot.kt",
    "content": "fun someFun(f: () -> Unit) {\n\tf()\n}\n\nfun main(args : Array<String>) {\n\tsomeF<caret> {}\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withLambdaAndBracesOnDot.kt.after",
    "content": "fun someFun(f: () -> Unit) {\n\tf()\n}\n\nfun main(args : Array<String>) {\n\tsomeFun {}.\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBraces.kt",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithPar<caret>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBraces.kt.after",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithParams(<caret>)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBracesOnBrace.kt",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithPar<caret>()\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBracesOnBrace.kt.after",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithParams(<caret>)\n}\n\n// COMPLETION_CHAR: ("
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBracesOnDot.kt",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithPar<caret>()\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/handlers/withParamsAndBracesOnDot.kt.after",
    "content": "fun withParams(x: Int, y: Int) {\t\n}\n\nfun main(args : Array<String>) {\n\twithParams().\n}\n\n// COMPLETION_CHAR: ."
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/keywords/InFunctionTypePosition.kt",
    "content": "fun foo() {\n    val test : <caret>\n}\n\n// EXIST: suspend\n// NOTHING_ELSE\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/byCamelCaseLocal.kt",
    "content": "val SomeVal4 = 4\nval someVal1 = 1\nval SomeVal3 = 3\nval someVal2 = 2\n\nfun test() {\n    Some<caret>\n}\n\n// ORDER: SomeVal3\n// ORDER: SomeVal4"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/byPrefixMatchLocal.kt",
    "content": "val SomeVal4 = 4\nval someVal1 = 1\nval SomeVal3 = 3\nval someVal2 = 2\n\nfun test() {\n    some<caret>\n}\n\n// ORDER: someVal1\n// ORDER: someVal2\n// ORDER: SomeVal3\n// ORDER: SomeVal4\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/byPrefixWithImported.kt",
    "content": "import java.util.Date\n\nval date = 3\nval DATE = 10\n\nfun test() {\n    dat<caret>\n}\n\n// ORDER: date\n// ORDER: Date\n// ORDER: DATE"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/localBeforeNonImported.kt",
    "content": "fun test(c: Dat<caret>) {\n}\n\nclass DatK\n\n// ORDER: DatK\n// ORDER: Date"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/sortingForLocal.kt",
    "content": "val someVal3 = 3\nval someVal1 = 1\nval someVal5 = 5\nval someVal2 = 2\nval someVal4 = 4\n\nfun test() {\n    someVal<caret>\n}\n\n// ORDER: someVal1\n// ORDER: someVal2\n// ORDER: someVal3\n// ORDER: someVal4\n// ORDER: someVal5"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/completion/relevance/sortingForNonImported.kt",
    "content": "fun test(c: Date<caret>) {\n}\n\n// ORDER: Date\n// ORDER: DateDV\n// ORDER: DateFormat"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/diagnostics/FunctionCalleeExpressions.kt",
    "content": "// !WITH_NEW_INFERENCE\n// !CHECK_TYPE\n\npackage foo\n\nfun Any.foo() : () -> Unit {\n  return {}\n}\n\nfun Any.foo1() : (i : Int) -> Unit {\n  return {}\n}\n\nfun foo2() : (i : () -> Unit) -> Unit {\n  return {}\n}\n\nfun <T> fooT1(t : T) : () -> T {\n  return {t}\n}\n\nfun <T> fooT2() : (t : T) -> T {\n  return {it}\n}\n\nfun main(args : Array<String>) {\n    args.foo()()\n    args.foo1()(<!NO_VALUE_FOR_PARAMETER!>)<!>\n    <!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo1<!>()()\n    <!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo1<!>()(<!UNRESOLVED_REFERENCE!>a<!>)\n\n    args.foo1()(1)\n    args.foo1()(<!TYPE_MISMATCH!>\"1\"<!>)\n    <!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo1<!>()(\"1\")\n    <!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo1<!>()(<!UNRESOLVED_REFERENCE!>a<!>)\n\n    foo2()({})\n    foo2()<!TOO_MANY_ARGUMENTS!>{}<!>\n    (foo2()){}\n    (foo2()){<!OI;CANNOT_INFER_PARAMETER_TYPE, OI;EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> }\n    foo2()({<!OI;CANNOT_INFER_PARAMETER_TYPE, OI;EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> })\n\n    val a = fooT1(1)()\n    checkSubtype<Int>(a)\n\n    val b = fooT2<Int>()(1)\n    checkSubtype<Int>(b)\n    <!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT2<!>()(1) // : Any?\n\n    <!FUNCTION_EXPECTED!>1<!>()\n    <!FUNCTION_EXPECTED!>1<!>{}\n    <!FUNCTION_EXPECTED!>1<!>(){}\n}\n\nfun f() :  Int.() -> Unit = {}\n\nfun main1() {\n    1.(fun Int.() = 1)();\n    {1}();\n    (fun (x : Int) = x)(1)\n    1.(fun Int.(x : Int) = x)(1);\n    <!OI;REDUNDANT_LABEL_WARNING!>l@<!>{ 1 }()\n    1.((fun Int.() = 1))()\n    1.(f())()\n    1.if(true){f()}else{f()}()\n    1.if(true)(fun Int.() {})else{f()}()\n\n    1.<!FUNCTION_EXPECTED!>\"sdf\"<!>()\n\n    1.<!ILLEGAL_SELECTOR!>\"sdf\"<!>\n    1.<!ILLEGAL_SELECTOR!>{}<!>\n    1.<!ILLEGAL_SELECTOR!>if (true) {}<!>\n}\n\nfun test() {\n    {<!UNUSED_ANONYMOUS_PARAMETER!>x<!> : Int -> 1}(<!NO_VALUE_FOR_PARAMETER!>)<!>;\n    (fun Int.() = 1)(<!NO_VALUE_FOR_PARAMETER!>)<!>\n    <!TYPE_MISMATCH!>\"sd\"<!>.(fun Int.() = 1)()\n    val i : Int? = null\n    i<!UNSAFE_CALL!>.<!>(fun Int.() = 1)();\n    {}<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>()\n    1<!UNNECESSARY_SAFE_CALL!>?.<!>(fun Int.() = 1)()\n    1.<!NO_RECEIVER_ALLOWED!>{}<!>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/diagnostics/FunctionCalleeExpressions.txt",
    "content": "package\n\npackage foo {\n    public fun f(): kotlin.Int.() -> kotlin.Unit\n    public fun foo2(): (i: () -> kotlin.Unit) -> kotlin.Unit\n    public fun </*0*/ T> fooT1(/*0*/ t: T): () -> T\n    public fun </*0*/ T> fooT2(): (t: T) -> T\n    public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit\n    public fun main1(): kotlin.Unit\n    public fun test(): kotlin.Unit\n    public fun kotlin.Any.foo(): () -> kotlin.Unit\n    public fun kotlin.Any.foo1(): (i: kotlin.Int) -> kotlin.Unit\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/diagnostics/annotationAsJavaAnnotationArgument.kt",
    "content": "// FILE: Ann.java\nimport java.lang.annotation.Repeatable;\n\n@Repeatable(Anns.class)\npublic @interface Ann {}\n\n// FILE: Anns.java\npublic @interface Anns {\n    Ann[] value();\n}\n\n// FILE: Aaa.kt\n@Ann\nclass Aaa\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/diagnostics/constAsJavaAnnotationArgument.kt",
    "content": "// FILE: Consts.java\npublic interface Consts {\n\tshort value = 5\n}\n\n// FILE: Ann.java\npublic @interface Ann {\n\tshort value();\n}\n\n// FILE: Aaa.kt\n@Ann(Consts.value)\nclass Aaa\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/diagnostics/resolveConstructor.kt",
    "content": "// FILE: Aaa.java\n\npublic class Aaa {\n}\n\n// FILE: bbb.kt\n\nfun Aaa.some(): Aaa = Aaa()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassAllUsages.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: usages\npublic class <caret>A {\n    public String bar = \"bar\";\n    public static String BAR = \"BAR\";\n\n    public A() {\n\n    }\n\n    public void foo() {\n\n    }\n\n    public static void foos() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassAllUsages.1.kt",
    "content": "public class X(bar: String? = A.BAR): A() {\n    var next: A? = A()\n    val myBar: String? = A.BAR\n\n    init {\n        A.BAR = \"\"\n        A.foos()\n    }\n\n    fun foo(a: A) {\n        val aa: A = a\n        aa.bar = \"\"\n    }\n\n    fun getNext(): A? {\n        return next\n    }\n\n    public override fun foo() {\n        super<A>.foo()\n    }\n\n    companion object: A() {\n\n    }\n}\n\nobject O: A() {\n\n}\n\nfun X.bar(a: A = A()) {\n\n}\n\nfun Any.toA(): A? {\n    return if (this is A) this as A else null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassAllUsages.results.txt",
    "content": "Class/object property type 2 var next: A? = A()\nFunction return types 15 fun getNext(): A? {\nFunction return types 36 fun Any.toA(): A? {\nLocal variable declaration 11 val aa: A = a\nNested class/object 1 public class X(bar: String? = A.BAR): A() {\nNested class/object 3 val myBar: String? = A.BAR\nNested class/object 6 A.BAR = \"\"\nNested class/object 7 A.foos()\nNew instance creation 2 var next: A? = A()\nNew instance creation 32 fun X.bar(a: A = A()) {\nParameter type 10 fun foo(a: A) {\nParameter type 32 fun X.bar(a: A = A()) {\nSuper type qualifier 20 super<A>.foo()\nSupertype 1 public class X(bar: String? = A.BAR): A() {\nSupertype 23 companion object: A() {\nSupertype 28 object O: A() {\nTarget type of 'is' operation 37 return if (this is A) this as A else null\nUsage in cast target type 37 return if (this is A) this as A else null\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedAnonymousObjects.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedAnonymousObjects.1.kt",
    "content": "fun foo() {\n    public interface T: A\n\n    val a = object: A() {}\n\n    fun bar() {\n        val b = object: T {}\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedAnonymousObjects.results.txt",
    "content": "Unclassified usage 2 public interface T: A\nUnclassified usage 4 val a = object: A() {}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedClasses.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedClasses.1.kt",
    "content": "public open class X: A()\n\npublic interface T: A\n\npublic open class Y: X()\n\npublic class Z: Y(), T"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedClasses.results.txt",
    "content": "Unclassified usage 1 public open class X: A()\nUnclassified usage 3 public interface T: A"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerClasses.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerClasses.1.kt",
    "content": "public class Outer {\n    public open class X: A()\n\n    public interface T: A\n\n    public class Inner {\n        public open class Y: X()\n\n        public class Z: Y(), T\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerClasses.results.txt",
    "content": "Unclassified usage 2 public open class X: A()\nUnclassified usage 4 public interface T: A"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerObjects.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerObjects.1.kt",
    "content": "class Outer {\n    public interface T: A\n\n    public object O1: A()\n\n    class Inner {\n        public object O2: T\n    }\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedInnerObjects.results.txt",
    "content": "Unclassified usage 2 public interface T: A\nUnclassified usage 4 public object O1: A()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalClasses.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalClasses.1.kt",
    "content": "fun foo() {\n    public open class X: A()\n\n    public interface T: A\n\n    fun bar() {\n        public open class Y: X()\n\n        public class Z: Y(), T\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalClasses.results.txt",
    "content": "Unclassified usage 2 public open class X: A()\nUnclassified usage 4 public interface T: A"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalObjects.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalObjects.1.kt",
    "content": "fun foo() {\n    public interface T: A\n\n    public object O1: A()\n\n    fun bar() {\n        public object O2: T\n    }\n}\n\n\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedLocalObjects.results.txt",
    "content": "Unclassified usage 2 public interface T: A\nUnclassified usage 4 public object O1: A()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedObjects.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedClasses\npublic class <caret>A {\n    public A() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedObjects.1.kt",
    "content": "public interface T: A\n\npublic object O1: A()\n\npublic object O2: T\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassDerivedObjects.results.txt",
    "content": "Unclassified usage 1 public interface T: A\nUnclassified usage 3 public object O1: A()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassWithImplicitConstructorAllUsages.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: usages\npublic class <caret>A {\n    public String bar = \"bar\";\n    public static String BAR = \"BAR\";\n\n    public void foo() {\n\n    }\n\n    public static void foos() {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassWithImplicitConstructorAllUsages.1.kt",
    "content": "public class X(bar: String? = A.BAR): A() {\n    var next: A? = A()\n    val myBar: String? = A.BAR\n\n    init {\n        A.BAR = \"\"\n        A.foos()\n    }\n\n    fun foo(a: A) {\n        val aa: A = a\n        aa.bar = \"\"\n    }\n\n    fun getNext(): A? {\n        return next\n    }\n\n    public override fun foo() {\n        super<A>.foo()\n    }\n\n    companion object: A() {\n\n    }\n}\n\nobject O: A() {\n\n}\n\nfun X.bar(a: A = A()) {\n\n}\n\nfun Any.toA(): A? {\n    return if (this is A) this as A else null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKClassWithImplicitConstructorAllUsages.results.txt",
    "content": "Class/object property type 2 var next: A? = A()\nFunction return types 15 fun getNext(): A? {\nFunction return types 36 fun Any.toA(): A? {\nLocal variable declaration 11 val aa: A = a\nNested class/object 1 public class X(bar: String? = A.BAR): A() {\nNested class/object 3 val myBar: String? = A.BAR\nNested class/object 6 A.BAR = \"\"\nNested class/object 7 A.foos()\nNew instance creation 2 var next: A? = A()\nNew instance creation 32 fun X.bar(a: A = A()) {\nParameter type 10 fun foo(a: A) {\nParameter type 32 fun X.bar(a: A = A()) {\nSuper type qualifier 20 super<A>.foo()\nSupertype 1 public class X(bar: String? = A.BAR): A() {\nSupertype 23 companion object: A() {\nSupertype 28 object O: A() {\nTarget type of 'is' operation 37 return if (this is A) this as A else null\nUsage in cast target type 37 return if (this is A) this as A else null\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKDerivedInterfaces.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: derivedInterfaces\npublic interface <caret>A {\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKDerivedInterfaces.1.kt",
    "content": "public open class X: A\n\npublic interface T: A\n\npublic open class Y: X()\n\npublic class Z: Y(), T"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKDerivedInterfaces.results.txt",
    "content": "Unclassified usage (3: 18) public interface T: A\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKNestedClassAllUsages.0.java",
    "content": "// PSI_ELEMENT: com.intellij.psi.PsiClass\n// OPTIONS: usages\npublic class Outer {\n    public static class <caret>A {\n        public String bar = \"bar\";\n        public static String BAR = \"BAR\";\n\n        public A() {\n\n        }\n\n        public void foo() {\n\n        }\n\n        public static void foos() {\n\n        }\n    }\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKNestedClassAllUsages.1.kt",
    "content": "public class X(bar: String? = Outer.A.BAR): Outer.A() {\n    var next: Outer.A? = Outer.A()\n    val myBar: String? = Outer.A.BAR\n\n    init {\n        Outer.A.BAR = \"\"\n        Outer.A.foos()\n    }\n\n    fun foo(a: Outer.A) {\n        val aa: Outer.A = a\n        aa.bar = \"\"\n    }\n\n    fun getNext(): Outer.A? {\n        return next\n    }\n\n    public override fun foo() {\n        super<Outer.A>.foo()\n    }\n\n    companion object: Outer.A() {\n\n    }\n}\n\nobject O: Outer.A() {\n\n}\n\nfun X.bar(a: Outer.A = Outer.A()) {\n\n}\n\nfun Any.toA(): Outer.A? {\n    return if (this is Outer.A) this as Outer.A else null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/java/JKNestedClassAllUsages.results.txt",
    "content": "Class/object property type 2 var next: Outer.A? = Outer.A()\nFunction return types 15 fun getNext(): Outer.A? {\nFunction return types 36 fun Any.toA(): Outer.A? {\nLocal variable declaration 11 val aa: Outer.A = a\nNested class/object 1 public class X(bar: String? = Outer.A.BAR): Outer.A() {\nNested class/object 3 val myBar: String? = Outer.A.BAR\nNested class/object 6 Outer.A.BAR = \"\"\nNested class/object 7 Outer.A.foos()\nNew instance creation 2 var next: Outer.A? = Outer.A()\nNew instance creation 32 fun X.bar(a: Outer.A = Outer.A()) {\nParameter type 10 fun foo(a: Outer.A) {\nParameter type 32 fun X.bar(a: Outer.A = Outer.A()) {\nSuper type qualifier 20 super<Outer.A>.foo()\nSupertype 1 public class X(bar: String? = Outer.A.BAR): Outer.A() {\nSupertype 23 companion object: Outer.A() {\nSupertype 28 object O: Outer.A() {\nTarget type of 'is' operation 37 return if (this is Outer.A) this as Outer.A else null\nUsage in cast target type 37 return if (this is Outer.A) this as Outer.A else null\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/javaMethodUsages.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction\n// OPTIONS: usages\npackage testing\n\npublic open class Server() {\n    public open fun <caret>processRequest() = \"foo\"\n}\n\npublic class ServerEx(): Server() {\n    public override fun processRequest() = \"foofoo\"\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/javaMethodUsages.1.java",
    "content": "import testing.*;\n\nclass Client {\n    public void foo() {\n        new Server().processRequest();\n        new ServerEx().processRequest();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/javaMethodUsages.results.txt",
    "content": "Unclassified usage 5 new Server().processRequest();"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMethodUsages.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction\n// OPTIONS: usages\npackage server\n\npublic open class Server() {\n    open fun <caret>processRequest() = \"foo\"\n}\n\npublic class ServerEx(): Server() {\n    override fun processRequest() = \"foofoo\"\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMethodUsages.1.kt",
    "content": "import server.*;\n\nclass Client {\n    public fun foo() {\n        Server().processRequest()\n        ServerEx().processRequest()\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMethodUsages.results.txt",
    "content": "Function call 5 Server().processRequest()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMultiRefInImport.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction\n// OPTIONS: usages\npackage server\n\nfun <caret>foo() {\n\n}\n\nfun Int.foo() {\n\n}\n\nfun foo(n: Int) {\n\n}\n\nval foo: Int\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMultiRefInImport.1.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction\n// OPTIONS: usages\npackage client\n\nimport server.foo\n\nfun test() {\n    foo()\n    foo(1)\n    val t = foo\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findFunctionUsages/kotlinMultiRefInImport.results.txt",
    "content": "Function call 8 foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/javaObjectUsages.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetObjectDeclaration\npackage server\n\nobject <caret>O {\n    var foo: String = \"foo\"\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/javaObjectUsages.1.java",
    "content": "package client;\n\nimport server.O;\n\nclass Client {\n    void fooBar() {\n        System.out.println(\"foo = \" + O.INSTANCE$.getFoo());\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/javaObjectUsages.results.txt",
    "content": "Class static member access 7 System.out.println(\"foo = \" + O.INSTANCE$.getFoo());"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinNestedObjectUsages.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetObjectDeclaration\npackage a\n\nclass A {\n    object <caret>O {\n        var foo: String = \"foo\"\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinNestedObjectUsages.1.kt",
    "content": "package b\n\nimport a.A.O\nimport a.A\n\nclass Client {\n    fun fooBar() {\n        val a = A()\n\n        println(\"foo = ${a.O.foo}\")\n        val obj = a.O\n        println(\"length: ${obj.foo.length}\")\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinNestedObjectUsages.results.txt",
    "content": "Receiver 10 println(\"foo = ${a.O.foo}\")\nValue read 11 val obj = a.O\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinObjectUsages.0.kt",
    "content": "// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetObjectDeclaration\npackage server\n\nobject <caret>O {\n    var foo: String = \"foo\"\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinObjectUsages.1.kt",
    "content": "package client\n\nimport server.O\n\nclass Client {\n    fun fooBar() {\n        println(\"foo = ${O.foo}\")\n        val obj = O\n        println(\"length: ${obj.foo.length()}\")\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findObjectUsages/kotlinObjectUsages.results.txt",
    "content": "Receiver 7 println(\"foo = ${O.foo}\")\nValue read 8 val obj = O\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorByRef.0.kt",
    "content": "open class A (n: Int) {\n}\n\nclass B: A(0) {\n}\n\nclass C(): A(1)\n\nfun test() {\n    A()\n    <caret>A(1)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorByRef.results.txt",
    "content": "4 A(0)\n7 A(1)\n11 A(1)\n10 A()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorWithKeyword.0.kt",
    "content": "open class A <caret>constructor(n: Int) {\n}\n\nclass B: A(0) {\n}\n\nclass C(): A(1)\n\nfun test() {\n    A()\n    A(1)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPrimaryConstructorUsages/primaryConstructorWithKeyword.results.txt",
    "content": "4 A(0)\n7 A(1)\n11 A(1)\n10 A()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt",
    "content": "@file:kotlin.jvm.JvmName(\"ServerPackage\")\n// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetProperty\n// OPTIONS: usages\npackage server\n\nvar <caret>foo: String = \"foo\"\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.1.kt",
    "content": "package client\n\nimport server.foo\n\nclass Client {\n    fun fooBar() {\n        println(\"foo = ${server.foo}\")\n        println(\"length: ${server.foo.length()}\")\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.2.java",
    "content": "package client;\n\nimport server.ServerPackage;\n\nclass JClient {\n    void fooBar() {\n        System.out.println(\"foo = \" + ServerPackage.getFoo());\n        System.out.println(\"length: \" + ServerPackage.getFoo().length());\n        ServerPackage.setFoo(\"\");\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.results.txt",
    "content": "[kotlinTopLevelPropertyUsages.1.kt] Receiver 8 println(\"length: ${server.foo.length()}\")\n[kotlinTopLevelPropertyUsages.1.kt] Value read 7 println(\"foo = ${server.foo}\")\n[kotlinTopLevelPropertyUsages.2.java] Unclassified usage 7 System.out.println(\"foo = \" + ServerPackage.getFoo());\n[kotlinTopLevelPropertyUsages.2.java] Unclassified usage 8 System.out.println(\"length: \" + ServerPackage.getFoo().length());\n[kotlinTopLevelPropertyUsages.2.java] Unclassified usage 9 ServerPackage.setFoo(\"\");"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterFunCallInScript.after.kts",
    "content": "println()\n<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterFunCallInScript.kts",
    "content": "println()<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOneOpenBrace.after.kt",
    "content": "fun tt(){\n    <caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOneOpenBrace.kt",
    "content": "fun tt(){<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOpenBraceWithShift.after.kt",
    "content": "data class User(\n        val name: String) {\n    <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOpenBraceWithShift.kt",
    "content": "data class User(\n        val name: String) {<caret>}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOperatorIfWithoutBraces.after.kt",
    "content": "fun tt() {\n    if (true)\n        <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOperatorIfWithoutBraces.kt",
    "content": "fun tt() {\n    if (true)<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOperatorWhileWithoutBraces.after.kt",
    "content": "fun tt() {\n    while (true)\n        <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/afterOperatorWhileWithoutBraces.kt",
    "content": "fun tt() {\n    while (true)<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/beforeCloseBrace.after.kt",
    "content": "{\n\n<caret>}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/beforeCloseBrace.kt",
    "content": "{\n<caret>}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/beforeFunctionStart.after.kt",
    "content": "\n<caret>fun tt() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/beforeFunctionStart.kt",
    "content": "<caret>fun tt() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesOnDifferentLine.after.kt",
    "content": "fun tt() {\n    <caret>\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesOnDifferentLine.kt",
    "content": "fun tt() {<caret>\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesOnOneLine.after.kt",
    "content": "{\n    <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesOnOneLine.kt",
    "content": "{<caret>}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesAtStart.after.kt",
    "content": "fun test() {\n    listOf(1).filter {\n        <caret>\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesAtStart.kt",
    "content": "fun test() {\n    listOf(1).filter {<caret>    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesEnd1.after.kt",
    "content": "fun test() {\n    listOf(1).filter {\n        <caret>\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesEnd1.kt",
    "content": "fun test() {\n    listOf(1).filter {       <caret>   }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesEnd2.after.kt",
    "content": "fun test() {\n    listOf(1).filter {\n        <caret>\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesEnd2.kt",
    "content": "fun test() {\n    listOf(1).filter {       <caret>}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesMiddle.after.kt",
    "content": "fun test() {\n    listOf(1).filter {\n        <caret>\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/betweenBracesWithSpacesMiddle.kt",
    "content": "fun test() {\n    listOf(1).filter { <caret> }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/breakLineAfterIfWithoutBraces.after.kt",
    "content": "fun tt() {\n    if (true)\n        true\n    <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/breakLineAfterIfWithoutBraces.kt",
    "content": "fun tt() {\n    if (true)\n        true<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/continuationAfterDotCall.after.kt",
    "content": "fun some() {\n    listOf(1, 2).\n            <caret>map { it >= 2 }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/continuationAfterDotCall.kt",
    "content": "fun some() {\n    listOf(1, 2).<caret>map { it >= 2 }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/continuationBeforeFunName.after.kt",
    "content": "fun\n        <caret>test() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/continuationBeforeFunName.kt",
    "content": "fun <caret>test() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/indentBeforeWhile.after.kt",
    "content": "fun test() {\n    val some = 1\n    \n    <caret>while (true) {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/indentBeforeWhile.kt",
    "content": "fun test() {\n    val some = 1\n    <caret>while (true) {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/lineBreakSaveIndent.after.kt",
    "content": "fun tt() {\n    \n    <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/lineBreakSaveIndent.kt",
    "content": "fun tt() {\n    <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/nestedOperatorsWithBraces.after.kt",
    "content": "fun tt() {\n    if (true) {\n        if (true) {\n            <caret>\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/nestedOperatorsWithBraces.kt",
    "content": "fun tt() {\n    if (true) {\n        if (true) {<caret>\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/nestedOperatorsWithoutBraces.after.kt",
    "content": "fun tt() {\n    if (true)\n        if (true)\n            <caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/nestedOperatorsWithoutBraces.kt",
    "content": "fun tt() {\n    if (true)\n        if (true)<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/newLineInParameters1.after.kt",
    "content": "fun test() {\n    fun some(a: Int, b: Int) {}\n    some(\n            <caret>12, 3)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/newLineInParameters1.kt",
    "content": "fun test() {\n    fun some(a: Int, b: Int) {}\n    some(<caret>12, 3)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/newLineInParameters2.after.kt",
    "content": "fun test() {\n    fun some(/*1*/a: Int, /*2*/b: Int) {}\n    some(12,\n            <caret>3)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/newLineInParameters2.kt",
    "content": "fun test() {\n    fun some(/*1*/a: Int, /*2*/b: Int) {}\n    some(12, <caret>3)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/sampleTest.after.kt",
    "content": "ab\n<caret>c"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/autoIndent/sampleTest.kt",
    "content": "ab<caret>c"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/blockCommentBeforeDeclaration.kt",
    "content": "class Cls{\n/*\n */\nfun test() {}\n    \n/*\n */\nval vls = 1\n    \n/*\n*/\ncompanion object {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/blockCommentBeforeDeclaration.kt.after",
    "content": "class Cls {\n    /*\n     */\n    fun test() {\n    }\n\n    /*\n     */\n    val vls = 1\n\n    /*\n    */\n    companion object {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/classesAndPropertiesFormatTest.kt",
    "content": "package format\n\nclass Foo {\nfun foo() {\n}\n\nval f: String? = null\n }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/classesAndPropertiesFormatTest.kt.after",
    "content": "package format\n\nclass Foo {\n    fun foo() {\n    }\n\n    val f: String? = null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/commentOnTheLastLineOfLambda.kt",
    "content": "fun main(args: Array<String>) {\nlistOf(\"A\").map {\nnull\n// Can't add newlines in 'map' lambda if this is the last/only line in the lambda\n}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/commentOnTheLastLineOfLambda.kt.after",
    "content": "fun main(args: Array<String>) {\n    listOf(\"A\").map {\n        null\n// Can't add newlines in 'map' lambda if this is the last/only line in the lambda\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/formatScriptFile.kts",
    "content": "with(Any()) {\nlistOf(  1).    apply {\n    fun test(x:Int,s:String):Any=19\n}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/formatScriptFile.kts.after",
    "content": "with(Any()) {\n    listOf(1).apply {\n        fun test(x: Int, s: String): Any = 19\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/formatSelection.kt",
    "content": "fun test1(x:Int,y:String) {}\n\n<selection>fun test2(x:Int):Int{return    1}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/formatSelection.kt.after",
    "content": "fun test1(x:Int,y:String) {}\n\nfun test2(x: Int): Int {\n    return 1\n}<caret>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInDoWhile.kt",
    "content": "fun aa() {\n    do {\n    println(\"some\")\n    } while (true)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInDoWhile.kt.after",
    "content": "fun aa() {\n    do {\n        println(\"some\")\n    } while (true)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInIfExpressionBlock.kt",
    "content": "fun sm() {\n    val aa = if (true) {\n    1\n    } else {\n2\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInIfExpressionBlock.kt.after",
    "content": "fun sm() {\n    val aa = if (true) {\n        1\n    } else {\n        2\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInPropertyAccessor.kt",
    "content": "class C {\n    var someProp: Int\n        get() = throw UnsupportedOperationException()\n        set(value) {\n        println(\"10\")\n        }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInPropertyAccessor.kt.after",
    "content": "class C {\n    var someProp: Int\n        get() = throw UnsupportedOperationException()\n        set(value) {\n            println(\"10\")\n        }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInWhenEntry.kt",
    "content": "fun a() {\n    when (1) {\n        is Int {\n        println()\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/indentInWhenEntry.kt.after",
    "content": "fun a() {\n    when (1) {\n        is Int {\n            println()\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/initIndent.kt",
    "content": "class Test {\ninit {\n\tval a = 1\n}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/initIndent.kt.after",
    "content": "class Test {\n    init {\n        val a = 1\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/lambdaInBlock.kt",
    "content": "fun test() {\n    listOf(1, 2).forEach { number ->\n        println(number)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/lambdaInBlock.kt.after",
    "content": "fun test() {\n    listOf(1, 2).forEach { number ->\n        println(number)\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/newLineAfterImportsAndPackage.kt",
    "content": "package some\nimport hello\nimport other\nfun test() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/newLineAfterImportsAndPackage.kt.after",
    "content": "package some\n\nimport hello\nimport other\n\nfun test() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/objectsAndLocalFunctionsFormatTest.kt",
    "content": "package format\n\nobject Foo {\n    fun foo() {\nfun localFoo() {\n  }\n}\n }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/objectsAndLocalFunctionsFormatTest.kt.after",
    "content": "package format\n\nobject Foo {\n    fun foo() {\n        fun localFoo() {\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/packageFunctionsFormatTest.kt",
    "content": "package format\n\nfun foo() {\nval s = \"\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/packageFunctionsFormatTest.kt.after",
    "content": "package format\n\nfun foo() {\n    val s = \"\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/respectCaretAfterFormatting.kt",
    "content": "fun nonFormatter(x:Int){\n    val x    =     10\n    \n    if(true){\n        \n            }\n    <caret>fun local() {}\n    fun other() {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/respectCaretAfterFormatting.kt.after",
    "content": "fun nonFormatter(x: Int) {\n    val x = 10\n\n    if (true) {\n\n    }\n    <caret>fun local() {}\n    fun other() {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withBlockComments.kt",
    "content": "class Hello {\n    /*\n    class classInComment {\n        fun someFun {\n        }\n    }\n    */\n    fun someFun() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withBlockComments.kt.after",
    "content": "class Hello {\n    /*\n    class classInComment {\n        fun someFun {\n        }\n    }\n    */\n    fun someFun() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withJavaDoc.kt",
    "content": "package some\n\n/**\n*\n*\n*/\nclass SomeTest {\n\t/**\n\t*\n\t* @param x\n\t*/\nfun someFun(x: Int) {\n}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withJavaDoc.kt.after",
    "content": "package some\n\n/**\n *\n *\n */\nclass SomeTest {\n    /**\n     *\n     * @param x\n     */\n    fun someFun(x: Int) {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withLineComments.kt",
    "content": "package some.test\n\n// Hello\n// Some\nclass SomeCls {\n//  Test\n//  Test1\n//  Test2\n\tfun function() {\n}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withLineComments.kt.after",
    "content": "package some.test\n\n// Hello\n// Some\nclass SomeCls {\n    //  Test\n//  Test1\n//  Test2\n    fun function() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withMutableVariable.kt",
    "content": "class C {\n    var someProp: Int\n    get() = throw UnsupportedOperationException()\n        set(value) {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withMutableVariable.kt.after",
    "content": "class C {\n    var someProp: Int\n        get() = throw UnsupportedOperationException()\n        set(value) {\n        }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withWhitespaceBeforeBrace.kt",
    "content": "package format\n\nclass Some{\n    \n    init{\n        \n    }\n\n    fun some(){\n        \n    }\n\n    fun some2() {\n        if (true){\n            \n        }\n    }\n\n  }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withWhitespaceBeforeBrace.kt.after",
    "content": "package format\n\nclass Some {\n\n    init {\n\n    }\n\n    fun some() {\n\n    }\n\n    fun some2() {\n        if (true) {\n\n        }\n    }\n\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withoutComments.kt",
    "content": "package org.jet.test\n\nclass SimpleTest\n\nfun topLevelFun() {\n\tfun localFun() {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/format/withoutComments.kt.after",
    "content": "package org.jet.test\n\nclass SimpleTest\n\nfun topLevelFun() {\n    fun localFun() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/blockComment.kt",
    "content": "<comment>/* test\n\ntest\n\n*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/forKeyword.kt",
    "content": "<keyword>for</keyword>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/function.kt",
    "content": "<keyword>fun</keyword> foo() {\n\t<keyword>fun</keyword> innerF() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/getterSetter.kt",
    "content": "<keyword>class</keyword> Cl {\n\t<keyword>var</keyword> x: Int = 1\n\t\t<keyword>set</keyword>() = 2\n\t\t<keyword>get</keyword>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/highlightCompanionObject.kt",
    "content": "<keyword>class</keyword> C {\n\t<keyword>companion</keyword> <keyword>object</keyword> {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/importKeyword.kt",
    "content": "<keyword>import</keyword> some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/inKeyword.kt",
    "content": "<keyword>in</keyword>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/interfaceKeyword.kt",
    "content": "<keyword>interface</keyword> Some {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocBasic.kt",
    "content": "<comment>/**</comment>\n<comment>* some</comment>\n<comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithEmptyLines.kt",
    "content": "<comment>/**</comment>\n\n<comment>* some</comment>\n<comment>*</comment>\n\n<comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithMyTag.kt",
    "content": "<comment>/**</comment>\n <comment>*</comment>\n <comment>* </comment>@myTag <comment>test</comment>\n <comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithParam.kt",
    "content": "<comment>/**</comment>\n <comment>*</comment>\n <comment>* </comment>@param T <comment>the type of a member in this group.</comment>\n <comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithProperty.kt",
    "content": "<comment>/**</comment>\n <comment>*</comment>\n <comment>* </comment>@property test\n <comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithSee.kt",
    "content": "<comment>/**</comment>\n <comment>*</comment>\n <comment>* </comment>@see NotComent <comment>text</comment>\n <comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithThrows.kt",
    "content": "<comment>/**</comment>\n <comment>*</comment>\n <comment>* </comment>@throws Some <comment>comment</comment>\n <comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/kdocWithoutLeadingAsterisk.kt",
    "content": "<comment>/**</comment>\n\n<comment>some text</comment>\n\n<comment>* some</comment>\n<comment>*</comment>\n\n<comment>*/</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/keywordWithText.kt",
    "content": "<keyword>in</keyword> some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/openKeyword.kt",
    "content": "<keyword>open</keyword> <keyword>class</keyword> Some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/singleLineComment.kt",
    "content": "<comment>// abc def</comment>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/softImportKeyword.kt",
    "content": "<keyword>class</keyword> some {\n\timport\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/softKeywords.kt",
    "content": "<keyword>import</keyword> some\n\n<keyword>open</keyword> <keyword>abstract</keyword> <keyword>class</keyword> Cls {\n\timport\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/stringInterpolation.kt",
    "content": "<keyword>val</keyword> xyz = 10\n<string>\"test: </string>$xyz<string>\"</string>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/stringToken.kt",
    "content": "<string>\"Hello\"</string>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/textWithTokenBetween.kt",
    "content": "sinus"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/textWithTokenInPrefix.kt",
    "content": "inprefix"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/basic/textWithTokenInSuffix.kt",
    "content": "main"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/afterFunctionName.kt",
    "content": "fun fnName<caret> {}\n\n// TYPE: Some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/afterFunctionName.kt.after",
    "content": "fun <pos>fnNameSome</pos> {}\n\n// TYPE: Some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/afterHighlightedPosition.kt",
    "content": "fun fnName() { <caret> }\n\n// TYPE: println()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/afterHighlightedPosition.kt.after",
    "content": "fun <pos>fnName</pos>() { println() }\n\n// TYPE: println()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/beforeFunctionName.kt",
    "content": "fun <caret>fnName() {}\n\n// TYPE: some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/beforeFunctionName.kt.after",
    "content": "fun <pos>somefnName</pos>() {}\n\n// TYPE: some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/beforeHighlightedPosition.kt",
    "content": "<caret>\nval ktProperty = 10\n\n// TYPE: val test = 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/beforeHighlightedPosition.kt.after",
    "content": "val test = 1\nval <pos>ktProperty</pos> = 10\n\n// TYPE: val test = 1"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersAfter.kt",
    "content": "fun fnName<caret>() {}\n\n// TYPE: /+-"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersAfter.kt.after",
    "content": "fun fnName/+-() {}\n\n// TYPE: /+-"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersBefore.kt",
    "content": "fun <caret>fnName() {}\n\n// TYPE: /+-"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersBefore.kt.after",
    "content": "fun /+-fnName() {}\n\n// TYPE: /+-"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersBeforeHighlightedPosition.kt",
    "content": "<caret>val someProperty = 10\n\n// TYPE: /-()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/illegalCharactersBeforeHighlightedPosition.kt.after",
    "content": "/-()val <pos>someProperty</pos> = 10\n\n// TYPE: /-()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/insideHighlightedPosition.kt",
    "content": "fun fn<caret>Name() {}\n\n// TYPE: some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/highlighting/positionUpdater/insideHighlightedPosition.kt.after",
    "content": "fun <pos>fnsomeName</pos>() {}\n\n// TYPE: some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/analyzerHasKotlinAnnotations.kt",
    "content": "import java.util.regex.Pattern\n\nfun main(args : Array<String>) {\n    println(Pattern.compile(\"Some\").matcher(\"Some\"))\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/analyzerHasKotlinRuntime.kt",
    "content": "fun main(args: Array<String>) {\n    println(\"Some\")\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/checkAnalyzerFoundError.kt",
    "content": "fun foo() {\n    <error>prin</error>()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/checkExistancePackageLevelFunctions/Bar.kt",
    "content": "fun topLevel1() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/checkExistancePackageLevelFunctions/Baz.kt",
    "content": "fun topLevel2() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/checkExistancePackageLevelFunctions/Foo.java",
    "content": "class Foo {\n\tpublic void some() {\n\t\tBarKt.topLevel1();\n\t\tBazKt.topLevel2();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/checkTestsFoundJavaError/J1.java",
    "content": "public class J1 {\n    public void foo() {\n        new <error>SomeTest</error>();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/companionObjectFromJava/Bar.kt",
    "content": "class Some {\n    companion object {\n        val bar = 1\n        fun func() = \"\"\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/companionObjectFromJava/Foo.java",
    "content": "public class Foo {\n    void foo() {\n        String str = Some.Companion.func();\n        int bar = Some.Companion.getBar();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/javaFromKotlin/Bar.kt",
    "content": "package testing\n\nfun foo() {\n    val x = Foo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/javaFromKotlin/Foo.java",
    "content": "package testing;\n\npublic class Foo {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinFromJava/Bar.kt",
    "content": "class Bar"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinFromJava/Foo.java",
    "content": "public class Foo {\n    public void foo() {\n        new Bar();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinInPackageFromJava/J1.java",
    "content": "import org.jetbrains.kotlin.test.Some;\n\npublic class J1 {\n    public void foo() {\n        new Some();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinInPackageFromJava/K1.kt",
    "content": "package org.jetbrains.kotlin.test\n\nclass Some"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinJavaKotlin/J1.java",
    "content": "public class J1 extends KFirst {\n    void baz() {}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinJavaKotlin/K1.kt",
    "content": "open class KFirst() {\n    fun foo() {\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinJavaKotlin/K2.kt",
    "content": "class K2: J1() {\n    fun bar() {\n        foo()\n        baz()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinWithErrorsFromJava/J1.java",
    "content": "public class J1 {\n    public void foo() {\n        Some some = new Some();\n        String str = some.method1();\n        some.method2();\n        some.method3(1);\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/kotlinWithErrorsFromJava/K1.kt",
    "content": "class Some {\n    fun method1(): String {\n    <error>}</error>\n\n    <error>fun method2()</error>\n\n    <error>fun method3(s: Integer)</error>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/packageLevelFunctionsFromJava/Bar.kt",
    "content": "package kotlin.eclipse.ide\n\nfun some(n: Integer): String = \"\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/packageLevelFunctionsFromJava/Foo.java",
    "content": "import kotlin.eclipse.ide.BarKt;\n\npublic class Foo {\n    void foo() {\n        String some = BarKt.some(1);\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/packageLevelPropertiesFromJava/Bar.kt",
    "content": "val x = 123\nval inc = { n: Int -> n + 1 }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/packageLevelPropertiesFromJava/Foo.java",
    "content": "import kotlin.jvm.functions.Function1;\n\npublic class Foo {\n    void foo() {\n        int x = BarKt.getX();\n        Function1<Integer, Integer> inc = BarKt.getInc();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/unresolvedPackageType/Bar.kt",
    "content": "package org.jet\n\nfun hello() {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/ide_analyzer/unresolvedPackageType/Baz.kt",
    "content": "package org.jet\n\nfun some() {\n\t<error>JetPackage</error>.hello()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/changeReturnTypeInScript.kts",
    "content": "fun testReturn(): List<Int> {\n    return listOf(1, 2).toType<caret>dArray()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/changeReturnTypeInScript.kts.after",
    "content": "fun testReturn(): Array<Int> {\n    return listOf(1, 2).toTypedArray()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/typeMismatchInReturnLambda.kt",
    "content": "fun foo(): String {\n    return 123.apply { }<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/typeMismatchInReturnLambda.kt.after",
    "content": "fun foo(): Int {\n    return 123.apply { }<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/typeMismatchInReturnLambdaWithLabel.kt",
    "content": "fun foo(): Int {\n    val greet = \"hello\"\n    return with(greet) {<caret>\n        return@with greet\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/changeReturnType/typeMismatchInReturnLambdaWithLabel.kt.after",
    "content": "fun foo(): String {\n    val greet = \"hello\"\n    return with(greet) {<caret>\n        return@with greet\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToBlockBody/implicitlyNonUnitFun.kt",
    "content": "interface Item {\n    fun title(): String\n    fun wight(): Int\n}\n\nclass Book: Item {\n    override fun <caret>title() = \"Book\"\n    override fun wight() = 12\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToBlockBody/implicitlyNonUnitFun.kt.after",
    "content": "interface Item {\n    fun title(): String\n    fun wight(): Int\n}\n\nclass Book: Item {\n    override fun title(): String {\n        return \"Book\"\n    }\n    override fun wight() = 12\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/anonymousObjectExpression.kt",
    "content": "interface I {\n    fun foo(): String\n}\n\nfun bar(): I {\n    <caret>return object: I {\n        override fun foo(): String {\n            return \"a\"\n        }\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/anonymousObjectExpression.kt.after",
    "content": "interface I {\n    fun foo(): String\n}\n\nfun bar(): I<caret> = object : I {\n    override fun foo(): String {\n        return \"a\"\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithImplicitUnitTypeWithThrow.kt",
    "content": "// WITH_RUNTIME\n\nfun foo() {\n    <caret>throw UnsupportedOperationException()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithImplicitUnitTypeWithThrow.kt.after",
    "content": "// WITH_RUNTIME\n\nfun foo(): Unit<caret> = throw UnsupportedOperationException()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithNothingType.kt",
    "content": "// WITH_RUNTIME\n\nfun foo(): Nothing {\n    <caret>throw UnsupportedOperationException()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithNothingType.kt.after",
    "content": "// WITH_RUNTIME\n\nfun foo(): Nothing<caret> = throw UnsupportedOperationException()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithReturn.kt",
    "content": "fun <caret>foo(): String {\n    return \"abc\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithReturn.kt.after",
    "content": "fun foo(): String<caret> = \"abc\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithUnitTypeWithThrow.kt",
    "content": "// WITH_RUNTIME\n\nfun foo(): Unit {\n    <caret>throw UnsupportedOperationException()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/convertToExpressionBody/funWithUnitTypeWithThrow.kt.after",
    "content": "// WITH_RUNTIME\n\nfun foo(): Unit<caret> = throw UnsupportedOperationException()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/implementMethods/implementMethodInScript.kts",
    "content": "interface IntInScript {\n    fun test()\n}\n\nprintln(obje<caret>ct : IntInScript {})"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/implementMethods/implementMethodInScript.kts.after",
    "content": "interface IntInScript {\n    fun test()\n}\n\nprintln(object : IntInScript {\n    override fun test() {\n        TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n    }\n})"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/replaceGetOrSet/replaceGetInScript.kts",
    "content": "val p = listOf(1, 2)\np.ge<caret>t(0)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/replaceGetOrSet/replaceGetInScript.kts.after",
    "content": "val p = listOf(1, 2)\np[0]"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/specifyType/ClassNameClashing.kt",
    "content": "// \"Specify type explicitly\" \"true\"\nfun getEntry() : Map.Entry<kotlin.Array<String>, java.sql.Array> {\n}\n\nval <caret>x = getEntry()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/specifyType/ClassNameClashing.kt.after",
    "content": "// \"Specify type explicitly\" \"true\"\nfun getEntry() : Map.Entry<kotlin.Array<String>, java.sql.Array> {\n}\n\nval x: Map.Entry<Array<String>, Array> = getEntry()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/specifyType/StringRedefined.kt",
    "content": "// \"Specify type explicitly\" \"true\"\nclass String {}\n\nval <caret>x = \"\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/intentions/specifyType/StringRedefined.kt.after",
    "content": "// \"Specify type explicitly\" \"true\"\nclass String {}\n\nval x: String = \"\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/launch/junit/RunTestExtendingTestCase.kt",
    "content": "import org.junit.Assert\nimport junit.framework.TestCase\n\npublic class SomeKt: TestCase() {\n\tfun testOK() {\n\t}\n\t\n\tfun testFail() {\n\t\tAssert.assertTrue(false);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/launch/junit/SimpleJUnitTests.kt",
    "content": "import org.junit.Test\nimport org.junit.Assert\nimport org.junit.Before\nimport org.junit.After\n\npublic class SomeKt {\n\tBefore fun setUp() {\n\t}\n\t\n\tAfter fun tearDown() {\n\t}\n\t\n\tTest fun okTest() {\n\t\tAssert.assertEquals(0, 0)\n\t}\n\t\n\tTest fun failTest() {\n\t\tAssert.assertEquals(0, 1)\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/classDefinitionTypoErrorTest.kt",
    "content": "package parsingMarkers\n\nclas Foo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/classDefinitionTypoErrorTest.kt.after",
    "content": "package parsingMarkers\n\n<error>clas</error> <error>Foo</error>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/excessBraceTypingErrorTest.kt",
    "content": "package parsingMarkers\n\nfun foo() {\n}<caret>\n\n// TYPE: }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/excessBraceTypingErrorTest.kt.after",
    "content": "package parsingMarkers\n\nfun foo() {\n}<error>}</error>\n\n// TYPE: }"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/missingClosingBraceErrorTest.kt",
    "content": "package parsingMarkers\n\nfun foo() {"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/missingClosingBraceErrorTest.kt.after",
    "content": "package parsingMarkers\n\nfun foo() <error>{</error>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/missingFunctionBodyErrorTest.kt",
    "content": "package parsingMarkers\n\nfun foo() =\n\nclass Foo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/markers/parsing/missingFunctionBodyErrorTest.kt.after",
    "content": "package parsingMarkers\n\nfun foo() <error>=</error>\n\nclass Foo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromGetterSyntheticProperty/Bar.kt.before",
    "content": "package navigation\n\nfun some() {\n    val foo = Foo()\n    foo.b<caret>ar\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromGetterSyntheticProperty/Foo.java.after",
    "content": "package navigation\n\npublic class Foo {\n    private int bar = 3;\n    \n    public int getBar<caret>() {\n        return bar;\n    }\n    \n    public void setBar(int x) {\n        bar = x;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromSetterSyntheticProperty/Bar.kt.before",
    "content": "package navigation\n\nfun some() {\n    val foo = Foo()\n    foo.b<caret>ar = 3\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromSetterSyntheticProperty/Foo.java.after",
    "content": "package navigation\n\npublic class Foo {\n    private int bar = 3;\n    \n    public int getBar() {\n        return bar;\n    }\n    \n    public void setBar<caret>(int x) {\n        bar = x;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromSyntheticPropertyOnlyWithGetter/Bar.kt.before",
    "content": "package navigation\n\nfun some() {\n    Foo().ba<caret>r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/fromSyntheticPropertyOnlyWithGetter/Foo.java.after",
    "content": "package navigation\n\npublic class Foo {\n    public int getBar<caret>() {\n       return 10;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/specifiedPackageLevelFunction/Bar.kt",
    "content": "package org.jet\n\nfun someTwo() {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/specifiedPackageLevelFunction/Baz.kt.after",
    "content": "package org.jet\n\nfun <caret>someOne() {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/specifiedPackageLevelFunction/Foo.java.before",
    "content": "package org.jet;\n\npublic class SomeJava extends SomeKotlin {\n\tpublic void callKotlin() {\n\t\tBazKt.someOn<caret>e();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toBasicProperty/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tval <caret>basicProp = 10\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toBasicProperty/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().get<caret>BasicProp();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toBasicTopLevelProperty/Bar.kt.after",
    "content": "package pckg.navigation\n\nval <caret>topLevelProp = 20"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toBasicTopLevelProperty/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.getTopLevelPro<caret>p();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toCompanionObject/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tcompanion <caret>object {\n\t\tfun asStatic() {\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toCompanionObject/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tSomeKotlin.Compan<caret>ion.asStatic();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFilePart/Baz.kt.after",
    "content": "<caret>package org.jet\n\nfun someOne() {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFilePart/Foo.java.before",
    "content": "package org.jet;\n\npublic class SomeJava extends SomeKotlin {\n    public void callKotlin() {\n        Baz<caret>Kt.someOne();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunInBaseClass/Bar.kt.after",
    "content": "package org.jet.kot\n\npublic open class BaseClass {\n\tfun <caret>inBaseFun() {\n\t}\n}\n\npublic open class SomeKotlin : BaseClass() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunInBaseClass/Foo.java.before",
    "content": "package org.jet;\n\nimport org.jet.kot.SomeKotlin;\n\npublic class SomeJava {\n\tpublic void callKotlin() {\n\t\tnew SomeKotlin().inBas<caret>eFun();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInEnumClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass ForEnum {\n\tenum class KotlinEnum {\n\t\tABC\n\t\tABD\n\t\t\n\t\tfun <caret>inEnumEntry() {\n\t\t\t\n\t\t}\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInEnumClass/Foo.java.before",
    "content": "import pckg.navigation.ForEnum;\n\npublic class Foo {\n\tpublic void some() {\n\t\tForEnum.KotlinEnum.ABC.inEnumE<caret>ntry();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInFilePart/Baz.kt.after",
    "content": "package org.jet\n\nfun <caret>someOne() {\n\t\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInFilePart/Foo.java.before",
    "content": "package org.jet;\n\npublic class SomeJava extends SomeKotlin {\n    public void callKotlin() {\n        BazKt.someOn<caret>e();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInInnerClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tpublic class NestedKotlin {\n\t\tfun <caret>nestedSome() {\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInInnerClass/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\nimport pckg.navigation.SomeKotlin.NestedKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tNestedKotlin some = new SomeKotlin().some();\n\t\tsome.nes<caret>tedSome();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInObject/Bar.kt.after",
    "content": "package pckg.navigation\n\nobject KotlinObject { \n\tfun <caret>inObject() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionInObject/Foo.java.before",
    "content": "import pckg.navigation.KotlinObject;\n\npublic class Foo {\n\tpublic void some() {\n\t\tKotlinObject.INSTANCE.inOb<caret>ject();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithExistingConstructorEqualSignature/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass <caret>KtClass { \n\tfun ktFun() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithExistingConstructorEqualSignature/Foo.java.before",
    "content": "import pckg.navigation.KotlinObject;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew KtCl<caret>ass().ktFun();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithExistingEqualSignature/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun some1(x: Int): String = \"\"\nfun <caret>some2(x: Int): String = \"\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithExistingEqualSignature/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.s<caret>ome2(3);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithNameDuplicate/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun <caret>topLevelFun() {\n}\n\nclass SomeKotlin {\n\tfun topLevelFun() {\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithNameDuplicate/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.topL<caret>evelFun();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithNameDuplicateInClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun topLevelFun() {\n}\n\nclass SomeKotlin {\n\tfun <caret>topLevelFun() {\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithNameDuplicateInClass/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().topLev<caret>elFun();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithPlatformName/Bar.kt.after",
    "content": "package pckg.navigation\n\nimport kotlin.jvm.JvmmName\n\n@JvmName(\"doGetX\")\nfun <caret>getSome() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toFunctionWithPlatformName/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.doG<caret>etX();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tfun some() = NestedKotlin()\n\tpublic class <caret>NestedKotlin {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinClass/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\nimport pckg.navigation.SomeKotlin.NestedKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tN<caret>estedKotlin some = new SomeKotlin().some();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinEnumClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass ForEnum {\n\tenum class <caret>KotlinEnum {\n\t\tABC\n\t\tABD\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinEnumClass/Foo.java.before",
    "content": "import pckg.navigation.ForEnum;\nimport pckg.navigation.KotlinEnum;\n\npublic class Foo {\n\tpublic void some() {\n\t\tForEnum.KotlinE<caret>num;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinEnumEntry/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass ForEnum {\n\tenum class KotlinEnum {\n\t\t<caret>ABC\n\t\tABD\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toInnerKotlinEnumEntry/Foo.java.before",
    "content": "import pckg.navigation.ForEnum;\n\npublic class Foo {\n\tpublic void some() {\n\t\tForEnum.KotlinEnum.A<caret>BC;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinClass/Bar.kt.after",
    "content": "class <caret>SomeKotlin"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinClass/Foo.java.before",
    "content": "public class Foo {\n\tpublic void some() {\n\t\tnew Some<caret>Kotlin();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinClassInPackage/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass <caret>SomeKotlin"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinClassInPackage/Foo.java.before",
    "content": "import pckg.navigation\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKo<caret>tlin();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinEnumClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nenum class <caret>KotlinEnum {\n\tABC\n\tABD\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinEnumClass/Foo.java.before",
    "content": "import pckg.navigation.KotlinEnum;\n\npublic class Foo {\n\tpublic void some() {\n\t\tKotlin<caret>Enum.valueOf(\"ABC\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinEnumEntry/Bar.kt.after",
    "content": "package pckg.navigation\n\nenum class KotlinEnum {\n\tABC,\n\t<caret>ABD,\n\tABE\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinEnumEntry/Foo.java.before",
    "content": "import pckg.navigation.KotlinEnum;\n\npublic class Foo {\n\tpublic void some() {\n\t\tKotlinEnum.AB<caret>D;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinFunction/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tfun <caret>some() {\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinFunction/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().som<caret>e();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinFunctionInCompanion/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tcompanion object {\n\t\tfun <caret>asStatic() {\n\t\t\t\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinFunctionInCompanion/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tSomeKotlin.Companion.asStat<caret>ic();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinObject/Bar.kt.after",
    "content": "package pckg.navigation\n\nobject <caret>KotlinObject"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinObject/Foo.java.before",
    "content": "import pckg.navigation.KotlinObject;\n\npublic class Foo {\n\tpublic void some() {\n\t\tKo<caret>tlinObject k;\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinSuperClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nopen class <caret>SomeKotlin"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinSuperClass/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo extends SomeKotlin {\n\tpublic Foo() {\n\t\tsup<caret>er();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinTopLevelFunction/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun <caret>topLevelFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toKotlinTopLevelFunction/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.topLevel<caret>Fun();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMethodWithDefaultArg/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tfun <caret>methodWithDefaultArgs(x: Int = 10) {\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMethodWithDefaultArg/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().meth<caret>odWithDefaultArgs(1);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyFromGetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tvar <caret>mutableProp: Int = 1\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyFromGetter/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().getMutableP<caret>rop();\n\t\tnew SomeKotlin().setMutableProp(3);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyFromSetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tvar <caret>mutableProp: Int = 1\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyFromSetter/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().getMutableProp();\n\t\tnew SomeKotlin().setMutabl<caret>eProp(3);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyInCompanion/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n    companion object {\n        var <caret>foo: String = \"foo\"\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toMutablePropertyInCompanion/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n    public void some() {\n        SomeKotlin.Companion.setF<caret>oo(\"test\");\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toNamedCompanionObject/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tcompanion object <caret>Factory {\n\t\tfun asStatic() {\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toNamedCompanionObject/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tSomeKotlin.Fa<caret>ctory.asStatic();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toNestedCompanionObject/Bar.kt.after",
    "content": "package org.jet.kot\n\npublic open class SomeKotlin {\n\tcompanion object {\n\t\tfun asStatic() {\n\t\t\t\n\t\t}\n\t}\n\n\tfun getNested(): NestedInSome = NestedInSome()\n\t\n\tpublic class NestedInSome {\n\t\tcompanion <caret>object {\n\t\t\tfun staticInNested() {\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toNestedCompanionObject/Foo.java.before",
    "content": "package org.jet;\n\nimport org.jet.kot.SomeKotlin.NestedInSome;\n\npublic class SomeJava {\n\tpublic void callKotlin() {\n\t\tNestedInSome.Com<caret>panion.staticInNested();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toObjectInstance/Bar.kt.after",
    "content": "package pckg.navigation\n\nobject <caret>SomeObject"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toObjectInstance/Foo.java.before",
    "content": "import pckg.navigation.SomeObject;\n\npublic class Foo {\n\tpublic void some() {\n\t\tSomeObject.INSTA<caret>NCE.hashCode();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverloadMethod1/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin() {\n\tfun <caret>overloadMethod(x: Int) {\n\t\t\n\t}\n\t\n\tfun overloadMethod(x: String) {\n\t\t\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverloadMethod1/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().ove<caret>rloadMethod(1);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverloadMethod2/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin() {\n\tfun overloadMethod(x: Int) {\n\t\t\n\t}\n\t\n\tfun <caret>overloadMethod(x: String) {\n\t\t\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverloadMethod2/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().ove<caret>rloadMethod(\"\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverridenProperty/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin : BaseKotlin() {\n\toverride val <caret>ovProp: Int = 20\n}\n\nopen class BaseKotlin {\n\topen val ovProp: Int = 10 \n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toOverridenProperty/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().getOvP<caret>rop();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass <caret>KtWithTypes<T, R: Comparable<T>> "
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedClass/Foo.java.before",
    "content": "import pckg.navigation.KtWithTypes;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew KtWithTy<caret>pes<String, String>();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedFunction/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun <T> <caret>withType(id: T): T = id"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedFunction/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.wi<caret>thType(\"\");\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedFunctionWithOverload/Bar.kt.after",
    "content": "package pckg.navigation\n\nfun <T> withType(id: T): T = id\n\nfun <caret>withType(some: Int): Int = 3 "
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toParametrizedFunctionWithOverload/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.w<caret>ithType(3);\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPrimaryConstructor/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass KotlinConstructors<caret>() {\n\tconstructor(x: Int): this() {\n\t}\n\tconstructor(x: String): this() {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPrimaryConstructor/Foo.java.before",
    "content": "import pckg.navigation.KotlinConstructors;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew KotlinCon<caret>structors();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyInBaseClass/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin : BaseKotlin() \n\nopen class BaseKotlin {\n\topen val <caret>ovProp: Int = 10 \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyInBaseClass/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().getOvP<caret>rop();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyInCompanion/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n    companion object {\n        val <caret>foo: String = \"foo\"\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyInCompanion/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n    public void some() {\n        System.out.println(SomeKotlin.Companion.getF<caret>oo());\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyWithGetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tval basicProp: Int\n\t\t<caret>get() = 20\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyWithGetter/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().ge<caret>tBasicProp();\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyWithSetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass SomeKotlin {\n\tvar basicProp: Int\n\t\tget() = 20\n\t\t<caret>set(x: Int) {\n\t\t\tbasicProp = 10\n\t\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toPropertyWithSetter/Foo.java.before",
    "content": "import pckg.navigation.SomeKotlin;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew SomeKotlin().set<caret>BasicProp(2);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toSecondaryConstructor1/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass KotlinConstructors {\n\t<caret>constructor(x: Int) {\n\t}\n\tconstructor(x: String) {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toSecondaryConstructor1/Foo.java.before",
    "content": "import pckg.navigation.KotlinConstructors;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew KotlinCons<caret>tructors(3);\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toSecondaryConstructor2/Bar.kt.after",
    "content": "package pckg.navigation\n\nclass KotlinConstructors {\n\tconstructor(x: Int) {\n\t}\n\t<caret>constructor(x: String) {\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toSecondaryConstructor2/Foo.java.before",
    "content": "import pckg.navigation.KotlinConstructors;\n\npublic class Foo {\n\tpublic void some() {\n\t\tnew KotlinConstruct<caret>ors(\"\");\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toTopLevelPropertyWithGetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nval withGetter: Int\n\t<caret>get() = 10"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toTopLevelPropertyWithGetter/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.getWithG<caret>etter();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toTopLevelPropertyWithSetter/Bar.kt.after",
    "content": "package pckg.navigation\n\nvar withSetter: Int\n\tget() = 20\n\t<caret>set(x: Int) {\n\t\twithSetter = x\n\t} "
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/javaToKotlin/toTopLevelPropertyWithSetter/Foo.java.before",
    "content": "import pckg.navigation.BarKt;\n\npublic class Foo {\n\tpublic void some() {\n\t\tBarKt.setWithSett<caret>er();\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/scripts/basic/toFunction.kts",
    "content": "fun someFun() {\n}\n\nsom<caret>eFun()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/scripts/basic/toFunction.kts.after",
    "content": "fun <caret>someFun() {\n}\n\nsomeFun()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/scripts/basic/toVariable.kts",
    "content": "var sample = 10\n\nprintln(samp<caret>le)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/scripts/basic/toVariable.kts.after",
    "content": "var <caret>sample = 10\n\nprintln(sample)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaClassNavigation/Bar.kt.before",
    "content": "package navigation\n\npublic class Bar : <caret>Foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaClassNavigation/Foo.java.after",
    "content": "package navigation\n\npublic class Foo<caret> {\n\t\n\tpublic void method() {\n\t\t\n\t}\n\t\n\tpublic static void staticMethod() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaGetterMethod/Bar.kt.before",
    "content": "package navigation\n\nfun some() {\n    val foo = Foo()\n    foo.getBa<caret>r()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaGetterMethod/Foo.java.after",
    "content": "package navigation\n\npublic class Foo {\n    private int bar = 3;\n    \n    public int getBar<caret>() {\n        return bar;\n    }\n    \n    public void setBar(int x) {\n        bar = x;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaMethodNavigation/Bar.kt.before",
    "content": "package navigation\n\npublic class Bar : Foo()\n\nfun test() {\n\tBar().metho<caret>d()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toJavaMethodNavigation/Foo.java.after",
    "content": "package navigation\n\npublic class Foo {\n\t\n\tpublic void method<caret>() {\n\t\t\n\t}\n\t\n\tpublic static void staticMethod() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinClassNavigation/Bar.kt",
    "content": "package navigation\n\npublic open class Bar : Foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinClassNavigation/Baz.kt.before",
    "content": "package navigation\n\npublic class Baz : Bar()\n\nfun test() {\n\tFo<caret>o()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinClassNavigation/Foo.kt.after",
    "content": "package navigation\n\npublic open class <caret>Foo"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinMethodNavigation/Bar.kt",
    "content": "package navigation\n\npublic open class Bar : Foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinMethodNavigation/Baz.kt.before",
    "content": "package navigation\n\npublic class Baz : Bar()\n\nfun test() {\n\tBaz().fo<caret>o()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/toKotlinMethodNavigation/Foo.kt.after",
    "content": "package navigation\n\npublic open class Foo {\n\tfun <caret>foo() {\n\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileFromConstructorToClassNavigation.kt",
    "content": "package temp\n\nfun test() {\n\tBig<caret>Test()\n}\n\nclass BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileFromConstructorToClassNavigation.kt.after",
    "content": "package temp\n\nfun test() {\n\tBigTest()\n}\n\nclass <caret>BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileToClassNavigation.kt",
    "content": "package temp\n\nfun test(t: BigTe<caret>st) {\n}\n\nclass BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileToClassNavigation.kt.after",
    "content": "package temp\n\nfun test(t: BigTest) {\n}\n\nclass <caret>BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileToMethodNavigation.kt",
    "content": "package temp\n\nfun main(args : Array<String>) {\n    BigTest()\n    t<caret>est()\n}\n\nfun test() {\n}\n\nclass BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/navigation/withinFileToMethodNavigation.kt.after",
    "content": "package temp\n\nfun main(args : Array<String>) {\n    BigTest()\n    test()\n}\n\nfun <caret>test() {\n}\n\nclass BigTest"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/doNotInsertLinesForNoErrors.kt",
    "content": "package some\n\nimport java.util.ArrayList\n\nfun test(s: ArrayList<Int>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/doNotInsertLinesForNoErrors.kt.after",
    "content": "package some\n\nimport java.util.ArrayList\n\nfun test(s: ArrayList<Int>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importOneClass.kt",
    "content": "fun test(s: ArrayList<Int>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importOneClass.kt.after",
    "content": "import java.util.ArrayList\n\nfun test(s: ArrayList<Int>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importSeveralClasses.kt",
    "content": "fun test(s: ArrayList<Int>) {\n    val k: HashSet<Int>? = null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importSeveralClasses.kt.after",
    "content": "import java.util.ArrayList\nimport java.util.HashSet\n\nfun test(s: ArrayList<Int>) {\n    val k: HashSet<Int>? = null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importSeveralClassesWithExistingPackage.kt",
    "content": "package some\n\nfun test(s: ArrayList<Int>) {\n    val k: HashSet<Int>? = null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/importSeveralClassesWithExistingPackage.kt.after",
    "content": "package some\n\nimport java.util.ArrayList\nimport java.util.HashSet\n\nfun test(s: ArrayList<Int>) {\n    val k: HashSet<Int>? = null\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/includeImportsOnlyFromActiveFile/Bar.kt",
    "content": "fun test() {\n    val s: HashSet<Int>? = null\n    callFromBaz()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/includeImportsOnlyFromActiveFile/Bar.kt.after",
    "content": "import java.util.HashSet\n\nfun test() {\n    val s: HashSet<Int>? = null\n    callFromBaz()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/organizeImports/includeImportsOnlyFromActiveFile/Baz.kt",
    "content": "fun callFromBaz(l: ArrayList<Int>) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/after/JavaFoo.java",
    "content": "class JavaFoo extends Bar {\n    public static void main(String[] args) {\n        Bar foo = null;\n        new Bar() {\n        };\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/after/lib.kt",
    "content": "data class Pair<out A, out B>(\n        public val first: A,\n        public val second: B\n)\n\n\npublic fun listOf<T>(): List<T> = throw Error()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/after/main.kt",
    "content": "open class Bar : Throwable()\n\nval foo: Bar = Bar()\nval foo1: Bar = Bar()\n\nval foos: List<Bar> = listOf()\nval foos1: Array<Bar> = array()\n\nfun main(args: Array<String>) {\n    val foo: Bar = Bar()\n    val someVerySpecialFoo: Bar = Bar()\n    val fooAnother: Bar = Bar()\n\n    val anonymous = object : Bar() {\n    }\n\n    val (foo1: Bar, foos: List<Bar>) = Pair(Bar(), listOf<Bar>())\n\n    try {\n        for (foo2: Bar in listOf<Bar>()) {\n\n        }\n    } catch (foo: Bar) {\n\n    }\n\n    fun local(foo: Bar) {\n\n    }\n}\n\nfun topLevel(foo: Bar) {\n\n}\n\nfun collectionLikes(foos: List<Array<Bar>>, foos: List<Map<Bar, Bar>>) {\n\n}\n\nclass FooImpl : Bar()\n\nobject FooObj : Bar()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/before/JavaFoo.java",
    "content": "class JavaFoo extends Foo {\n    public static void main(String[] args) {\n        Foo foo = null;\n        new Foo() {\n        };\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/before/lib.kt",
    "content": "data class Pair<out A, out B>(\n        public val first: A,\n        public val second: B\n)\n\n\npublic fun listOf<T>(): List<T> = throw Error()\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/before/main.kt",
    "content": "open class Foo : Throwable()\n\nval foo: Foo = Foo()\nval foo1: Foo = Foo()\n\nval foos: List<Foo> = listOf()\nval foos1: Array<Foo> = array()\n\nfun main(args: Array<String>) {\n    val foo: Foo = Foo()\n    val someVerySpecialFoo: Foo = Foo()\n    val fooAnother: Foo = Foo()\n\n    val anonymous = object : Foo() {\n    }\n\n    val (foo1: Foo, foos: List<Foo>) = Pair(Foo(), listOf<Foo>())\n\n    try {\n        for (foo2: Foo in listOf<Foo>()) {\n\n        }\n    } catch (foo: Foo) {\n\n    }\n\n    fun local(foo: Foo) {\n\n    }\n}\n\nfun topLevel(foo: Foo) {\n\n}\n\nfun collectionLikes(foos: List<Array<Foo>>, foos: List<Map<Foo, Foo>>) {\n\n}\n\nclass FooImpl : Foo()\n\nobject FooObj : Foo()"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/automaticRenamer/simple.test",
    "content": "{\n  \"type\": \"KOTLIN_CLASS\",\n  \"classId\": \"/Foo\",\n  \"oldName\": \"Foo\",\n  \"newName\": \"Bar\",\n  \"mainFile\": \"main.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClass/after/RenameJavaClass.kt",
    "content": "package kotlin.testing\n\nimport testing.NewName\n\nclass Some : NewName() {\n    val test = NewName()\n\n    fun testFun(param : NewName) : NewName {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClass/after/testing/NewName.java",
    "content": "package testing;\n\npublic class NewName {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClass/before/RenameJavaClass.kt",
    "content": "package kotlin.testing\n\nimport testing.SomeClass\n\nclass Some : SomeClass() {\n    val test = SomeClass()\n\n    fun testFun(param : SomeClass) : SomeClass {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClass/before/testing/SomeClass.java",
    "content": "package testing;\n\npublic class SomeClass {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClass/renameJavaClass.test",
    "content": "{\n  \"type\": \"JAVA_CLASS\",\n  \"classId\": \"testing/SomeClass\",\n  \"newName\": \"NewName\",\n  \"mainFile\": \"RenameJavaClass.kt\",\n  \"oldName\": \"SomeClass\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClassSamePackage/after/RenameJavaClassSamePackage.kt",
    "content": "package testing\n\nclass Some : NewName() {\n    val test = NewName()\n\n    fun testFun(param : NewName) : NewName {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClassSamePackage/after/testing/NewName.java",
    "content": "package testing;\n\nclass NewName {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClassSamePackage/before/RenameJavaClassSamePackage.kt",
    "content": "package testing\n\nclass Some : SomeClass() {\n    val test = SomeClass()\n\n    fun testFun(param : SomeClass) : SomeClass {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClassSamePackage/before/testing/SomeClass.java",
    "content": "package testing;\n\nclass SomeClass {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaClassSamePackage/renameJavaClassSamePackage.test",
    "content": "{\n  \"type\": \"JAVA_CLASS\",\n  \"classId\": \"testing/SomeClass\",\n  \"newName\": \"NewName\",\n  \"mainFile\": \"RenameJavaClassSamePackage.kt\",\n  \"oldName\": \"SomeClass\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaInterface/after/RenameJavaClass.kt",
    "content": "package kotlin.testing\n\nimport testing.NewInterface\n\nclass Some(s: NewInterface) : NewInterface() {\n    val test = s\n\n    fun testFun(param : NewInterface) : NewInterface {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaInterface/after/testing/NewInterface.java",
    "content": "package testing;\n\npublic interface NewInterface {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaInterface/before/RenameJavaClass.kt",
    "content": "package kotlin.testing\n\nimport testing.SomeInterface\n\nclass Some(s: SomeInterface) : SomeInterface() {\n    val test = s\n\n    fun testFun(param : SomeInterface) : SomeInterface {\n        return test;\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaInterface/before/testing/SomeInterface.java",
    "content": "package testing;\n\npublic interface SomeInterface {\n}\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaInterface/renameJavaInterface.test",
    "content": "{\n  \"type\": \"JAVA_CLASS\",\n  \"classId\": \"testing/SomeInterface\",\n  \"newName\": \"NewInterface\",\n  \"oldName\": \"SomeInterface\",\n  \"comment\": \"For KT-4100 Imports doesn't change after java interface name refactoring\",\n  \"mainFile\": \"RenameJavaClass.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/after/MethodUsages.kt",
    "content": "package testing.kotlin\n\nimport testing.JavaClass\n\nclass KotlinClass: JavaClass() {\n    override fun bar(): String = \"Override\"\n}\n\nfun usages() {\n    val a = JavaClass().bar()\n    val b = KotlinClass().bar()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/after/testing/JavaClass.java",
    "content": "package testing;\n\npublic class JavaClass {\n    public String bar() {\n        return \"Test\";\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/before/MethodUsages.kt",
    "content": "package testing.kotlin\n\nimport testing.JavaClass\n\nclass KotlinClass: JavaClass() {\n    override fun foo(): String = \"Override\"\n}\n\nfun usages() {\n    val a = JavaClass().foo()\n    val b = KotlinClass().foo()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/before/testing/JavaClass.java",
    "content": "package testing;\n\npublic class JavaClass {\n    public String foo() {\n        return \"Test\";\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/javaBaseMethod.test",
    "content": "{\n  \"type\": \"JAVA_METHOD\",\n  \"classId\": \"testing/JavaClass\",\n  \"methodSignature\": \"String foo()\",\n  \"newName\": \"bar\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaMethod/kotlinOverridenMethod.test",
    "content": "{\n  \"type\": \"KOTLIN_FUNCTION\",\n  \"classId\": \"testing/kotlin/KotlinClass\",\n  \"oldName\": \"foo\",\n  \"newName\": \"bar\",\n  \"mainFile\": \"MethodUsages.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaStaticMethod/after/Some.kt",
    "content": "fun ktTest() {\n    SomeJava.javaRenamedTest()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaStaticMethod/after/SomeJava.java",
    "content": "public class SomeJava {\n    static void javaRenamedTest() {\n        \n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaStaticMethod/before/Some.kt",
    "content": "fun ktTest() {\n    SomeJava.test()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaStaticMethod/before/SomeJava.java",
    "content": "public class SomeJava {\n    static void test() {\n        \n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameJavaStaticMethod/renameJavaStaticMethod.test",
    "content": "{\n  \"oldName\": \"test\",\n  \"newName\": \"javaRenamedTest\",\n  \"mainFile\": \"Some.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/after/RenameKotlinBaseMethod.kt",
    "content": "package testing.rename\n\ninterface A {\n    fun second() : Int\n}\n\npublic open class B: A {\n    override fun second() = 1\n}\n\nclass C: B() {\n    override fun second() = 2\n}\n\nfun usages() {\n    val b = B()\n    val a: A = b\n    val c = C()\n\n    a.second()\n    b.second()\n    c.second()\n}\n\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/after/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.*;\n\nclass JavaClient {\n    public void foo(A a) {\n        a.second();\n        new B().second();\n        new C().second();\n        new D().second();\n    }\n\n    public static class D implements A {\n        @Override\n        public int second() {\n            return 3;\n        }\n    }\n\n    public static class E extends D {\n        @Override\n        public int second() {\n            return 4;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/before/RenameKotlinBaseMethod.kt",
    "content": "package testing.rename\n\ninterface A {\n    fun first() : Int\n}\n\npublic open class B: A {\n    override fun first() = 1\n}\n\nclass C: B() {\n    override fun first() = 2\n}\n\nfun usages() {\n    val b = B()\n    val a: A = b\n    val c = C()\n\n    a.first()\n    b.first()\n    c.first()\n}\n\n\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/before/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.*;\n\nclass JavaClient {\n    public void foo(A a) {\n        a.first();\n        new B().first();\n        new C().first();\n        new D().first();\n    }\n\n    public static class D implements A {\n        @Override\n        public int first() {\n            return 3;\n        }\n    }\n\n    public static class E extends D {\n        @Override\n        public int first() {\n            return 4;\n        }\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/javaWrapperForBaseFunction.test",
    "content": "{\n  \"type\": \"JAVA_METHOD\",\n  \"classId\": \"testing/rename/A\",\n  \"methodSignature\": \"void first()\",\n  \"newName\": \"second\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/javaWrapperForOverridenFunctionWithKotlinBase.test",
    "content": "{\n  \"type\": \"JAVA_METHOD\",\n  \"classId\": \"testing/JavaClient.D\",\n  \"methodSignature\": \"void first()\",\n  \"newName\": \"second\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinBaseMethod/kotlinBaseFunction.test",
    "content": "{\n  \"type\": \"KOTLIN_FUNCTION\",\n  \"classId\": \"testing/rename/A\",\n  \"oldName\": \"first\",\n  \"newName\": \"second\",\n  \"comment\": \"KT-2836 Rename method with all its implementations\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/after/RenameKotlinClass.kt",
    "content": "package testing.rename\n\npublic open class Third {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/after/Second.kt",
    "content": "package testing.rename2\n\nimport testing.rename.Third\nimport java.util.ArrayList\n\n// Extends testing.rename.First\npublic class Second : Third() {\n  val temp : testing.rename.Third = Third()\n\n  fun tempName(param : Third) : testing.rename.Third {\n    val local = Third()\n    val otherLocal = param\n    val arr = ArrayList<Third>()\n\n    return testing.rename.Third()\n  }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/after/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.Third;\n\nclass JavaClient {\n    private Third myField;\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/before/RenameKotlinClass.kt",
    "content": "package testing.rename\n\npublic open class First {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/before/Second.kt",
    "content": "package testing.rename2\n\nimport testing.rename.First\nimport java.util.ArrayList\n\n// Extends testing.rename.First\npublic class Second : First() {\n  val temp : testing.rename.First = First()\n\n  fun tempName(param : First) : testing.rename.First {\n    val local = First()\n    val otherLocal = param\n    val arr = ArrayList<First>()\n\n    return testing.rename.First()\n  }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/before/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.First;\n\nclass JavaClient {\n    private First myField;\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/javaWrapperForKotlinClass.test",
    "content": "{\n  \"type\": \"JAVA_CLASS\",\n  \"classId\": \"testing/rename/First\",\n  \"newName\": \"Third\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClass/kotlinClass.test",
    "content": "{\n  \"type\": \"KOTLIN_CLASS\",\n  \"classId\": \"testing/rename/First\",\n  \"oldName\": \"First\",\n  \"mainFile\": \"Second.kt\",\n  \"newName\": \"Third\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassByConstructorRef/after/main.kt",
    "content": "fun main(args : Array<String>) {\n    println(Bar().hashCode())\n}\n\nclass Bar"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassByConstructorRef/before/main.kt",
    "content": "fun main(args : Array<String>) {\n    println(Hello().hashCode())\n}\n\nclass Hello"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassByConstructorRef/renameKotlinClassByConstructorRef.test",
    "content": "{\n  \"oldName\": \"Hello\",\n  \"newName\": \"Bar\",\n  \"mainFile\": \"main.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassFromJava/after/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinRenamedCls cls = new KotlinRenamedCls();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassFromJava/after/KotlinCls.kt",
    "content": "class KotlinRenamedCls"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassFromJava/before/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinCls cls = new KotlinCls();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassFromJava/before/KotlinCls.kt",
    "content": "class KotlinCls"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinClassFromJava/renameKotlinClassFromJava.test",
    "content": "{\n  \"oldName\": \"KotlinCls\",\n  \"newName\": \"KotlinRenamedCls\",\n  \"mainFile\": \"JavaUsage.java\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/after/RenameKotlinMethod.kt",
    "content": "package testing.rename\n\npublic open class C {\n    public fun second() = 1\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/after/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.C;\n\nclass JavaClient {\n    public void foo() {\n        new C().second();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/before/RenameKotlinMethod.kt",
    "content": "package testing.rename\n\npublic open class C {\n    public fun first() = 1\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/before/testing/JavaClient.java",
    "content": "package testing;\n\nimport testing.rename.C;\n\nclass JavaClient {\n    public void foo() {\n        new C().first();\n    }\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/javaWrapperForKotlinMethod.test",
    "content": "{\n  \"type\": \"JAVA_METHOD\",\n  \"classId\": \"testing/rename/C\",\n  \"methodSignature\": \"int first()\",\n  \"newName\": \"second\",\n  \"comment\": \"KT-3256 Can't rename a Kotlin function from Java code\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethod/renameKotlinMethod.test",
    "content": "{\n  \"type\": \"KOTLIN_FUNCTION\",\n  \"classId\": \"testing/rename/C\",\n  \"oldName\": \"first\",\n  \"newName\": \"second\",\n  \"mainFile\": \"RenameKotlinMethod.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethodFromJava/after/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinCls cls = new KotlinCls();\n        cls.renamedMethodFromKotlin();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethodFromJava/after/KotlinCls.kt",
    "content": "class KotlinCls {\n    fun renamedMethodFromKotlin() {\n        renamedMethodFromKotlin()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethodFromJava/before/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinCls cls = new KotlinCls();\n        cls.methodFromKotlin();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethodFromJava/before/KotlinCls.kt",
    "content": "class KotlinCls {\n    fun methodFromKotlin() {\n        methodFromKotlin()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinMethodFromJava/renameKotlinMethodFromJava.test",
    "content": "{\n  \"oldName\": \"methodFromKotlin\",\n  \"newName\": \"renamedMethodFromKotlin\",\n  \"mainFile\": \"JavaUsage.java\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFun/after/Some.kt",
    "content": "fun kotlinRenamedTest() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFun/after/SomeJava.java",
    "content": "public class SomeJava {\n    static void test() {\n        SomeKt.kotlinRenamedTest();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFun/before/Some.kt",
    "content": "fun test() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFun/before/SomeJava.java",
    "content": "public class SomeJava {\n    static void test() {\n        SomeKt.test();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFun/renameKotlinTopLevelFun.test",
    "content": "{\n  \"oldName\": \"test\",\n  \"newName\": \"kotlinRenamedTest\",\n  \"mainFile\": \"Some.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFunFromJava/after/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinClsKt.renamedFun();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFunFromJava/after/KotlinCls.kt",
    "content": "fun renamedFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFunFromJava/before/JavaUsage.java",
    "content": "class JavaUsage {\n    public void foo() {\n        KotlinClsKt.kotlinTopLevelFun();\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFunFromJava/before/KotlinCls.kt",
    "content": "fun kotlinTopLevelFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/renameKotlinTopLevelFunFromJava/renameKotlinTopLevelFunFromJava.test",
    "content": "{\n  \"oldName\": \"kotlinTopLevelFun\",\n  \"newName\": \"renamedFun\",\n  \"mainFile\": \"JavaUsage.java\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameClassInScript/after/main.kts",
    "content": "class RenamedKClass\n\nfun sample(): RenamedKClass {\n    val k: RenamedKClass = RenamedKClass()\n    return k\n}\n\nRenamedKClass().apply {  }\nwith(RenamedKClass()) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameClassInScript/before/main.kts",
    "content": "class TestKClass\n\nfun sample(): TestKClass {\n    val k: TestKClass = TestKClass()\n    return k\n}\n\nTestKClass().apply {  }\nwith(TestKClass()) {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameClassInScript/info.test",
    "content": "{\n  \"oldName\": \"TestKClass\",\n  \"newName\": \"RenamedKClass\",\n  \"mainFile\": \"main.kts\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameFunctionInScript/after/main.kts",
    "content": "fun renamedFun() = \"test\"\n\nprintln(renamedFun())\nval k = renamedFun()\n\nfun sample() {\n    renamedFun()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameFunctionInScript/before/main.kts",
    "content": "fun testFun() = \"test\"\n\nprintln(testFun())\nval k = testFun()\n\nfun sample() {\n    testFun()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameFunctionInScript/info.test",
    "content": "{\n  \"oldName\": \"testFun\",\n  \"newName\": \"renamedFun\",\n  \"mainFile\": \"main.kts\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameInScriptLocally/after/main.kts",
    "content": "fun renamedFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameInScriptLocally/after/other.kts",
    "content": "fun sampleFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameInScriptLocally/before/main.kts",
    "content": "fun sampleFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameInScriptLocally/before/other.kts",
    "content": "fun sampleFun() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renameInScriptLocally/info.test",
    "content": "{\n  \"oldName\": \"sampleFun\",\n  \"newName\": \"renamedFun\",\n  \"mainFile\": \"main.kts\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renamePropertyInScript/after/main.kts",
    "content": "var renamedName = 10\n\nfun sample(): Int {\n    println(renamedName)\n    return renamedName\n}\n\nrun {\n    renamedName\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renamePropertyInScript/before/main.kts",
    "content": "var longVarName = 10\n\nfun sample(): Int {\n    println(longVarName)\n    return longVarName\n}\n\nrun {\n    longVarName\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/scripts/renamePropertyInScript/info.test",
    "content": "{\n  \"oldName\": \"longVarName\",\n  \"newName\": \"renamedName\",\n  \"mainFile\": \"main.kts\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/simple/after/main.kt",
    "content": "class Bar\n\nfun main(args : Array<String>) {\n    println(Bar().hashCode())\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/simple/before/main.kt",
    "content": "class Hello\n\nfun main(args : Array<String>) {\n    println(Hello().hashCode())\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/refactoring/rename/simple/info.test",
    "content": "{\n  \"type\": \"KOTLIN_FUNCTION\",\n  \"classId\": \"/A\",\n  \"oldName\": \"Hello\",\n  \"newName\": \"Bar\",\n  \"mainFile\": \"main.kt\"\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/scripts/templates/customEPResolver.kts",
    "content": "val date = Date()\n\nval f: String = \"\"\nval s: Int = 12\n\nval l = listOf(1, 2)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/scripts/templates/sample.testDef.kts",
    "content": "doSomething()\n\ncallFromBase(3)\n\nval file = File(\"someone\")\nval map = ConcurrentHashMap<Int, String>()\n\nval f: String = testNameParam\nval s: Int = secondParam\nval t: Int = thirdParam\n\nval result: String = testExtension(42)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/scripts/templates/sampleEx.testDef.kts",
    "content": "val file = File(\"someone\")\nval map = ConcurrentHashMap<Int, String>()\n\nval date = Date()\n\nval f: String = testNameParam\nval s: Int = secondParam\nval t: Int = thirdParam"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/scripts/templates/standard.kts",
    "content": "// check that we load standard definition if there isn't any valid template provider\n\nval x = 10\nprintln(x)"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/DocComment/0.kt",
    "content": "package p\n\n/**\n * Doc comment <caret>here\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/DocComment/1.kt",
    "content": "package p\n\n/**\n *<selection> Doc comment <caret>here</selection>\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/DocComment/2.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */</selection>\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/DocComment/3.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */\nfun foo() {\n}</selection>\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ForRange/0.kt",
    "content": "fun foo() {\n    for (i in 1..<caret>10) {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ForRange/1.kt",
    "content": "fun foo() {\n    for (i in 1..<selection><caret>10</selection>) {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ForRange/2.kt",
    "content": "fun foo() {\n    for (i in <selection>1..<caret>10</selection>) {\n\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ForRange/3.kt",
    "content": "fun foo() {\n    <selection>for (i in 1..<caret>10) {\n\n    }</selection>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentAfter/0.kt",
    "content": "fun a() : <caret>Int {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentAfter/1.kt",
    "content": "fun a() : <selection><caret>Int</selection> {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentAfter/2.kt",
    "content": "<selection>fun a() : <caret>Int {}</selection> // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentAfter/3.kt",
    "content": "<selection>fun a() : <caret>Int {} // fun a</selection>\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentBefore/0.kt",
    "content": "fun a() : Int {}\n\n// TODO: Refactor\nfun b() : <caret>Short {\n    f()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentBefore/1.kt",
    "content": "fun a() : Int {}\n\n// TODO: Refactor\nfun b() : <selection><caret>Short</selection> {\n    f()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentBefore/2.kt",
    "content": "fun a() : Int {}\n\n// TODO: Refactor\n<selection>fun b() : <caret>Short {\n    f()\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/FunctionWithLineCommentBefore/3.kt",
    "content": "fun a() : Int {}\n\n<selection>// TODO: Refactor\nfun b() : <caret>Short {\n    f()\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/0.kt",
    "content": "fun foo() {\n    if (a) {\n        <caret>f()\n        g()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/1.kt",
    "content": "fun foo() {\n    if (a) {\n        <selection><caret>f</selection>()\n        g()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/2.kt",
    "content": "fun foo() {\n    if (a) {\n        <selection><caret>f()</selection>\n        g()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/3.kt",
    "content": "fun foo() {\n    if (a) {\n        <selection><caret>f()\n        g()</selection>\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/4.kt",
    "content": "fun foo() {\n    if (a) <selection>{\n        <caret>f()\n        g()\n    }</selection>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfBody/5.kt",
    "content": "fun foo() {\n    <selection>if (a) {\n        <caret>f()\n        g()\n    }</selection>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfCondition/0.kt",
    "content": "fun foo() {\n    if (!<caret>a) {\n       bar()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfCondition/1.kt",
    "content": "fun foo() {\n    if (!<selection><caret>a</selection>) {\n       bar()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfCondition/2.kt",
    "content": "fun foo() {\n    if (<selection>!<caret>a</selection>) {\n       bar()\n    }\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/IfCondition/3.kt",
    "content": "fun foo() {\n    <selection>if (!<caret>a) {\n       bar()\n    }</selection>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/LineComment/0.kt",
    "content": "package p\n\nclass C{\n    // This is a <caret>val\n    val v = 1\n\n    fun foo(){}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/LineComment/1.kt",
    "content": "package p\n\nclass C{\n    <selection>// This is a <caret>val</selection>\n    val v = 1\n\n    fun foo(){}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/LineComment/2.kt",
    "content": "package p\n\nclass C{\n    <selection>// This is a <caret>val\n    val v = 1</selection>\n\n    fun foo(){}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ShiftOnWhitespace/0.kt",
    "content": "fun<caret> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ShiftOnWhitespace/1.kt",
    "content": "<selection>fun<caret></selection> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleComment/0.kt",
    "content": "fun main() {\n\tfun1()\n\t//this is a standalone<caret> comment\n\n\tfun2()\n}\nfun fun1() {}\nfun fun2() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleComment/1.kt",
    "content": "fun main() {\n\tfun1()\n\t<selection>//this is a standalone<caret> comment</selection>\n\n\tfun2()\n}\nfun fun1() {}\nfun fun2() {}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral/0.kt",
    "content": "val v = \"aaa <caret>bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral/1.kt",
    "content": "val v = \"<selection>aaa <caret>bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral/2.kt",
    "content": "val v = <selection>\"aaa <caret>bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral2/0.kt",
    "content": "fun main(args: Array<String>) {\n    println(\"<caret>foo bar\")\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral2/1.kt",
    "content": "fun main(args: Array<String>) {\n    println(\"<selection><caret>foo bar</selection>\")\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/SimpleStringLiteral2/2.kt",
    "content": "fun main(args: Array<String>) {\n    println(<selection>\"<caret>foo bar\"</selection>)\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/0.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/1.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        <selection>pr<caret>intln</selection>()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/2.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        <selection>pr<caret>intln()</selection>\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/3.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        <selection>println()\n\n\n        pr<caret>intln()\n        println()</selection>\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/4.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() <selection>{\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }</selection>\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/5.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    <selection>println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }</selection>\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/6.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    <selection>println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()</selection>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/7.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit <selection>{\n    println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/8.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\n<selection>fun foo() : Unit {\n    println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/Statements/9.kt",
    "content": "<selection>fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        pr<caret>intln()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/0.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/1.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() {\r\n        println()\r\n\r\n\r\n        <selection>pr<caret>intln</selection>()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/2.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() {\r\n        println()\r\n\r\n\r\n        <selection>pr<caret>intln()</selection>\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/3.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() {\r\n        <selection>println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()</selection>\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/4.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() <selection>{\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }</selection>\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/5.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    <selection>println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }</selection>\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/6.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    <selection>println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()</selection>\r\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/7.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit <selection>{\r\n    println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/8.kt",
    "content": "fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\n<selection>fun foo() : Unit {\r\n    println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/StatementsWithWindowsDelimiter/9.kt",
    "content": "<selection>fun main(args : Array<String>) {\r\n    for (i in 1..100) {\r\n        when {\r\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\r\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\r\n\r\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}\r\n            else -> println()\r\n        }\r\n    }\r\n}\r\n\r\nfun foo() : Unit {\r\n    println() {\r\n        println()\r\n\r\n\r\n        pr<caret>intln()\r\n        println()\r\n    }\r\n\r\n    println(array(1, 2, 3))\r\n    println()\r\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral1/0.kt",
    "content": "val v = \"aaa $x <caret>bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral1/1.kt",
    "content": "val v = \"aaa $x<selection> <caret>bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral1/2.kt",
    "content": "val v = \"<selection>aaa $x <caret>bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral1/3.kt",
    "content": "val v = <selection>\"aaa $x <caret>bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral2/0.kt",
    "content": "val v = \"aaa $<caret>x bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral2/1.kt",
    "content": "val v = \"aaa $<selection><caret>x</selection> bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral2/2.kt",
    "content": "val v = \"aaa <selection>$<caret>x</selection> bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral2/3.kt",
    "content": "val v = \"<selection>aaa $<caret>x bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral2/4.kt",
    "content": "val v = <selection>\"aaa $<caret>x bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/0.kt",
    "content": "val v = \"aaa ${<caret>x + y} bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/1.kt",
    "content": "val v = \"aaa ${<selection><caret>x</selection> + y} bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/2.kt",
    "content": "val v = \"aaa ${<selection><caret>x + y</selection>} bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/3.kt",
    "content": "val v = \"aaa <selection>${<caret>x + y}</selection> bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/4.kt",
    "content": "val v = \"<selection>aaa ${<caret>x + y} bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TemplateStringLiteral3/5.kt",
    "content": "val v = <selection>\"aaa ${<caret>x + y} bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeArguments/0.kt",
    "content": "fun <A, B> foo() {\n    foo<<selection>I<caret>nt</selection>, B>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeArguments/1.kt",
    "content": "fun <A, B> foo() {\n    foo<<selection>I<caret>nt, B</selection>>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeArguments/2.kt",
    "content": "fun <A, B> foo() {\n    <selection>foo<I<caret>nt, B>()</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeParameters/0.kt",
    "content": "fun <A, <selection><caret>B</selection>> foo() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeParameters/1.kt",
    "content": "fun <<selection>A, <caret>B</selection>> foo() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/TypeParameters/2.kt",
    "content": "<selection>fun <A, <caret>B> foo() {\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueArguments/0.kt",
    "content": "fun foo() {\n    foo(<selection><caret>1</selection>, 2)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueArguments/1.kt",
    "content": "fun foo() {\n    foo(<selection><caret>1, 2</selection>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueArguments/2.kt",
    "content": "fun foo() {\n    <selection>foo(<caret>1, 2)</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueParameters/0.kt",
    "content": "fun foo(a : Array<String>, <selection><caret>b : Int</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueParameters/1.kt",
    "content": "fun foo(<selection>a : Array<String>, <caret>b : Int</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/ValueParameters/2.kt",
    "content": "<selection>fun foo(a : Array<String>, <caret>b : Int) {\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WhenEntries/0.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); <selection>continue;}<caret></selection>\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        println()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WhenEntries/1.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> <selection>{print(i); continue;}<caret></selection>\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        println()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WhenEntries/2.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            <selection>(i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret></selection>\n            else -> println()\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        println()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WhenEntries/3.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        when {\n            <selection>i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret>\n            else -> println()</selection>\n        }\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        println()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WhenEntries/4.kt",
    "content": "fun main(args : Array<String>) {\n    for (i in 1..100) {\n        <selection>when {\n            i%3 == 0 -> {print(\"Fizz\"); continue;}\n            i%5 == 0 -> {print(\"Buzz\"); continue;}\n\n            (i%3 != 0 && i%5 != 0) -> {print(i); continue;}<caret>\n            else -> println()\n        }</selection>\n    }\n}\n\nfun foo() : Unit {\n    println() {\n        println()\n\n\n        println()\n        println()\n    }\n\n    println(array(1, 2, 3))\n    println()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WholeFileSelection/0.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/WholeFileSelection/1.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/0.kt",
    "content": "fun main(args : Array<String>)\n{\n    val x = te<caret>st1()\n}\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/1.kt",
    "content": "fun main(args : Array<String>)\n{\n    val x = <selection>te<caret>st1</selection>()\n}\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/2.kt",
    "content": "fun main(args : Array<String>)\n{\n    val x = <selection>te<caret>st1()</selection>\n}\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/3.kt",
    "content": "fun main(args : Array<String>)\n{\n    <selection>val x = te<caret>st1()</selection>\n}\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/4.kt",
    "content": "fun main(args : Array<String>)\n<selection>{\n    val x = te<caret>st1()\n}</selection>\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/5.kt",
    "content": "<selection>fun main(args : Array<String>)\n{\n    val x = te<caret>st1()\n}</selection>\nfun test1() :Int\n{\n    return 42\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectEnclosing/selectEnclosingFunctionNameWithoutSelection/6.kt",
    "content": "<selection>fun main(args : Array<String>)\n{\n    val x = te<caret>st1()\n}\nfun test1() :Int\n{\n    return 42\n}\n</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/0.kt",
    "content": "fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\t<selection>println(\"5 isn't more than 10\")</selection>\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/1.kt",
    "content": "fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\t<selection>println(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")</selection>\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/2.kt",
    "content": "fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\t<selection>println(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")</selection>\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/3.kt",
    "content": "fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t<selection>{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/4.kt",
    "content": "fun main(args: Array<String>)\n{\n\t<selection>if( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/5.kt",
    "content": "fun main(args: Array<String>)\n{\n\t<selection>if( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/6.kt",
    "content": "fun main(args: Array<String>)\n<selection>{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/7.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/8.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b</selection>\nfun less(a: Int, b: Int)\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatements/9.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}\nfun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/0.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\t<selection>println(\"5 isn't more than 10\")</selection>\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/1.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\t<selection>println(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")</selection>\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/2.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\t<selection>println(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")</selection>\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/3.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t<selection>{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/4.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\t<selection>if( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/5.kt",
    "content": "fun main(args: Array<String>)\r\n{\r\n\t<selection>if( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/6.kt",
    "content": "fun main(args: Array<String>)\r\n<selection>{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/7.kt",
    "content": "<selection>fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/8.kt",
    "content": "<selection>fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b</selection>\r\nfun less(a: Int, b: Int)\r\n\t= a < b"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/BlockStatementsWithWindowsDelimiter/9.kt",
    "content": "<selection>fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}\r\nfun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Classes/0.kt",
    "content": "class A {\n\t<caret>\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\tfun none() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Classes/1.kt",
    "content": "class A <selection>{\n\t<caret>\n}</selection>\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\tfun none() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Classes/2.kt",
    "content": "<selection>class A {\n\t<caret>\n}</selection>\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\tfun none() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Classes/3.kt",
    "content": "<selection>class A {\n\t<caret>\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}</selection>\nclass C {\n\tfun none() {\n\t\t\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Classes/4.kt",
    "content": "<selection>class A {\n\t<caret>\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\tfun none() {\n\t\t\n\t}\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/DocComment/0.kt",
    "content": "package p\n\n/**\n * Doc comment <caret>here\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/DocComment/1.kt",
    "content": "package p\n\n/**\n *<selection> Doc comment <caret>here</selection>\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/DocComment/2.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */</selection>\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/DocComment/3.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */\nfun foo() {\n}</selection>\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/DocComment/4.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */\nfun foo() {\n}\n\nfun bar(){}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/FunctionWithLineComments/0.kt",
    "content": "//comment before\nfun a() : <caret>Int {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/FunctionWithLineComments/1.kt",
    "content": "//comment before\nfun a() : <selection><caret>Int</selection> {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/FunctionWithLineComments/2.kt",
    "content": "//comment before\n<selection>fun a() : <caret>Int {}</selection> // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/FunctionWithLineComments/3.kt",
    "content": "//comment before\n<selection>fun a() : <caret>Int {} // fun a</selection>\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/FunctionWithLineComments/4.kt",
    "content": "<selection>//comment before\nfun a() : <caret>Int {} // fun a</selection>\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Functions/0.kt",
    "content": "<selection>fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}</selection>\nfun fun2(a: Int, b: Int): Int\n\t= a - b\nfun fun3() {\n\tprintln(\"I'm fun3\")\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Functions/1.kt",
    "content": "<selection>fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}\nfun fun2(a: Int, b: Int): Int\n\t= a - b</selection>\nfun fun3() {\n\tprintln(\"I'm fun3\")\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Functions/2.kt",
    "content": "<selection>fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}\nfun fun2(a: Int, b: Int): Int\n\t= a - b\nfun fun3() {\n\tprintln(\"I'm fun3\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/0.kt",
    "content": "package p\n\nimport jav<caret>a.io.File\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/1.kt",
    "content": "package p\n\nimport <selection>jav<caret>a</selection>.io.File\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/2.kt",
    "content": "package p\n\nimport <selection>jav<caret>a.io</selection>.File\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/3.kt",
    "content": "package p\n\nimport <selection>jav<caret>a.io.File</selection>\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/4.kt",
    "content": "package p\n\n<selection>import jav<caret>a.io.File</selection>\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/5.kt",
    "content": "package p\n\n<selection>import jav<caret>a.io.File\nimport java.util.ArrayList</selection>\nimport java.util.Vector\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/6.kt",
    "content": "package p\n\n<selection>import jav<caret>a.io.File\nimport java.util.ArrayList\nimport java.util.Vector</selection>\nimport java.io.Console\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/Imports/7.kt",
    "content": "package p\n\n<selection>import jav<caret>a.io.File\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/NonTraversableElement/0.kt",
    "content": "val property: String <caret>= \"Non-traversable test\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/NonTraversableElement/1.kt",
    "content": "val property: String <selection><caret>=</selection> \"Non-traversable test\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/NonTraversableElement/2.kt",
    "content": "<selection>val property: String <caret>= \"Non-traversable test\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ShiftOnWhitespace/0.kt",
    "content": "fun<caret> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ShiftOnWhitespace/1.kt",
    "content": "<selection>fun<caret></selection> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/0.kt",
    "content": "val v = \"a<caret>aa ${x + y} bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/1.kt",
    "content": "val v = \"<selection>a<caret>aa </selection>${x + y} bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/2.kt",
    "content": "val v = \"<selection>a<caret>aa ${x + y}</selection> bbb\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/3.kt",
    "content": "val v = \"<selection>a<caret>aa ${x + y} bbb</selection>\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/4.kt",
    "content": "val v = <selection>\"a<caret>aa ${x + y} bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TemplateStringLiteral/5.kt",
    "content": "<selection>val v = \"a<caret>aa ${x + y} bbb\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeArguments/0.kt",
    "content": "fun <A, B> foo() {\n    foo<<selection>I<caret>nt</selection>, B>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeArguments/1.kt",
    "content": "fun <A, B> foo() {\n    foo<<selection>I<caret>nt, B</selection>>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeArguments/2.kt",
    "content": "fun <A, B> foo() {\n    <selection>foo<I<caret>nt, B>()</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeParameters/0.kt",
    "content": "fun <<selection><caret>A</selection>, B> foo() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeParameters/1.kt",
    "content": "fun <<selection><caret>A, B</selection>> foo() {\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/TypeParameters/2.kt",
    "content": "<selection>fun <<caret>A, B> foo() {\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueArguments/0.kt",
    "content": "fun foo() {\n    foo(<selection><caret>1</selection>, 2, 3)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueArguments/1.kt",
    "content": "fun foo() {\n    foo(<selection><caret>1, 2</selection>, 3)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueArguments/2.kt",
    "content": "fun foo() {\n    foo(<selection><caret>1, 2, 3</selection>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueArguments/3.kt",
    "content": "fun foo() {\n    <selection>foo(<caret>1, 2, 3)</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueParameters/0.kt",
    "content": "fun foo(<selection><caret>a : Array<String></selection>, b : Int, c: String) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueParameters/1.kt",
    "content": "fun foo(<selection><caret>a : Array<String>, b : Int</selection>, c: String) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueParameters/2.kt",
    "content": "fun foo(<selection><caret>a : Array<String>, b : Int, c: String</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/ValueParameters/3.kt",
    "content": "<selection>fun foo(<caret>a : Array<String>, b : Int, c: String) {\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/WholeFile/0.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectNext/WholeFile/1.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/0.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\t<selection>println(\"And one more\")</selection>\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/1.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\t<selection>println(\"Some meaningless println\")\n\t\tprintln(\"And one more\")</selection>\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/2.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\t<selection>println(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")</selection>\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/3.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t<selection>{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/4.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\t<selection>if( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/5.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\t<selection>if( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/6.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n<selection>{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/7.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\n<selection>fun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/8.kt",
    "content": "fun more(a: Int, b: Int)\n\t= a > b\n<selection>fun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatements/9.kt",
    "content": "<selection>fun more(a: Int, b: Int)\n\t= a > b\nfun less(a: Int, b: Int)\n\t= a < b\nfun main(args: Array<String>)\n{\n\tif( more(5, 10) )\n\t{\n\t\tprintln(\"5 is more than 10\")\n\t} \n\telse \n\t{\n\t\tprintln(\"5 isn't more than 10\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n\tif( less(2, 3))\t\t{\n\t\tprintln(\"2 is less than 3\")\n\t} \n\telse \n\t{\n\t\tprintln(\"2 isn't less than 3\")\n\t\tprintln(\"Some meaningless println\")\n\t\tprintln(\"And one more\")\n\t}\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/0.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\t<selection>println(\"And one more\")</selection>\r\n\t}\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/1.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\t<selection>println(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")</selection>\r\n\t}\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/2.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\t<selection>println(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")</selection>\r\n\t}\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/3.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t<selection>{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/4.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\t<selection>if( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/5.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\t<selection>if( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}</selection>\r\n}\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/6.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n<selection>{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/7.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\n<selection>fun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/8.kt",
    "content": "fun more(a: Int, b: Int)\r\n\t= a > b\r\n<selection>fun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/BlockStatementsWithWindowsDelimiter/9.kt",
    "content": "<selection>fun more(a: Int, b: Int)\r\n\t= a > b\r\nfun less(a: Int, b: Int)\r\n\t= a < b\r\nfun main(args: Array<String>)\r\n{\r\n\tif( more(5, 10) )\r\n\t{\r\n\t\tprintln(\"5 is more than 10\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"5 isn't more than 10\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n\tif( less(2, 3))\t\t{\r\n\t\tprintln(\"2 is less than 3\")\r\n\t} \r\n\telse \r\n\t{\r\n\t\tprintln(\"2 isn't less than 3\")\r\n\t\tprintln(\"Some meaningless println\")\r\n\t\tprintln(\"And one more\")\r\n\t}\r\n}</selection>\r\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Classes/0.kt",
    "content": "class A {\n\tfun none() {\n\t\t\n\t}\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\t<caret>\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Classes/1.kt",
    "content": "class A {\n\tfun none() {\n\t\t\n\t}\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C <selection>{\n\t<caret>\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Classes/2.kt",
    "content": "class A {\n\tfun none() {\n\t\t\n\t}\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n<selection>class C {\n\t<caret>\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Classes/3.kt",
    "content": "class A {\n\tfun none() {\n\t\t\n\t}\n}\n<selection>class B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\t<caret>\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Classes/4.kt",
    "content": "<selection>class A {\n\tfun none() {\n\t\t\n\t}\n}\nclass B {\n\tfun meaningless() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\nclass C {\n\t<caret>\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/DocComment/0.kt",
    "content": "package p\n\n/**\n * Doc comment <caret>here\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/DocComment/1.kt",
    "content": "package p\n\n/**\n *<selection> Doc comment <caret>here</selection>\n */\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/DocComment/2.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */</selection>\nfun foo() {\n}\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/DocComment/3.kt",
    "content": "package p\n\n<selection>/**\n * Doc comment <caret>here\n */\nfun foo() {\n}</selection>\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/DocComment/4.kt",
    "content": "<selection>package p\n\n/**\n * Doc comment <caret>here\n */\nfun foo() {\n}</selection>\n\nfun bar(){}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/FunctionWithLineComments/0.kt",
    "content": "//comment before\nfun a() : <caret>Int {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/FunctionWithLineComments/1.kt",
    "content": "//comment before\nfun a() : <selection><caret>Int</selection> {} // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/FunctionWithLineComments/2.kt",
    "content": "//comment before\n<selection>fun a() : <caret>Int {}</selection> // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/FunctionWithLineComments/3.kt",
    "content": "<selection>//comment before\nfun a() : <caret>Int {}</selection> // fun a\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/FunctionWithLineComments/4.kt",
    "content": "<selection>//comment before\nfun a() : <caret>Int {} // fun a</selection>\n\nfun b() : Short {\n    f()\n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Functions/0.kt",
    "content": "fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}\nfun fun2(a: Int, b: Int): Int\n\t= a - b\n<selection>fun fun3() {\n\tprintln(\"I'm fun3\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Functions/1.kt",
    "content": "fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}\n<selection>fun fun2(a: Int, b: Int): Int\n\t= a - b\nfun fun3() {\n\tprintln(\"I'm fun3\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Functions/2.kt",
    "content": "<selection>fun fun1(a: Int, b: Int): Int {\n\treturn a+b\n}\nfun fun2(a: Int, b: Int): Int\n\t= a - b\nfun fun3() {\n\tprintln(\"I'm fun3\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/0.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\nimport jav<caret>a.io.File\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/1.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\nimport <selection>jav<caret>a</selection>.io.File\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/2.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\nimport <selection>jav<caret>a.io</selection>.File\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/3.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\nimport <selection>jav<caret>a.io.File</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/4.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\n<selection>import jav<caret>a.io.File</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/5.kt",
    "content": "package p\n\nimport java.util.ArrayList\nimport java.util.Vector\n<selection>import java.io.Console\nimport jav<caret>a.io.File</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/6.kt",
    "content": "package p\n\nimport java.util.ArrayList\n<selection>import java.util.Vector\nimport java.io.Console\nimport jav<caret>a.io.File</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/Imports/7.kt",
    "content": "package p\n\n<selection>import java.util.ArrayList\nimport java.util.Vector\nimport java.io.Console\nimport jav<caret>a.io.File</selection>\n\nclass NonSibling {\n\tfun AlsoNonSelectable() {\n\t\tprintln(\"You're not supposed to be here\")\n\t}\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/NonTraversableElement/0.kt",
    "content": "val property: String <caret>= \"Non-traversable test\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/NonTraversableElement/1.kt",
    "content": "val property: String <selection><caret>=</selection> \"Non-traversable test\""
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/NonTraversableElement/2.kt",
    "content": "<selection>val property: String <caret>= \"Non-traversable test\"</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ShiftOnWhitespace/0.kt",
    "content": "fun<caret> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ShiftOnWhitespace/1.kt",
    "content": "<selection>fun<caret></selection> main(args: Array<String>) {\n    \n}"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/0.kt",
    "content": "val v = \"aaa ${x + y} b<caret>bb\"\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/1.kt",
    "content": "val v = \"aaa ${x + y}<selection> b<caret>bb</selection>\"\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/2.kt",
    "content": "val v = \"aaa <selection>${x + y} b<caret>bb</selection>\"\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/3.kt",
    "content": "val v = \"<selection>aaa ${x + y} b<caret>bb</selection>\"\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/4.kt",
    "content": "val v = <selection>\"aaa ${x + y} b<caret>bb\"</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TemplateStringLiteral/5.kt",
    "content": "<selection>val v = \"aaa ${x + y} b<caret>bb\"</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeArguments/0.kt",
    "content": "fun <A, B> foo() {\n    foo<Int, B, <selection><caret>A</selection>>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeArguments/1.kt",
    "content": "fun <A, B> foo() {\n    foo<Int, <selection>B, <caret>A</selection>>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeArguments/2.kt",
    "content": "fun <A, B> foo() {\n    foo<<selection>Int, B, <caret>A</selection>>()\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeArguments/3.kt",
    "content": "fun <A, B> foo() {\n    <selection>foo<Int, B, <caret>A>()</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeParameters/0.kt",
    "content": "fun <A, B, <selection><caret>C</selection>> foo() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeParameters/1.kt",
    "content": "fun <A, <selection>B, <caret>C</selection>> foo() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeParameters/2.kt",
    "content": "fun <<selection>A, B, <caret>C</selection>> foo() {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/TypeParameters/3.kt",
    "content": "<selection>fun <A, B, <caret>C> foo() {\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueArguments/0.kt",
    "content": "fun foo() {\n    foo(1, 2, <selection><caret>3</selection>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueArguments/1.kt",
    "content": "fun foo() {\n    foo(1, <selection>2, <caret>3</selection>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueArguments/2.kt",
    "content": "fun foo() {\n    foo(<selection>1, 2, <caret>3</selection>)\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueArguments/3.kt",
    "content": "fun foo() {\n    <selection>foo(1, 2, <caret>3)</selection>\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueParameters/0.kt",
    "content": "fun foo(a : Array<String>, b : Int, <selection><caret>c: String</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueParameters/1.kt",
    "content": "fun foo(a : Array<String>, <selection>b : Int, <caret>c: String</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueParameters/2.kt",
    "content": "fun foo(<selection>a : Array<String>, b : Int, <caret>c: String</selection>) {\n}\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/ValueParameters/3.kt",
    "content": "<selection>fun foo(a : Array<String>, b : Int, <caret>c: String) {\n}</selection>\n"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/WholeFile/0.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-eclipse-ui-test/testData/wordSelection/selectPrevious/WholeFile/1.kt",
    "content": "<selection>fun main(args: Array<String>)\n{\n\tprintln(\"Whole file selection test!\")\n}</selection>"
  },
  {
    "path": "kotlin-weaving-feature/build.properties",
    "content": "bin.includes = feature.xml\n"
  },
  {
    "path": "kotlin-weaving-feature/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n      id=\"org.jetbrains.kotlin.weaving.feature\"\n      label=\"kotlin-weaving-feature\"\n      version=\"0.8.24.qualifier\"\n      provider-name=\"JetBrains\">\n\n   <includes\n         id=\"org.eclipse.equinox.weaving.sdk\"\n         version=\"0.0.0\"\n         optional=\"true\"/>\n\n   <plugin\n         id=\"org.aspectj.runtime\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.aspectj.weaver\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.equinox.weaving.aspectj\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n</feature>\n"
  },
  {
    "path": "kotlin-weaving-feature/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\n\txmlns=\"http://maven.apache.org/POM/4.0.0\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<modelVersion>4.0.0</modelVersion>\n\n\t<parent>\n\t\t<relativePath>../pom.xml</relativePath>\n\t\t<groupId>kotlin.eclipse</groupId>\n\t\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t\t<version>0.8.24-SNAPSHOT</version>\n\t</parent>\n\n\t<artifactId>org.jetbrains.kotlin.weaving.feature</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>eclipse-feature</packaging>\n\n</project>"
  },
  {
    "path": "maven-build/maven-build-install-offline.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.eclipse.m2e.Maven2LaunchConfigurationType\">\n<booleanAttribute key=\"M2_DEBUG_OUTPUT\" value=\"false\"/>\n<stringAttribute key=\"M2_GOALS\" value=\"install\"/>\n<booleanAttribute key=\"M2_NON_RECURSIVE\" value=\"false\"/>\n<booleanAttribute key=\"M2_OFFLINE\" value=\"true\"/>\n<stringAttribute key=\"M2_PROFILES\" value=\"\"/>\n<listAttribute key=\"M2_PROPERTIES\">\n<listEntry value=\"-f=maven_build\\pom.xml\"/>\n</listAttribute>\n<stringAttribute key=\"M2_RUNTIME\" value=\"EMBEDDED\"/>\n<booleanAttribute key=\"M2_SKIP_TESTS\" value=\"false\"/>\n<intAttribute key=\"M2_THREADS\" value=\"1\"/>\n<booleanAttribute key=\"M2_UPDATE_SNAPSHOTS\" value=\"false\"/>\n<stringAttribute key=\"M2_USER_SETTINGS\" value=\"\"/>\n<booleanAttribute key=\"M2_WORKSPACE_RESOLUTION\" value=\"false\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.WORKING_DIRECTORY\" value=\"${project_loc}/..\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "maven-build/maven-build-install.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.eclipse.m2e.Maven2LaunchConfigurationType\">\n<booleanAttribute key=\"M2_DEBUG_OUTPUT\" value=\"false\"/>\n<stringAttribute key=\"M2_GOALS\" value=\"install\"/>\n<booleanAttribute key=\"M2_NON_RECURSIVE\" value=\"false\"/>\n<booleanAttribute key=\"M2_OFFLINE\" value=\"false\"/>\n<stringAttribute key=\"M2_PROFILES\" value=\"\"/>\n<listAttribute key=\"M2_PROPERTIES\">\n<listEntry value=\"-f=maven_build\\pom.xml\"/>\n</listAttribute>\n<stringAttribute key=\"M2_RUNTIME\" value=\"EMBEDDED\"/>\n<booleanAttribute key=\"M2_SKIP_TESTS\" value=\"false\"/>\n<intAttribute key=\"M2_THREADS\" value=\"1\"/>\n<booleanAttribute key=\"M2_UPDATE_SNAPSHOTS\" value=\"false\"/>\n<stringAttribute key=\"M2_USER_SETTINGS\" value=\"\"/>\n<booleanAttribute key=\"M2_WORKSPACE_RESOLUTION\" value=\"false\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.WORKING_DIRECTORY\" value=\"${project_loc}/..\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "maven-build/maven-update-version.launch",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<launchConfiguration type=\"org.eclipse.m2e.Maven2LaunchConfigurationType\">\n<booleanAttribute key=\"M2_DEBUG_OUTPUT\" value=\"false\"/>\n<stringAttribute key=\"M2_GOALS\" value=\"org.eclipse.tycho:tycho-versions-plugin:0.22.0:set-version\"/>\n<booleanAttribute key=\"M2_NON_RECURSIVE\" value=\"false\"/>\n<booleanAttribute key=\"M2_OFFLINE\" value=\"false\"/>\n<stringAttribute key=\"M2_PROFILES\" value=\"\"/>\n<listAttribute key=\"M2_PROPERTIES\">\n<listEntry value=\"newVersion=0.8.24-SNAPSHOT\"/>\n</listAttribute>\n<stringAttribute key=\"M2_RUNTIME\" value=\"EMBEDDED\"/>\n<booleanAttribute key=\"M2_SKIP_TESTS\" value=\"false\"/>\n<intAttribute key=\"M2_THREADS\" value=\"1\"/>\n<booleanAttribute key=\"M2_UPDATE_SNAPSHOTS\" value=\"false\"/>\n<stringAttribute key=\"M2_USER_SETTINGS\" value=\"\"/>\n<booleanAttribute key=\"M2_WORKSPACE_RESOLUTION\" value=\"false\"/>\n<stringAttribute key=\"org.eclipse.jdt.launching.WORKING_DIRECTORY\" value=\"${project_loc}/..\"/>\n</launchConfiguration>\n"
  },
  {
    "path": "pom.xml",
    "content": "<project>\n\t<modelVersion>4.0.0</modelVersion>\n\t<groupId>kotlin.eclipse</groupId>\n\t<artifactId>kotlin.eclipse.plugin</artifactId>\n\t<version>0.8.24-SNAPSHOT</version>\n\t<packaging>pom</packaging>\n\n\t<modules>\n\t\t<module>kotlin-bundled-compiler</module>\n\t\t<module>kotlin-eclipse-aspects</module>\n\t\t<module>kotlin-eclipse-core</module>\n\t\t<module>kotlin-eclipse-ui</module>\n\t\t<!--<module>kotlin-eclipse-ui-test</module>-->\n\t\t<module>kotlin-eclipse-test-framework</module>\n\t\t<module>kotlin-eclipse-policy</module>\n\t\t<module>kotlin-eclipse-feature</module>\n\t\t<module>kotlin-weaving-feature</module>\n\t\t<module>kotlin-eclipse-p2updatesite</module>\n\t\t<module>kotlin-eclipse-maven</module>\n\t\t<module>kotlin-eclipse-gradle-model</module>\n\t\t<module>kotlin-eclipse-gradle</module>\n\t\t<module>kotlin-eclipse-gradle-feature</module>\n\t</modules>\n\n\t<properties>\n\t\t<tycho.version>2.7.5</tycho.version>\n\t\t<tycho-extras.version>2.7.5</tycho-extras.version>\n\n\t\t<eclipse-repo.url>http://download.eclipse.org/releases/2022-09</eclipse-repo.url>\n\t\t<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n\n\t\t<ajdt-eclipse-repo.url>http://download.eclipse.org/tools/ajdt/423/dev/update</ajdt-eclipse-repo.url>\n\t\t<buildship-repo.url>http://download.eclipse.org/buildship/updates/e423/releases/3.x</buildship-repo.url>\n\n\t\t<kotlin.version>1.6.21</kotlin.version>\n\n\t\t<weaving-hook.version>1.3.200</weaving-hook.version>\n\t</properties>\n\n\t<repositories>\n\t\t<repository>\n\t\t\t<id>eclipse</id>\n\t\t\t<url>${eclipse-repo.url}</url>\n\t\t\t<layout>p2</layout>\n\t\t</repository>\n\t\t<repository>\n\t\t\t<id>ajdt</id>\n\t\t\t<url>${ajdt-eclipse-repo.url}</url>\n\t\t\t<layout>p2</layout>\n\t\t</repository>\n\t\t<repository>\n\t\t\t<id>buildship</id>\n\t\t\t<url>${buildship-repo.url}</url>\n\t\t\t<layout>p2</layout>\n\t\t</repository>\n\t\t<repository>\n\t\t\t<id>sonatype.oss.snapshots</id>\n\t\t\t<name>Sonatype OSS Snapshot Repository</name>\n\t\t\t<url>https://oss.sonatype.org/content/repositories/snapshots</url>\n\t\t\t<releases>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</releases>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>true</enabled>\n\t\t\t</snapshots>\n\t\t</repository>\n\t</repositories>\n\n\t<pluginRepositories>\n\t\t<pluginRepository>\n\t\t\t<id>sonatype-nexus-staging</id>\n\t\t\t<name>Sonatype OSS Snapshot Repository</name>\n\t\t\t<url>https://oss.sonatype.org/content/repositories/snapshots</url>\n\t\t\t<releases>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</releases>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>true</enabled>\n\t\t\t</snapshots>\n\t\t</pluginRepository>\n\t</pluginRepositories>\n\n\t<build>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t<artifactId>tycho-maven-plugin</artifactId>\n\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t<extensions>true</extensions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t<artifactId>target-platform-configuration</artifactId>\n\t\t\t\t<configuration>\n\t\t\t\t\t<environments>\n\t\t\t\t\t\t<environment>\n\t\t\t\t\t\t\t<os>linux</os>\n\t\t\t\t\t\t\t<ws>gtk</ws>\n\t\t\t\t\t\t\t<arch>x86_64</arch>\n\t\t\t\t\t\t</environment>\n\t\t\t\t\t\t<environment>\n\t\t\t\t\t\t\t<os>win32</os>\n\t\t\t\t\t\t\t<ws>win32</ws>\n\t\t\t\t\t\t\t<arch>x86_64</arch>\n\t\t\t\t\t\t</environment>\n\t\t\t\t\t\t<environment>\n\t\t\t\t\t\t\t<os>macosx</os>\n\t\t\t\t\t\t\t<ws>cocoa</ws>\n\t\t\t\t\t\t\t<arch>x86_64</arch>\n\t\t\t\t\t\t</environment>\n\t\t\t\t\t</environments>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\n\t\t<pluginManagement>\n\t\t\t<plugins>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>target-platform-configuration</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-compiler-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<compilerArguments>\n\t\t\t\t\t\t\t<inlineJSR />\n\t\t\t\t\t\t\t<enableJavadoc />\n\t\t\t\t\t\t\t<encoding>ISO-8859-1</encoding>\n\t\t\t\t\t\t</compilerArguments>\n\t\t\t\t\t\t<compilerArgument>-err:-forbidden</compilerArgument>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-packaging-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<dependencies>\n\t\t\t\t\t\t<dependency>\n\t\t\t\t\t\t\t<groupId>org.eclipse.tycho.extras</groupId>\n\t\t\t\t\t\t\t<artifactId>tycho-buildtimestamp-jgit</artifactId>\n\t\t\t\t\t\t\t<version>${tycho-extras.version}</version>\n\t\t\t\t\t\t</dependency>\n\t\t\t\t\t</dependencies>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<strictBinIncludes>false</strictBinIncludes>\n\t\t\t\t\t\t<format>'v'yyyyMMdd-HHmm</format>\n\t\t\t\t\t\t<timestampProvider>jgit</timestampProvider>\n\t\t\t\t\t\t<jgit.dirtyWorkingTree>warning</jgit.dirtyWorkingTree>\n\t\t\t\t\t\t<jgit.ignore>\n\t\t\t\t\t\t</jgit.ignore>\n\t\t\t\t\t\t<jgit.dirtyWorkingTree>warning</jgit.dirtyWorkingTree>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-surefire-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<testFailureIgnore>true</testFailureIgnore>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-source-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<strictSrcIncludes>false</strictSrcIncludes>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-p2-director-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-p2-repository-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<finalName>kotlin-eclipse-plugin</finalName>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho.extras</groupId>\n\t\t\t\t\t<artifactId>tycho-source-feature-plugin</artifactId>\n\t\t\t\t\t<version>${tycho-extras.version}</version>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho.extras</groupId>\n\t\t\t\t\t<artifactId>tycho-custom-bundle-plugin</artifactId>\n\t\t\t\t\t<version>${tycho-extras.version}</version>\n\t\t\t\t</plugin>\n\t\t\t\t<plugin>\n\t\t\t\t\t<groupId>org.eclipse.tycho</groupId>\n\t\t\t\t\t<artifactId>tycho-p2-plugin</artifactId>\n\t\t\t\t\t<version>${tycho.version}</version>\n\t\t\t\t\t<configuration>\n\t\t\t\t\t\t<baselineMode>warn</baselineMode>\n\t\t\t\t\t\t<baselineReplace>none</baselineReplace>\n\t\t\t\t\t\t<baselineRepositories>\n\t\t\t\t\t\t\t<repository>\n\t\t\t\t\t\t\t\t<url>https://download.eclipse.org/eclipse/updates/4.25</url>\n\t\t\t\t\t\t\t</repository>\n\t\t\t\t\t\t</baselineRepositories>\n\t\t\t\t\t</configuration>\n\t\t\t\t</plugin>\n\t\t\t</plugins>\n\t\t</pluginManagement>\n\t</build>\n</project>\n"
  },
  {
    "path": "publish-new-version.md",
    "content": "#### How to publish new Kotlin Eclipse Version\n\n * Update TeamCity version prefix and reset counter for [Eclipse Build Configuration](https://teamcity.jetbrains.com/admin/editBuild.html?id=buildType:Kotlin_EclipsePlugin)\n * Update version in `maven-build/maven-update-version.launch` launch configuration and execute it\n * Update version in description of [kotlin-eclipse-feature](https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-feature/feature.xml)\n * Push the changes and wait for the [successful build](https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_EclipsePlugin&branch_Kotlin=%3Cdefault%3E&tab=buildTypeStatusDiv)\n * *Check that version is correct!*\n * Pin the build and add `release` tag\n * Add release notes at [GitHub Releases](https://github.com/JetBrains/kotlin-eclipse/releases)\n * Upload artifacts to [Eclipse-Plugin package](https://bintray.com/jetbrains/kotlin/eclipse-plugin/view) at BinTray:\n   * Download and unpack artifacts.zip from the [last build with release tag](https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_EclipsePlugin&branch_Kotlin=%3Cdefault%3E&tab=buildTypeStatusDiv)\n   * Unpack the file into some folder\n   * Download [*pushToBintray.sh*](https://github.com/goodwinnk/bintray-publish-p2-updatesite) script that will help you in uploading files\n   * Execute it (Git Bash (MinGW32) can be used on windows): \n     ```$ ./pushToBintray.sh BINTRAY_USER_NAME BINTRAY_REST_API_KEY jetbrains kotlin eclipse-plugin NEW_VERSION PATH_TO_UNPACKED_PLUGIN last PREVIOUS_VERSION```\n * **Test that you can install new version from Eclipse!**\n\n"
  }
]