Skip to content

Commit

Permalink
[FIX] ensure association of CSV/TSV/PSV files to this plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeSharpSoft committed Apr 18, 2020
1 parent f3458a2 commit c11b0d4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -4,8 +4,9 @@ jdk:

env:
- IDEA_VERSION=IC-2017.3.1 GRAMMAR_KIT_VERSION=2017.1.2
- IDEA_VERSION=IC-2018.3.2 GRAMMAR_KIT_VERSION=2017.1.7
- IDEA_VERSION=PC-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=2019.3
- IDEA_VERSION=PC-2018.3.2 GRAMMAR_KIT_VERSION=2017.1.7
- IDEA_VERSION=RD-2019.3.3 GRAMMAR_KIT_VERSION=2019.3
- IDEA_VERSION=IU-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=2019.3

script: xvfb-run gradle check

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -71,7 +71,7 @@ idea {
apply plugin: 'org.jetbrains.intellij'
intellij {
// IDE version - https://www.jetbrains.com/intellij-repository/releases
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2019.1.3')
version = System.getenv().getOrDefault('IDEA_VERSION', 'IU-LATEST-EAP-SNAPSHOT')
pluginName = 'CSV Plugin'
instrumentCode = true
updateSinceUntilBuild = false
Expand All @@ -98,7 +98,7 @@ grammarKit {
jflexRelease = '1.7.0-1'

// tag or short commit hash of Grammar-Kit to use - https://github.com/JetBrains/Grammar-Kit
grammarKitRelease = System.getenv().getOrDefault('GRAMMAR_KIT_VERSION', '2019.1.1')
grammarKitRelease = System.getenv().getOrDefault('GRAMMAR_KIT_VERSION', '2019.3')
}

import org.jetbrains.grammarkit.tasks.GenerateLexer
Expand Down
@@ -0,0 +1,31 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.impl.FileTypeOverrider;
import com.intellij.openapi.vfs.VirtualFile;
import net.seesharpsoft.intellij.plugins.psv.PsvFileType;
import net.seesharpsoft.intellij.plugins.tsv.TsvFileType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class CsvFileTypeOverrider implements FileTypeOverrider {
@Nullable
@Override
public FileType getOverriddenFileType(@NotNull VirtualFile file) {
if (file != null) {
String extension = file.getExtension();
if (extension != null) {
switch (extension.toLowerCase()) {
case "csv":
return CsvFileType.INSTANCE;
case "tsv":
case "tab":
return TsvFileType.INSTANCE;
case "psv":
return PsvFileType.INSTANCE;
}
}
}
return null;
}
}
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Expand Up @@ -57,6 +57,8 @@ FIX: consider escape char inside quotes as escaped text
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.2099.1" />
<!-- <idea-version since-build="192" until-build="192.*" />-->
<!-- <idea-version since-build="173.2099.1" until-build="192.*" />-->
<!-- <idea-version since-build="193" />-->

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
Expand All @@ -72,6 +74,12 @@ FIX: consider escape char inside quotes as escaped text
<fileTypeFactory implementation="net.seesharpsoft.intellij.plugins.tsv.TsvFileTypeFactory"/>
<fileTypeFactory implementation="net.seesharpsoft.intellij.plugins.psv.PsvFileTypeFactory"/>

<!-- <fileType name="CSV" language="csv" implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvFileType" extensions="csv" fieldName="INSTANCE"/>-->
<!-- <fileType name="TSV" language="tsv" implementationClass="net.seesharpsoft.intellij.plugins.tsv.TsvFileType" extensions="tsv;tab" fieldName="INSTANCE"/>-->
<!-- <fileType name="PSV" language="psv" implementationClass="net.seesharpsoft.intellij.plugins.psv.PsvFileType" extensions="psv" fieldName="INSTANCE"/>-->

<fileTypeOverrider implementation="net.seesharpsoft.intellij.plugins.csv.CsvFileTypeOverrider" />

<lang.parserDefinition language="csv"
implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvParserDefinition"/>
<lang.parserDefinition language="tsv"
Expand Down

0 comments on commit c11b0d4

Please sign in to comment.