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

refactor: remove javax.annotation #36

Merged
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
9 changes: 4 additions & 5 deletions src/main/java/com/redhat/devtools/lsp4ij/LSPIJUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -93,8 +92,8 @@ public static void openInEditor(VirtualFile file, Position position, Project pro
}
}

@Nonnull
public static Language getFileLanguage(@Nonnull VirtualFile file, Project project) {
@NotNull
public static Language getFileLanguage(@NotNull VirtualFile file, Project project) {
return ReadAction.compute(() -> LanguageUtil.getLanguageForPsi(project, file));
}

Expand Down Expand Up @@ -230,8 +229,8 @@ public static Position toPosition(int offset, Document document) {
return new Position(line, column);
}

@Nonnull
public static WorkspaceFolder toWorkspaceFolder(@Nonnull Project project) {
@NotNull
public static WorkspaceFolder toWorkspaceFolder(@NotNull Project project) {
WorkspaceFolder folder = new WorkspaceFolder();
folder.setUri(toUri(project).toASCIIString());
folder.setName(project.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
import com.redhat.devtools.lsp4ij.client.LanguageClientImpl;
import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.jsonrpc.validation.NonNull;
import org.eclipse.lsp4j.services.LanguageServer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.swing.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -44,22 +42,22 @@ enum Scope {

private static final int DEFAULT_LAST_DOCUMENTED_DISCONNECTED_TIMEOUT = 5;

public final @Nonnull
public final @NotNull
String id;
public final @Nonnull
public final @NotNull
String label;
public final boolean isSingleton;
public final @Nonnull
public final @NotNull
Map<Language, String> languageIdMappings;
public final String description;
public final int lastDocumentDisconnectedTimeout;
private boolean enabled;

public final boolean supportsLightEdit;

final @Nonnull Scope scope;
final @NotNull Scope scope;

public LanguageServerDefinition(@Nonnull String id, @Nonnull String label, String description, boolean isSingleton, Integer lastDocumentDisconnectedTimeout, String scope, boolean supportsLightEdit) {
public LanguageServerDefinition(@NotNull String id, @NotNull String label, String description, boolean isSingleton, Integer lastDocumentDisconnectedTimeout, String scope, boolean supportsLightEdit) {
this.id = id;
this.label = label;
this.description = description;
Expand Down Expand Up @@ -90,11 +88,11 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public void registerAssociation(@Nonnull Language language, @Nonnull String languageId) {
public void registerAssociation(@NotNull Language language, @NotNull String languageId) {
this.languageIdMappings.put(language, languageId);
}

@Nonnull
@NotNull
public String getDisplayName() {
return label != null ? label : id;
}
Expand Down Expand Up @@ -282,7 +280,7 @@ public DocumentMatcher getDocumentMatcher() {
*
* @return the language server definition for the given language server id and null otherwise.
*/
public @Nullable LanguageServerDefinition getServerDefinition(@NonNull String languageServerId) {
public @Nullable LanguageServerDefinition getServerDefinition(@NotNull String languageServerId) {
return serverDefinitions.get(languageServerId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
*******************************************************************************/
package com.redhat.devtools.lsp4ij.internal;

import java.util.Arrays;
import java.util.List;

import org.eclipse.lsp4j.*;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.List;

/**
*
*/
public class SupportedFeatures {

public static @Nonnull TextDocumentClientCapabilities getTextDocumentClientCapabilities() {
public static @NotNull TextDocumentClientCapabilities getTextDocumentClientCapabilities() {
final var textDocumentClientCapabilities = new TextDocumentClientCapabilities();

// Code Action support
Expand Down Expand Up @@ -119,7 +118,7 @@ public class SupportedFeatures {
return textDocumentClientCapabilities;
}

public static @Nonnull WorkspaceClientCapabilities getWorkspaceClientCapabilities() {
public static @NotNull WorkspaceClientCapabilities getWorkspaceClientCapabilities() {
final var workspaceClientCapabilities = new WorkspaceClientCapabilities();
workspaceClientCapabilities.setApplyEdit(Boolean.TRUE);
// TODO
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/redhat/devtools/lsp4ij/server/OS.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.lsp4ij.server;

import java.util.Locale;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.lsp4ij.server;

import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Objects;

/**
* Process stream connection provider used to start a language server with a process.
*/
public abstract class ProcessStreamConnectionProvider implements StreamConnectionProvider {
private @Nullable
Process process;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package com.redhat.devtools.lsp4ij.server;

import org.eclipse.lsp4j.jsonrpc.messages.Message;
import org.eclipse.lsp4j.services.LanguageServer;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nullable;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;

/**
* Stream connection provider API used to:
* <ul>
* <li>start a language server.</li>
* <li>get the stream of LSP requests, responses and notifications.</li>
* </ul>
*/
public interface StreamConnectionProvider {

void start() throws CannotStartProcessException;
Expand Down
Loading