Skip to content

Commit 7f27d4d

Browse files
author
mgricken
committed
Allowing compilers to suggest file extension, e.g. HJ --> .hj
git-svn-id: file:///tmp/test-svn/trunk@5395 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent a0fae01 commit 7f27d4d

File tree

19 files changed

+729
-673
lines changed

19 files changed

+729
-673
lines changed

drjava/lib/platform.jar

67 Bytes
Binary file not shown.

drjava/src/edu/rice/cs/drjava/model/DrJavaFileUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
import java.io.File;
4040
import java.util.Set;
4141
import java.util.HashSet;
42-
import edu.rice.cs.plt.io.IOUtil;
42+
import edu.rice.cs.drjava.DrJava;
4343
import edu.rice.cs.drjava.config.OptionConstants;
44+
import edu.rice.cs.plt.io.IOUtil;
4445

4546
/** Some common methods for determining Java source files, language level files, etc.
4647
* @version $Id$
@@ -58,6 +59,13 @@ public static Set<String> getSourceFileExtensions() {
5859
return extensions;
5960
}
6061

62+
/** Return the suggested file extension that will be appended to a file without extension.
63+
* @return the suggested file extension */
64+
public static String getSuggestedFileExtension() {
65+
return OptionConstants.LANGUAGE_LEVEL_EXTENSIONS[DrJava.getConfig().getSetting(OptionConstants.LANGUAGE_LEVEL)];
66+
}
67+
68+
6169
/** .java --> true
6270
* .dj --> true
6371
* .dj0 --> true

drjava/src/edu/rice/cs/drjava/model/compiler/CompilerInterface.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ List<? extends DJError> compile(List<? extends File> files, List<? extends File>
103103
/** Return the set of source file extensions that this compiler supports.
104104
* @return the set of source file extensions that this compiler supports. */
105105
Set<String> getSourceFileExtensions();
106+
107+
/** Return the suggested file extension that will be appended to a file without extension.
108+
* @return the suggested file extension */
109+
public String getSuggestedFileExtension();
106110

107111
/** Return a file filter that can be used to open files this compiler supports.
108112
* @return file filter for appropriate source files for this compiler. */

drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java

Lines changed: 329 additions & 314 deletions
Large diffs are not rendered by default.

drjava/src/edu/rice/cs/drjava/model/compiler/NoCompilerAvailable.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public List<? extends DJError> compile(List<? extends File> files, List<? extend
9696
/** Return the set of source file extensions that this compiler supports.
9797
* @return the set of source file extensions that this compiler supports. */
9898
public Set<String> getSourceFileExtensions() { return DrJavaFileUtils.getSourceFileExtensions(); }
99+
100+
/** Return the suggested file extension that will be appended to a file without extension.
101+
* @return the suggested file extension */
102+
public String getSuggestedFileExtension() {
103+
return DrJavaFileUtils.getSuggestedFileExtension();
104+
}
99105

100106
/** Return a file filter that can be used to open files this compiler supports.
101107
* @return file filter for appropriate source files for this compiler */

drjava/src/edu/rice/cs/drjava/ui/MainFrame.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,18 @@ private javax.swing.filechooser.FileFilter getSourceFileFilter() {
344344
return cm.getActiveCompiler().getFileFilter();
345345
}
346346
}
347+
348+
/** Return the suggested file extension that will be appended to a file without extension.
349+
* @return the suggested file extension */
350+
private String getSuggestedFileExtension() {
351+
edu.rice.cs.drjava.model.compiler.CompilerModel cm = _model.getCompilerModel();
352+
if (cm==null) {
353+
return DrJavaFileUtils.getSuggestedFileExtension();
354+
}
355+
else {
356+
return cm.getActiveCompiler().getSuggestedFileExtension();
357+
}
358+
}
347359

348360
/** Returns the files to open to the model (command pattern). */
349361
private final FileOpenSelector _openSelector = new FileOpenSelector() {
@@ -5955,8 +5967,7 @@ private File getChosenFile(JFileChooser fc, int choice, File previous,
59555967
String previousName = (previous!=null)?previous.getName():"";
59565968
if (!DrJavaFileUtils.isSourceFile(previousName)) {
59575969
// previous file name doesn't have a file extension either
5958-
File newFile = new File(chosen.getAbsolutePath() + OptionConstants.
5959-
LANGUAGE_LEVEL_EXTENSIONS[DrJava.getConfig().getSetting(LANGUAGE_LEVEL)]);
5970+
File newFile = new File(chosen.getAbsolutePath() + getSuggestedFileExtension());
59605971
return newFile;
59615972
}
59625973
else {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)