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

Implement file type defnition mapping #253

Closed
wants to merge 4 commits into from

Conversation

Tatskaari
Copy link

@Tatskaari Tatskaari commented May 5, 2021

Purpose

Resolves #252

Goals

Lots of files don't have extension: Makefile, Dockerfile, and in my case: BUILD files. Mapping a definition to a filetype also seems to fit into the Intellij framework better.

Approach

Added a new map to IntellijLanguageClient and added new API methods to register definitions against a filetype.

Release note

LanguageServerDefinitions can now be registered against file types with IntellijLanguageClient#addServerDefinition

@CLAassistant
Copy link

CLAassistant commented May 5, 2021

CLA assistant check
All committers have signed the CLA.

private static Map<String, LSPExtensionManager> extToExtManager = new ConcurrentHashMap<>();
private static final Map<String, Set<LanguageServerWrapper>> projectToLanguageWrappers = new ConcurrentHashMap<>();
private static final Map<Pair<String, String>, LanguageServerDefinition> extToServerDefinition = new ConcurrentHashMap<>();
private static final Map<Pair<Class<? extends FileType>, String>, LanguageServerDefinition> fileTypeToServerDefinition = new ConcurrentHashMap<>();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit new to this but it might be a safe assumption to assume that all file types are singletons and have this be

private static final Map<Pair<FileType, String>, LanguageServerDefinition> fileTypeToServerDefinition = new ConcurrentHashMap<>();

@@ -67,7 +66,7 @@ public Object collectInformation(@NotNull PsiFile file, @NotNull Editor editor,
VirtualFile virtualFile = file.getVirtualFile();

// If the file is not supported, we skips the annotation by returning null.
if (!FileUtils.isFileSupported(virtualFile) || !IntellijLanguageClient.isExtensionSupported(virtualFile)) {
if (!FileUtils.isFileSupported(virtualFile) || !FileUtils.isFileSupported(virtualFile)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant checks

import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
import org.wso2.lsp4intellij.client.languageserver.requestmanager.RequestManager;
import com.intellij.openapi.vfs.VirtualFile;
import org.eclipse.lsp4j.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets avoid wildcard imports.

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets avoid wildcard imports.

@Tatskaari
Copy link
Author

I'm unlikely to come back to this. I've instead taken to writing a language plugin based off the Python language for my use case. Feel free to fix this up, or close this PR as you see fit.

@github-actions
Copy link

github-actions bot commented Sep 8, 2021

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Sep 8, 2021
@github-actions
Copy link

Closed PR due to inactivity for more than 18 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Associate language server with FileType rather than an extension
4 participants