-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Check if project is a MicroProfile, Qute, etc project to map file
with a language server Fixes #850 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
28559b5
commit 54c9c86
Showing
17 changed files
with
245 additions
and
58 deletions.
There are no files selected for viewing
12 changes: 11 additions & 1 deletion
12
src/main/java/com/redhat/devtools/intellij/lsp4ij/ContentTypeToLanguageServerDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
package com.redhat.devtools.intellij.lsp4ij; | ||
|
||
import com.intellij.lang.Language; | ||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.AbstractMap; | ||
|
||
public class ContentTypeToLanguageServerDefinition extends AbstractMap.SimpleEntry<Language, LanguageServersRegistry.LanguageServerDefinition> { | ||
|
||
private final DocumentMatcher documentMatcher; | ||
public ContentTypeToLanguageServerDefinition(@Nonnull Language language, | ||
@Nonnull LanguageServersRegistry.LanguageServerDefinition provider) { | ||
DocumentMatcher documentMatcher, @Nonnull LanguageServersRegistry.LanguageServerDefinition provider) { | ||
super(language, provider); | ||
this.documentMatcher = documentMatcher; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return true; | ||
} | ||
|
||
public boolean matches(Document document, VirtualFile file, Project project) { | ||
return documentMatcher.match(document, file, project); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/redhat/devtools/intellij/lsp4ij/DefaultDocumentMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.redhat.devtools.intellij.lsp4ij; | ||
|
||
import com.intellij.lang.Language; | ||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
|
||
import java.util.HashSet; | ||
import java.util.LinkedList; | ||
import java.util.Queue; | ||
import java.util.Set; | ||
|
||
public class DefaultDocumentMatcher implements DocumentMatcher{ | ||
|
||
public static final DocumentMatcher INSTANCE = new DefaultDocumentMatcher(); | ||
|
||
@Override | ||
public boolean match(Document document, VirtualFile file, Project fileProject) { | ||
return true; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/redhat/devtools/intellij/lsp4ij/DocumentMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.redhat.devtools.intellij.lsp4ij; | ||
|
||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
|
||
public interface DocumentMatcher { | ||
|
||
boolean match(Document document, VirtualFile file, Project fileProject); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/redhat/devtools/intellij/quarkus/lsp/AbstractQuarkusDocumentMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.redhat.devtools.intellij.quarkus.lsp; | ||
|
||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.redhat.devtools.intellij.lsp4ij.DocumentMatcher; | ||
import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; | ||
import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; | ||
import com.redhat.devtools.intellij.qute.psi.utils.PsiQuteProjectUtils; | ||
|
||
public class AbstractQuarkusDocumentMatcher implements DocumentMatcher { | ||
@Override | ||
public boolean match(Document document, VirtualFile file, Project fileProject) { | ||
Module module = LSPIJUtils.getModule(file); | ||
return module != null && QuarkusModuleUtil.isQuarkusModule(module); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForJavaFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.redhat.devtools.intellij.quarkus.lsp; | ||
|
||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; | ||
import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; | ||
|
||
public class QuarkusDocumentMatcherForJavaFile extends AbstractQuarkusDocumentMatcher { | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ava/com/redhat/devtools/intellij/quarkus/lsp/QuarkusDocumentMatcherForPropertiesFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.redhat.devtools.intellij.quarkus.lsp; | ||
|
||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; | ||
|
||
public class QuarkusDocumentMatcherForPropertiesFile extends AbstractQuarkusDocumentMatcher { | ||
|
||
@Override | ||
public boolean match(Document document, VirtualFile file, Project fileProject) { | ||
if (!matchFile(file, fileProject)) { | ||
return false; | ||
} | ||
return super.match(document, file, fileProject); | ||
} | ||
|
||
private boolean matchFile(VirtualFile file, Project fileProject) { | ||
return QuarkusModuleUtil.isQuarkusPropertiesFile(file, fileProject) || QuarkusModuleUtil.isQuarkusYAMLFile(file, fileProject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/redhat/devtools/intellij/qute/lsp/AbstractQuteDocumentMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.redhat.devtools.intellij.qute.lsp; | ||
|
||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.redhat.devtools.intellij.lsp4ij.DocumentMatcher; | ||
import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; | ||
import com.redhat.devtools.intellij.qute.psi.utils.PsiQuteProjectUtils; | ||
|
||
public class AbstractQuteDocumentMatcher implements DocumentMatcher { | ||
|
||
@Override | ||
public boolean match(Document document, VirtualFile file, Project fileProject) { | ||
Module module = LSPIJUtils.getModule(file); | ||
return module != null && PsiQuteProjectUtils.hasQuteSupport(module); | ||
} | ||
} |
Oops, something went wrong.