Skip to content

Commit a6b6127

Browse files
committed
pretty-print 'default' modifier
1 parent 0287ac0 commit a6b6127

36 files changed

+87
-84
lines changed

lsif-semanticdb/src/main/java/com/sourcegraph/lsif_semanticdb/SignatureFormatter.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,7 @@ private void formatMethodSignature(MethodSignature methodSignature) {
151151
printKeywordln(formatAnnotations());
152152
printKeyword(formatAccess());
153153

154-
String owner = SymbolDescriptor.parseFromSymbol(symbolInformation.getSymbol()).owner;
155-
SymbolInformation ownerSymbol =
156-
symtab.symbols.get(SymbolDescriptor.parseFromSymbol(symbolInformation.getSymbol()).owner);
157-
if (ownerSymbol != null && ownerSymbol.getKind() != SymbolInformation.Kind.INTERFACE)
158-
printKeyword(formatModifiers());
154+
printKeyword(formatModifiers());
159155

160156
List<SymbolInformation> typeParameters = getSymlinks(methodSignature.getTypeParameters());
161157
if (!typeParameters.isEmpty()) {
@@ -169,6 +165,7 @@ private void formatMethodSignature(MethodSignature methodSignature) {
169165
printKeyword(formatType(methodSignature.getReturnType()));
170166
s.append(symbolInformation.getDisplayName());
171167
} else {
168+
String owner = SymbolDescriptor.parseFromSymbol(symbolInformation.getSymbol()).owner;
172169
// Fix for https://github.com/sourcegraph/lsif-java/issues/150
173170
if (!owner.equals(SemanticdbSymbols.NONE)) {
174171
s.append(SymbolDescriptor.parseFromSymbol(owner).descriptor.name);
@@ -402,17 +399,13 @@ private String formatAccess() {
402399
return "";
403400
}
404401

402+
// https://checkstyle.sourceforge.io/config_modifier.html#ModifierOrder
405403
private String formatModifiers() {
406404
ArrayList<String> modifiers = new ArrayList<>();
407-
if (has(Property.ABSTRACT)) {
408-
modifiers.add("abstract");
409-
}
410-
if (has(Property.STATIC)) {
411-
modifiers.add("static");
412-
}
413-
if (has(Property.FINAL)) {
414-
modifiers.add("final");
415-
}
405+
if (has(Property.ABSTRACT)) modifiers.add("abstract");
406+
if (has(Property.DEFAULT)) modifiers.add("default");
407+
if (has(Property.STATIC)) modifiers.add("static");
408+
if (has(Property.FINAL)) modifiers.add("final");
416409
return String.join(" ", modifiers);
417410
}
418411

semanticdb-java/src/main/protobuf/semanticdb.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ message SymbolInformation {
9797
SEALED = 0x10;
9898
STATIC = 0x1000;
9999
ENUM = 0x4000;
100+
DEFAULT = 0x8000;
100101
}
101102
reserved 2, 6, 7, 8, 9, 10, 11, 12, 14, 15;
102103
string symbol = 1;

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,12 @@ private int semanticdbSymbolInfoProperties(Symbol sym) {
530530
int properties = 0;
531531
properties |= sym.isEnum() ? Property.ENUM_VALUE : 0;
532532
properties |= sym.isStatic() ? Property.STATIC_VALUE : 0;
533-
properties |= (sym.flags() & Flags.ABSTRACT) > 0 ? Property.ABSTRACT_VALUE : 0;
533+
// for default interface methods, Flags.ABSTRACT is also set...
534+
boolean abstractNotDefault =
535+
((sym.flags() & Flags.ABSTRACT) > 0) && ((sym.flags() & Flags.DEFAULT) == 0);
536+
properties |= abstractNotDefault ? Property.ABSTRACT_VALUE : 0;
534537
properties |= (sym.flags() & Flags.FINAL) > 0 ? Property.FINAL_VALUE : 0;
538+
properties |= (sym.flags() & Flags.DEFAULT) > 0 ? Property.DEFAULT_VALUE : 0;
535539
return properties;
536540
}
537541

tests/minimized/src/main/java/minimized/Interfaces.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package minimized;
22

33
public interface Interfaces {
4+
static void staticInterfaceMethod() {}
5+
46
String abstractInterfaceMethod();
57

68
default String defaultInterfaceMethod() {

tests/snapshots/src/main/generated/com/airbnb/epoxy/AsyncEpoxyDiffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AsyncEpoxyDiffer {
5555
interface ResultCallback {
5656
// ^^^^^^^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback# interface ResultCallback
5757
void onResult(@NonNull DiffResult result);
58-
// ^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback#onResult(). public void onResult(DiffResult result)
58+
// ^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback#onResult(). public abstract void onResult(DiffResult result)
5959
// ^^^^^^^ reference androidx/annotation/NonNull#
6060
// ^^^^^^^^^^ reference com/airbnb/epoxy/DiffResult#
6161
// ^^^^^^ definition local0 @NonNull DiffResult result

tests/snapshots/src/main/generated/com/airbnb/epoxy/BaseEpoxyTouchCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface BaseEpoxyTouchCallback<T extends EpoxyModel> {
2121
* @see androidx.recyclerview.widget.ItemTouchHelper.Callback#getMovementFlags
2222
*/
2323
int getMovementFlagsForModel(T model, int adapterPosition);
24-
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback#getMovementFlagsForModel(). public int getMovementFlagsForModel(T model, int adapterPosition)
24+
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback#getMovementFlagsForModel(). public abstract int getMovementFlagsForModel(T model, int adapterPosition)
2525
// ^ reference com/airbnb/epoxy/BaseEpoxyTouchCallback#[T]
2626
// ^^^^^ definition local0 T model
2727
// ^^^^^^^^^^^^^^^ definition local1 int adapterPosition
@@ -37,7 +37,7 @@ interface BaseEpoxyTouchCallback<T extends EpoxyModel> {
3737
* @param itemView The view being cleared.
3838
*/
3939
void clearView(T model, View itemView);
40-
// ^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback#clearView(). public void clearView(T model, unresolved_type itemView)
40+
// ^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback#clearView(). public abstract void clearView(T model, unresolved_type itemView)
4141
// ^ reference com/airbnb/epoxy/BaseEpoxyTouchCallback#[T]
4242
// ^^^^^ definition local2 T model
4343
// ^^^^ reference _root_/

tests/snapshots/src/main/generated/com/airbnb/epoxy/EpoxyAttribute.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ enum Option {
104104
// ^^^^^^ reference com/airbnb/epoxy/EpoxyAttribute#Option#`<init>`().
105105
Option[] value() default {};
106106
//^^^^^^ reference com/airbnb/epoxy/EpoxyAttribute#Option#
107-
// ^^^^^ definition com/airbnb/epoxy/EpoxyAttribute#value(). public Option[] value()
107+
// ^^^^^ definition com/airbnb/epoxy/EpoxyAttribute#value(). public abstract Option[] value()
108108

109109
/**
110110
* Whether or not to include this attribute in equals and hashCode calculations.
@@ -117,7 +117,7 @@ enum Option {
117117
@Deprecated
118118
// ^^^^^^^^^^ reference java/lang/Deprecated#
119119
boolean hash() default true;
120-
// ^^^^ definition com/airbnb/epoxy/EpoxyAttribute#hash(). @Deprecated public boolean hash()
120+
// ^^^^ definition com/airbnb/epoxy/EpoxyAttribute#hash(). @Deprecated public abstract boolean hash()
121121

122122
/**
123123
* Whether or not to generate setter for this attribute.
@@ -130,5 +130,5 @@ enum Option {
130130
@Deprecated
131131
// ^^^^^^^^^^ reference java/lang/Deprecated#
132132
boolean setter() default true;
133-
// ^^^^^^ definition com/airbnb/epoxy/EpoxyAttribute#setter(). @Deprecated public boolean setter()
133+
// ^^^^^^ definition com/airbnb/epoxy/EpoxyAttribute#setter(). @Deprecated public abstract boolean setter()
134134
}

tests/snapshots/src/main/generated/com/airbnb/epoxy/EpoxyController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,11 @@ void addAfterInterceptorCallback(ModelInterceptorCallback callback) {
672672
interface ModelInterceptorCallback {
673673
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback# interface ModelInterceptorCallback
674674
void onInterceptorsStarted(EpoxyController controller);
675-
// ^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback#onInterceptorsStarted(). public void onInterceptorsStarted(EpoxyController controller)
675+
// ^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback#onInterceptorsStarted(). public abstract void onInterceptorsStarted(EpoxyController controller)
676676
// ^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyController#
677677
// ^^^^^^^^^^ definition local18 EpoxyController controller
678678
void onInterceptorsFinished(EpoxyController controller);
679-
// ^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback#onInterceptorsFinished(). public void onInterceptorsFinished(EpoxyController controller)
679+
// ^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback#onInterceptorsFinished(). public abstract void onInterceptorsFinished(EpoxyController controller)
680680
// ^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyController#
681681
// ^^^^^^^^^^ definition local19 EpoxyController controller
682682
}
@@ -750,7 +750,7 @@ public interface Interceptor {
750750
* exception.
751751
*/
752752
void intercept(@NonNull List<EpoxyModel<?>> models);
753-
// ^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#Interceptor#intercept(). public void intercept(List<EpoxyModel<?>> models)
753+
// ^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#Interceptor#intercept(). public abstract void intercept(List<EpoxyModel<?>> models)
754754
// ^^^^^^^ reference androidx/annotation/NonNull#
755755
// ^^^^ reference java/util/List#
756756
// ^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyModel#
@@ -1448,7 +1448,7 @@ public interface ExceptionHandler {
14481448
* @param controller The EpoxyController that the error occurred in.
14491449
*/
14501450
void onException(@NonNull EpoxyController controller, @NonNull RuntimeException exception);
1451-
// ^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ExceptionHandler#onException(). public void onException(EpoxyController controller, RuntimeException exception)
1451+
// ^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ExceptionHandler#onException(). public abstract void onException(EpoxyController controller, RuntimeException exception)
14521452
// ^^^^^^^ reference androidx/annotation/NonNull#
14531453
// ^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyController#
14541454
// ^^^^^^^^^^ definition local63 @NonNull EpoxyController controller

tests/snapshots/src/main/generated/com/airbnb/epoxy/EpoxyDataBindingLayouts.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/** A list of databinding layout resources that should have EpoxyModel's generated for them. */
5151
@LayoutRes int[] value();
5252
// ^^^^^^^^^ reference androidx/annotation/LayoutRes#
53-
// ^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingLayouts#value(). @LayoutRes public int[] value()
53+
// ^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingLayouts#value(). @LayoutRes public abstract int[] value()
5454

5555
/**
5656
* If true, any variable whose type does not implement equals and hashcode will have the
@@ -62,5 +62,5 @@
6262
* For details on the nuances of this, see https://github.com/airbnb/epoxy/wiki/DoNotHash
6363
*/
6464
boolean enableDoNotHash() default true;
65-
// ^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingLayouts#enableDoNotHash(). public boolean enableDoNotHash()
65+
// ^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingLayouts#enableDoNotHash(). public abstract boolean enableDoNotHash()
6666
}

tests/snapshots/src/main/generated/com/airbnb/epoxy/EpoxyDataBindingPattern.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*/
4646
Class<?> rClass();
4747
//^^^^^ reference java/lang/Class#
48-
// ^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#rClass(). public Class<?> rClass()
48+
// ^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#rClass(). public abstract Class<?> rClass()
4949
/**
5050
* A string prefix that your databinding layouts start with. Epoxy will generate a model for each
5151
* databinding layout whose name starts with this.
@@ -55,7 +55,7 @@
5555
*/
5656
String layoutPrefix();
5757
//^^^^^^ reference java/lang/String#
58-
// ^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#layoutPrefix(). public String layoutPrefix()
58+
// ^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#layoutPrefix(). public abstract String layoutPrefix()
5959

6060
/**
6161
* If true, any variable whose type does not implement equals and hashcode will have the
@@ -67,5 +67,5 @@
6767
* For details on the nuances of this, see https://github.com/airbnb/epoxy/wiki/DoNotHash
6868
*/
6969
boolean enableDoNotHash() default true;
70-
// ^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#enableDoNotHash(). public boolean enableDoNotHash()
70+
// ^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDataBindingPattern#enableDoNotHash(). public abstract boolean enableDoNotHash()
7171
}

0 commit comments

Comments
 (0)