├── .github └── workflows │ ├── ci-build.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── bom ├── .project ├── .settings │ └── org.eclipse.core.resources.prefs └── pom.xml ├── bundles ├── org.example.ui │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.jdt.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── plugin.launch │ ├── plugin.properties │ ├── plugin.xml │ ├── pom.xml │ ├── resources │ │ └── template.txt │ └── src │ │ └── org │ │ └── example │ │ └── ui │ │ ├── Activator.java │ │ ├── DataProcessingHandler.java │ │ ├── DataProcessingHandlerDialog.java │ │ ├── Messages.java │ │ └── messages.properties ├── org.example │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.jdt.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ ├── plugin.properties │ ├── plugin.xml │ ├── pom.xml │ └── src │ │ └── org │ │ └── example │ │ ├── ExampleValidator.java │ │ ├── Messages.java │ │ └── messages.properties └── pom.xml ├── checkstyle.xml ├── features ├── org.example.feature │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── build.properties │ ├── feature.properties │ ├── feature.xml │ ├── pom.xml │ └── sourceTemplateFeature │ │ ├── build.properties │ │ └── feature.properties ├── org.example.sdk.feature │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── build.properties │ ├── feature.properties │ ├── feature.xml │ └── pom.xml └── pom.xml ├── java.header ├── pom.xml ├── repositories ├── org.example.repository.sdk │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── category.xml │ └── pom.xml ├── org.example.repository │ ├── .project │ ├── .settings │ │ └── org.eclipse.core.resources.prefs │ ├── category.xml │ └── pom.xml └── pom.xml ├── targets ├── .project ├── .settings │ └── org.eclipse.core.resources.prefs ├── default │ ├── default.target │ └── pom.xml └── pom.xml └── tests ├── org.example.itests ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── build.properties ├── plugin.properties ├── pom.xml ├── src │ └── org │ │ └── example │ │ └── itests │ │ └── ExampleValidatorTest.java └── workspace │ └── test │ ├── .project │ ├── .settings │ └── org.eclipse.core.resources.prefs │ ├── DT-INF │ └── PROJECT.PMF │ └── src │ └── Configuration │ ├── CommandInterface.cmi │ ├── Configuration.mdo │ ├── MainSectionCommandInterface.cmi │ └── ManagedApplicationModule.bsl └── pom.xml /.github/workflows/ci-build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: Set up Maven 3.9.6 14 | uses: s4u/setup-maven-action@v1.12.0 15 | with: 16 | java-version: 17 17 | java-package: jdk+fx 18 | server-id: dt_repository 19 | server-username: MAVEN_USERNAME 20 | server-password: MAVEN_CENTRAL_TOKEN 21 | 22 | - name: Cache maven repo 23 | uses: actions/cache@v1 24 | if: github.event_name == 'push' || github.event_name == 'pull_request' 25 | with: 26 | path: ~/.m2/repository 27 | key: ${{ runner.os }}-maven-latest-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('targets/latest/latest.target') }} 28 | restore-keys: | 29 | ${{ runner.os }}-maven-latest- 30 | 31 | - name: Build with Maven 32 | env: 33 | MAVEN_USERNAME: ${{ secrets.P2_USER }} 34 | MAVEN_CENTRAL_TOKEN: ${{ secrets.P2_TOKEN }} 35 | working-directory: ./ 36 | run: | 37 | Xvfb :5 -screen 0 1280x1024x8 -fbdir /tmp & 38 | export DISPLAY=:5 39 | mvn clean verify -PSDK,find-bugs -Dtycho.localArtifacts=ignore -B -V 40 | 41 | - name: Publish Test Report 42 | uses: scacap/action-surefire-report@v1 43 | if: always() 44 | with: 45 | github_token: ${{ secrets.GITHUB_TOKEN }} 46 | 47 | - name: Upload JaCoCo exec data 48 | uses: actions/upload-artifact@v4 49 | if: always() 50 | with: 51 | name: jacoco 52 | path: | 53 | ./**/target/jacoco.exec 54 | ./**/target/site/jacoco*/ 55 | 56 | - name: Upload test logs on failure 57 | uses: actions/upload-artifact@v4 58 | if: failure() 59 | with: 60 | name: logs 61 | path: ./**/.log -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Build and upload Release Asset 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Set up JDK 17 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: 17 20 | java-package: jdk+fx 21 | server-id: dt_repository 22 | server-username: MAVEN_USERNAME 23 | server-password: MAVEN_CENTRAL_TOKEN 24 | 25 | - name: Cache maven repo 26 | uses: actions/cache@v1 27 | if: github.event_name == 'push' 28 | with: 29 | path: ~/.m2/repository 30 | key: ${{ runner.os }}-maven-base-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('targets/base/base.target') }} 31 | restore-keys: | 32 | ${{ runner.os }}-maven-base- 33 | 34 | - name: Build with Maven 35 | env: 36 | MAVEN_USERNAME: ${{ secrets.P2_USER }} 37 | MAVEN_CENTRAL_TOKEN: ${{ secrets.P2_TOKEN }} 38 | working-directory: ./ 39 | run: | 40 | Xvfb :5 -screen 0 1280x1024x8 -fbdir /tmp & 41 | export DISPLAY=:5 42 | mvn clean verify -PSDK,find-bugs -Dtycho.localArtifacts=ignore -B -V 43 | 44 | - name: Publish Test Report 45 | uses: scacap/action-surefire-report@v1 46 | if: always() 47 | with: 48 | github_token: ${{ secrets.GITHUB_TOKEN }} 49 | 50 | - name: Upload test logs on failure 51 | uses: actions/upload-artifact@v2 52 | if: failure() 53 | with: 54 | name: logs 55 | path: ./**/.log 56 | 57 | - name: Create Release 58 | id: create_release 59 | uses: actions/create-release@latest 60 | env: 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 62 | with: 63 | tag_name: ${{ github.ref }} 64 | release_name: Release ${{ github.ref }} 65 | draft: false 66 | prerelease: true 67 | 68 | - name: Upload Release Asset 69 | uses: actions/upload-release-asset@v1 70 | env: 71 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 72 | with: 73 | upload_url: ${{ steps.create_release.outputs.upload_url }} 74 | asset_path: ./repositories/org.example.repository.sdk/target/org.example.repository.sdk.zip 75 | asset_name: repo.zip 76 | asset_content_type: application/zip -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Eclipse project files 2 | .metadata/ 3 | .metricsapp/ 4 | .metricsapp-tests/ 5 | .JETEmitters/ 6 | #Build targets 7 | bin/ 8 | target/ 9 | #Report directories 10 | /reports 11 | */reports 12 | #Mac-specific directory that no other operating system needs. 13 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION 5 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial content 12 | Distributed under this Agreement, and 13 | 14 | b) in the case of each subsequent Contributor: 15 | i) changes to the Program, and 16 | ii) additions to the Program; 17 | where such changes and/or additions to the Program originate from 18 | and are Distributed by that particular Contributor. A Contribution 19 | "originates" from a Contributor if it was added to the Program by 20 | such Contributor itself or anyone acting on such Contributor's behalf. 21 | Contributions do not include changes or additions to the Program that 22 | are not Modified Works. 23 | 24 | "Contributor" means any person or entity that Distributes the Program. 25 | 26 | "Licensed Patents" mean patent claims licensable by a Contributor which 27 | are necessarily infringed by the use or sale of its Contribution alone 28 | or when combined with the Program. 29 | 30 | "Program" means the Contributions Distributed in accordance with this 31 | Agreement. 32 | 33 | "Recipient" means anyone who receives the Program under this Agreement 34 | or any Secondary License (as applicable), including Contributors. 35 | 36 | "Derivative Works" shall mean any work, whether in Source Code or other 37 | form, that is based on (or derived from) the Program and for which the 38 | editorial revisions, annotations, elaborations, or other modifications 39 | represent, as a whole, an original work of authorship. 40 | 41 | "Modified Works" shall mean any work in Source Code or other form that 42 | results from an addition to, deletion from, or modification of the 43 | contents of the Program, including, for purposes of clarity any new file 44 | in Source Code form that contains any contents of the Program. Modified 45 | Works shall not include works that contain only declarations, 46 | interfaces, types, classes, structures, or files of the Program solely 47 | in each case in order to link to, bind by name, or subclass the Program 48 | or Modified Works thereof. 49 | 50 | "Distribute" means the acts of a) distributing or b) making available 51 | in any manner that enables the transfer of a copy. 52 | 53 | "Source Code" means the form of a Program preferred for making 54 | modifications, including but not limited to software source code, 55 | documentation source, and configuration files. 56 | 57 | "Secondary License" means either the GNU General Public License, 58 | Version 2.0, or any later versions of that license, including any 59 | exceptions or additional permissions as identified by the initial 60 | Contributor. 61 | 62 | 2. GRANT OF RIGHTS 63 | 64 | a) Subject to the terms of this Agreement, each Contributor hereby 65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright 66 | license to reproduce, prepare Derivative Works of, publicly display, 67 | publicly perform, Distribute and sublicense the Contribution of such 68 | Contributor, if any, and such Derivative Works. 69 | 70 | b) Subject to the terms of this Agreement, each Contributor hereby 71 | grants Recipient a non-exclusive, worldwide, royalty-free patent 72 | license under Licensed Patents to make, use, sell, offer to sell, 73 | import and otherwise transfer the Contribution of such Contributor, 74 | if any, in Source Code or other form. This patent license shall 75 | apply to the combination of the Contribution and the Program if, at 76 | the time the Contribution is added by the Contributor, such addition 77 | of the Contribution causes such combination to be covered by the 78 | Licensed Patents. The patent license shall not apply to any other 79 | combinations which include the Contribution. No hardware per se is 80 | licensed hereunder. 81 | 82 | c) Recipient understands that although each Contributor grants the 83 | licenses to its Contributions set forth herein, no assurances are 84 | provided by any Contributor that the Program does not infringe the 85 | patent or other intellectual property rights of any other entity. 86 | Each Contributor disclaims any liability to Recipient for claims 87 | brought by any other entity based on infringement of intellectual 88 | property rights or otherwise. As a condition to exercising the 89 | rights and licenses granted hereunder, each Recipient hereby 90 | assumes sole responsibility to secure any other intellectual 91 | property rights needed, if any. For example, if a third party 92 | patent license is required to allow Recipient to Distribute the 93 | Program, it is Recipient's responsibility to acquire that license 94 | before distributing the Program. 95 | 96 | d) Each Contributor represents that to its knowledge it has 97 | sufficient copyright rights in its Contribution, if any, to grant 98 | the copyright license set forth in this Agreement. 99 | 100 | e) Notwithstanding the terms of any Secondary License, no 101 | Contributor makes additional grants to any Recipient (other than 102 | those set forth in this Agreement) as a result of such Recipient's 103 | receipt of the Program under the terms of a Secondary License 104 | (if permitted under the terms of Section 3). 105 | 106 | 3. REQUIREMENTS 107 | 108 | 3.1 If a Contributor Distributes the Program in any form, then: 109 | 110 | a) the Program must also be made available as Source Code, in 111 | accordance with section 3.2, and the Contributor must accompany 112 | the Program with a statement that the Source Code for the Program 113 | is available under this Agreement, and informs Recipients how to 114 | obtain it in a reasonable manner on or through a medium customarily 115 | used for software exchange; and 116 | 117 | b) the Contributor may Distribute the Program under a license 118 | different than this Agreement, provided that such license: 119 | i) effectively disclaims on behalf of all other Contributors all 120 | warranties and conditions, express and implied, including 121 | warranties or conditions of title and non-infringement, and 122 | implied warranties or conditions of merchantability and fitness 123 | for a particular purpose; 124 | 125 | ii) effectively excludes on behalf of all other Contributors all 126 | liability for damages, including direct, indirect, special, 127 | incidental and consequential damages, such as lost profits; 128 | 129 | iii) does not attempt to limit or alter the recipients' rights 130 | in the Source Code under section 3.2; and 131 | 132 | iv) requires any subsequent distribution of the Program by any 133 | party to be under a license that satisfies the requirements 134 | of this section 3. 135 | 136 | 3.2 When the Program is Distributed as Source Code: 137 | 138 | a) it must be made available under this Agreement, or if the 139 | Program (i) is combined with other material in a separate file or 140 | files made available under a Secondary License, and (ii) the initial 141 | Contributor attached to the Source Code the notice described in 142 | Exhibit A of this Agreement, then the Program may be made available 143 | under the terms of such Secondary Licenses, and 144 | 145 | b) a copy of this Agreement must be included with each copy of 146 | the Program. 147 | 148 | 3.3 Contributors may not remove or alter any copyright, patent, 149 | trademark, attribution notices, disclaimers of warranty, or limitations 150 | of liability ("notices") contained within the Program from any copy of 151 | the Program which they Distribute, provided that Contributors may add 152 | their own appropriate notices. 153 | 154 | 4. COMMERCIAL DISTRIBUTION 155 | 156 | Commercial distributors of software may accept certain responsibilities 157 | with respect to end users, business partners and the like. While this 158 | license is intended to facilitate the commercial use of the Program, 159 | the Contributor who includes the Program in a commercial product 160 | offering should do so in a manner which does not create potential 161 | liability for other Contributors. Therefore, if a Contributor includes 162 | the Program in a commercial product offering, such Contributor 163 | ("Commercial Contributor") hereby agrees to defend and indemnify every 164 | other Contributor ("Indemnified Contributor") against any losses, 165 | damages and costs (collectively "Losses") arising from claims, lawsuits 166 | and other legal actions brought by a third party against the Indemnified 167 | Contributor to the extent caused by the acts or omissions of such 168 | Commercial Contributor in connection with its distribution of the Program 169 | in a commercial product offering. The obligations in this section do not 170 | apply to any claims or Losses relating to any actual or alleged 171 | intellectual property infringement. In order to qualify, an Indemnified 172 | Contributor must: a) promptly notify the Commercial Contributor in 173 | writing of such claim, and b) allow the Commercial Contributor to control, 174 | and cooperate with the Commercial Contributor in, the defense and any 175 | related settlement negotiations. The Indemnified Contributor may 176 | participate in any such claim at its own expense. 177 | 178 | For example, a Contributor might include the Program in a commercial 179 | product offering, Product X. That Contributor is then a Commercial 180 | Contributor. If that Commercial Contributor then makes performance 181 | claims, or offers warranties related to Product X, those performance 182 | claims and warranties are such Commercial Contributor's responsibility 183 | alone. Under this section, the Commercial Contributor would have to 184 | defend claims against the other Contributors related to those performance 185 | claims and warranties, and if a court requires any other Contributor to 186 | pay any damages as a result, the Commercial Contributor must pay 187 | those damages. 188 | 189 | 5. NO WARRANTY 190 | 191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" 193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF 195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 196 | PURPOSE. Each Recipient is solely responsible for determining the 197 | appropriateness of using and distributing the Program and assumes all 198 | risks associated with its exercise of rights under this Agreement, 199 | including but not limited to the risks and costs of program errors, 200 | compliance with applicable laws, damage to or loss of data, programs 201 | or equipment, and unavailability or interruption of operations. 202 | 203 | 6. DISCLAIMER OF LIABILITY 204 | 205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS 207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE 213 | POSSIBILITY OF SUCH DAMAGES. 214 | 215 | 7. GENERAL 216 | 217 | If any provision of this Agreement is invalid or unenforceable under 218 | applicable law, it shall not affect the validity or enforceability of 219 | the remainder of the terms of this Agreement, and without further 220 | action by the parties hereto, such provision shall be reformed to the 221 | minimum extent necessary to make such provision valid and enforceable. 222 | 223 | If Recipient institutes patent litigation against any entity 224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 225 | Program itself (excluding combinations of the Program with other software 226 | or hardware) infringes such Recipient's patent(s), then such Recipient's 227 | rights granted under Section 2(b) shall terminate as of the date such 228 | litigation is filed. 229 | 230 | All Recipient's rights under this Agreement shall terminate if it 231 | fails to comply with any of the material terms or conditions of this 232 | Agreement and does not cure such failure in a reasonable period of 233 | time after becoming aware of such noncompliance. If all Recipient's 234 | rights under this Agreement terminate, Recipient agrees to cease use 235 | and distribution of the Program as soon as reasonably practicable. 236 | However, Recipient's obligations under this Agreement and any licenses 237 | granted by Recipient relating to the Program shall continue and survive. 238 | 239 | Everyone is permitted to copy and distribute copies of this Agreement, 240 | but in order to avoid inconsistency the Agreement is copyrighted and 241 | may only be modified in the following manner. The Agreement Steward 242 | reserves the right to publish new versions (including revisions) of 243 | this Agreement from time to time. No one other than the Agreement 244 | Steward has the right to modify this Agreement. The Eclipse Foundation 245 | is the initial Agreement Steward. The Eclipse Foundation may assign the 246 | responsibility to serve as the Agreement Steward to a suitable separate 247 | entity. Each new version of the Agreement will be given a distinguishing 248 | version number. The Program (including Contributions) may always be 249 | Distributed subject to the version of the Agreement under which it was 250 | received. In addition, after a new version of the Agreement is published, 251 | Contributor may elect to Distribute the Program (including its 252 | Contributions) under the new version. 253 | 254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient 255 | receives no rights or licenses to the intellectual property of any 256 | Contributor under this Agreement, whether expressly, by implication, 257 | estoppel or otherwise. All rights in the Program not expressly granted 258 | under this Agreement are reserved. Nothing in this Agreement is intended 259 | to be enforceable by any entity that is not a Contributor or Recipient. 260 | No third-party beneficiary rights are created under this Agreement. 261 | 262 | Exhibit A - Form of Secondary Licenses Notice 263 | 264 | "This Source Code may also be made available under the following 265 | Secondary Licenses when the conditions for such availability set forth 266 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), 267 | version(s), and exceptions or additional permissions here}." 268 | 269 | Simply including a copy of this Agreement, including this Exhibit A 270 | is not sufficient to license the Source Code under Secondary Licenses. 271 | 272 | If it is not possible or desirable to put the notice in a particular 273 | file, then You may include the notice in a location (such as a LICENSE 274 | file in a relevant directory) where a recipient would be likely to 275 | look for such a notice. 276 | 277 | You may add additional accurate notices of copyright ownership. 278 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Build](https://github.com/1C-Company/dt-example-plugins/workflows/CI/badge.svg) 2 | 3 | Пример реализации плагина для "1C: Enterprise Development Tools". 4 | 5 | Данный плагин представляет собой плагин, который добавляет в 1C:EDT команду для создания обработчика проведения документа через специальный диалог, а также пример расширения проверок модуля. В плагине продемонстрированы следующие приемы: 6 | * расширение контекстного меню редактора встроенного языка, 7 | * генерация кода модуля, 8 | * работа с объектами конфигурации, 9 | * расширение проверки модуля. 10 | 11 | Для изучения и запуска демонстрационного плагина выполните следующие шаги: 12 | * [Настройте](https://edt.1c.ru/dev/ru/docs/plugins/project/env-setup/) необходимое программное обеспечение, 13 | * [Скопируйте или склонируйте](https://edt.1c.ru/dev/ru/docs/plugins/project/copy-clone/) проект плагина из GitHub-репозитория фирмы «1С», 14 | * [Познакомьтесь](https://edt.1c.ru/dev/ru/docs/plugins/project/project-structure/) со структурой демонстрационного проекта, 15 | * [Запустите](https://edt.1c.ru/dev/ru/docs/plugins/project/run/) плагин из Eclipse. 16 | 17 | Руководство по разработке плагинов доступно по [ссылке](https://edt.1c.ru/dev/ru/) 18 | -------------------------------------------------------------------------------- /bom/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | bom 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bom/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bom/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | org.example 17 | bom 18 | 1.0.0-SNAPSHOT 19 | pom 20 | 21 | BOM 22 | 23 | 24 | 3.9.4 25 | 26 | 27 | 28 | 4.0.5 29 | 4.0.5 30 | 31 | 4.8.3.1 32 | 8.5 33 | 34 | UTF-8 35 | UTF-8 36 | 17 37 | 17 38 | 17 39 | 40 | 'v'yyyyMMdd-HHmm 41 | ${maven.build.timestamp} 42 | 43 | http://download.eclipse.org/releases/2022-03/ 44 | 45 | false 46 | 0.8.8 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.eclipse.tycho 54 | target-platform-configuration 55 | ${tycho.version} 56 | 57 | p2 58 | JavaSE-17 59 | false 60 | 61 | 62 | org.example 63 | default 64 | 1.0.0-SNAPSHOT 65 | 66 | 67 | 68 | 69 | 70 | eclipse-plugin 71 | javax.annotation 72 | 0.0.0 73 | 74 | 75 | 76 | 77 | 78 | win32 79 | win32 80 | x86_64 81 | 82 | 83 | linux 84 | gtk 85 | x86_64 86 | 87 | 88 | macosx 89 | cocoa 90 | x86_64 91 | 92 | 93 | 94 | 95 | 96 | org.eclipse.tycho 97 | tycho-maven-plugin 98 | ${tycho.version} 99 | true 100 | 101 | 102 | org.eclipse.tycho 103 | tycho-compiler-plugin 104 | ${tycho.version} 105 | 106 | UTF-8 107 | true 108 | true 109 | true 110 | true 111 | true 112 | true 113 | 114 | 115 | -Xlint:all 116 | -Xlint:serial 117 | -Xlint:serial 118 | 119 | 120 | 121 | 122 | org.eclipse.tycho 123 | tycho-source-plugin 124 | ${tycho.version} 125 | 126 | 127 | false 128 | 129 | 130 | 131 | 132 | 133 | plugin-source 134 | 135 | 136 | 137 | 138 | 139 | org.eclipse.tycho 140 | tycho-surefire-plugin 141 | ${tycho.version} 142 | 143 | ${tycho.surefire.skipPluginTest} 144 | 145 | UTF-8 146 | UTF-8 147 | 148 | 149 | 150 | 151 | org.eclipse.tycho 152 | tycho-packaging-plugin 153 | ${tycho.version} 154 | 155 | 'v'yyyyMMddHHmm 156 | 157 | 158 | 159 | org.eclipse.tycho 160 | tycho-p2-plugin 161 | ${tycho.version} 162 | 163 | 164 | org.eclipse.tycho 165 | tycho-p2-repository-plugin 166 | ${tycho.version} 167 | 168 | Repository 169 | ${project.artifactId} 170 | {p2repo.archive.skip} 171 | 172 | 173 | 174 | org.eclipse.tycho.extras 175 | tycho-eclipserun-plugin 176 | ${tycho.extras.version} 177 | 178 | 179 | org.apache.maven.plugins 180 | maven-resources-plugin 181 | 2.7 182 | 183 | 184 | org.apache.maven.plugins 185 | maven-checkstyle-plugin 186 | 2.17 187 | 188 | 189 | com.puppycrawl.tools 190 | checkstyle 191 | ${checkstyle.version} 192 | 193 | 194 | 195 | checkstyle.xml 196 | true 197 | true 198 | true 199 | true 200 | warning 201 | 202 | 203 | 204 | maven-antrun-plugin 205 | 1.8 206 | 207 | 208 | org.jacoco 209 | jacoco-maven-plugin 210 | ${org.jacoco.version} 211 | 212 | 213 | **/MdClassPackageImpl* 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | org.eclipse.tycho 223 | tycho-maven-plugin 224 | true 225 | 226 | 227 | org.codehaus.mojo 228 | build-helper-maven-plugin 229 | 1.9.1 230 | 231 | 232 | add-source 233 | generate-sources 234 | 235 | add-source 236 | 237 | 238 | 239 | ${project.build.directory}/xcore-gen 240 | 241 | 242 | 243 | 244 | 245 | 246 | maven-antrun-plugin 247 | 248 | 249 | export-properties 250 | package 251 | 252 | run 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | find-bugs 268 | 269 | 270 | 271 | com.github.spotbugs 272 | spotbugs-maven-plugin 273 | ${spotbugs.maven.plugin.version} 274 | 275 | Max 276 | Low 277 | true 278 | 9 279 | true 280 | -Xmx1536m 281 | 1536 282 | ${project.build.directory}/findbugs 283 | 284 | 285 | 286 | analyze-compile 287 | compile 288 | 289 | check 290 | 291 | 292 | 293 | 294 | 295 | 296 | com.github.spotbugs 297 | spotbugs 298 | 4.8.3 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | -------------------------------------------------------------------------------- /bundles/org.example.ui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bundles/org.example.ui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.ui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /bundles/org.example.ui/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.example.ui/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.compliance=17 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=17 8 | -------------------------------------------------------------------------------- /bundles/org.example.ui/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %pluginName 4 | Bundle-Vendor: %providerName 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-SymbolicName: org.example.ui;singleton:=true 7 | Bundle-Activator: org.example.ui.Activator 8 | Bundle-ActivationPolicy: lazy 9 | Bundle-Localization: plugin 10 | Require-Bundle: org.eclipse.ui;bundle-version="[3.201.0,4.0.0)", 11 | org.eclipse.ui.ide;bundle-version="[3.18.500,4.0.0)", 12 | org.eclipse.xtext.ui;bundle-version="[2.26.0,3.0.0)", 13 | org.apache.log4j;bundle-version="[1.2.15,2.0.0)" 14 | Import-Package: com._1c.g5.v8.dt.bsl.model;version="[5.0.0,6.0.0)", 15 | com._1c.g5.v8.dt.mcore;version="[7.0.0,8.0.0)", 16 | com._1c.g5.v8.dt.mcore.impl;version="[7.0.0,8.0.0)", 17 | com._1c.g5.v8.dt.metadata.mdclass;version="[9.0.0,10.0.0)", 18 | org.antlr.stringtemplate;version="[3.2.0,4.0.0)", 19 | org.eclipse.core.runtime;version="[3.4.0,4.0.0)", 20 | org.osgi.framework;version="[1.8.0,2.0.0)" 21 | Bundle-RequiredExecutionEnvironment: JavaSE-17 22 | Automatic-Module-Name: org.example.ui 23 | -------------------------------------------------------------------------------- /bundles/org.example.ui/build.properties: -------------------------------------------------------------------------------- 1 | javacCustomEncodings.. = src/[UTF-8] 2 | source.. = src/,\ 3 | resources/ 4 | bin.includes = META-INF/,\ 5 | .,\ 6 | plugin.xml,\ 7 | plugin.properties,\ 8 | resources/ 9 | -------------------------------------------------------------------------------- /bundles/org.example.ui/plugin.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /bundles/org.example.ui/plugin.properties: -------------------------------------------------------------------------------- 1 | pluginName = \u041F\u0440\u0438\u043C\u0435\u0440 \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools" 2 | providerName = 1C LLC 3 | command.name = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 4 | command.tooltip = \u0412\u044B\u0437\u044B\u0432\u0430\u0435\u0442 \u043A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F -------------------------------------------------------------------------------- /bundles/org.example.ui/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 10 | 11 | 12 | 13 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /bundles/org.example.ui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | bundles 9 | 1.0.0-SNAPSHOT 10 | 11 | org.example.ui 12 | 1.0.0-SNAPSHOT 13 | eclipse-plugin 14 | -------------------------------------------------------------------------------- /bundles/org.example.ui/resources/template.txt: -------------------------------------------------------------------------------- 1 | 2 | Процедура ОбработкаПроведения(Отказ, РежимПроведения) 3 | Запись = Движения.$RegisterName$.Добавить(); 4 | $body$ 5 | Движения.$RegisterName$.Записать(); 6 | КонецПроцедуры -------------------------------------------------------------------------------- /bundles/org.example.ui/src/org/example/ui/Activator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example.ui; 5 | 6 | import org.eclipse.core.runtime.IStatus; 7 | import org.eclipse.core.runtime.Plugin; 8 | import org.eclipse.core.runtime.Status; 9 | import org.osgi.framework.BundleContext; 10 | 11 | /** 12 | * Данный класс представляет собой начальную точку в работе плагина. 13 | * В нем следует реализовывать логику создания плагина, 14 | * а так же необходимые действия при завершении работы плагина.
15 | * 16 | * Так же данный класс содержит в себе ряд методов для удобного логирования ошибок 17 | */ 18 | public class Activator 19 | extends Plugin 20 | { 21 | public static final String PLUGIN_ID = "com.example.dt.plugin.ui"; //$NON-NLS-1$ 22 | private static Activator plugin; 23 | 24 | private BundleContext bundleContext; 25 | 26 | /** 27 | * Получить экземпляр плагина. Через экземпляр плагина можно получать доступ к разнообразным механизмам Eclipse, 28 | * таким как: 29 | * 34 | * 35 | * @return экземпляр плагина, никогда не должен возвращать null 36 | */ 37 | public static Activator getDefault() 38 | { 39 | return plugin; 40 | } 41 | 42 | /** 43 | * Запись статуса события в лог журнал плагина. 44 | * 45 | * @param status статус события для логирования, не может быть null. 46 | * Данный статус содержит в себе информацию о произошедшем событии (ошибка выполнения, 47 | * разнообразные предупреждения), которые были зафиксированы в логике работы плагина. 48 | */ 49 | public static void log(IStatus status) 50 | { 51 | plugin.getLog().log(status); 52 | } 53 | 54 | /** 55 | * Запись исключения в лог журнал плагина 56 | * 57 | * @param throwable выкинутое исключение, не может быть null 58 | */ 59 | public static void logError(Throwable throwable) 60 | { 61 | log(createErrorStatus(throwable.getMessage(), throwable)); 62 | } 63 | 64 | /** 65 | * Создание записи с описанием ошибки в лог журнале плагина по выкинотому исключению и сообщению, его описывающим 66 | * 67 | * @param message описание выкинутого исключения, не может быть null 68 | * @param throwable выкинутое исключение, может быть null 69 | * @return созданное статус событие, не может быть null 70 | */ 71 | public static IStatus createErrorStatus(String message, Throwable throwable) 72 | { 73 | return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, throwable); 74 | } 75 | 76 | /** 77 | * Создание записи с описанием предупреждения в лог журнале плагина 78 | * 79 | * @param message описание предупреждения, не может быть null 80 | * @return созданное статус событие, не может быть null 81 | */ 82 | public static IStatus createWarningStatus(String message) 83 | { 84 | return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null); 85 | } 86 | 87 | /** 88 | * Создание записи с описанием предупреждения в лог журнале плагина по выкинотому исключению и сообщению, 89 | * его описывающим 90 | * 91 | * @param message описание выкинутого исключения, не может быть null 92 | * @param throwable выкинутое исключение, может быть null 93 | * @return созданное статус событие, не может быть null 94 | */ 95 | public static IStatus createWarningStatus(final String message, 96 | Exception throwable) 97 | { 98 | return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, throwable); 99 | } 100 | 101 | /** 102 | * Данный метод является начальной точкой работы плагина 103 | * 104 | * @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, 105 | * по работе с файловыми ресурсами внутри проекта 106 | */ 107 | @Override 108 | public void start(BundleContext bundleContext) throws Exception 109 | { 110 | super.start(bundleContext); 111 | 112 | this.bundleContext = bundleContext; 113 | plugin = this; 114 | } 115 | 116 | /** 117 | * Данный метод вызывается при завершении работы плагина 118 | * 119 | * @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, 120 | * по работе с файловыми ресурсами внутри проекта 121 | */ 122 | @Override 123 | public void stop(BundleContext bundleContext) throws Exception 124 | { 125 | plugin = null; 126 | super.stop(bundleContext); 127 | } 128 | 129 | /** 130 | * Получить объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с 131 | * файловыми ресурсами внутри проекта 132 | * 133 | * @return объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с 134 | * файловыми ресурсами внутри проекта 135 | */ 136 | protected BundleContext getContext() 137 | { 138 | return bundleContext; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /bundles/org.example.ui/src/org/example/ui/DataProcessingHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example.ui; 5 | 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | import java.nio.charset.StandardCharsets; 9 | import java.util.List; 10 | 11 | import org.antlr.stringtemplate.StringTemplate; 12 | import org.eclipse.core.commands.AbstractHandler; 13 | import org.eclipse.core.commands.ExecutionEvent; 14 | import org.eclipse.core.commands.ExecutionException; 15 | import org.eclipse.core.resources.IFile; 16 | import org.eclipse.core.resources.IProject; 17 | import org.eclipse.emf.ecore.EObject; 18 | import org.eclipse.emf.ecore.util.EcoreUtil; 19 | import org.eclipse.jface.text.BadLocationException; 20 | import org.eclipse.jface.window.Window; 21 | import org.eclipse.swt.SWT; 22 | import org.eclipse.swt.widgets.Display; 23 | import org.eclipse.swt.widgets.MessageBox; 24 | import org.eclipse.ui.IFileEditorInput; 25 | import org.eclipse.ui.IWorkbenchPart; 26 | import org.eclipse.ui.handlers.HandlerUtil; 27 | import org.eclipse.xtext.nodemodel.util.NodeModelUtils; 28 | import org.eclipse.xtext.resource.XtextResource; 29 | import org.eclipse.xtext.ui.editor.XtextEditor; 30 | import org.eclipse.xtext.ui.editor.model.IXtextDocument; 31 | import org.eclipse.xtext.util.Pair; 32 | import org.eclipse.xtext.util.concurrent.IUnitOfWork; 33 | 34 | import com._1c.g5.v8.dt.bsl.model.DeclareStatement; 35 | import com._1c.g5.v8.dt.bsl.model.Module; 36 | import com._1c.g5.v8.dt.bsl.model.ModuleType; 37 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegister; 38 | import com._1c.g5.v8.dt.metadata.mdclass.BasicRegister; 39 | import com._1c.g5.v8.dt.metadata.mdclass.Document; 40 | import com.google.common.base.Function; 41 | import com.google.common.base.Joiner; 42 | import com.google.common.collect.Collections2; 43 | import com.google.common.collect.Lists; 44 | import com.google.common.io.CharSource; 45 | import com.google.common.io.CharStreams; 46 | import com.google.common.io.Resources; 47 | 48 | /** 49 | * Команда создания обработчика проведения в объектном модуле документа, с 50 | * которым связан регистр накопления. Данная команда регистрируется при помощи 51 | * точки разширения с именем "org.eclipse.ui.commands", которая присваивает 52 | * данной команде уникальный идентификатор, по которому можно производит вызов 53 | * данной команды из различных мест, например, из контекстного меню текстового 54 | * редактора. 55 | *

56 | * Данная команда предназначена для работы только с текстовым редактором Xtext 57 | * {@link XtextEditor} и содержит в себе логику для проверки корректности 58 | * добавления обработчика проведения в данный модуль, а так же для определения 59 | * позиции вставки обработчика 60 | */ 61 | public class DataProcessingHandler 62 | extends AbstractHandler 63 | { 64 | private static final String TEMPLATE_NAME = "template.txt"; //$NON-NLS-1$ 65 | private static String templateContent; 66 | 67 | static 68 | { 69 | //TODO: сделать поддержку генерации английского варианта обработчика 70 | templateContent = readContents(getFileInputSupplier(TEMPLATE_NAME), TEMPLATE_NAME); 71 | } 72 | 73 | @Override 74 | public Object execute(ExecutionEvent event) throws ExecutionException 75 | { 76 | // получим активный Xtext редактор 77 | IWorkbenchPart part = HandlerUtil.getActivePart(event); 78 | XtextEditor target = part.getAdapter(XtextEditor.class); 79 | 80 | if (target != null) 81 | { 82 | // для полученного редактора убедимся, что под ним лежит файл в 83 | // проекте с конфигурацией, иначе это точно не модель объекта 84 | // документа 85 | if (!(target.getEditorInput() instanceof IFileEditorInput)) 86 | return null; 87 | IFileEditorInput input = (IFileEditorInput)target.getEditorInput(); 88 | IFile file = input.getFile(); 89 | if (file == null) 90 | return null; 91 | IProject project = file.getProject(); 92 | if (project == null) 93 | return null; 94 | IXtextDocument doc = target.getDocument(); 95 | 96 | // получим объект метаданных, к которому принадлежит модуль, из 97 | // которого была вызвана команда 98 | EObject moduleOwner = getModuleOwner(doc); 99 | // проверим, что команда была вызвана из правильного модуля и у 100 | // документа есть хотя бы 1 регистр 101 | if (!(moduleOwner instanceof Document)) 102 | { 103 | // Данный модуль не является объектным модулем документа, 104 | // выдадим сообщение об этом и завершим работу 105 | MessageBox dialog = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR); 106 | dialog.setText(Messages.DataProcessingHandler_Error); 107 | dialog.setMessage(Messages.DataProcessingHandler_Error_not_document_object_module); 108 | dialog.open(); 109 | return null; 110 | } 111 | 112 | Document mdDocument = (Document)moduleOwner; 113 | List registers = findAccumulationRegister(mdDocument.getRegisterRecords()); 114 | if (registers.isEmpty()) 115 | { 116 | // У документа нет ниодного регистра накопления, выдадим 117 | // сообщение об этом и завершим работу 118 | MessageBox dialog = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR); 119 | dialog.setText(Messages.DataProcessingHandler_Error); 120 | dialog.setMessage(Messages.DataProcessingHandler_Error_no_accumulation_registers); 121 | dialog.open(); 122 | return null; 123 | } 124 | 125 | // создадим диалог конструктора движения регистра 126 | DataProcessingHandlerDialog dialog = 127 | new DataProcessingHandlerDialog(Display.getCurrent().getActiveShell(), mdDocument, registers); 128 | // обработаем завершение работы пользователя с диалогом 129 | if (dialog.open() == Window.OK) 130 | { 131 | // создаем текст обработчика на основании того, что было выбрано 132 | // в конструкторе движения регистра 133 | // для этого воспользуемся заранее приготовленным шаблоном 134 | // обработчика (файл с данным шаблоном находится в папке 135 | // ресурсов плагина) 136 | StringTemplate template = new StringTemplate(templateContent); // считали 137 | // шаблон 138 | // текста 139 | // обработчика 140 | // подставим в шаблон имя регистра, 141 | // для которого делается 142 | // обработка проведения 143 | template.setAttribute("RegisterName", dialog.getRegisterName()); //$NON-NLS-1$ 144 | // формируем тело обработчика проведения на основе данных из 145 | // диалога 146 | String body = Joiner.on(System.lineSeparator()).join( 147 | Collections2.transform(dialog.getExpressions(), new Function, String>() 148 | { 149 | @Override 150 | public String apply(Pair item) 151 | { 152 | return "Запись." + item.getFirst() + " = " //$NON-NLS-1$ //$NON-NLS-2$ 153 | + item.getSecond() + ';'; 154 | } 155 | })); 156 | template.setAttribute("body", body); // дозаполнили шаблон //$NON-NLS-1$ 157 | // обработчика 158 | try 159 | { 160 | // определим позицию в модуле, в которую следует добавить 161 | // обработчик 162 | int insertPosition = getInsertHandlerPosition(doc); 163 | // добавляем текст обработчика в модуль 164 | doc.replace(insertPosition, insertPosition, template.toString()); 165 | } 166 | catch (BadLocationException e) 167 | { 168 | Activator.createErrorStatus(e.getMessage(), e); 169 | } 170 | } 171 | } 172 | return null; 173 | } 174 | 175 | /* 176 | * Метод выбирает всех регистраторов типа Регистр накопления 177 | */ 178 | private List findAccumulationRegister(List registerRecords) 179 | { 180 | List registers = Lists.newArrayList(); 181 | for (BasicRegister register : registerRecords) 182 | { 183 | if (register instanceof AccumulationRegister) 184 | registers.add(register); 185 | } 186 | return registers; 187 | } 188 | 189 | private int getInsertHandlerPosition(IXtextDocument doc) 190 | { 191 | //работа с семантической моделью встроенного языка через документ возможна только через специальный метод 192 | //использование других способов приведет к ошибкам 193 | int insertPosition = doc.readOnly(new IUnitOfWork() 194 | { 195 | @Override 196 | public Integer exec(XtextResource res) throws Exception 197 | { 198 | //сперва проверяем, доступность семантической модели встроенного языка 199 | if (res.getContents() != null && !res.getContents().isEmpty()) 200 | { 201 | EObject obj = res.getContents().get(0); 202 | if (obj instanceof Module) // проверили, что работаем с правильным объектом семантической модели 203 | { 204 | Module module = (Module)obj; 205 | if (!module.allDeclareStatements().isEmpty()) 206 | { 207 | // обработчик вставляется в начало модуля, 208 | // сразу после объявления переменных, если 209 | // они были 210 | DeclareStatement lastDeclStatement = 211 | module.allDeclareStatements().get(module.allDeclareStatements().size() - 1); 212 | return NodeModelUtils.findActualNodeFor(lastDeclStatement).getTotalEndOffset(); 213 | } 214 | } 215 | } 216 | return 0; 217 | } 218 | }); 219 | return insertPosition; 220 | } 221 | 222 | private EObject getModuleOwner(IXtextDocument doc) 223 | { 224 | //работа с семантической моделью встроенного языка через документ возможна только через специальный метод 225 | //использование других способов приведет к ошибкам 226 | return doc.readOnly(new IUnitOfWork() 227 | { 228 | @Override 229 | public EObject exec(XtextResource res) throws Exception 230 | { 231 | //сперва проверяем, доступность семантической модели встроенного языка 232 | if (res.getContents() != null && !res.getContents().isEmpty()) 233 | { 234 | EObject obj = res.getContents().get(0); 235 | if (obj instanceof Module) // проверили, что работаем с правильным объектом семантической модели 236 | { 237 | // интересуют только объектные модули 238 | if (((Module)obj).getModuleType() != ModuleType.OBJECT_MODULE) 239 | return null; 240 | Module module = (Module)obj; 241 | return EcoreUtil.resolve(module.getOwner(), module); 242 | } 243 | } 244 | return null; 245 | } 246 | }); 247 | } 248 | 249 | private static String readContents(CharSource source, String path) 250 | { 251 | try (Reader reader = source.openBufferedStream()) 252 | { 253 | return CharStreams.toString(reader); 254 | } 255 | catch (IOException | NullPointerException e) 256 | { 257 | return ""; //$NON-NLS-1$ 258 | } 259 | } 260 | 261 | private static CharSource getFileInputSupplier(String partName) 262 | { 263 | return Resources.asCharSource(DataProcessingHandler.class.getResource("/resources/" + partName), //$NON-NLS-1$ 264 | StandardCharsets.UTF_8); 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /bundles/org.example.ui/src/org/example/ui/DataProcessingHandlerDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example.ui; 5 | 6 | import java.util.List; 7 | 8 | import org.eclipse.jface.dialogs.TitleAreaDialog; 9 | import org.eclipse.jface.layout.GridDataFactory; 10 | import org.eclipse.jface.layout.TableColumnLayout; 11 | import org.eclipse.jface.viewers.ArrayContentProvider; 12 | import org.eclipse.jface.viewers.CellEditor; 13 | import org.eclipse.jface.viewers.ColumnViewer; 14 | import org.eclipse.jface.viewers.ColumnWeightData; 15 | import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider; 16 | import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; 17 | import org.eclipse.jface.viewers.DoubleClickEvent; 18 | import org.eclipse.jface.viewers.EditingSupport; 19 | import org.eclipse.jface.viewers.IDoubleClickListener; 20 | import org.eclipse.jface.viewers.ISelectionChangedListener; 21 | import org.eclipse.jface.viewers.IStructuredSelection; 22 | import org.eclipse.jface.viewers.LabelProvider; 23 | import org.eclipse.jface.viewers.SelectionChangedEvent; 24 | import org.eclipse.jface.viewers.StyledString; 25 | import org.eclipse.jface.viewers.TableViewer; 26 | import org.eclipse.jface.viewers.TableViewerColumn; 27 | import org.eclipse.jface.viewers.TextCellEditor; 28 | import org.eclipse.jface.viewers.ViewerCell; 29 | import org.eclipse.swt.SWT; 30 | import org.eclipse.swt.graphics.Image; 31 | import org.eclipse.swt.layout.GridLayout; 32 | import org.eclipse.swt.widgets.Composite; 33 | import org.eclipse.swt.widgets.Control; 34 | import org.eclipse.swt.widgets.Shell; 35 | import org.eclipse.xtext.util.Pair; 36 | import org.eclipse.xtext.util.Tuples; 37 | 38 | import com._1c.g5.v8.dt.mcore.Field; 39 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegister; 40 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegisterDimension; 41 | import com._1c.g5.v8.dt.metadata.mdclass.AccumulationRegisterResource; 42 | import com._1c.g5.v8.dt.metadata.mdclass.BasicRegister; 43 | import com._1c.g5.v8.dt.metadata.mdclass.Document; 44 | import com._1c.g5.v8.dt.metadata.mdclass.DocumentAttribute; 45 | import com.google.common.base.Strings; 46 | import com.google.common.collect.Lists; 47 | 48 | /** 49 | * Диалог конструктора движения регистра. 50 | * В данном диалоге пользователь может выбрать регистр накопления, для которого он хочет сделать обработку проведения. 51 | * А так же указать, состав полей, которые будут учавствовать в логике работы обработчика
52 | * Данный конструктор не поддерживает работу с табличными частями документов 53 | */ 54 | public class DataProcessingHandlerDialog 55 | extends TitleAreaDialog 56 | { 57 | private final Document document; 58 | private TableViewer expressionTable; 59 | private TableViewer registerTable; 60 | private String registerName; 61 | private List> expressions; 62 | private List registers; 63 | 64 | /** 65 | * Конструктор 66 | * @param parentShell родительское окно диалога, не может быть null 67 | * @param document документ конфигурации, для модуля которого был вызван диалог, не может быть null 68 | * @param registers все регистраторы документа, типа Регистр накопления, не может быть null 69 | */ 70 | public DataProcessingHandlerDialog(Shell parentShell, Document document, List registers) 71 | { 72 | super(parentShell); 73 | this.document = document; 74 | this.registers = registers; 75 | registerName = registers.get(0).getName(); 76 | } 77 | 78 | /** 79 | * Получение выражений, заполненных пользователем, которые должны учавствовать в логике работы обработчки проведения 80 | * @return набор выражения обработчика проведения. Данный набор содержит пары значений. 81 | * Где первый элемент пары - это левая часть выражения, которое 82 | * нужно добавить в тело обработчика, а второй элемент пары - это правая часть выражения. 83 | * Не может быть null 84 | */ 85 | public List> getExpressions() 86 | { 87 | return expressions; 88 | } 89 | 90 | /** 91 | * Получение имени регистра накопления, для которого пользователь хочет создать обработчик проведения 92 | * @return имя регистра накопления, для которого создается обработчик проведения, не может быть null 93 | */ 94 | public String getRegisterName() 95 | { 96 | return registerName; 97 | } 98 | 99 | /** 100 | * Данный метод будет вызван, когда пользователь нажмет кнопку "Ок" диалога. 101 | * В нем происходит наполнение набора выражений обработчика проведения, в соответствии с теми данными, 102 | * которые указал пользователь при работе с диалогом 103 | */ 104 | @Override 105 | @SuppressWarnings("unchecked") 106 | protected void okPressed() 107 | { 108 | expressions = Lists.newArrayList(); 109 | for (Expression expr : (List)expressionTable.getInput()) 110 | { 111 | expressions.add(Tuples.create(expr.field, expr.expression)); 112 | } 113 | super.okPressed(); 114 | } 115 | 116 | /** 117 | * Данный метод создает и размещает все необходимые элементы в диалоге 118 | * {@inheritDoc} 119 | */ 120 | @Override 121 | protected Control createDialogArea(Composite parent) 122 | { 123 | setTitle(Messages.DataProcessingHandlerDialog_dialog_title); 124 | setMessage(Messages.DataProcessingHandlerDialog_dialog_message); 125 | getShell().setText(Messages.DataProcessingHandlerDialog_dialog_text); 126 | Composite control = (Composite)super.createDialogArea(parent); 127 | createTableViewer(control); 128 | 129 | return control; 130 | } 131 | 132 | private void createTableViewer(Composite control) 133 | { 134 | Composite composite = new Composite(control, SWT.NONE); 135 | composite.setLayout(new GridLayout(2, true)); 136 | GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); 137 | registerTable = createDataTable(composite, Messages.DataProcessingHandlerDialog_Registers, getRegisters()); 138 | registerTable.addSelectionChangedListener(new ISelectionChangedListener() 139 | { 140 | @Override 141 | public void selectionChanged(SelectionChangedEvent event) 142 | { 143 | //данный метод соответствует событию выбора регистра накопления из списка 144 | //при данном событии мы должны пересчитать выражения для обработчика проведения 145 | if (!registerName.equals(((IStructuredSelection)event.getSelection()).getFirstElement())) 146 | { 147 | int index = registerTable.getTable().getSelectionIndex(); 148 | registerName = registers.get(index).getName(); 149 | expressionTable.setInput(createExpressionContent(index)); 150 | expressionTable.refresh(); 151 | } 152 | } 153 | }); 154 | final TableViewer documentTable = createDataTable(composite, 155 | Messages.DataProcessingHandlerDialog_Document_attributes, getDocumentAttributes()); 156 | documentTable.addDoubleClickListener(new IDoubleClickListener() 157 | { 158 | @Override 159 | @SuppressWarnings("unchecked") 160 | public void doubleClick(DoubleClickEvent event) 161 | { 162 | //данный метод соответствует событию двойного клика на атрибуте документа 163 | //при данном событии мы заполняем правую часть активного выражения обработчика 164 | //проведения именем данного атрибута 165 | int index = documentTable.getTable().getSelectionIndex(); 166 | String documentAttr = ((List)documentTable.getInput()).get(index); 167 | int expressionIndex = expressionTable.getTable().getSelectionIndex(); 168 | List listOfExpressions = (List)expressionTable.getInput(); 169 | if (expressionIndex < 0 || expressionIndex >= listOfExpressions.size()) 170 | { 171 | expressionIndex = 0; 172 | } 173 | listOfExpressions.get(expressionIndex).expression = documentAttr; 174 | expressionTable.refresh(); 175 | } 176 | }); 177 | composite = new Composite(control, SWT.NONE); 178 | TableColumnLayout columnLayout = new TableColumnLayout(); 179 | GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); 180 | composite.setLayout(columnLayout); 181 | expressionTable = createExpressionTable(composite, columnLayout); 182 | } 183 | 184 | private TableViewer createExpressionTable(Composite composite, TableColumnLayout columnLayout) 185 | { 186 | final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION); 187 | GridDataFactory.fillDefaults().grab(true, true).applyTo(tableViewer.getTable()); 188 | int height = tableViewer.getTable().getItemHeight() * 5; 189 | tableViewer.getTable().setHeaderVisible(true); 190 | GridDataFactory.fillDefaults().hint(SWT.DEFAULT, height).grab(true, false).applyTo(tableViewer.getTable()); 191 | TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.BORDER); 192 | columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(5, ColumnWeightData.MINIMUM_WIDTH, true)); 193 | column.getColumn().setResizable(true); 194 | column.getColumn().setText(Messages.DataProcessingHandlerDialog_Field); 195 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExpressionLabelProvider(true))); 196 | column = new TableViewerColumn(tableViewer, SWT.BORDER); 197 | columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(5, ColumnWeightData.MINIMUM_WIDTH, true)); 198 | column.getColumn().setResizable(true); 199 | column.getColumn().setText(Messages.DataProcessingHandlerDialog_Expressions); 200 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExpressionLabelProvider(false))); 201 | column.setEditingSupport(new CustomEditingSupport(column.getViewer())); 202 | tableViewer.setContentProvider(ArrayContentProvider.getInstance()); 203 | tableViewer.setInput(createExpressionContent(0)); 204 | return tableViewer; 205 | } 206 | 207 | private List createExpressionContent(int index) 208 | { 209 | List documentAttr = getDocumentAttributes(); 210 | List registerAttr = getRegisterAttr(registers.get(index)); 211 | List expressionList = Lists.newArrayList(); 212 | for (String attr : registerAttr) 213 | { 214 | if (documentAttr.contains(attr)) 215 | expressionList.add(new Expression(attr, attr)); 216 | else 217 | expressionList.add(new Expression(attr, "")); //$NON-NLS-1$ 218 | } 219 | return expressionList; 220 | } 221 | 222 | private List getRegisterAttr(BasicRegister registerRecords) 223 | { 224 | List fields = Lists.newArrayList(); 225 | if (registerRecords instanceof AccumulationRegister) 226 | { 227 | for (AccumulationRegisterDimension dimension : ((AccumulationRegister)registerRecords).getDimensions()) 228 | { 229 | if (!Strings.isNullOrEmpty(dimension.getName())) 230 | fields.add(dimension.getName()); 231 | } 232 | 233 | for (AccumulationRegisterResource resource : ((AccumulationRegister)registerRecords).getResources()) 234 | { 235 | if (!Strings.isNullOrEmpty(resource.getName())) 236 | fields.add(resource.getName()); 237 | } 238 | fields.add("Период"); //TODO: сделать поддержку генерации английского варианта обработчика //$NON-NLS-1$ 239 | } 240 | return fields; 241 | } 242 | 243 | private TableViewer createDataTable(Composite composite, String headerName, List content) 244 | { 245 | final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION); 246 | int height = tableViewer.getTable().getItemHeight() * 5; 247 | tableViewer.getTable().setHeaderVisible(true); 248 | GridDataFactory.fillDefaults().hint(SWT.DEFAULT, height).grab(true, false).applyTo(tableViewer.getTable()); 249 | TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.BORDER); 250 | column.getColumn().setText(headerName); 251 | column.setLabelProvider(new DelegatingStyledCellLabelProvider(new CustomLabelProvider())); 252 | tableViewer.setContentProvider(ArrayContentProvider.getInstance()); 253 | tableViewer.setInput(content); 254 | column.getColumn().pack(); 255 | return tableViewer; 256 | } 257 | 258 | private List getRegisters() 259 | { 260 | List registerNames = Lists.newArrayList(); 261 | for (BasicRegister register : this.registers) 262 | { 263 | if (!Strings.isNullOrEmpty(register.getName())) 264 | registerNames.add(register.getName()); 265 | } 266 | return registerNames; 267 | } 268 | 269 | private List getDocumentAttributes() 270 | { 271 | List documentAttributes = Lists.newArrayList(); 272 | for (DocumentAttribute attr : document.getAttributes()) 273 | { 274 | if (!Strings.isNullOrEmpty(attr.getName())) 275 | documentAttributes.add(attr.getName()); 276 | } 277 | for (Field field : document.getFields()) 278 | { 279 | if (!Strings.isNullOrEmpty(field.getNameRu())) 280 | documentAttributes.add(field.getNameRu()); 281 | } 282 | return documentAttributes; 283 | } 284 | 285 | private static class Expression 286 | { 287 | public String field; 288 | public String expression; 289 | 290 | Expression(String field, String expression) 291 | { 292 | this.field = field; 293 | this.expression = expression; 294 | } 295 | } 296 | 297 | private static class CustomLabelProvider 298 | extends LabelProvider 299 | implements IStyledLabelProvider 300 | { 301 | @Override 302 | public String getText(Object element) 303 | { 304 | return super.getText(element); 305 | } 306 | 307 | @Override 308 | public StyledString getStyledText(Object element) 309 | { 310 | return new StyledString(super.getText(element)); 311 | } 312 | 313 | @Override 314 | public Image getImage(Object element) 315 | { 316 | return super.getImage(element); 317 | } 318 | } 319 | 320 | private static class ExpressionLabelProvider 321 | extends LabelProvider 322 | implements IStyledLabelProvider 323 | { 324 | private final boolean isFieldProvider; 325 | 326 | ExpressionLabelProvider(boolean isFieldProvider) 327 | { 328 | this.isFieldProvider = isFieldProvider; 329 | } 330 | 331 | @Override 332 | public String getText(Object element) 333 | { 334 | if (isFieldProvider) 335 | return super.getText(((Expression)element).field); 336 | else 337 | return super.getText(((Expression)element).expression); 338 | } 339 | 340 | @Override 341 | public StyledString getStyledText(Object element) 342 | { 343 | if (isFieldProvider) 344 | return new StyledString(super.getText(((Expression)element).field)); 345 | else 346 | return new StyledString(super.getText(((Expression)element).expression)); 347 | } 348 | 349 | @Override 350 | public Image getImage(Object element) 351 | { 352 | return super.getImage(element); 353 | } 354 | } 355 | 356 | private static class CustomEditingSupport 357 | extends EditingSupport 358 | { 359 | private final CellEditor editor; 360 | 361 | CustomEditingSupport(ColumnViewer viewer) 362 | { 363 | super(viewer); 364 | editor = new TextCellEditor((Composite)viewer.getControl()); 365 | } 366 | 367 | @Override 368 | protected boolean canEdit(Object arg0) 369 | { 370 | return true; 371 | } 372 | 373 | @Override 374 | protected CellEditor getCellEditor(Object arg0) 375 | { 376 | return editor; 377 | } 378 | 379 | @Override 380 | protected Object getValue(Object arg0) 381 | { 382 | return ((Expression)arg0).expression; 383 | } 384 | 385 | @Override 386 | protected void setValue(Object arg0, Object arg1) 387 | { 388 | //no op 389 | } 390 | 391 | @Override 392 | protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) 393 | { 394 | String value = (String)cellEditor.getValue(); 395 | ((Expression)cell.getElement()).expression = value; 396 | getViewer().refresh(); 397 | } 398 | } 399 | } 400 | -------------------------------------------------------------------------------- /bundles/org.example.ui/src/org/example/ui/Messages.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example.ui; 5 | 6 | import org.eclipse.osgi.util.NLS; 7 | 8 | /** 9 | * Данный класс - представитель локализации механизма строк в Eclipse. 10 | */ 11 | final class Messages 12 | extends NLS 13 | { 14 | private static final String BUNDLE_NAME = "org.example.ui.messages"; //$NON-NLS-1$ 15 | 16 | public static String DataProcessingHandler_Error_not_document_object_module; 17 | public static String DataProcessingHandler_Error_no_accumulation_registers; 18 | public static String DataProcessingHandler_Error; 19 | 20 | public static String DataProcessingHandlerDialog_dialog_title; 21 | public static String DataProcessingHandlerDialog_dialog_message; 22 | public static String DataProcessingHandlerDialog_dialog_text; 23 | public static String DataProcessingHandlerDialog_Registers; 24 | public static String DataProcessingHandlerDialog_Document_attributes; 25 | public static String DataProcessingHandlerDialog_Field; 26 | public static String DataProcessingHandlerDialog_Expressions; 27 | 28 | static 29 | { 30 | // initialize resource bundle 31 | NLS.initializeMessages(BUNDLE_NAME, Messages.class); 32 | } 33 | 34 | private Messages() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bundles/org.example.ui/src/org/example/ui/messages.properties: -------------------------------------------------------------------------------- 1 | DataProcessingHandler_Error_not_document_object_module = \u0414\u0430\u043D\u043D\u0430\u044F \u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043D\u043E\u043C \u043C\u043E\u0434\u0443\u043B\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430 2 | DataProcessingHandler_Error_no_accumulation_registers = \u041D\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D \u043D\u0438 \u043E\u0434\u0438\u043D \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043E\u0432. \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u044B \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E 3 | DataProcessingHandler_Error = \u041E\u0448\u0438\u0431\u043A\u0430! 4 | DataProcessingHandlerDialog_dialog_title = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 5 | DataProcessingHandlerDialog_dialog_message = \u0417\u0430\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F \u043C\u043E\u0434\u0443\u043B\u044F \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430 6 | DataProcessingHandlerDialog_dialog_text = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 7 | DataProcessingHandlerDialog_Registers = \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044B 8 | DataProcessingHandlerDialog_Document_attributes = \u0420\u0435\u043A\u0432\u0438\u0437\u0438\u0442\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430 9 | DataProcessingHandlerDialog_Field = \u041F\u043E\u043B\u0435 10 | DataProcessingHandlerDialog_Expressions = \u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435 11 | -------------------------------------------------------------------------------- /bundles/org.example/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bundles/org.example/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /bundles/org.example/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /bundles/org.example/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.compliance=17 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=17 8 | -------------------------------------------------------------------------------- /bundles/org.example/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %pluginName 4 | Bundle-Vendor: %providerName 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-SymbolicName: org.example;singleton:=true 7 | Bundle-ActivationPolicy: lazy 8 | Bundle-Localization: plugin 9 | Require-Bundle: com._1c.g5.v8.dt.bsl;bundle-version="[26.0.0,27.0.0)", 10 | com._1c.g5.v8.dt.bsl.model;bundle-version="[11.0.0,12.0.0)", 11 | com._1c.g5.v8.dt.mcore;bundle-version="[8.0.0,9.0.0)", 12 | org.eclipse.emf.ecore;bundle-version="[2.26.0,3.0.0)", 13 | org.eclipse.xtext;bundle-version="[2.26.0,3.0.0)" 14 | Bundle-RequiredExecutionEnvironment: JavaSE-17 15 | Automatic-Module-Name: org.example 16 | Export-Package: org.example;version="1.0.0" 17 | -------------------------------------------------------------------------------- /bundles/org.example/build.properties: -------------------------------------------------------------------------------- 1 | javacCustomEncodings.. = src/[UTF-8] 2 | source.. = src/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | plugin.xml,\ 6 | plugin.properties 7 | -------------------------------------------------------------------------------- /bundles/org.example/plugin.properties: -------------------------------------------------------------------------------- 1 | pluginName = \u041F\u0440\u0438\u043C\u0435\u0440 \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools" 2 | providerName = 1C LLC -------------------------------------------------------------------------------- /bundles/org.example/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bundles/org.example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | bundles 9 | 1.0.0-SNAPSHOT 10 | 11 | org.example 12 | 1.0.0-SNAPSHOT 13 | eclipse-plugin 14 | -------------------------------------------------------------------------------- /bundles/org.example/src/org/example/ExampleValidator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example; 5 | 6 | import org.eclipse.emf.ecore.EObject; 7 | import org.eclipse.xtext.util.CancelIndicator; 8 | import org.eclipse.xtext.validation.Check; 9 | import org.eclipse.xtext.validation.CheckType; 10 | 11 | import com._1c.g5.v8.dt.bsl.model.Method; 12 | import com._1c.g5.v8.dt.bsl.validation.CustomValidationMessageAcceptor; 13 | import com._1c.g5.v8.dt.bsl.validation.IExternalBslValidator; 14 | import com._1c.g5.v8.dt.mcore.McorePackage; 15 | 16 | /** 17 | * Пример расширения проверки модулей. 18 | * Для подробностей см. https://edt.1c.ru/dev/ru/docs/plugins/dev/lang/ 19 | * 20 | */ 21 | public class ExampleValidator 22 | implements IExternalBslValidator 23 | { 24 | public static final String ERROR_CODE = "Example_MethodNameStartWithCapitalLetter"; //$NON-NLS-1$ 25 | 26 | @Override 27 | @Check(CheckType.FAST) 28 | public void validate(EObject object, CustomValidationMessageAcceptor messageAcceptor, CancelIndicator monitor) 29 | { 30 | Method method = (Method)object; 31 | if (!Character.isUpperCase(method.getName().charAt(0))) 32 | { 33 | messageAcceptor.warning( 34 | Messages.getString("ExampleValidator.MethodNameStartWithCapitalLetter"), //$NON-NLS-1$ 35 | method, 36 | McorePackage.Literals.NAMED_ELEMENT__NAME, ERROR_CODE); 37 | } 38 | } 39 | 40 | @Override 41 | public boolean needValidation(EObject object) 42 | { 43 | return object instanceof Method; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bundles/org.example/src/org/example/Messages.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example; 5 | 6 | import java.util.MissingResourceException; 7 | import java.util.ResourceBundle; 8 | 9 | /** 10 | * Локализация 11 | */ 12 | final class Messages 13 | { 14 | private static final String BUNDLE_NAME = "org.example.messages"; //$NON-NLS-1$ 15 | 16 | private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); 17 | 18 | private Messages() 19 | { 20 | } 21 | 22 | public static String getString(String key) 23 | { 24 | try 25 | { 26 | return RESOURCE_BUNDLE.getString(key); 27 | } 28 | catch (MissingResourceException e) 29 | { 30 | return '!' + key + '!'; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bundles/org.example/src/org/example/messages.properties: -------------------------------------------------------------------------------- 1 | ExampleValidator.MethodNameStartWithCapitalLetter=\u0418\u043C\u044F \u043C\u0435\u0442\u043E\u0434\u0430 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0441 \u0437\u0430\u0433\u043B\u0430\u0432\u043D\u043E\u0439 \u0431\u0443\u043A\u0432\u044B 2 | -------------------------------------------------------------------------------- /bundles/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 13 | 4.0.0 14 | 15 | org.example 16 | parent 17 | 1.0.0-SNAPSHOT 18 | 19 | 20 | org.example 21 | bundles 22 | pom 23 | Bundles 24 | 25 | 26 | org.example 27 | org.example.ui 28 | 29 | 30 | 31 | 32 | 33 | org.eclipse.tycho 34 | tycho-source-plugin 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-checkstyle-plugin 39 | 40 | 41 | run-checkstyle 42 | validate 43 | 44 | check 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /features/org.example.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /features/org.example.feature/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /features/org.example.feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml,\ 2 | feature.properties -------------------------------------------------------------------------------- /features/org.example.feature/feature.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2020 1C-Soft LLC. 3 | # 4 | # This program and the accompanying materials are made available under 5 | # the terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/ 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # 1C-Soft LLC - initial API and implementation 12 | ############################################################################### 13 | # feature.properties 14 | # contains externalized strings for feature.xml 15 | # "%foo" in feature.xml corresponds to the key "foo" in this file 16 | # java.io.Properties file (ISO 8859-1 with "\" escapes) 17 | # This file should be translated. 18 | 19 | # "featureName" property - name of the feature 20 | featureName=Example Feature 21 | 22 | # "providerName" property - name of the company that provides the feature 23 | providerName=1C-Soft LLC 24 | 25 | # "description" property - description of the feature 26 | description=Example tycho build 27 | 28 | # "copyright" property - text of the "Feature Update Copyright" 29 | copyright=\ 30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\ 31 | This program and the accompanying materials are made available under\n\ 32 | the terms of the Eclipse Public License 2.0 which is available at\n\ 33 | https://www.eclipse.org/legal/epl-2.0/\n\n\ 34 | SPDX-License-Identifier: EPL-2.0\n 35 | ################ end of copyright property #################################### -------------------------------------------------------------------------------- /features/org.example.feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 18 | 19 | 20 | %description 21 | 22 | 23 | 24 | %copyright 25 | 26 | 27 | 28 | %license 29 | 30 | 31 | 37 | 38 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /features/org.example.feature/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 13 | 4.0.0 14 | 15 | 16 | org.example 17 | features 18 | 1.0.0-SNAPSHOT 19 | 20 | 21 | org.example.feature 22 | eclipse-feature 23 | 24 | 25 | 26 | 27 | org.eclipse.tycho 28 | tycho-source-plugin 29 | 30 | 31 | package 32 | 33 | feature-source 34 | 35 | 36 | 37 | 38 | 39 | org.eclipse.tycho 40 | tycho-p2-plugin 41 | 42 | 43 | package 44 | 45 | p2-metadata 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /features/org.example.feature/sourceTemplateFeature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml,\ 2 | feature.properties 3 | 4 | root = target/root-include -------------------------------------------------------------------------------- /features/org.example.feature/sourceTemplateFeature/feature.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2020 1C-Soft LLC. 3 | # 4 | # This program and the accompanying materials are made available under 5 | # the terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/ 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # 1C-Soft LLC - initial API and implementation 12 | ############################################################################### 13 | # feature.properties 14 | # contains externalized strings for feature.xml 15 | # "%foo" in feature.xml corresponds to the key "foo" in this file 16 | # java.io.Properties file (ISO 8859-1 with "\" escapes) 17 | # This file should be translated. 18 | 19 | # "featureName" property - name of the feature 20 | featureName=Example Source Feature 21 | 22 | # "providerName" property - name of the company that provides the feature 23 | providerName=1C-Soft LLC 24 | 25 | # "description" property - description of the feature 26 | description=Example tycho build 27 | 28 | # "copyright" property - text of the "Feature Update Copyright" 29 | copyright=\ 30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\ 31 | This program and the accompanying materials are made available under\n\ 32 | the terms of the Eclipse Public License 2.0 which is available at\n\ 33 | https://www.eclipse.org/legal/epl-2.0/\n\n\ 34 | SPDX-License-Identifier: EPL-2.0\n 35 | ################ end of copyright property #################################### -------------------------------------------------------------------------------- /features/org.example.sdk.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.sdk.feature 4 | 5 | 6 | 7 | 8 | 9 | 10 | org.eclipse.pde.FeatureNature 11 | 12 | 13 | -------------------------------------------------------------------------------- /features/org.example.sdk.feature/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /features/org.example.sdk.feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml,\ 2 | feature.properties 3 | individualSourceBundles=true 4 | generate.feature@org.example.source=org.example 5 | -------------------------------------------------------------------------------- /features/org.example.sdk.feature/feature.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2020 1C-Soft LLC. 3 | # 4 | # This program and the accompanying materials are made available under 5 | # the terms of the Eclipse Public License 2.0 which is available at 6 | # https://www.eclipse.org/legal/epl-2.0/ 7 | # 8 | # SPDX-License-Identifier: EPL-2.0 9 | # 10 | # Contributors: 11 | # 1C-Soft LLC - initial API and implementation 12 | ############################################################################### 13 | # feature.properties 14 | # contains externalized strings for feature.xml 15 | # "%foo" in feature.xml corresponds to the key "foo" in this file 16 | # java.io.Properties file (ISO 8859-1 with "\" escapes) 17 | # This file should be translated. 18 | 19 | # "featureName" property - name of the feature 20 | featureName=Example SDK Feature 21 | 22 | # "providerName" property - name of the company that provides the feature 23 | providerName=1C-Soft LLC 24 | 25 | # "description" property - description of the feature 26 | description=Example tycho build 27 | 28 | # "copyright" property - text of the "Feature Update Copyright" 29 | copyright=\ 30 | Copyright (c) 2020 1C-Soft LLC and others.\n\n\ 31 | This program and the accompanying materials are made available under\n\ 32 | the terms of the Eclipse Public License 2.0 which is available at\n\ 33 | https://www.eclipse.org/legal/epl-2.0/\n\n\ 34 | SPDX-License-Identifier: EPL-2.0\n 35 | ################ end of copyright property #################################### -------------------------------------------------------------------------------- /features/org.example.sdk.feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 18 | 19 | 20 | %description 21 | 22 | 23 | 24 | %copyright 25 | 26 | 27 | 28 | %license 29 | 30 | 31 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /features/org.example.sdk.feature/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 13 | 4.0.0 14 | 15 | 16 | org.example 17 | features 18 | 1.0.0-SNAPSHOT 19 | 20 | 21 | org.example.sdk 22 | eclipse-feature 23 | 24 | -------------------------------------------------------------------------------- /features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | parent 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | features 23 | pom 24 | 25 | Features 26 | 27 | 28 | true 29 | 30 | 31 | 32 | org.example.feature 33 | 34 | 35 | 36 | 37 | SDK 38 | 39 | 40 | org.example.sdk.feature 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /java.header: -------------------------------------------------------------------------------- 1 | ^/\**$ 2 | ^ \* Copyright \(C\) (\d\d\d\d), 1C-Soft LLC$ 3 | ^ \*/$ -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | bom 19 | 1.0.0-SNAPSHOT 20 | ./bom/pom.xml 21 | 22 | 23 | org.example 24 | parent 25 | 1.0.0-SNAPSHOT 26 | pom 27 | 28 | Tycho Build Example 29 | 30 | 31 | scm:git:git@github.com:1C-Company/dt-example-plugins.git 32 | 33 | 34 | 35 | targets 36 | bundles 37 | features 38 | repositories 39 | tests 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.eclipse.tycho 47 | tycho-p2-repository-plugin 48 | 49 | ${project.name} Repository 50 | 51 | 52 | 53 | org.eclipse.tycho 54 | target-platform-configuration 55 | 56 | 57 | 58 | 59 | eclipse-plugin 60 | org.apache.felix.scr 61 | 0.0.0 62 | 63 | 64 | eclipse-plugin 65 | org.apache.aries.spifly.dynamic.bundle 66 | 1.3.7 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /repositories/org.example.repository.sdk/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.repository.sdk 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /repositories/org.example.repository.sdk/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /repositories/org.example.repository.sdk/category.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /repositories/org.example.repository.sdk/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | repositories 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | org.example.repository.sdk 23 | eclipse-repository 24 | 25 | -------------------------------------------------------------------------------- /repositories/org.example.repository/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.repository 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /repositories/org.example.repository/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /repositories/org.example.repository/category.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /repositories/org.example.repository/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | repositories 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | org.example.repository 23 | eclipse-repository 24 | 25 | -------------------------------------------------------------------------------- /repositories/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | parent 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | repositories 23 | pom 24 | 25 | Update Sites 26 | 27 | 28 | org.example.repository 29 | 30 | 31 | 32 | ${eclipse.p2.latest} 33 | true 34 | 35 | 36 | 37 | 38 | SDK 39 | 40 | 41 | org.example.repository.sdk 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /targets/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.targets 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /targets/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /targets/default/default.target: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /targets/default/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | targets 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | org.example 23 | default 24 | 1.0.0-SNAPSHOT 25 | 26 | eclipse-target-definition 27 | 28 | Target Platform 29 | 30 | -------------------------------------------------------------------------------- /targets/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | parent 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | targets 23 | pom 24 | 25 | Targets Definitions 26 | 27 | 28 | true 29 | 30 | 31 | 32 | default 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/org.example.itests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/org.example.itests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.example.itests 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.pde.PluginNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/org.example.itests/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /tests/org.example.itests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.compliance=17 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=17 8 | -------------------------------------------------------------------------------- /tests/org.example.itests/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: %pluginName 4 | Bundle-Vendor: %providerName 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-SymbolicName: org.example.itests;singleton:=true 7 | Bundle-ActivationPolicy: lazy 8 | Bundle-Localization: plugin 9 | Require-Bundle: org.example;bundle-version="[1.0.0,2.0.0)", 10 | org.junit;bundle-version="[4.13.0,5.0.0)", 11 | org.eclipse.xtext;bundle-version="[2.26.0,3.0.0)", 12 | org.eclipse.core.resources;bundle-version="[3.16.100,4.0.0)", 13 | org.eclipse.core.runtime;bundle-version="[3.24.100,4.0.0)", 14 | com._1c.g5.v8.dt.bsl;bundle-version="[26.0.0,27.0.0)", 15 | com._1c.g5.v8.dt.bsl.core;bundle-version="[6.0.0,7.0.0)", 16 | com._1c.g5.v8.dt.bsl.model;bundle-version="[11.0.0,12.0.0)", 17 | com._1c.g5.v8.dt.core;bundle-version="[23.0.0,24.0.0)", 18 | com._1c.g5.v8.dt.mcore;bundle-version="[8.0.0,9.0.0)", 19 | com._1c.g5.v8.dt.testing;bundle-version="[3.2.200,4.0.0)", 20 | com._1c.g5.ides.core;bundle-version="[6.0.200,7.0.0)" 21 | Bundle-RequiredExecutionEnvironment: JavaSE-17 22 | Automatic-Module-Name: org.example.itests 23 | -------------------------------------------------------------------------------- /tests/org.example.itests/build.properties: -------------------------------------------------------------------------------- 1 | javacCustomEncodings.. = src/[UTF-8] 2 | source.. = src/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | workspace/,\ 6 | plugin.properties 7 | -------------------------------------------------------------------------------- /tests/org.example.itests/plugin.properties: -------------------------------------------------------------------------------- 1 | pluginName = \u0418\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0435 \u0442\u0435\u0441\u0442\u044B \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools" 2 | providerName = 1C LLC -------------------------------------------------------------------------------- /tests/org.example.itests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | tests 9 | 1.0.0-SNAPSHOT 10 | 11 | org.example.itests 12 | 1.0.0-SNAPSHOT 13 | eclipse-test-plugin 14 | -------------------------------------------------------------------------------- /tests/org.example.itests/src/org/example/itests/ExampleValidatorTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2020, 1C-Soft LLC 3 | */ 4 | package org.example.itests; 5 | 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | import org.eclipse.xtext.EcoreUtil2; 10 | import org.eclipse.xtext.diagnostics.Severity; 11 | import org.eclipse.xtext.resource.IResourceServiceProvider; 12 | import org.eclipse.xtext.resource.XtextResource; 13 | import org.eclipse.xtext.util.concurrent.IUnitOfWork; 14 | import org.eclipse.xtext.validation.CheckMode; 15 | import org.eclipse.xtext.validation.IResourceValidator; 16 | import org.eclipse.xtext.validation.Issue; 17 | import org.example.ExampleValidator; 18 | import org.junit.Assert; 19 | import org.junit.Rule; 20 | import org.junit.Test; 21 | 22 | import com._1c.g5.v8.dt.bsl.resource.BslResource; 23 | import com._1c.g5.v8.dt.core.handle.IV8File; 24 | import com._1c.g5.v8.dt.core.handle.impl.V8ModelManager; 25 | import com._1c.g5.v8.dt.core.handle.impl.V8XtextFile; 26 | import com._1c.g5.v8.dt.testing.TestingWorkspace; 27 | import com.google.common.base.Predicate; 28 | import com.google.common.collect.Collections2; 29 | 30 | /** 31 | * Пример теста на валидатор 32 | * 33 | * Больше информации о написании тестов см https://edt.1c.ru/dev/ru/docs/plugins/dev/testing/ 34 | */ 35 | public class ExampleValidatorTest 36 | { 37 | @Rule 38 | public TestingWorkspace testingWorkspace = new TestingWorkspace(); 39 | 40 | @Test 41 | public void testMethodStartsWithCapitalLetterWarning() throws Exception 42 | { 43 | check("test", "src/Configuration/ManagedApplicationModule.bsl", Severity.WARNING, //$NON-NLS-1$//$NON-NLS-2$ 44 | ExampleValidator.ERROR_CODE, 1); 45 | } 46 | 47 | private void check(String projectName, String fileName, Severity severity, final String issueCode, int lineNumber) 48 | throws Exception 49 | { 50 | Collection issues = validate(projectName, fileName); 51 | 52 | issues = Collections2.filter(issues, new Predicate() 53 | { 54 | @Override 55 | public boolean apply(Issue input) 56 | { 57 | return issueCode.equals(input.getCode()); 58 | } 59 | }); 60 | Assert.assertEquals(1, issues.size()); 61 | Issue issue = issues.iterator().next(); 62 | Assert.assertEquals(severity, issue.getSeverity()); 63 | Assert.assertEquals(lineNumber, (int)issue.getLineNumber()); 64 | } 65 | 66 | private List validate(String projectName, String fileName) throws Exception 67 | { 68 | testingWorkspace.setUpProject(projectName, getClass()); 69 | 70 | IV8File file = V8ModelManager.INSTANCE.getV8Model().getV8Project(projectName).getV8File(fileName); 71 | Assert.assertTrue(file instanceof V8XtextFile); 72 | V8XtextFile xtextFile = (V8XtextFile)file; 73 | List issues = xtextFile.readOnly(new IUnitOfWork, XtextResource>() 74 | { 75 | @Override 76 | public List exec(XtextResource state) throws Exception 77 | { 78 | 79 | Assert.assertTrue(state instanceof BslResource); 80 | BslResource resource = (BslResource)state; 81 | resource.setDeepAnalysis(true); 82 | 83 | IResourceServiceProvider provider = resource.getResourceServiceProvider(); 84 | IResourceValidator validator = provider.get(IResourceValidator.class); 85 | Assert.assertTrue(validator != null); 86 | 87 | EcoreUtil2.resolveLazyCrossReferences(resource, null); 88 | 89 | return validator.validate(resource, CheckMode.ALL, null); 90 | } 91 | }); 92 | 93 | return issues; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | test 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.xtext.ui.shared.xtextBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.xtext.ui.shared.xtextNature 16 | com._1c.g5.v8.dt.core.V8ConfigurationNature 17 | 18 | 19 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/DT-INF/PROJECT.PMF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Runtime-Version: 8.3.22 3 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/src/Configuration/CommandInterface.cmi: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/src/Configuration/Configuration.mdo: -------------------------------------------------------------------------------- 1 | 2 | 3 | Конфигурация 4 | 5 | ru 6 | Конфигурация 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 8.3.16 15 | ManagedApplication 16 | PersonalComputer 17 | Russian 18 | 19 | AllowOSBackup 20 | true 21 | 22 | Language.Русский 23 | Managed 24 | NotAutoFree 25 | DontUse 26 | DontUse 27 | 8.3.16 28 | 29 | Русский 30 | 31 | ru 32 | Русский 33 | 34 | ru 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/src/Configuration/MainSectionCommandInterface.cmi: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tests/org.example.itests/workspace/test/src/Configuration/ManagedApplicationModule.bsl: -------------------------------------------------------------------------------- 1 | процедура процедура1() экспорт 2 | Сообщить("Предупреждение"); 3 | конецпроцедуры 4 | 5 | процедура Процедура2() экспорт 6 | Сообщить("Привет"); 7 | конецпроцедуры 8 | -------------------------------------------------------------------------------- /tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 14 | 4.0.0 15 | 16 | 17 | org.example 18 | parent 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | tests 23 | pom 24 | Tests 25 | 26 | 27 | org.example.itests 28 | 29 | 30 | 31 | 32 | macosx 33 | 34 | 35 | mac os x 36 | mac 37 | 38 | 39 | 40 | -XstartOnFirstThread 41 | 42 | 43 | 44 | other-os 45 | 46 | 47 | !mac 48 | !mac 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | debug 57 | 58 | -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y 59 | 60 | 61 | 62 | 63 | 64 | -Xms80m -Xmx2g -Dosgi.module.lock.timeout=24 --add-modules=ALL-SYSTEM --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.eclipse.tycho 72 | target-platform-configuration 73 | 74 | 75 | 76 | org.example 77 | default 78 | 1.0.0-SNAPSHOT 79 | 80 | 81 | 82 | 83 | 84 | p2-installable-unit 85 | com._1c.g5.v8.dt.rcp 86 | 0.0.0 87 | 88 | 89 | eclipse-feature 90 | com._1c.g5.v8.dt.platform.support_v8.3.22.feature 91 | 0.0.0 92 | 93 | 94 | 95 | p2 96 | 97 | 98 | 99 | org.jacoco 100 | jacoco-maven-plugin 101 | 102 | 103 | prepare-agent 104 | 105 | prepare-agent 106 | 107 | 108 | 109 | report 110 | verify 111 | 112 | report 113 | 114 | 115 | 116 | report-aggregate 117 | verify 118 | 119 | report-aggregate 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | org.eclipse.tycho 130 | tycho-surefire-plugin 131 | 132 | true 133 | true 134 | ${ui.test.vmargs} ${tycho-surefire-plugin.vmargs} ${debug.vmargs} 135 | ${project.build.directory}/work 136 | p2Installed 137 | 138 | 139 | 140 | 141 | 142 | 143 | --------------------------------------------------------------------------------