Skip to content

Commit be73105

Browse files
committed
Merge branch 'develop' into async-1818
2 parents df450f4 + 288df9e commit be73105

File tree

47 files changed

+1075
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1075
-102
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
# Initializes the CodeQL tools for scanning.
3939
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v1
40+
uses: github/codeql-action/init@v2
4141
# Override language selection by uncommenting this and choosing your languages
4242
with:
4343
languages: java
@@ -52,4 +52,4 @@ jobs:
5252
- run: ./gradlew jar
5353

5454
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@v1
55+
uses: github/codeql-action/analyze@v2

.github/workflows/pre-qa.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Pre-QA
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- "translations_*"
7+
pull_request:
8+
9+
jobs:
10+
gatekeeper:
11+
runs-on: ubuntu-latest
12+
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'translations_') == false || github.event_name == 'push'
13+
steps:
14+
- run: echo 'Open the Golden Gate'
15+
build:
16+
needs: gatekeeper
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Save PR number to file
20+
if: github.event_name == 'pull_request'
21+
run: echo ${{ github.event.number }} > PR_NUMBER.txt
22+
- name: Archive PR number
23+
if: github.event_name == 'pull_request'
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: PR_NUMBER
27+
path: PR_NUMBER.txt

.github/workflows/qa.yml

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,66 @@
11
name: QA
22

33
on:
4-
push:
5-
branches: [develop, master]
6-
7-
pull_request:
4+
workflow_run:
5+
workflows: [Pre-QA]
6+
types: [completed]
87

98
jobs:
10-
gatekeeper:
11-
runs-on: ubuntu-latest
12-
if: github.event_name == 'pull_request' && (!startsWith(github.head_ref, 'translations_') == false || github.event.pull_request.user.login != 'dependabot[bot]') || github.event_name == 'push'
13-
steps:
14-
- run: echo 'Open the Golden Gate'
159

1610
QA:
17-
needs: gatekeeper
1811
runs-on: ubuntu-latest
19-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name
12+
if: github.event.workflow_run.conclusion == 'success'
2013
steps:
14+
- name: Download PR number artifact
15+
if: github.event.workflow_run.event == 'pull_request'
16+
uses: dawidd6/action-download-artifact@v2
17+
with:
18+
workflow: ${{ github.event.workflow_run.name }}
19+
run_id: ${{ github.event.workflow_run.id }}
20+
name: PR_NUMBER
21+
- name: Read PR_NUMBER.txt
22+
if: github.event.workflow_run.event == 'pull_request'
23+
id: pr_number
24+
uses: juliangruber/read-file-action@v1
25+
with:
26+
path: ./PR_NUMBER.txt
27+
- name: Request GitHub API for PR data
28+
if: github.event.workflow_run.event == 'pull_request'
29+
uses: octokit/request-action@v2.x
30+
id: get_pr_data
31+
with:
32+
route: GET /repos/{full_name}/pulls/{number}
33+
number: ${{ steps.pr_number.outputs.content }}
34+
full_name: ${{ github.event.repository.full_name }}
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2137
- uses: actions/checkout@v3
2238
with:
23-
fetch-depth: ''
24-
- run: |
25-
git fetch --prune --unshallow
39+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
40+
ref: ${{ github.event.workflow_run.head_branch }}
41+
fetch-depth: 0
42+
- name: Checkout base branch
43+
if: github.event.workflow_run.event == 'pull_request'
44+
run: |
45+
git remote add upstream ${{ github.event.repository.clone_url }}
46+
git fetch upstream
47+
git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
48+
git checkout ${{ github.event.workflow_run.head_branch }}
49+
git clean -ffdx && git reset --hard HEAD
2650
- name: Set up JDK 11
2751
uses: actions/setup-java@v3
2852
with:
2953
java-version: 11
3054
distribution: 'temurin'
31-
- name: SonarCloud Scan
32-
run: ./gradlew check sonarqube
55+
- name: SonarCloud Scan on PR
56+
if: github.event.workflow_run.event == 'pull_request'
57+
run: ./gradlew check sonarqube -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
58+
env:
59+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
- name: SonarCloud Scan on push
62+
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
63+
run: ./gradlew check sonarqube -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.branch.name=${{ github.event.workflow_run.head_branch }}
3364
env:
3465
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3566
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/qodana.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v3
2222
- name: 'Qodana Scan'
23-
uses: JetBrains/qodana-action@v4.2.5
23+
uses: JetBrains/qodana-action@v5.1.0
2424
with:
2525
linter: jetbrains/qodana-jvm-community
26-
- uses: github/codeql-action/upload-sarif@v1
26+
- uses: github/codeql-action/upload-sarif@v2
2727
with:
2828
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
2929
- name: Deploy to GitHub Pages

.github/workflows/rebase.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
token: ${{ secrets.GITHUB_TOKEN }}
1515
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
1616
- name: Automatic Rebase
17-
uses: cirrus-actions/rebase@1.6
17+
uses: cirrus-actions/rebase@1.7
1818
env:
1919
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
id("io.freefair.javadoc-utf-8") version "6.4.3"
1515
id("io.freefair.aspectj.post-compile-weaving") version "6.4.3"
1616
id("io.freefair.maven-central.validate-poms") version "6.4.3"
17-
id("me.qoomon.git-versioning") version "5.2.0"
17+
id("me.qoomon.git-versioning") version "6.1.1"
1818
id("com.github.ben-manes.versions") version "0.42.0"
1919
id("org.springframework.boot") version "2.6.7"
2020
id("io.spring.dependency-management") version "1.0.11.RELEASE"
@@ -63,7 +63,7 @@ dependencies {
6363
api("org.eclipse.lsp4j", "org.eclipse.lsp4j", "0.12.0")
6464

6565
// 1c-syntax
66-
api("com.github.1c-syntax", "bsl-parser", "0.20.3") {
66+
api("com.github.1c-syntax", "bsl-parser", "0.21.0") {
6767
exclude("com.tunnelvisionlabs", "antlr4-annotations")
6868
exclude("com.ibm.icu", "*")
6969
exclude("org.antlr", "ST4")

qodana.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
version: "1.0"
22
profile:
33
name: qodana.starter
4+
include:
5+
- name: CheckDependencyLicenses
46
exclude:
57
- name: OptionalUsedAsFieldOrParameterType

src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.cli;
2323

24-
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
2524
import com.github._1c_syntax.bsl.languageserver.context.ServerContext;
2625
import com.github._1c_syntax.bsl.languageserver.providers.FormatProvider;
2726
import com.github._1c_syntax.utils.Absolute;
@@ -41,10 +40,10 @@
4140
import java.net.URI;
4241
import java.nio.charset.StandardCharsets;
4342
import java.nio.file.Path;
44-
import java.util.Collection;
45-
import java.util.Collections;
43+
import java.util.ArrayList;
4644
import java.util.List;
4745
import java.util.concurrent.Callable;
46+
import java.util.regex.Pattern;
4847

4948
import static picocli.CommandLine.Command;
5049
import static picocli.CommandLine.Option;
@@ -75,6 +74,7 @@
7574
@RequiredArgsConstructor
7675
public class FormatCommand implements Callable<Integer> {
7776

77+
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
7878
private final ServerContext serverContext;
7979
private final FormatProvider formatProvider;
8080

@@ -99,18 +99,12 @@ public class FormatCommand implements Callable<Integer> {
9999
public Integer call() {
100100
serverContext.clear();
101101

102-
Path srcDir = Absolute.path(srcDirOption);
103-
if (!srcDir.toFile().exists()) {
104-
LOGGER.error("Source dir `{}` is not exists", srcDir);
105-
return 1;
106-
}
102+
String[] filePaths = COMMA_PATTERN.split(srcDirOption);
107103

108-
Collection<File> files;
104+
List<File> files = findFilesForFormatting(filePaths);
109105

110-
if(srcDir.toFile().isDirectory()) {
111-
files = FileUtils.listFiles(srcDir.toFile(), new String[]{"bsl", "os"}, true);
112-
} else {
113-
files = Collections.singletonList(srcDir.toFile());
106+
if (files.isEmpty()) {
107+
return 1;
114108
}
115109

116110
if (silentMode) {
@@ -132,6 +126,25 @@ public Integer call() {
132126
return 0;
133127
}
134128

129+
private List<File> findFilesForFormatting(String[] filePaths) {
130+
List<File> files = new ArrayList<>();
131+
for (String filePath : filePaths) {
132+
Path srcDir = Absolute.path(filePath);
133+
if (!srcDir.toFile().exists()) {
134+
LOGGER.error("Source dir `{}` is not exists", srcDir);
135+
continue;
136+
}
137+
138+
if(srcDir.toFile().isDirectory()) {
139+
files.addAll(FileUtils.listFiles(srcDir.toFile(), new String[]{"bsl", "os"}, true));
140+
} else {
141+
files.add(srcDir.toFile());
142+
}
143+
}
144+
145+
return files;
146+
}
147+
135148
@SneakyThrows
136149
private void formatFile(File file) {
137150
String textDocumentContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8);

src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.github._1c_syntax.bsl.languageserver.configuration.codelens.CodeLensOptions;
3030
import com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions;
3131
import com.github._1c_syntax.bsl.languageserver.configuration.documentlink.DocumentLinkOptions;
32+
import com.github._1c_syntax.bsl.languageserver.configuration.formating.FormattingOptions;
3233
import com.github._1c_syntax.utils.Absolute;
3334
import lombok.AccessLevel;
3435
import lombok.AllArgsConstructor;
@@ -88,6 +89,10 @@ public class LanguageServerConfiguration {
8889
@JsonProperty("documentLink")
8990
@Setter(value = AccessLevel.NONE)
9091
private DocumentLinkOptions documentLinkOptions = new DocumentLinkOptions();
92+
93+
@JsonProperty("formatting")
94+
@Setter(value = AccessLevel.NONE)
95+
private FormattingOptions formattingOptions = new FormattingOptions();
9196

9297
private String siteRoot = "https://1c-syntax.github.io/bsl-language-server";
9398
private boolean useDevSite;
@@ -213,6 +218,7 @@ private void copyPropertiesFrom(LanguageServerConfiguration configuration) {
213218
PropertyUtils.copyProperties(this.codeLensOptions, configuration.codeLensOptions);
214219
PropertyUtils.copyProperties(this.diagnosticsOptions, configuration.diagnosticsOptions);
215220
PropertyUtils.copyProperties(this.documentLinkOptions, configuration.documentLinkOptions);
221+
PropertyUtils.copyProperties(this.formattingOptions, configuration.formattingOptions);
216222
}
217223

218224
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2022
5+
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
package com.github._1c_syntax.bsl.languageserver.configuration.formating;
23+
24+
import com.fasterxml.jackson.annotation.JsonCreator;
25+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
26+
import lombok.AllArgsConstructor;
27+
import lombok.Data;
28+
import lombok.NoArgsConstructor;
29+
30+
@Data
31+
@AllArgsConstructor(onConstructor = @__({@JsonCreator(mode = JsonCreator.Mode.DISABLED)}))
32+
@NoArgsConstructor
33+
@JsonIgnoreProperties(ignoreUnknown = true)
34+
public class FormattingOptions {
35+
private boolean useUpperCaseForOrNotAndKeywords = true;
36+
private boolean useKeywordsFormatting = true;
37+
}

0 commit comments

Comments
 (0)