Skip to content

Commit ccce387

Browse files
committed
Make a few static methods non-static to directly use fields (instead of args)
1 parent ca8ff64 commit ccce387

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/java/engineering/swat/watch/impl/mac/NativeEventStream.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,23 @@ public NativeEventStream(Path path, NativeEventHandler handler) throws IOExcepti
100100

101101
public synchronized void open() {
102102
if (!closed) {
103-
throw new IllegalStateException("Stream already open");
103+
throw new IllegalStateException("Stream is already open");
104104
} else {
105105
closed = false;
106106
}
107107

108108
// Allocate native memory. (Checker Framework: The local variables are
109109
// `@NonNull` copies of the `@Nullable` fields.)
110-
var callback = this.callback = createCallback(path, handler);
111-
var stream = this.stream = createFSEventStream(path, callback);
110+
var callback = this.callback = createCallback();
111+
var stream = this.stream = createFSEventStream(callback);
112112
var queue = this.queue = createDispatchQueue();
113113

114114
// Start the stream
115115
FSE.FSEventStreamSetDispatchQueue(stream, queue);
116116
FSE.FSEventStreamStart(stream);
117117
}
118118

119-
private static FSEventStreamCallback createCallback(Path path, NativeEventHandler handler) {
119+
private FSEventStreamCallback createCallback() {
120120
return new FSEventStreamCallback() {
121121
@Override
122122
public void callback(Pointer streamRef, Pointer clientCallBackInfo,
@@ -132,10 +132,10 @@ public void callback(Pointer streamRef, Pointer clientCallBackInfo,
132132
for (var i = 0; i < numEvents; i++) {
133133
var context = path.relativize(Path.of(paths[i]));
134134

135-
// Note: Multiple "physical" native events might be merged
136-
// into a single "logical" native event, so the following
137-
// series of checks should be if-statements (instead of
138-
// if/else-statements).
135+
// Note: Multiple "physical" native events might be
136+
// coalesced into a single "logical" native event, so the
137+
// following series of checks should be if-statements
138+
// (instead of if/else-statements).
139139
if (any(flags[i], ITEM_CREATED.mask)) {
140140
handler.handle(ENTRY_CREATE, context);
141141
}
@@ -157,7 +157,7 @@ private boolean any(int bits, int mask) {
157157
};
158158
}
159159

160-
private static Pointer createFSEventStream(Path path, FSEventStreamCallback callback) {
160+
private Pointer createFSEventStream(FSEventStreamCallback callback) {
161161
try (
162162
var pathsToWatch = new Strings(path.toString());
163163
) {
@@ -170,7 +170,7 @@ private static Pointer createFSEventStream(Path path, FSEventStreamCallback call
170170
}
171171
}
172172

173-
private static Pointer createDispatchQueue() {
173+
private Pointer createDispatchQueue() {
174174
var label = "engineering.swat.watch";
175175
var attr = Pointer.NULL;
176176
return DQ.dispatch_queue_create(label, attr);

0 commit comments

Comments
 (0)