1
+ /*
2
+ * Copyright 2024 DiffPlug
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
package com .diffplug .spotless .extra .glue .jdt ;
2
17
3
18
import java .util .Comparator ;
@@ -58,10 +73,10 @@ static String sortMember(String code, SortProperties properties) {
58
73
try {
59
74
CompilationUnit compilationUnit = compilationUnit (code );
60
75
DefaultJavaElementComparator comparator = DefaultJavaElementComparator .of (
61
- properties .doNotSortFields ,
62
- properties .membersOrder ,
63
- properties .sortByVisibility ,
64
- properties .visibilityOrder );
76
+ properties .doNotSortFields ,
77
+ properties .membersOrder ,
78
+ properties .sortByVisibility ,
79
+ properties .visibilityOrder );
65
80
new Sorter (AST .getJLSLatest (), compilationUnit , null , comparator ).sort ();
66
81
String content = compilationUnit .getBuffer ().getContents ();
67
82
if (content != null ) {
@@ -81,17 +96,13 @@ private static class Buffer implements IBuffer {
81
96
this .contents = contents ;
82
97
}
83
98
84
- public void addBufferChangedListener (IBufferChangedListener listener ) {
85
- }
99
+ public void addBufferChangedListener (IBufferChangedListener listener ) {}
86
100
87
- public void append (char [] text ) {
88
- }
101
+ public void append (char [] text ) {}
89
102
90
- public void append (String text ) {
91
- }
103
+ public void append (String text ) {}
92
104
93
- public void close () {
94
- }
105
+ public void close () {}
95
106
96
107
public char getChar (int position ) {
97
108
return '\u0000' ;
@@ -133,20 +144,15 @@ public boolean isReadOnly() {
133
144
return true ;
134
145
}
135
146
136
- public void removeBufferChangedListener (IBufferChangedListener listener ) {
137
- }
147
+ public void removeBufferChangedListener (IBufferChangedListener listener ) {}
138
148
139
- public void replace (int position , int length , char [] text ) {
140
- }
149
+ public void replace (int position , int length , char [] text ) {}
141
150
142
- public void replace (int position , int length , String text ) {
143
- }
151
+ public void replace (int position , int length , String text ) {}
144
152
145
- public void save (IProgressMonitor progress , boolean force ) {
146
- }
153
+ public void save (IProgressMonitor progress , boolean force ) {}
147
154
148
- public void setContents (char [] contents ) {
149
- }
155
+ public void setContents (char [] contents ) {}
150
156
151
157
public void setContents (String contents ) {
152
158
this .contents = contents ;
@@ -172,12 +178,11 @@ static class SortProperties {
172
178
final String visibilityOrder ;
173
179
174
180
SortProperties (
175
- boolean enabled ,
176
- String membersOrder ,
177
- boolean doNotSortFields ,
178
- boolean sortByVisibility ,
179
- String visibilityOrder
180
- ) {
181
+ boolean enabled ,
182
+ String membersOrder ,
183
+ boolean doNotSortFields ,
184
+ boolean sortByVisibility ,
185
+ String visibilityOrder ) {
181
186
this .enabled = enabled ;
182
187
this .membersOrder = membersOrder ;
183
188
this .doNotSortFields = doNotSortFields ;
0 commit comments