Expose GetLanguageType (#2)
This commit is contained in:
parent
821f01cdde
commit
4e3a49c565
@ -247,4 +247,14 @@ public class Enry {
|
|||||||
public static synchronized boolean isTest(String path) {
|
public static synchronized boolean isTest(String path) {
|
||||||
return toJavaBool(nativeLib.IsTest(toGoString(path)));
|
return toJavaBool(nativeLib.IsTest(toGoString(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns type for given language.
|
||||||
|
*
|
||||||
|
* @param language of the file
|
||||||
|
* @return type (data, programming, markup, prose)
|
||||||
|
*/
|
||||||
|
public static synchronized String getLanguageType(String language) {
|
||||||
|
return toJavaString(nativeLib.GetLanguageType(toGoString(language)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,11 @@ public class EnryTest {
|
|||||||
assertFalse(Enry.isTest("src/java/foo.java"));
|
assertFalse(Enry.isTest("src/java/foo.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getLanguageType() {
|
||||||
|
assertEquals("data", Enry.getLanguageType("CSV"));
|
||||||
|
}
|
||||||
|
|
||||||
void assertGuess(String language, boolean safe, Guess guess) {
|
void assertGuess(String language, boolean safe, Guess guess) {
|
||||||
assertEquals(language, guess.language);
|
assertEquals(language, guess.language);
|
||||||
assertEquals(safe, guess.safe);
|
assertEquals(safe, guess.safe);
|
||||||
|
@ -5,6 +5,7 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import "github.com/go-enry/go-enry/v2"
|
import "github.com/go-enry/go-enry/v2"
|
||||||
|
import "github.com/go-enry/go-enry/v2/data"
|
||||||
|
|
||||||
//export GetLanguage
|
//export GetLanguage
|
||||||
func GetLanguage(filename string, content []byte) string {
|
func GetLanguage(filename string, content []byte) string {
|
||||||
@ -141,10 +142,15 @@ func IsTest(path string) bool {
|
|||||||
return enry.IsTest(path)
|
return enry.IsTest(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export GetLanguageType
|
||||||
|
func GetLanguageType(language string) string {
|
||||||
|
return data.Type(enry.GetLanguageType(language)).String()
|
||||||
|
}
|
||||||
|
|
||||||
func strSliceCopy(result *[]*C.char, slice []string) {
|
func strSliceCopy(result *[]*C.char, slice []string) {
|
||||||
for _, str := range slice {
|
for _, str := range slice {
|
||||||
*result = append(*result, C.CString(str))
|
*result = append(*result, C.CString(str))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {}
|
func main() {}
|
Loading…
Reference in New Issue
Block a user