changeset 22209:dcee887614b1

Removing hardcoded MIME types in the source. Each language is supposed to register its own FileTypeDetector as SL did in cf19259edf87.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 30 Sep 2015 13:09:22 +0200
parents df57bc2fcdbd
children 3a96086cf698
files truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java
diffstat 2 files changed, 9 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java	Wed Sep 30 12:38:35 2015 +0200
+++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java	Wed Sep 30 13:09:22 2015 +0200
@@ -381,15 +381,7 @@
         if (location.getScheme().equals("file")) {
             File file = new File(location);
             s = Source.fromFileName(file.getPath(), true);
-            if (file.getName().endsWith(".c")) {
-                mimeType = "text/x-c";
-            } else if (file.getName().endsWith(".sl")) {
-                mimeType = "application/x-sl";
-            } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) {
-                mimeType = "application/x-r";
-            } else {
-                mimeType = Files.probeContentType(file.toPath());
-            }
+            mimeType = Files.probeContentType(file.toPath());
         } else {
             URL url = location.toURL();
             s = Source.fromURL(url, location.toString());
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java	Wed Sep 30 12:38:35 2015 +0200
+++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java	Wed Sep 30 13:09:22 2015 +0200
@@ -905,16 +905,10 @@
 
         @Override
         String findMimeType() {
-            if (file.getName().endsWith(".c")) {
-                return "text/x-c";
-            } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) {
-                return "application/x-r";
-            } else {
-                try {
-                    return Files.probeContentType(file.toPath());
-                } catch (IOException ex) {
-                    LOG.log(Level.SEVERE, null, ex);
-                }
+            try {
+                return Files.probeContentType(file.toPath());
+            } catch (IOException ex) {
+                LOG.log(Level.SEVERE, null, ex);
             }
             return null;
         }
@@ -993,16 +987,10 @@
 
         @Override
         String findMimeType() {
-            if (file.getName().endsWith(".c")) {
-                return "text/x-c";
-            } else if (file.getName().endsWith(".R") || file.getName().endsWith(".r")) {
-                return "application/x-r";
-            } else {
-                try {
-                    return Files.probeContentType(file.toPath());
-                } catch (IOException ex) {
-                    LOG.log(Level.SEVERE, null, ex);
-                }
+            try {
+                return Files.probeContentType(file.toPath());
+            } catch (IOException ex) {
+                LOG.log(Level.SEVERE, null, ex);
             }
             return null;
         }