File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed
main/java/com/github/_1c_syntax/bsl/languageserver/providers
java/com/github/_1c_syntax/bsl/languageserver/providers Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,11 @@ public String getNewText(
246
246
newTextBuilder .append (StringUtils .repeat ("\n " + currentIndentation , token .getLine () - lastLine - 1 ));
247
247
}
248
248
249
+ if (needNewLine && tokenType == BSLLexer .DOT && additionalIndentLevel < 0 ) {
250
+ currentIndentLevel ++;
251
+ additionalIndentLevel = currentIndentLevel ;
252
+ }
253
+
249
254
// Decrement indent on operators ends and right paren.
250
255
if (needDecrementIndent (tokenType )) {
251
256
currentIndentLevel --;
Original file line number Diff line number Diff line change @@ -231,6 +231,32 @@ void testFormatEngKeywords() throws IOException {
231
231
assertThat (textEdit .getNewText ()).isEqualTo (formattedFileContent );
232
232
}
233
233
234
+ @ Test
235
+ void testFormatFluent () throws IOException {
236
+ var originalFile = new File ("./src/test/resources/providers/formatFluent.bsl" );
237
+ var formattedFile = new File ("./src/test/resources/providers/format_formattedFluent.bsl" );
238
+ // given
239
+ DocumentFormattingParams params = new DocumentFormattingParams ();
240
+ params .setTextDocument (getTextDocumentIdentifier ());
241
+ params .setOptions (new FormattingOptions (2 , true ));
242
+
243
+ String fileContent = FileUtils .readFileToString (originalFile , StandardCharsets .UTF_8 );
244
+ String formattedFileContent = FileUtils .readFileToString (formattedFile , StandardCharsets .UTF_8 );
245
+ var documentContext = TestUtils .getDocumentContext (
246
+ URI .create (params .getTextDocument ().getUri ()),
247
+ fileContent
248
+ );
249
+
250
+ // when
251
+ List <TextEdit > textEdits = formatProvider .getFormatting (params , documentContext );
252
+
253
+ // then
254
+ assertThat (textEdits ).hasSize (1 );
255
+
256
+ TextEdit textEdit = textEdits .get (0 );
257
+ assertThat (textEdit .getNewText ()).isEqualTo (formattedFileContent );
258
+ }
259
+
234
260
@ Test
235
261
void testFormatUnaryMinus () {
236
262
Original file line number Diff line number Diff line change
1
+ Процедура ДляФорматирования ()
2
+
3
+ Утверждения()
4
+ .Что(ЗадаНаКонтейнер)
5
+ .Свойство("Статус" )
6
+ .Равно(Перечисления .усСтатусыЗадач.Завершена);
7
+
8
+ КонецПроцедуры
Original file line number Diff line number Diff line change
1
+ Процедура ДляФорматирования ()
2
+
3
+ Утверждения()
4
+ .Что(ЗадаНаКонтейнер)
5
+ .Свойство("Статус" )
6
+ .Равно(Перечисления .усСтатусыЗадач.Завершена);
7
+
8
+ КонецПроцедуры
You can’t perform that action at this time.
0 commit comments