code = diagnostic.getCode();
51 | return code == null //
52 | ? diagnostic.getMessage()
53 | : diagnostic.getMessage() + " [" + code.get() + "]"; //$NON-NLS-1$//$NON-NLS-2$
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageClientImpl.java:
--------------------------------------------------------------------------------
1 | package org.eclipse.lsp4e;
2 |
3 | import org.eclipse.lsp4e.client.DefaultLanguageClient;
4 |
5 | /**
6 | * This class is deprecated, and only present to avoid breaking
7 | * existing code due to the refactor done to make the previous
8 | * class officially available as API.
9 | *
10 | * Use {@link DefaultLanguageClient} instead.
11 | */
12 | @Deprecated(forRemoval = true)
13 | public class LanguageClientImpl extends DefaultLanguageClient {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/Versioned.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022-3 Cocotec Ltd and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Ahmed Hussain (Cocotec Ltd) - initial implementation
11 | *
12 | *******************************************************************************/
13 | package org.eclipse.lsp4e;
14 |
15 | import org.eclipse.jface.text.IDocument;
16 | import org.eclipse.lsp4e.internal.DocumentUtil;
17 |
18 | /**
19 | * Bundles together a result from a language server with the document version at the time it was run.
20 | * Supports optimistic locking.
21 | *
22 | * @param
23 | */
24 | public class Versioned {
25 | protected final IDocument document;
26 | public final long sourceDocumentVersion;
27 | public final T data;
28 |
29 | /**
30 | * Constructs a new Versioned for the given document, and specify source version
31 | */
32 | public Versioned(final IDocument document, long sourceDocumentVersion, final T data) {
33 | this.document = document;
34 | this.sourceDocumentVersion = sourceDocumentVersion;
35 | this.data = data;
36 | }
37 |
38 | /**
39 | * Constructs a new Versioned for the given document, using its current modification
40 | * stamp as source version.
41 | */
42 | public Versioned(final IDocument document, final T data) {
43 | this(document, DocumentUtil.getDocumentModificationStamp(document), data);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/VersionedEdits.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022-3 Cocotec Ltd and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Ahmed Hussain (Cocotec Ltd) - initial implementation
11 | *
12 | *******************************************************************************/
13 | package org.eclipse.lsp4e;
14 |
15 | import java.util.ConcurrentModificationException;
16 | import java.util.List;
17 |
18 | import org.eclipse.jface.text.BadLocationException;
19 | import org.eclipse.jface.text.IDocument;
20 | import org.eclipse.lsp4e.internal.DocumentUtil;
21 | import org.eclipse.lsp4j.TextEdit;
22 |
23 | /**
24 | * Specialization of Versioned
for document edits specifically
25 | *
26 | */
27 | public class VersionedEdits extends Versioned> {
28 |
29 | public VersionedEdits(long version, List extends TextEdit> data, IDocument document) {
30 | super(document, version, data);
31 | }
32 |
33 | /**
34 | * Apply the edits from the server, provided the document is unchanged since the request used
35 | * to compute the edits
36 | *
37 | * @throws BadLocationException
38 | * @throws ConcurrentModificationException if the document has changed since the server
39 | * received the request
40 | */
41 | public void apply() throws BadLocationException, ConcurrentModificationException {
42 | if (this.sourceDocumentVersion != DocumentUtil.getDocumentModificationStamp(this.document)) {
43 | throw new ConcurrentModificationException();
44 | } else {
45 | LSPEclipseUtils.applyEdits(this.document, data);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/callhierarchy/CallHierarchyCommandHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Avaloq Group AG (http://www.avaloq.com).
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Andrew Lamb (Avaloq Group AG) - Initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.callhierarchy;
13 |
14 | import org.eclipse.core.commands.ExecutionEvent;
15 | import org.eclipse.jdt.annotation.Nullable;
16 | import org.eclipse.jface.text.IDocument;
17 | import org.eclipse.jface.text.ITextSelection;
18 | import org.eclipse.lsp4e.LSPEclipseUtils;
19 | import org.eclipse.lsp4e.LanguageServerPlugin;
20 | import org.eclipse.lsp4e.internal.LSPDocumentAbstractHandler;
21 | import org.eclipse.lsp4e.ui.UI;
22 | import org.eclipse.lsp4j.ServerCapabilities;
23 | import org.eclipse.ui.PartInitException;
24 | import org.eclipse.ui.texteditor.ITextEditor;
25 |
26 | /**
27 | * Command handler for the LSP call hierarchy view.
28 | */
29 | public class CallHierarchyCommandHandler extends LSPDocumentAbstractHandler {
30 |
31 | @Override
32 | protected void execute(ExecutionEvent event, ITextEditor editor) {
33 | IDocument document = LSPEclipseUtils.getDocument(editor);
34 | if (document == null) {
35 | return;
36 | }
37 | if (editor.getSelectionProvider().getSelection() instanceof ITextSelection sel) {
38 | int offset = sel.getOffset();
39 |
40 | try {
41 | CallHierarchyView theView = UI.showView(CallHierarchyView.ID);
42 | theView.initialize(document, offset);
43 | } catch (PartInitException e) {
44 | LanguageServerPlugin.logError("Error while opening the Call Hierarchy view", e); //$NON-NLS-1$
45 | }
46 | }
47 | }
48 |
49 | @Override
50 | public void setEnabled(final @Nullable Object evaluationContext) {
51 | setEnabled(ServerCapabilities::getCallHierarchyProvider, this::hasSelection);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/callhierarchy/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.callhierarchy;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/client/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.client;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/command/internal/CommandConverter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2019 Fraunhofer FOKUS and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.command.internal;
10 |
11 | import org.eclipse.core.commands.AbstractParameterValueConverter;
12 | import org.eclipse.core.commands.ParameterValueConversionException;
13 | import org.eclipse.jdt.annotation.Nullable;
14 | import org.eclipse.lsp4j.Command;
15 |
16 | import com.google.gson.Gson;
17 | import com.google.gson.GsonBuilder;
18 |
19 | /**
20 | * This converter can be used to serialize/deserialize instances of LSP {@link Command}s.
21 | */
22 | public class CommandConverter extends AbstractParameterValueConverter {
23 |
24 | private final Gson gson;
25 |
26 | public CommandConverter() {
27 | this.gson = new GsonBuilder().create();
28 | }
29 |
30 | @Override
31 | public @Nullable Object convertToObject(@Nullable String parameterValue) throws ParameterValueConversionException {
32 | return gson.fromJson(parameterValue, Command.class);
33 | }
34 |
35 | @Override
36 | public String convertToString(@Nullable Object parameterValue) throws ParameterValueConversionException {
37 | return gson.toJson(parameterValue);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/command/internal/CommandEventParameter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2019 Fraunhofer FOKUS and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.command.internal;
10 |
11 | import java.util.Collections;
12 |
13 | import org.eclipse.core.commands.IParameter;
14 | import org.eclipse.core.commands.IParameterValues;
15 | import org.eclipse.core.commands.ITypedParameter;
16 | import org.eclipse.core.commands.ParameterType;
17 | import org.eclipse.core.commands.ParameterValuesException;
18 |
19 | /**
20 | * This parameter class is needed for defining an Eclipse command (a handler can
21 | * be registered for) for an LSP Command.
22 | */
23 | public class CommandEventParameter implements IParameter, ITypedParameter {
24 |
25 | private final ParameterType paramType;
26 | private final String name;
27 | private final String id;
28 |
29 | public CommandEventParameter(ParameterType paramType, String name, String id) {
30 | super();
31 | this.paramType = paramType;
32 | this.name = name;
33 | this.id = id;
34 | }
35 |
36 | @Override
37 | public ParameterType getParameterType() {
38 | return paramType;
39 | }
40 |
41 | @Override
42 | public String getId() {
43 | return id;
44 | }
45 |
46 | @Override
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | @Override
52 | public IParameterValues getValues() throws ParameterValuesException {
53 | return Collections::emptyMap;
54 | }
55 |
56 | @Override
57 | public boolean isOptional() {
58 | return false;
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/command/internal/PathConverter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2019 Fraunhofer FOKUS and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.command.internal;
10 |
11 | import java.util.Objects;
12 |
13 | import org.eclipse.core.commands.AbstractParameterValueConverter;
14 | import org.eclipse.core.commands.ParameterValueConversionException;
15 | import org.eclipse.core.runtime.IPath;
16 | import org.eclipse.core.runtime.Path;
17 | import org.eclipse.jdt.annotation.Nullable;
18 |
19 | /**
20 | * Serializes {@link IPath} instances and de-serializes them to {@link Path} instances.
21 | */
22 | public class PathConverter extends AbstractParameterValueConverter {
23 |
24 | @Override
25 | public @Nullable Object convertToObject(@Nullable String parameterValue) throws ParameterValueConversionException {
26 | return parameterValue == null ? null : new Path(parameterValue);
27 | }
28 |
29 | @Override
30 | public String convertToString(@Nullable Object parameterValue) throws ParameterValueConversionException {
31 | return Objects.toString(parameterValue);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/command/internal/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.command.internal;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/command/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.command;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/enablement/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.enablement;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/format/DefaultFormatRegionsProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * See git history
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.format;
13 |
14 | import org.eclipse.jdt.annotation.Nullable;
15 | import org.eclipse.jface.text.IDocument;
16 | import org.eclipse.jface.text.IRegion;
17 | import org.osgi.service.component.annotations.Component;
18 |
19 | /**
20 | * Default OSGi service implementation if no bundle provides a OSGi service for {@link IFormatRegionsProvider}.
21 | *
22 | */
23 | @Component
24 | public class DefaultFormatRegionsProvider implements IFormatRegionsProvider {
25 |
26 | @Override
27 | public IRegion @Nullable [] getFormattingRegions(IDocument document) {
28 | // return null until user can disable the format-on-save feature in LSP4E.
29 | return null;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/format/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.format;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/CancellationUtil.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Avaloq Group AG.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Rubén Porras Campo (Avaloq Group AG) - Initial Implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import java.util.concurrent.CancellationException;
15 | import java.util.concurrent.CompletionException;
16 | import java.util.concurrent.ExecutionException;
17 |
18 | import org.eclipse.jdt.annotation.Nullable;
19 | import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
20 | import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
21 | import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode;
22 |
23 | public final class CancellationUtil {
24 |
25 | private CancellationUtil() {
26 | // this class shouldn't be instantiated
27 | }
28 |
29 | public static boolean isRequestCancelledException(@Nullable Throwable throwable) {
30 | if (throwable instanceof CompletionException || throwable instanceof ExecutionException) {
31 | throwable = throwable.getCause();
32 | }
33 | if (throwable instanceof ResponseErrorException responseErrorException) {
34 | return isRequestCancelled(responseErrorException);
35 | }
36 | return throwable instanceof CancellationException;
37 | }
38 |
39 | private static boolean isRequestCancelled(ResponseErrorException responseErrorException) {
40 | ResponseError responseError = responseErrorException.getResponseError();
41 | return responseError != null
42 | && responseError.getCode() == ResponseErrorCode.RequestCancelled.getValue();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/DocumentInputStream.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2024 Sebastian Thomschke and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Sebastian Thomschke - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import org.eclipse.jface.text.IDocument;
15 |
16 | public final class DocumentInputStream extends CharsInputStream {
17 |
18 | public DocumentInputStream(final IDocument doc) {
19 | super(doc::getChar, doc::getLength, DocumentUtil.getCharset(doc));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/FileBufferListenerAdapter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 Rogue Wave Software Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import org.eclipse.core.filebuffers.IFileBuffer;
15 | import org.eclipse.core.filebuffers.IFileBufferListener;
16 | import org.eclipse.core.runtime.IPath;
17 |
18 | public class FileBufferListenerAdapter implements IFileBufferListener {
19 |
20 | @Override
21 | public void bufferCreated(IFileBuffer buffer) {
22 | }
23 |
24 | @Override
25 | public void bufferDisposed(IFileBuffer buffer) {
26 | }
27 |
28 | @Override
29 | public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
30 | }
31 |
32 | @Override
33 | public void bufferContentReplaced(IFileBuffer buffer) {
34 | }
35 |
36 | @Override
37 | public void stateChanging(IFileBuffer buffer) {
38 | }
39 |
40 | @Override
41 | public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
42 | }
43 |
44 | @Override
45 | public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
46 | }
47 |
48 | @Override
49 | public void underlyingFileMoved(IFileBuffer buffer, IPath path) {
50 | }
51 |
52 | @Override
53 | public void underlyingFileDeleted(IFileBuffer buffer) {
54 | }
55 |
56 | @Override
57 | public void stateChangeFailed(IFileBuffer buffer) {
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/Pair.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Avaloq Group AG.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Rubén Porras Campo (Avaloq Group AG) - Initial Implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | public record Pair(F first, S second) {
15 |
16 | public static Pair of(final F first, final S second) {
17 | return new Pair<>(first, second);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/StyleUtil.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Avaloq Group AG.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Rubén Porras Campo (Avaloq Group AG) - Initial Implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import org.eclipse.jface.viewers.StyledString.Styler;
15 | import org.eclipse.swt.graphics.TextStyle;
16 |
17 | public class StyleUtil {
18 |
19 | private StyleUtil() {
20 | // this class shouldn't be instantiated
21 | }
22 |
23 | public static final Styler DEPRECATE = new Styler() {
24 | @Override
25 | public void applyStyles(final TextStyle textStyle) {
26 | textStyle.strikeout = true;
27 | }
28 | };
29 | }
30 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/ThrowingConsumer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2024 Sebastian Thomschke and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Sebastian Thomschke - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import java.util.function.Consumer;
15 |
16 | /**
17 | * @author Sebastian Thomschke
18 | */
19 | @FunctionalInterface
20 | public interface ThrowingConsumer extends Consumer {
21 |
22 | static ThrowingConsumer from(final Consumer consumer) {
23 | return consumer::accept;
24 | }
25 |
26 | @Override
27 | default void accept(final I elem) {
28 | try {
29 | acceptOrThrow(elem);
30 | } catch (final RuntimeException rex) {
31 | throw rex;
32 | } catch (final Throwable t) {
33 | throw new RuntimeException(t);
34 | }
35 | }
36 |
37 | void acceptOrThrow(I elem) throws X;
38 | }
39 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/ThrowingPredicate.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2024 Sebastian Thomschke and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Sebastian Thomschke - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.internal;
13 |
14 | import java.util.function.Predicate;
15 |
16 | @FunctionalInterface
17 | public interface ThrowingPredicate extends Predicate {
18 |
19 | static ThrowingPredicate from(final Predicate predicate) {
20 | return predicate::test;
21 | }
22 |
23 | @Override
24 | default boolean test(final I elem) {
25 | try {
26 | return testOrThrow(elem);
27 | } catch (final RuntimeException rex) {
28 | throw rex;
29 | } catch (final Throwable t) {
30 | throw new RuntimeException(t);
31 | }
32 | }
33 |
34 | boolean testOrThrow(I elem) throws X;
35 | }
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/internal/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.internal;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.codeactions;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codelens/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.codelens;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/color/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.color;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/completion/LSCompletionProposalComparator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016, 2019 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Mickael Istria (Red Hat Inc.) - initial implementation
11 | * Michał Niewrzał (Rogue Wave Software Inc.)
12 | * Lucas Bullen (Red Hat Inc.) - Refactored for incomplete completion lists
13 | *******************************************************************************/
14 | package org.eclipse.lsp4e.operations.completion;
15 |
16 | import java.util.Comparator;
17 |
18 | import org.eclipse.jface.text.BadLocationException;
19 | import org.eclipse.lsp4e.LanguageServerPlugin;
20 |
21 | final class LSCompletionProposalComparator implements Comparator {
22 | @Override
23 | public int compare(LSCompletionProposal o1, LSCompletionProposal o2) {
24 | try {
25 | int docFilterLen1 = o1.getDocumentFilter().length();
26 | int docFilterLen2 = o2.getDocumentFilter().length();
27 | if (docFilterLen1 > docFilterLen2) {
28 | return -1;
29 | } else if (docFilterLen1 < docFilterLen2) {
30 | return +1;
31 | }
32 | } catch (BadLocationException e) {
33 | LanguageServerPlugin.logError(e);
34 | }
35 | if (o1.getRankCategory() < o2.getRankCategory()) {
36 | return -1;
37 | } else if (o1.getRankCategory() > o2.getRankCategory()) {
38 | return +1;
39 | }
40 | if ((o1.getRankCategory() < 5 && o2.getRankCategory() < 5)
41 | && (!(o1.getRankScore() == -1 && o2.getRankScore() == -1))) {
42 | if (o2.getRankScore() == -1 || o1.getRankScore() < o2.getRankScore()) {
43 | return -1;
44 | } else if (o1.getRankScore() == -1 || o1.getRankScore() > o2.getRankScore()) {
45 | return +1;
46 | }
47 | }
48 | String c1 = o1.getSortText();
49 | String c2 = o2.getSortText();
50 | if (c1 == null) {
51 | return -1;
52 | }
53 | return c1.compareToIgnoreCase(c2);
54 | }
55 | }
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/completion/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.completion;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/declaration/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.declaration;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/DiagnosticAnnotation.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2019 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Mickael Istria (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.operations.diagnostics;
13 |
14 | import java.util.function.Function;
15 |
16 | import org.eclipse.jdt.annotation.Nullable;
17 | import org.eclipse.jface.text.source.Annotation;
18 | import org.eclipse.lsp4j.Diagnostic;
19 |
20 | class DiagnosticAnnotation extends Annotation {
21 |
22 | private final Diagnostic diagnostic;
23 | private final Function textComputer;
24 |
25 | public DiagnosticAnnotation(Diagnostic diagnostic, Function textComputer) {
26 | this.diagnostic = diagnostic;
27 | this.textComputer = textComputer;
28 | }
29 |
30 | @Override
31 | public String getType() {
32 | return switch (diagnostic.getSeverity()) {
33 | case Error -> "org.eclipse.ui.workbench.texteditor.error"; //$NON-NLS-1$
34 | case Warning -> "org.eclipse.ui.workbench.texteditor.warning"; //$NON-NLS-1$
35 | case Information -> "org.eclipse.ui.workbench.texteditor.info"; //$NON-NLS-1$
36 | case Hint -> "org.eclipse.ui.workbench.texteditor.info"; //$NON-NLS-1$
37 | };
38 | }
39 |
40 | @Override
41 | public void setType(@Nullable String type) {
42 | throw new UnsupportedOperationException();
43 | }
44 |
45 | @Override
46 | public String getText() {
47 | return textComputer.apply(diagnostic);
48 | }
49 |
50 | @Override
51 | public void setText(@Nullable String text) {
52 | throw new UnsupportedOperationException();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.diagnostics;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/documentLink/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.documentLink;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/folding/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.folding;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/format/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.format;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/highlight/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.highlight;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/hover/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.hover;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/inlayhint/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.inlayhint;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/linkedediting/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.linkedediting;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSFindReferences.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016-2023 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Mickael Istria (Red Hat Inc.) - initial implementation
11 | * Michał Niewrzał (Rogue Wave Software Inc.)
12 | * Angelo Zerr - fix Bug 526255
13 | *******************************************************************************/
14 | package org.eclipse.lsp4e.operations.references;
15 |
16 | import org.eclipse.core.commands.ExecutionEvent;
17 | import org.eclipse.core.commands.IHandler;
18 | import org.eclipse.jdt.annotation.Nullable;
19 | import org.eclipse.jface.text.IDocument;
20 | import org.eclipse.jface.text.ITextSelection;
21 | import org.eclipse.jface.viewers.ISelection;
22 | import org.eclipse.lsp4e.LSPEclipseUtils;
23 | import org.eclipse.lsp4e.LanguageServerPlugin;
24 | import org.eclipse.lsp4e.internal.LSPDocumentAbstractHandler;
25 | import org.eclipse.lsp4e.ui.UI;
26 | import org.eclipse.lsp4j.ServerCapabilities;
27 | import org.eclipse.search.ui.NewSearchUI;
28 | import org.eclipse.ui.texteditor.ITextEditor;
29 |
30 | /**
31 | * LSP "Find references" handler.
32 | *
33 | */
34 | public class LSFindReferences extends LSPDocumentAbstractHandler implements IHandler {
35 |
36 | @Override
37 | protected void execute(ExecutionEvent event, ITextEditor textEditor) {
38 | ISelection sel = textEditor.getSelectionProvider().getSelection();
39 | if (sel instanceof ITextSelection textSelection) {
40 | IDocument document = LSPEclipseUtils.getDocument(textEditor);
41 | if (document != null) {
42 | try {
43 | final var query = new LSSearchQuery(textSelection.getOffset(), document);
44 | UI.getDisplay().asyncExec(() -> NewSearchUI.runQueryInBackground(query));
45 | } catch (Exception e) {
46 | LanguageServerPlugin.logError(e);
47 | }
48 | }
49 | }
50 | }
51 |
52 | @Override
53 | public void setEnabled(@Nullable Object evaluationContext) {
54 | setEnabled(ServerCapabilities::getReferencesProvider, this::hasSelection);
55 | }
56 |
57 | @Override
58 | public boolean isHandled() {
59 | return true;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/URIMatch.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.operations.references;
10 |
11 | import static org.eclipse.lsp4e.internal.NullSafetyHelper.castNonNull;
12 |
13 | import java.net.URI;
14 | import java.net.URISyntaxException;
15 |
16 | import org.eclipse.jface.text.BadLocationException;
17 | import org.eclipse.jface.text.IDocument;
18 | import org.eclipse.lsp4e.LSPEclipseUtils;
19 | import org.eclipse.lsp4j.Location;
20 | import org.eclipse.search.ui.text.Match;
21 |
22 | public class URIMatch extends Match {
23 |
24 | public static URIMatch create(final Location location) throws BadLocationException, URISyntaxException {
25 | final URI uri = new URI(location.getUri());
26 | final IDocument doc = castNonNull(LSPEclipseUtils.getDocument(uri));
27 | final int offset = LSPEclipseUtils.toOffset(location.getRange().getStart(), doc);
28 | final int length = LSPEclipseUtils.toOffset(location.getRange().getEnd(), doc) - LSPEclipseUtils.toOffset(location.getRange().getStart(), doc);
29 | return new URIMatch(location, uri, offset, length);
30 | }
31 |
32 | public final Location location;
33 |
34 | protected URIMatch(final Location location, final URI uri, final int offset, final int length) {
35 | super(uri, offset, length);
36 | this.location = location;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.references;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/rename/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.rename;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/selectionRange/LSPSelectionRangeDownHandler.java:
--------------------------------------------------------------------------------
1 | package org.eclipse.lsp4e.operations.selectionRange;
2 |
3 | /*******************************************************************************
4 | * Copyright (c) 2023 Red Hat Inc. and others.
5 | * This program and the accompanying materials are made
6 | * available under the terms of the Eclipse Public License 2.0
7 | * which is available at https://www.eclipse.org/legal/epl-2.0/
8 | *
9 | * SPDX-License-Identifier: EPL-2.0
10 | *
11 | * Contributors:
12 | * Angelo ZERR (Red Hat Inc.) - initial implementation
13 | *******************************************************************************/
14 | import org.eclipse.lsp4e.operations.selectionRange.LSPSelectionRangeAbstractHandler.SelectionRangeHandler.Direction;
15 | /**
16 | * Selection range DOWN handler.
17 | *
18 | * @author Angelo ZERR
19 | *
20 | */
21 | public class LSPSelectionRangeDownHandler extends LSPSelectionRangeAbstractHandler {
22 |
23 | @Override
24 | protected Direction getDirection() {
25 | return Direction.DOWN;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/selectionRange/LSPSelectionRangeUpHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo ZERR (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.operations.selectionRange;
13 |
14 | import org.eclipse.lsp4e.operations.selectionRange.LSPSelectionRangeAbstractHandler.SelectionRangeHandler.Direction;
15 |
16 | /**
17 | * Selection range UP handler.
18 | *
19 | * @author Angelo ZERR
20 | *
21 | */
22 | public class LSPSelectionRangeUpHandler extends LSPSelectionRangeAbstractHandler {
23 |
24 | @Override
25 | protected Direction getDirection() {
26 | return Direction.UP;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/selectionRange/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.selectionRange;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/semanticTokens/VersionedSemanticTokens.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Avaloq Group AG.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Rubén Porras Campo (Avaloq Group AG) - Initial Implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.operations.semanticTokens;
13 |
14 | import java.util.function.Consumer;
15 | import java.util.function.LongConsumer;
16 |
17 | import org.eclipse.jdt.annotation.Nullable;
18 | import org.eclipse.jface.text.IDocument;
19 | import org.eclipse.lsp4e.Versioned;
20 | import org.eclipse.lsp4e.internal.DocumentUtil;
21 | import org.eclipse.lsp4e.internal.Pair;
22 | import org.eclipse.lsp4j.SemanticTokens;
23 | import org.eclipse.lsp4j.SemanticTokensLegend;
24 |
25 | /**
26 | * Specialization of Versioned
for semanticTokens
27 | */
28 | public class VersionedSemanticTokens extends Versioned>{
29 |
30 | public VersionedSemanticTokens(long version, Pair<@Nullable SemanticTokens, @Nullable SemanticTokensLegend> data,
31 | IDocument document) {
32 | super(document, version, data);
33 | }
34 |
35 | /**
36 | * Apply the semantic tokens from the server, provided the document is unchanged since the request used
37 | * to compute the edits
38 | *
39 | */
40 | public void apply(Consumer> first, LongConsumer second) {
41 | if (sourceDocumentVersion == DocumentUtil.getDocumentModificationStamp(document)) {
42 | first.accept(data);
43 | second.accept(sourceDocumentVersion);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/semanticTokens/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.semanticTokens;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/symbols/LSPSymbolInFileHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2016 Rogue Wave Software Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation
11 | * Lucas Bullen (Red Hat Inc.) - [Bug 517428] Requests sent before initialization
12 | *******************************************************************************/
13 | package org.eclipse.lsp4e.operations.symbols;
14 |
15 | import java.util.concurrent.CompletableFuture;
16 |
17 | import org.eclipse.core.commands.ExecutionEvent;
18 | import org.eclipse.jdt.annotation.Nullable;
19 | import org.eclipse.jface.text.IDocument;
20 | import org.eclipse.lsp4e.LSPEclipseUtils;
21 | import org.eclipse.lsp4e.LanguageServers;
22 | import org.eclipse.lsp4e.internal.LSPDocumentAbstractHandler;
23 | import org.eclipse.lsp4j.ServerCapabilities;
24 | import org.eclipse.swt.widgets.Shell;
25 | import org.eclipse.ui.handlers.HandlerUtil;
26 | import org.eclipse.ui.texteditor.ITextEditor;
27 |
28 | public class LSPSymbolInFileHandler extends LSPDocumentAbstractHandler {
29 |
30 | @Override
31 | protected void execute(ExecutionEvent event, ITextEditor textEditor) {
32 | final IDocument document = LSPEclipseUtils.getDocument(textEditor);
33 | if (document == null) {
34 | return;
35 | }
36 |
37 | final Shell shell = HandlerUtil.getActiveShell(event);
38 |
39 | if (shell == null) {
40 | return;
41 | }
42 |
43 | // TODO maybe consider better strategy such as iterating on all LS until we have
44 | // a good result
45 | LanguageServers.forDocument(document).withCapability(ServerCapabilities::getDocumentSymbolProvider)
46 | .computeFirst((w, ls) -> CompletableFuture.completedFuture(w)) //
47 | .thenAcceptAsync(
48 | oW -> oW.ifPresent(w -> new LSPSymbolInFileDialog(shell, textEditor, document, w).open()),
49 | shell.getDisplay());
50 | }
51 |
52 | @Override
53 | public void setEnabled(@Nullable Object evaluationContext) {
54 | setEnabled(ServerCapabilities::getDocumentSymbolProvider, x -> true);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/symbols/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.symbols;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/typeHierarchy/TypeHierarchyHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.operations.typeHierarchy;
10 |
11 | import java.util.concurrent.CompletableFuture;
12 |
13 | import org.eclipse.core.commands.ExecutionEvent;
14 | import org.eclipse.jdt.annotation.Nullable;
15 | import org.eclipse.jface.text.IDocument;
16 | import org.eclipse.jface.text.ITextSelection;
17 | import org.eclipse.lsp4e.LSPEclipseUtils;
18 | import org.eclipse.lsp4e.LanguageServers;
19 | import org.eclipse.lsp4e.internal.LSPDocumentAbstractHandler;
20 | import org.eclipse.lsp4j.ServerCapabilities;
21 | import org.eclipse.ui.texteditor.ITextEditor;
22 |
23 | public class TypeHierarchyHandler extends LSPDocumentAbstractHandler {
24 |
25 | @Override
26 | protected void execute(ExecutionEvent event, ITextEditor editor) {
27 | IDocument document = LSPEclipseUtils.getDocument(editor);
28 | if (document != null) {
29 | LanguageServers.forDocument(document)
30 | .withCapability(ServerCapabilities::getTypeHierarchyProvider)
31 | .computeFirst((wrapper, ls) -> CompletableFuture.completedFuture(wrapper.serverDefinition))
32 | .thenAcceptAsync(definition -> definition.ifPresent(def -> new TypeHierarchyDialog(editor.getSite().getShell(), (ITextSelection)editor.getSelectionProvider().getSelection(), document, def).open()), editor.getSite().getShell().getDisplay());
33 | }
34 | }
35 |
36 | @Override
37 | public void setEnabled(@Nullable Object evaluationContext) {
38 | setEnabled(ServerCapabilities::getTypeDefinitionProvider, editor -> true);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/typeHierarchy/TypeHierarchyItemLabelProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *******************************************************************************/
9 | package org.eclipse.lsp4e.operations.typeHierarchy;
10 |
11 | import org.eclipse.jdt.annotation.Nullable;
12 | import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
13 | import org.eclipse.jface.viewers.LabelProvider;
14 | import org.eclipse.jface.viewers.StyledString;
15 | import org.eclipse.lsp4e.ui.LSPImages;
16 | import org.eclipse.lsp4j.TypeHierarchyItem;
17 | import org.eclipse.swt.graphics.Image;
18 |
19 | public class TypeHierarchyItemLabelProvider extends LabelProvider implements IStyledLabelProvider {
20 |
21 | @Override
22 | public String getText(Object element) {
23 | if (element instanceof TypeHierarchyItem item) {
24 | return item.getName();
25 | }
26 | return super.getText(element);
27 | }
28 |
29 | @Override
30 | public @Nullable Image getImage(@Nullable Object element) {
31 | if (element instanceof TypeHierarchyItem item) {
32 | return LSPImages.imageFromSymbolKind(item.getKind());
33 | }
34 | return element == null ? null : super.getImage(element);
35 | }
36 |
37 | @Override
38 | public StyledString getStyledText(@Nullable Object element) {
39 | if (element instanceof TypeHierarchyItem item) {
40 | return new StyledString(item.getName());
41 | } else if (element instanceof String s) {
42 | return new StyledString(s);
43 | }
44 | return new StyledString();
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/typeHierarchy/TypeHierarchyViewHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Bachmann electronic GmbH and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.operations.typeHierarchy;
13 |
14 | import org.eclipse.core.commands.ExecutionEvent;
15 | import org.eclipse.jdt.annotation.Nullable;
16 | import org.eclipse.jface.text.IDocument;
17 | import org.eclipse.jface.text.ITextSelection;
18 | import org.eclipse.lsp4e.LSPEclipseUtils;
19 | import org.eclipse.lsp4e.LanguageServerPlugin;
20 | import org.eclipse.lsp4e.callhierarchy.CallHierarchyCommandHandler;
21 | import org.eclipse.lsp4e.ui.UI;
22 | import org.eclipse.lsp4j.ServerCapabilities;
23 | import org.eclipse.ui.PartInitException;
24 | import org.eclipse.ui.texteditor.ITextEditor;
25 |
26 | /**
27 | * Command handler for the LSP type hierarchy view.
28 | */
29 | public class TypeHierarchyViewHandler extends CallHierarchyCommandHandler {
30 |
31 | @Override
32 | protected void execute(ExecutionEvent event, ITextEditor editor) {
33 | IDocument document = LSPEclipseUtils.getDocument(editor);
34 | if (document == null) {
35 | return;
36 | }
37 | if (editor.getSelectionProvider().getSelection() instanceof ITextSelection sel) {
38 | int offset = sel.getOffset();
39 | try {
40 | final TypeHierarchyView view = UI.showView(TypeHierarchyView.ID);
41 | view.initialize(document, offset);
42 | } catch (PartInitException e) {
43 | LanguageServerPlugin.logError("Error while opening the Type Hierarchy view", e); //$NON-NLS-1$
44 | }
45 | }
46 | }
47 |
48 | @Override
49 | public void setEnabled(@Nullable Object evaluationContext) {
50 | setEnabled(ServerCapabilities::getTypeHierarchyProvider, this::hasSelection);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/typeHierarchy/TypeMemberContentProvider.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2023 Bachmann electronic GmbH and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Gesa Hentschke (Bachmann electronic GmbH) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.operations.typeHierarchy;
13 |
14 |
15 | import static org.eclipse.lsp4e.internal.ArrayUtil.NO_OBJECTS;
16 |
17 | import java.net.URI;
18 | import java.util.List;
19 |
20 | import org.eclipse.jdt.annotation.Nullable;
21 | import org.eclipse.jface.viewers.IStructuredContentProvider;
22 | import org.eclipse.lsp4e.outline.SymbolsModel.DocumentSymbolWithURI;
23 | import org.eclipse.lsp4j.DocumentSymbol;
24 |
25 | public class TypeMemberContentProvider implements IStructuredContentProvider {
26 |
27 | @Override
28 | public Object[] getElements(@Nullable Object inputElement) {
29 | if (inputElement instanceof DocumentSymbolWithURI symbolContainer) {
30 | return toContainer(symbolContainer.symbol.getChildren(), symbolContainer.uri);
31 | }
32 | return NO_OBJECTS;
33 | }
34 |
35 | private Object[] toContainer(@Nullable List symbols, URI uri) {
36 | if (symbols != null) {
37 | var container = new DocumentSymbolWithURI[symbols.size()];
38 | for (int i = 0; i < symbols.size(); i++) {
39 | container[i] = new DocumentSymbolWithURI(symbols.get(i), uri);
40 | }
41 | return container;
42 | }
43 | return NO_OBJECTS;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/typeHierarchy/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.operations.typeHierarchy;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/CollapseAllOutlineHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2025 Vegard IT GmbH and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Sebastian Thomschke (Vegard IT GmbH) - initial implementation.
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.outline;
13 |
14 | import org.eclipse.core.commands.AbstractHandler;
15 | import org.eclipse.core.commands.ExecutionEvent;
16 | import org.eclipse.jdt.annotation.Nullable;
17 | import org.eclipse.lsp4e.ui.UI;
18 | import org.eclipse.ui.views.contentoutline.ContentOutline;
19 |
20 | public class CollapseAllOutlineHandler extends AbstractHandler {
21 |
22 | @Override
23 | public @Nullable Object execute(ExecutionEvent event) {
24 | final var workbenchPage = UI.getActivePage();
25 | if (workbenchPage != null //
26 | && workbenchPage.getActivePart() instanceof ContentOutline outline
27 | && outline.getCurrentPage() instanceof CNFOutlinePage page) {
28 | page.collapseTree();
29 | }
30 | return null;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/HasCNFOutlinePage.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2018 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Lucas Bullen (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.outline;
13 |
14 | import org.eclipse.core.expressions.PropertyTester;
15 | import org.eclipse.jdt.annotation.Nullable;
16 | import org.eclipse.ui.IEditorPart;
17 | import org.eclipse.ui.views.contentoutline.ContentOutline;
18 | import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
19 |
20 | public class HasCNFOutlinePage extends PropertyTester {
21 |
22 | @Override
23 | public boolean test(@Nullable Object receiver, String property, Object[] args, @Nullable Object expectedValue) {
24 | if (receiver instanceof ContentOutline outline) {
25 | return outline.getCurrentPage() instanceof CNFOutlinePage;
26 | }
27 | if (receiver instanceof IEditorPart editor) {
28 | IContentOutlinePage outlinePage = editor.getAdapter(IContentOutlinePage.class);
29 | return outlinePage instanceof CNFOutlinePage;
30 | }
31 | return false;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/ShowKindHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2018 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Lucas Bullen (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.outline;
13 |
14 | import org.eclipse.core.commands.AbstractHandler;
15 | import org.eclipse.core.commands.Command;
16 | import org.eclipse.core.commands.ExecutionEvent;
17 | import org.eclipse.core.commands.ExecutionException;
18 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19 | import org.eclipse.core.runtime.preferences.InstanceScope;
20 | import org.eclipse.jdt.annotation.Nullable;
21 | import org.eclipse.lsp4e.LanguageServerPlugin;
22 | import org.eclipse.ui.handlers.HandlerUtil;
23 |
24 | public class ShowKindHandler extends AbstractHandler {
25 |
26 | @Override
27 | public @Nullable Object execute(ExecutionEvent event) throws ExecutionException {
28 | Command command = event.getCommand();
29 | boolean oldValue = HandlerUtil.toggleCommandState(command);
30 |
31 | IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
32 | preferences.putBoolean(CNFOutlinePage.SHOW_KIND_PREFERENCE, !oldValue);
33 | return null;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/ToggleLinkingHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Rogue Wave Software Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Michal Niewrzal (Rogue Wave Software Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.outline;
13 |
14 | import org.eclipse.core.commands.AbstractHandler;
15 | import org.eclipse.core.commands.Command;
16 | import org.eclipse.core.commands.ExecutionEvent;
17 | import org.eclipse.core.commands.ExecutionException;
18 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19 | import org.eclipse.core.runtime.preferences.InstanceScope;
20 | import org.eclipse.jdt.annotation.Nullable;
21 | import org.eclipse.lsp4e.LanguageServerPlugin;
22 | import org.eclipse.ui.handlers.HandlerUtil;
23 |
24 | public class ToggleLinkingHandler extends AbstractHandler {
25 |
26 | @Override
27 | public @Nullable Object execute(ExecutionEvent event) throws ExecutionException {
28 | Command command = event.getCommand();
29 | boolean oldValue = HandlerUtil.toggleCommandState(command);
30 |
31 | IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
32 | preferences.putBoolean(CNFOutlinePage.LINK_WITH_EDITOR_PREFERENCE, !oldValue);
33 | return null;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/ToggleSortOutlineHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2021 Vegard IT GmbH and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Sebastian Thomschke (Vegard IT GmbH) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.outline;
13 |
14 | import org.eclipse.core.commands.AbstractHandler;
15 | import org.eclipse.core.commands.ExecutionEvent;
16 | import org.eclipse.core.commands.ExecutionException;
17 | import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18 | import org.eclipse.core.runtime.preferences.InstanceScope;
19 | import org.eclipse.jdt.annotation.Nullable;
20 | import org.eclipse.lsp4e.LanguageServerPlugin;
21 | import org.eclipse.ui.handlers.HandlerUtil;
22 |
23 | public class ToggleSortOutlineHandler extends AbstractHandler {
24 |
25 | @Override
26 | public @Nullable Object execute(final ExecutionEvent event) throws ExecutionException {
27 | final boolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());
28 | final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
29 | prefs.putBoolean(CNFOutlinePage.SORT_OUTLINE_PREFERENCE, !oldValue);
30 | return null;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.outline;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/progress/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.progress;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/refactoring/DeleteExternalFile.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2019 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Mickael Istria (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.refactoring;
13 |
14 | import java.io.File;
15 | import java.io.IOException;
16 | import java.nio.file.Files;
17 |
18 | import org.eclipse.core.runtime.CoreException;
19 | import org.eclipse.core.runtime.IProgressMonitor;
20 | import org.eclipse.core.runtime.IStatus;
21 | import org.eclipse.core.runtime.Status;
22 | import org.eclipse.jdt.annotation.Nullable;
23 | import org.eclipse.lsp4e.LanguageServerPlugin;
24 | import org.eclipse.ltk.core.refactoring.Change;
25 | import org.eclipse.ltk.core.refactoring.RefactoringStatus;
26 |
27 | public class DeleteExternalFile extends Change {
28 |
29 | private final File file;
30 |
31 | public DeleteExternalFile(File file) {
32 | this.file = file;
33 | }
34 |
35 | @Override
36 | public String getName() {
37 | return "Delete " + this.file.getName(); //$NON-NLS-1$
38 | }
39 |
40 | @Override
41 | public void initializeValidationData(IProgressMonitor pm) {
42 | // nothing to do yet, comment requested by sonar
43 | }
44 |
45 | @Override
46 | public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
47 | return RefactoringStatus.create(Status.OK_STATUS);
48 | }
49 |
50 | @Override
51 | public @Nullable Change perform(IProgressMonitor pm) throws CoreException {
52 | try {
53 | Files.delete(this.file.toPath());
54 | } catch (IOException e) {
55 | LanguageServerPlugin.logError(e);
56 | throw new CoreException(new Status(IStatus.ERROR, LanguageServerPlugin.PLUGIN_ID, e.getMessage(), e));
57 | }
58 | return null;
59 | }
60 |
61 | @Override
62 | public Object getModifiedElement() {
63 | return this.file;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/refactoring/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.refactoring;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/server/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.server;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/EnableDisableLSJob.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2018 Red Hat Inc. and others.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Rastislav Wagner (Red Hat Inc.) - initial implementation
11 | *******************************************************************************/
12 | package org.eclipse.lsp4e.ui;
13 |
14 | import java.util.List;
15 |
16 | import org.eclipse.core.runtime.IProgressMonitor;
17 | import org.eclipse.core.runtime.IStatus;
18 | import org.eclipse.core.runtime.Status;
19 | import org.eclipse.core.runtime.jobs.Job;
20 | import org.eclipse.jdt.annotation.Nullable;
21 | import org.eclipse.lsp4e.ContentTypeToLanguageServerDefinition;
22 | import org.eclipse.lsp4e.LanguageServiceAccessor;
23 | import org.eclipse.ui.IEditorReference;
24 |
25 | public class EnableDisableLSJob extends Job {
26 |
27 | private final List serverDefinitions;
28 | private final IEditorReference @Nullable [] editors;
29 |
30 | public EnableDisableLSJob(List serverDefinitions,
31 | IEditorReference @Nullable [] editors) {
32 | super(Messages.enableDisableLSJob);
33 | this.serverDefinitions = serverDefinitions;
34 | this.editors = editors;
35 | }
36 |
37 | @Override
38 | protected IStatus run(@Nullable IProgressMonitor monitor) {
39 | for (ContentTypeToLanguageServerDefinition changedDefinition : serverDefinitions) {
40 | if (!changedDefinition.isEnabled(null)) {
41 | LanguageServiceAccessor.disableLanguageServerContentType(changedDefinition);
42 | } else if (editors != null) {
43 | LanguageServiceAccessor.enableLanguageServerContentType(changedDefinition, editors);
44 | }
45 | }
46 | return Status.OK_STATUS;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.ui;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/views/HierarchyViewInput.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2022 Avaloq Group AG (http://www.avaloq.com).
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Andrew Lamb (Avaloq Group AG) - Initial implementation
11 | * Gesa Hentschke - made the class generic
12 | *******************************************************************************/
13 |
14 | package org.eclipse.lsp4e.ui.views;
15 |
16 | import org.eclipse.jface.text.IDocument;
17 |
18 | /**
19 | * Simple type representing the input to a hierarchy view.
20 | */
21 | public class HierarchyViewInput {
22 | private final IDocument document;
23 | private final int offset;
24 |
25 | /**
26 | * Creates a new instance of {@link HierarchyViewInput}.
27 | *
28 | * @param document
29 | * the document containing the selection to start a hierarchy
30 | * from.
31 | * @param offset
32 | * the offset into the document to select as the root of the
33 | * hierarchy.
34 | */
35 | public HierarchyViewInput(final IDocument document, final int offset) {
36 | this.document = document;
37 | this.offset = offset;
38 | }
39 |
40 | /**
41 | * Get the document containing the selection to start a hierarchy from.
42 | *
43 | * @return the document containing the selection to start a call hierarchy from.
44 | */
45 | public IDocument getDocument() {
46 | return document;
47 | }
48 |
49 | /**
50 | * Get the offset into the document to select as the root of the hierarchy.
51 | *
52 | * @return the offset into the document to select as the root of the hierarchy.
53 | */
54 | public int getOffset() {
55 | return offset;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/views/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullByDefault({ ARRAY_CONTENTS, PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT })
2 | package org.eclipse.lsp4e.ui.views;
3 |
4 | import static org.eclipse.jdt.annotation.DefaultLocation.*;
5 |
6 | import org.eclipse.jdt.annotation.NonNullByDefault;
7 |
--------------------------------------------------------------------------------
/repository/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | .project
3 |
--------------------------------------------------------------------------------
/repository/category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/repository/deploy-settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | jboss-snapshots-repository
5 | ${env.DEPLOY_USER}
6 | ${env.DEPLOY_PASS}
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/repository/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | repository
4 |
5 | org.eclipse.lsp4e
6 | parent
7 | 0.13.1-SNAPSHOT
8 |
9 | eclipse-repository
10 |
11 |
--------------------------------------------------------------------------------
/target-platforms/target-platform-latest/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | target-platform-latest
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/target-platforms/target-platform-latest/target-platform-latest.target:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | com.vegardit.no-npe
34 | no-npe-eea-all
35 | 1.3.5
36 | jar
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------