Skip to content

Commit c620f59

Browse files
authored
Merge pull request #176 from sourcegraph/nsc/fix-interface-sigs
2 parents 339a445 + a6b6127 commit c620f59

26 files changed

+45
-37
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ private void formatClassSignature(ClassSignature classSignature) {
5252
.anyMatch(t -> t.getTypeRef().getSymbol().equals(ANNOTATION_SYMBOL));
5353

5454
boolean isEnum = has(Property.ENUM);
55+
boolean isInterface = symbolInformation.getKind() == SymbolInformation.Kind.INTERFACE;
5556

5657
printKeywordln(formatAnnotations());
5758

5859
printKeyword(formatAccess());
59-
if (!isEnum && !isAnnotation) printKeyword(formatModifiers());
60+
if (!isEnum && !isAnnotation && !isInterface) printKeyword(formatModifiers());
6061

6162
switch (symbolInformation.getKind()) {
6263
case CLASS:
@@ -149,6 +150,7 @@ private void formatClassSignature(ClassSignature classSignature) {
149150
private void formatMethodSignature(MethodSignature methodSignature) {
150151
printKeywordln(formatAnnotations());
151152
printKeyword(formatAccess());
153+
152154
printKeyword(formatModifiers());
153155

154156
List<SymbolInformation> typeParameters = getSymlinks(methodSignature.getTypeParameters());
@@ -449,17 +451,13 @@ private String formatAccess() {
449451
return "";
450452
}
451453

454+
// https://checkstyle.sourceforge.io/config_modifier.html#ModifierOrder
452455
private String formatModifiers() {
453456
ArrayList<String> modifiers = new ArrayList<>();
454-
if (has(Property.ABSTRACT)) {
455-
modifiers.add("abstract");
456-
}
457-
if (has(Property.STATIC)) {
458-
modifiers.add("static");
459-
}
460-
if (has(Property.FINAL)) {
461-
modifiers.add("final");
462-
}
457+
if (has(Property.ABSTRACT)) modifiers.add("abstract");
458+
if (has(Property.DEFAULT)) modifiers.add("default");
459+
if (has(Property.STATIC)) modifiers.add("static");
460+
if (has(Property.FINAL)) modifiers.add("final");
463461
return String.join(" ", modifiers);
464462
}
465463

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
@@ -536,8 +536,12 @@ private int semanticdbSymbolInfoProperties(Symbol sym) {
536536
int properties = 0;
537537
properties |= sym.isEnum() ? Property.ENUM_VALUE : 0;
538538
properties |= sym.isStatic() ? Property.STATIC_VALUE : 0;
539-
properties |= (sym.flags() & Flags.ABSTRACT) > 0 ? Property.ABSTRACT_VALUE : 0;
539+
// for default interface methods, Flags.ABSTRACT is also set...
540+
boolean abstractNotDefault =
541+
((sym.flags() & Flags.ABSTRACT) > 0) && ((sym.flags() & Flags.DEFAULT) == 0);
542+
properties |= abstractNotDefault ? Property.ABSTRACT_VALUE : 0;
540543
properties |= (sym.flags() & Flags.FINAL) > 0 ? Property.FINAL_VALUE : 0;
544+
properties |= (sym.flags() & Flags.DEFAULT) > 0 ? Property.DEFAULT_VALUE : 0;
541545
return properties;
542546
}
543547

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
@@ -53,7 +53,7 @@ class AsyncEpoxyDiffer {
5353
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer# class AsyncEpoxyDiffer
5454

5555
interface ResultCallback {
56-
// ^^^^^^^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback# abstract static interface ResultCallback
56+
// ^^^^^^^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback# interface ResultCallback
5757
void onResult(@NonNull DiffResult result);
5858
// ^^^^^^^^ definition com/airbnb/epoxy/AsyncEpoxyDiffer#ResultCallback#onResult(). public abstract void onResult(DiffResult result)
5959
// ^^^^^^^ reference androidx/annotation/NonNull#

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// ^^^^ reference android/view/View#
77

88
interface BaseEpoxyTouchCallback<T extends EpoxyModel> {
9-
// ^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback# abstract interface BaseEpoxyTouchCallback<T extends EpoxyModel>
9+
// ^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback# interface BaseEpoxyTouchCallback<T extends EpoxyModel>
1010
// ^ definition com/airbnb/epoxy/BaseEpoxyTouchCallback#[T] T extends EpoxyModel
1111
// ^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyModel#
1212

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ void addAfterInterceptorCallback(ModelInterceptorCallback callback) {
670670
* to allow changes.
671671
*/
672672
interface ModelInterceptorCallback {
673-
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback# abstract static interface ModelInterceptorCallback
673+
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback# interface ModelInterceptorCallback
674674
void onInterceptorsStarted(EpoxyController controller);
675675
// ^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ModelInterceptorCallback#onInterceptorsStarted(). public abstract void onInterceptorsStarted(EpoxyController controller)
676676
// ^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyController#
@@ -738,7 +738,7 @@ private void runInterceptors() {
738738

739739
/** A callback that is run after {@link #buildModels()} completes and before diffing is run. */
740740
public interface Interceptor {
741-
// ^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#Interceptor# public abstract static interface Interceptor
741+
// ^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#Interceptor# public interface Interceptor
742742
/**
743743
* This is called immediately after {@link #buildModels()} and before diffing is run and the
744744
* models are set on the adapter. This is a final chance to make any changes to the the models
@@ -1437,7 +1437,7 @@ public static void setGlobalExceptionHandler(
14371437
}
14381438

14391439
public interface ExceptionHandler {
1440-
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ExceptionHandler# public abstract static interface ExceptionHandler
1440+
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyController#ExceptionHandler# public interface ExceptionHandler
14411441
/**
14421442
* This is called when recoverable exceptions happen at runtime. They can be ignored and Epoxy
14431443
* will recover, but you can override this to be aware of when they happen.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* For use with {@link EpoxyModelTouchCallback}
1010
*/
1111
public interface EpoxyDragCallback<T extends EpoxyModel> extends BaseEpoxyTouchCallback<T> {
12-
// ^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDragCallback# public abstract interface EpoxyDragCallback<T extends EpoxyModel> extends BaseEpoxyTouchCallback<T>
12+
// ^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyDragCallback# public interface EpoxyDragCallback<T extends EpoxyModel> extends BaseEpoxyTouchCallback<T>
1313
// ^ definition com/airbnb/epoxy/EpoxyDragCallback#[T] T extends EpoxyModel
1414
// ^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyModel#
1515
// ^^^^^^^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/BaseEpoxyTouchCallback#

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ public void addIf(@NonNull AddPredicate predicate, @NonNull EpoxyController cont
648648
* @see #addIf(AddPredicate, EpoxyController)
649649
*/
650650
public interface AddPredicate {
651-
// ^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModel#AddPredicate# public abstract static interface AddPredicate
651+
// ^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModel#AddPredicate# public interface AddPredicate
652652
boolean addIf();
653653
// ^^^^^ definition com/airbnb/epoxy/EpoxyModel#AddPredicate#addIf(). public abstract boolean addIf()
654654
}
@@ -913,7 +913,7 @@ public EpoxyModel<T> spanSizeOverride(@Nullable SpanSizeOverrideCallback spanSiz
913913
}
914914

915915
public interface SpanSizeOverrideCallback {
916-
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModel#SpanSizeOverrideCallback# public abstract static interface SpanSizeOverrideCallback
916+
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModel#SpanSizeOverrideCallback# public interface SpanSizeOverrideCallback
917917
int getSpanSize(int totalSpanCount, int position, int itemCount);
918918
// ^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModel#SpanSizeOverrideCallback#getSpanSize(). public abstract int getSpanSize(int totalSpanCount, int position, int itemCount)
919919
// ^^^^^^^^^^^^^^ definition local54 int totalSpanCount

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ private void iterateModels(ModelGroupHolder holder, IterateModelsCallback callba
540540
}
541541

542542
private interface IterateModelsCallback {
543-
// ^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModelGroup#IterateModelsCallback# private abstract static interface IterateModelsCallback
543+
// ^^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyModelGroup#IterateModelsCallback# private interface IterateModelsCallback
544544
void onModel(EpoxyModel model, EpoxyViewHolder viewHolder, int modelIndex);
545545
// ^^^^^^^ definition com/airbnb/epoxy/EpoxyModelGroup#IterateModelsCallback#onModel(). public abstract void onModel(EpoxyModel model, EpoxyViewHolder viewHolder, int modelIndex)
546546
// ^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyModel#

0 commit comments

Comments
 (0)