Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve customizability through more protected methods and fields #236

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2022 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -27,7 +27,7 @@
import org.eclipse.glsp.server.utils.MapUtil;

public class WorkflowGLSPServer extends DefaultGLSPServer {
private static final Logger LOGGER = LogManager.getLogger(WorkflowGLSPServer.class);
protected static final Logger LOGGER = LogManager.getLogger(WorkflowGLSPServer.class);
private static final String MESSAGE_KEY = "message";
private static final String TIMESTAMP_KEY = "timestamp";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020-2022 EclipseSource and others.
* Copyright (c) 2020-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -27,15 +27,15 @@
import org.eclipse.glsp.server.types.Severity;

public class LogActionHandler extends AbstractActionHandler<LogAction> {
private static Logger LOGGER = LogManager.getLogger(LogActionHandler.class);
protected static Logger LOGGER = LogManager.getLogger(LogActionHandler.class);

@Override
protected List<Action> executeAction(final LogAction action) {
LOGGER.log(toLevel(action.getSeverity()), action.getMessage());
return Collections.emptyList();
}

private static Level toLevel(final Severity severity) {
public static Level toLevel(final Severity severity) {
return Level.toLevel(severity.toString(), Level.DEBUG);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020-2021 EclipseSource and others.
* Copyright (c) 2020-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -37,7 +37,7 @@ public List<Action> executeAction(final RequestContextActions action) {
return actions;
}

private LogAction createLogAction(final RequestContextActions request, final SetContextActions response) {
protected LogAction createLogAction(final RequestContextActions request, final SetContextActions response) {
return new LogAction(Severity.OK,
"create " + response.getActions().size() + " server actions for " + request.getContextId() + ".");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -35,7 +35,7 @@
*/
public class EMapTypeAdapter<T> extends TypeAdapter<EMap<?, ?>> {

private final Gson gson;
protected final Gson gson;

public static class Factory implements TypeAdapterFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2023 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -57,15 +57,15 @@ public static boolean excludeField(final Field field) {
return new EObjectExclusionStrategy().shouldSkipField(attributes);
}

private static boolean isInnerClass(final Class<?> clazz) {
protected static boolean isInnerClass(final Class<?> clazz) {
return clazz.isMemberClass() && !isStatic(clazz);
}

private static boolean isStatic(final Class<?> clazz) {
protected static boolean isStatic(final Class<?> clazz) {
return (clazz.getModifiers() & Modifier.STATIC) != 0;
}

private static boolean isAnonymousOrNonStaticLocal(final Class<?> clazz) {
protected static boolean isAnonymousOrNonStaticLocal(final Class<?> clazz) {
return !Enum.class.isAssignableFrom(clazz) && !isStatic(clazz)
&& (clazz.isAnonymousClass() || clazz.isLocalClass());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -54,11 +54,11 @@ public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> typeToken)

}

private static String VALUE_FIELD_NAME = "value";
protected static String VALUE_FIELD_NAME = "value";

private final Map<String, T> nameToConstant = new HashMap<>();
private final Map<Integer, T> valueToConstant = new HashMap<>();
private final Map<T, Integer> constantToValue = new HashMap<>();
protected final Map<String, T> nameToConstant = new HashMap<>();
protected final Map<Integer, T> valueToConstant = new HashMap<>();
protected final Map<T, Integer> constantToValue = new HashMap<>();

EnumTypeAdapter(final Class<T> classOfT) throws IllegalAccessException {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2023 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -44,7 +44,7 @@

public class GModelElementTypeAdapter extends PropertyBasedTypeAdapter<GModelElement> {

private static final Logger LOGGER = LogManager.getLogger(GModelElementTypeAdapter.class);
protected static final Logger LOGGER = LogManager.getLogger(GModelElementTypeAdapter.class);

private final Gson gson;
private final Map<String, EClass> typeMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,30 +26,30 @@

public class GModelChangeNotifierImpl extends EContentAdapter implements GModelChangeNotifier {

private List<GModelListener> listeners = new CopyOnWriteArrayList<>();
protected List<GModelListener> listeners = new CopyOnWriteArrayList<>();

public GModelChangeNotifierImpl(EObject target) {
public GModelChangeNotifierImpl(final EObject target) {
target.eAdapters().add(this);
}

@Override
public void notifyChanged(Notification notification) {
public void notifyChanged(final Notification notification) {
super.notifyChanged(notification);
listeners.forEach(listener -> listener.notifyChanged(notification));
}

@Override
public void addListener(GModelListener listener) {
public void addListener(final GModelListener listener) {
listeners.add(listener);
}

@Override
public void removeListener(GModelListener listener) {
public void removeListener(final GModelListener listener) {
listeners.remove(listener);
}

@Override
public boolean isAdapterForType(Object type) {
public boolean isAdapterForType(final Object type) {
return GModelChangeNotifierImpl.class.equals(type);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2021 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -49,9 +49,9 @@
*/
public class GModelIndexImpl extends ECrossReferenceAdapter implements GModelIndex {

private final Map<String, GModelElement> idToElement = new HashMap<>();
private final Map<EClass, Set<GModelElement>> typeToElements = new HashMap<>();
private final GModelElement root;
protected final Map<String, GModelElement> idToElement = new HashMap<>();
protected final Map<EClass, Set<GModelElement>> typeToElements = new HashMap<>();
protected final GModelElement root;

public GModelIndexImpl(final EObject target) {
Preconditions.checkArgument(target instanceof GModelElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@Singleton
public class EMFModelStateImpl extends DefaultGModelState implements EMFModelState, ClientSessionListener {

private static Logger LOGGER = LogManager.getLogger(EMFModelStateImpl.class.getSimpleName());
protected static Logger LOGGER = LogManager.getLogger(EMFModelStateImpl.class.getSimpleName());

@Inject
protected ClientSessionManager clientSessionManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class EMFSourceModelStorage implements SourceModelStorage {

private static Logger LOGGER = LogManager.getLogger(EMFSourceModelStorage.class.getSimpleName());
protected static Logger LOGGER = LogManager.getLogger(EMFSourceModelStorage.class.getSimpleName());

@Inject
protected EMFModelState modelState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2022 EclipseSource and others.
* Copyright (c) 2022-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -54,7 +54,7 @@ public Optional<Command> createCommand(final ChangeBoundsOperation operation) {
return compoundCommand.getCommandList().isEmpty() ? Optional.empty() : Optional.of(compoundCommand);
}

private List<Command> updateShape(final EditingDomain editingDomain, final Shape shape,
protected List<Command> updateShape(final EditingDomain editingDomain, final Shape shape,
final ElementAndBounds elementAndBounds) {
List<Command> commands = new ArrayList<>();
if (elementAndBounds.getNewPosition() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class WebsocketServerLauncher extends GLSPServerLauncher {
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed. Accepting requests on port:";
private static Logger LOGGER = LogManager.getLogger(WebsocketServerLauncher.class);
protected static Logger LOGGER = LogManager.getLogger(WebsocketServerLauncher.class);
protected Server server;
protected final String endpointPath;
protected final Level websocketLogLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class RequestEditValidationHandler extends AbstractActionHandler<RequestEditValidationAction> {

private static Logger LOGGER = LogManager.getLogger(RequestEditValidationHandler.class);
protected static Logger LOGGER = LogManager.getLogger(RequestEditValidationHandler.class);

@Inject
protected ContextEditValidatorRegistry contextEditValidatorRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static ValidationStatus error(final String message, final Throwable throw
return new ValidationStatus(Severity.ERROR, message, throwable);
}

private static ResponseError toError(final Throwable throwable) {
public static ResponseError toError(final Throwable throwable) {
return throwable == null ? null : RemoteEndpoint.DEFAULT_EXCEPTION_HANDLER.apply(throwable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.google.gson.JsonSyntaxException;

public class JsonOpenerOptions {
private static final Logger LOGGER = LogManager.getLogger(JsonOpenerOptions.class);
protected static final Logger LOGGER = LogManager.getLogger(JsonOpenerOptions.class);

private TextSelection selection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class ResolveNavigationTargetActionHandler extends AbstractActionHandler<ResolveNavigationTargetAction> {

private static final Logger LOGGER = LogManager.getLogger(ResolveNavigationTargetActionHandler.class);
protected static final Logger LOGGER = LogManager.getLogger(ResolveNavigationTargetActionHandler.class);

@Inject
protected Optional<NavigationTargetResolver> navigationTargetResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ protected void notifyClient(final ClientNotification clientNotification) {
actionDispatcher.dispatch(new SourceModelChangedAction(clientNotification.modelSourceName));
}

class FileWatchWorker extends Thread {
protected class FileWatchWorker extends Thread {

private boolean stopped;
private boolean paused;
protected boolean stopped;
protected boolean paused;

private final String clientId;
private final Path filePath;
private WatchKey key;
protected final String clientId;
protected final Path filePath;
protected WatchKey key;

FileWatchWorker(final String clientId, final Path filePath) {
super();
Expand Down Expand Up @@ -180,7 +180,7 @@ public void run() {
}
}

private void pollEventsAndNotifyClient(final Path directory)
protected void pollEventsAndNotifyClient(final Path directory)
throws IOException {
for (final WatchEvent<?> event : key.pollEvents()) {
if (!paused && !stopped && Files.isSameFile(directory.resolve((Path) event.context()), filePath)) {
Expand Down Expand Up @@ -209,8 +209,8 @@ public void continueNotifications() {

protected class ClientNotification {

private final String clientId;
private final String modelSourceName;
protected final String clientId;
protected final String modelSourceName;

ClientNotification(final String clientId, final String modelSourceName) {
super();
Expand Down Expand Up @@ -242,7 +242,7 @@ public boolean equals(final Object obj) {
return Objects.equals(clientId, other.clientId) && Objects.equals(modelSourceName, other.modelSourceName);
}

private FileWatcher getEnclosingInstance() { return FileWatcher.this; }
protected FileWatcher getEnclosingInstance() { return FileWatcher.this; }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.google.inject.Inject;

public class UndoRedoActionHandler implements ActionHandler {
private static final Logger LOGGER = LogManager.getLogger(UndoRedoActionHandler.class);
protected static final Logger LOGGER = LogManager.getLogger(UndoRedoActionHandler.class);

@Inject
protected ModelSubmissionHandler modelSubmissionHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class RequestMarkersHandler extends AbstractActionHandler<RequestMarkersAction> {

private static final Logger LOGGER = LogManager.getLogger(RequestMarkersHandler.class);
protected static final Logger LOGGER = LogManager.getLogger(RequestMarkersHandler.class);

@Inject
protected Optional<ModelValidator> validator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class GModelChangeBoundsOperationHandler extends GModelOperationHandler<ChangeBoundsOperation> {

private static Logger LOGGER = LogManager.getLogger(GModelChangeBoundsOperationHandler.class);
protected static Logger LOGGER = LogManager.getLogger(GModelChangeBoundsOperationHandler.class);

@Override
public Optional<Command> createCommand(final ChangeBoundsOperation operation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Applies {@link DeleteOperation} directly to the GModel.
*/
public class GModelDeleteOperationHandler extends GModelOperationHandler<DeleteOperation> {
private static Logger LOGGER = LogManager.getLogger(GModelDeleteOperationHandler.class);
protected static Logger LOGGER = LogManager.getLogger(GModelDeleteOperationHandler.class);
protected Set<String> allDependantsIds;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
public class GModelPasteOperationHandler extends GModelOperationHandler<PasteOperation> {

private static final int DEFAULT_OFFSET = 20;
protected static final int DEFAULT_OFFSET = 20;

protected final Gson gson;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/
public class GModelStorage implements SourceModelStorage {

private static Logger LOGGER = LogManager.getLogger(GModelStorage.class);
protected static Logger LOGGER = LogManager.getLogger(GModelStorage.class);
public static final String EMPTY_ROOT_ID = "glsp-graph";

@Inject
Expand Down
Loading
Loading