Skip to content

Commit b1c3f05

Browse files
author
rcartwright
committed
This revision disables much of the code supporting Java language levels. It also replaces a detailed Java parse to
determine the package name for a class by a shallow lexing scan that looks for the first package statement. The latter scan works for Scala files provides they only contain code belong to a single package. The following files were modified, added, or deleted: M drjava/src/edu/rice/cs/drjava/model/DummyGlobalModel.java M drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModelTest.java M drjava/src/edu/rice/cs/drjava/model/repl/DefaultInteractionsModel.java M drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDABreakpoint.java M drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java M drjava/src/edu/rice/cs/drjava/model/debug/jpda/PendingRequestManager.java M drjava/src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java D drjava/src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java M drjava/src/edu/rice/cs/drjava/model/compiler/CompilerModel.java M drjava/src/edu/rice/cs/drjava/model/compiler/DefaultCompilerModel.java M drjava/src/edu/rice/cs/drjava/model/compiler/CompilerErrorModel.java M drjava/src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java AM drjava/src/edu/rice/cs/drjava/model/definitions/PackageLexer.java AM drjava/src/edu/rice/cs/drjava/model/definitions/PackageLexerTest.java M drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java M drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java M drjava/src/edu/rice/cs/drjava/model/junit/JUnitTestManager.java M drjava/src/edu/rice/cs/drjava/model/javadoc/DefaultJavadocModel.java M drjava/src/edu/rice/cs/drjava/model/DrJavaFileUtils.java M drjava/src/edu/rice/cs/drjava/model/GlobalModel.java M drjava/src/edu/rice/cs/drjava/config/OptionConstants.java M drjava/src/edu/rice/cs/drjava/ui/MainFrame.java M drjava/src/edu/rice/cs/drjava/ui/NewJavaClassDialog.java M drjava/src/edu/rice/cs/drjava/ui/JavaSourceFilter.java M drjava/src/edu/rice/cs/drjava/ui/SmartSourceFilter.java git-svn-id: file:///tmp/test-svn/branches/drscala@5516 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent a68bac0 commit b1c3f05

25 files changed

+699
-1143
lines changed

drjava/src/edu/rice/cs/drjava/config/OptionConstants.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,23 @@ public interface OptionConstants {
9393

9494
/** The extension for a Java source file */
9595
public static final String JAVA_FILE_EXTENSION = ".java";
96+
97+
/** The extension for a Java source file */
98+
public static final String SCALA_FILE_EXTENSION = ".scala";
99+
100+
// Java Language Levels is disabled
96101

97-
/** The extension for a language level source file */
98-
public static final String DJ_FILE_EXTENSION = ".dj";
99-
100-
/** The old extension for an elementary language level source file */
101-
public static final String OLD_DJ0_FILE_EXTENSION = ".dj0";
102-
103-
/** The old extension for an intermediate language level source file */
104-
public static final String OLD_DJ1_FILE_EXTENSION = ".dj1";
105-
106-
/** The old extension for an advanced language level source file */
107-
public static final String OLD_DJ2_FILE_EXTENSION = ".dj2";
102+
// /** The extension for a language level source file */
103+
// public static final String DJ_FILE_EXTENSION = ".dj";
104+
//
105+
// /** The old extension for an elementary language level source file */
106+
// public static final String OLD_DJ0_FILE_EXTENSION = ".dj0";
107+
//
108+
// /** The old extension for an intermediate language level source file */
109+
// public static final String OLD_DJ1_FILE_EXTENSION = ".dj1";
110+
//
111+
// /** The old extension for an advanced language level source file */
112+
// public static final String OLD_DJ2_FILE_EXTENSION = ".dj2";
108113

109114
/* Constants for language levels */
110115
public static final int FULL_JAVA = 0;
@@ -113,12 +118,13 @@ public interface OptionConstants {
113118
public static final int ADVANCED_LEVEL = 3;
114119
public static final int FUNCTIONAL_JAVA_LEVEL = 4;
115120
public static final String[] LANGUAGE_LEVEL_EXTENSIONS = new String[] {
116-
JAVA_FILE_EXTENSION, // = .java, do not include the dot
117-
OLD_DJ0_FILE_EXTENSION, // = .dj0
118-
OLD_DJ1_FILE_EXTENSION, // = .dj1
119-
OLD_DJ2_FILE_EXTENSION, // = .dj2
120-
DJ_FILE_EXTENSION }; // = .dj
121-
121+
JAVA_FILE_EXTENSION, // = .java, do not include the dot. What? It does!
122+
SCALA_FILE_EXTENSION
123+
// OLD_DJ0_FILE_EXTENSION, // = .dj0
124+
// OLD_DJ1_FILE_EXTENSION, // = .dj1
125+
// OLD_DJ2_FILE_EXTENSION, // = .dj2
126+
// DJ_FILE_EXTENSION // = .dj
127+
};
122128
/** The configuration XML file that DrJava looks for inside a .djapp file */
123129
public static final String EXTPROCESS_FILE_NAME_INSIDE_JAR = "process" + EXTPROCESS_FILE_EXTENSION;
124130

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

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ public void openFolder(File dir, boolean rec, String ext)
14501450
debug.logStart();
14511451

14521452
final File[] sfiles = getFilesInFolder(dir, rec, ext);
1453-
if(sfiles == null) return;
1453+
if (sfiles == null) return;
14541454
openFiles(new FileOpenSelector() { public File[] getFiles() { return sfiles; } });
14551455

14561456
if (sfiles.length > 0 && _state.inProjectPath(dir)) setProjectChanged(true);
@@ -2337,19 +2337,19 @@ public List<OpenDefinitionsDocument> getOpenDefinitionsDocuments() {
23372337
}
23382338
}
23392339

2340-
/** Returns a new collection of all language level documents currently open for editing.
2341-
* @return a random-access List of the open definitions documents..
2342-
*/
2343-
public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments() {
2344-
synchronized(_documentsRepos) {
2345-
ArrayList<OpenDefinitionsDocument> docs = new ArrayList<OpenDefinitionsDocument>(_documentsRepos.size());
2346-
for (OpenDefinitionsDocument doc: _documentsRepos.values()) {
2347-
File f = doc.getRawFile();
2348-
if (DrJavaFileUtils.isLLFile(f.getName())) docs.add(doc);
2349-
}
2350-
return docs;
2351-
}
2352-
}
2340+
// /** Returns a new collection of all language level documents currently open for editing.
2341+
// * @return a random-access List of the open definitions documents..
2342+
// */
2343+
// public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments() {
2344+
// synchronized(_documentsRepos) {
2345+
// ArrayList<OpenDefinitionsDocument> docs = new ArrayList<OpenDefinitionsDocument>(_documentsRepos.size());
2346+
// for (OpenDefinitionsDocument doc: _documentsRepos.values()) {
2347+
// File f = doc.getRawFile();
2348+
// if (DrJavaFileUtils.isLLFile(f.getName())) docs.add(doc);
2349+
// }
2350+
// return docs;
2351+
// }
2352+
// }
23532353

23542354
/* Returns a sorted (by time of insertion) collection of all open documents. */
23552355
public List<OpenDefinitionsDocument> getSortedOpenDefinitionsDocuments() { return getOpenDefinitionsDocuments(); }
@@ -4009,30 +4009,12 @@ public boolean containsClassOrInterfaceOrEnum() throws BadLocationException {
40094009
private static class TrivialFSS implements FileSaveSelector {
40104010
private File _file;
40114011
private TrivialFSS(File file) { _file = file; }
4012-
public File getFile() throws OperationCanceledException {
4013-
return proposeBetterFileName(_file);
4014-
}
4012+
public File getFile() throws OperationCanceledException { return proposeBetterFileName(_file); }
40154013
public boolean warnFileOpen(File f) { return true; }
40164014
public boolean verifyOverwrite(File f) { return true; }
40174015
public boolean shouldSaveAfterFileMoved(OpenDefinitionsDocument doc, File oldFile) { return true; }
40184016
public boolean shouldUpdateDocumentState() { return true; }
4019-
private File proposeBetterFileName(File f) {
4020-
if (DrJavaFileUtils.isOldLLFile(f) && DrJava.getConfig().getSetting(OptionConstants.PROMPT_RENAME_LL_FILES)) {
4021-
File newFile = DrJavaFileUtils.getNewLLForOldLLFile(f);
4022-
String newExt = DrJavaFileUtils.getExtension(newFile.getName());
4023-
return edu.rice.cs.drjava.ui.MainFrameStatics.proposeToChangeExtension
4024-
(null, // TODO: better parent component
4025-
f,
4026-
"Change Extension?",
4027-
f.getPath() + "\nThis file still has an old Language Level extension."
4028-
+ "\nDo you want to change the file's extension to \""
4029-
+ newExt + "\"?",
4030-
"Change to \"" + newExt + "\"",
4031-
"Keep \"" + DrJavaFileUtils.getExtension(f.getName()) + "\"",
4032-
newExt);
4033-
}
4034-
else return f;
4035-
}
4017+
private File proposeBetterFileName(File f) { return f; }
40364018
}
40374019

40384020
/** Creates a ConcreteOpenDefDoc for a NullFile object f (corresponding to a new empty document)

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

Lines changed: 15 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ public class DrJavaFileUtils {
5252
public static Set<String> getSourceFileExtensions() {
5353
HashSet<String> extensions = new HashSet<String>();
5454
extensions.add(OptionConstants.JAVA_FILE_EXTENSION);
55-
extensions.add(OptionConstants.DJ_FILE_EXTENSION);
56-
extensions.add(OptionConstants.OLD_DJ0_FILE_EXTENSION);
57-
extensions.add(OptionConstants.OLD_DJ1_FILE_EXTENSION);
58-
extensions.add(OptionConstants.OLD_DJ2_FILE_EXTENSION);
55+
extensions.add(OptionConstants.SCALA_FILE_EXTENSION);
56+
// Java language levels support is disabled
57+
// extensions.add(OptionConstants.DJ_FILE_EXTENSION);
58+
// extensions.add(OptionConstants.OLD_DJ0_FILE_EXTENSION);
59+
// extensions.add(OptionConstants.OLD_DJ1_FILE_EXTENSION);
60+
// extensions.add(OptionConstants.OLD_DJ2_FILE_EXTENSION);
5961
return extensions;
6062
}
6163

@@ -67,18 +69,16 @@ public static String getSuggestedFileExtension() {
6769

6870

6971
/** .java --> true
70-
* .dj --> true
71-
* .dj0 --> true
72-
* .dj1 --> true
73-
* .dj2 --> true
72+
* .scala --> true
7473
* otherwise false
7574
* @return true if the file is a Java or language level file. */
7675
public static boolean isSourceFile(String fileName) {
7776
return fileName.endsWith(OptionConstants.JAVA_FILE_EXTENSION)
78-
|| fileName.endsWith(OptionConstants.DJ_FILE_EXTENSION)
79-
|| fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)
80-
|| fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)
81-
|| fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION);
77+
|| fileName.endsWith(OptionConstants.SCALA_FILE_EXTENSION);
78+
// || fileName.endsWith(OptionConstants.DJ_FILE_EXTENSION)
79+
// || fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)
80+
// || fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)
81+
// || fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION);
8282
}
8383

8484
/** @return true if the file is a Java or language level file. */
@@ -88,44 +88,8 @@ public static boolean isSourceFile(File f) {
8888
return isSourceFile(fileName);
8989
}
9090

91-
/** .dj --> true
92-
* .dj0 --> true
93-
* .dj1 --> true
94-
* .dj2 --> true
95-
* otherwise false
96-
* @return true if the file is a language level file. */
97-
public static boolean isLLFile(String fileName) {
98-
return fileName.endsWith(OptionConstants.DJ_FILE_EXTENSION)
99-
|| fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)
100-
|| fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)
101-
|| fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION);
102-
}
103-
104-
/** @return true if the file is a language level file. */
105-
public static boolean isLLFile(File f) {
106-
File canonicalFile = IOUtil.attemptCanonicalFile(f);
107-
String fileName = canonicalFile.getPath();
108-
return isLLFile(fileName);
109-
}
110-
111-
/** .dj0 --> true
112-
* .dj1 --> true
113-
* .dj2 --> true
114-
* otherwise false
115-
* @return true if the file is an old language level file. */
116-
public static boolean isOldLLFile(String fileName) {
117-
return fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)
118-
|| fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)
119-
|| fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION);
120-
}
121-
122-
/** @return true if the file is an old language level file. */
123-
public static boolean isOldLLFile(File f) {
124-
File canonicalFile = IOUtil.attemptCanonicalFile(f);
125-
String fileName = canonicalFile.getPath();
126-
return isOldLLFile(fileName);
127-
}
128-
91+
// Java language levels is disabled
92+
12993
/** .pjt --> true
13094
* otherwise false
13195
* @return true if the file is an old project file. */
@@ -158,123 +122,6 @@ public static boolean isProjectFile(File f) {
158122
return isProjectFile(fileName);
159123
}
160124

161-
/** A.dj --> A.java
162-
* A.dj0 --> A.java
163-
* A.dj1 --> A.java
164-
* A.dj2 --> A.java
165-
* otherwise unchanged
166-
* @return matching Java file for a language level file. */
167-
public static String getJavaForLLFile(String fileName) {
168-
if (fileName.endsWith(OptionConstants.DJ_FILE_EXTENSION)) {
169-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.DJ_FILE_EXTENSION))
170-
+ OptionConstants.JAVA_FILE_EXTENSION;
171-
}
172-
else if (fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)) {
173-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ0_FILE_EXTENSION))
174-
+ OptionConstants.JAVA_FILE_EXTENSION;
175-
}
176-
else if (fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)) {
177-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ1_FILE_EXTENSION))
178-
+ OptionConstants.JAVA_FILE_EXTENSION;
179-
}
180-
else if (fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION)) {
181-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ2_FILE_EXTENSION))
182-
+ OptionConstants.JAVA_FILE_EXTENSION;
183-
}
184-
else return fileName;
185-
}
186-
187-
/** @return matching Java file for a language level file. */
188-
public static File getJavaForLLFile(File f) {
189-
File canonicalFile = IOUtil.attemptCanonicalFile(f);
190-
String fileName = canonicalFile.getPath();
191-
return new File(getJavaForLLFile(fileName));
192-
}
193-
194-
/** A.java --> A.dj
195-
* otherwise unchanged
196-
* @return matching .dj file for a .java file. */
197-
public static File getDJForJavaFile(File f) {
198-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.DJ_FILE_EXTENSION);
199-
}
200-
201-
/** A.java --> A.dj0
202-
* otherwise unchanged
203-
* @return matching .dj0 file for a .java file. */
204-
public static File getDJ0ForJavaFile(File f) {
205-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ0_FILE_EXTENSION);
206-
}
207-
208-
/** A.java --> A.dj1
209-
* otherwise unchanged
210-
* @return matching .dj1 file for a .java file. */
211-
public static File getDJ1ForJavaFile(File f) {
212-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ1_FILE_EXTENSION);
213-
}
214-
215-
/** A.java --> A.dj2
216-
* otherwise unchanged
217-
* @return matching .dj2 file for a .java file. */
218-
public static File getDJ2ForJavaFile(File f) {
219-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ2_FILE_EXTENSION);
220-
}
221-
222-
/** A.java --> A.dj
223-
* otherwise unchanged
224-
* @return matching .dj file for a .java file. */
225-
public static String getDJForJavaFile(String f) {
226-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.DJ_FILE_EXTENSION);
227-
}
228-
229-
/** A.java --> A.dj0
230-
* otherwise unchanged
231-
* @return matching .dj0 file for a .java file. */
232-
public static String getDJ0ForJavaFile(String f) {
233-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ0_FILE_EXTENSION);
234-
}
235-
236-
/** A.java --> A.dj1
237-
* otherwise unchanged
238-
* @return matching .dj1 file for a .java file. */
239-
public static String getDJ1ForJavaFile(String f) {
240-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ1_FILE_EXTENSION);
241-
}
242-
243-
/** A.java --> A.dj2
244-
* otherwise unchanged
245-
* @return matching .dj2 file for a .java file. */
246-
public static String getDJ2ForJavaFile(String f) {
247-
return getFileWithDifferentExt(f, OptionConstants.JAVA_FILE_EXTENSION, OptionConstants.OLD_DJ2_FILE_EXTENSION);
248-
}
249-
250-
/** A.dj0 -> A.dj
251-
* A.dj1 -> A.dj
252-
* A.dj2 -> A.java
253-
* otherwise unchanged
254-
* @return new language level file matching an old language level file. */
255-
public static String getNewLLForOldLLFile(String fileName) {
256-
if (fileName.endsWith(OptionConstants.OLD_DJ0_FILE_EXTENSION)) {
257-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ0_FILE_EXTENSION))
258-
+ OptionConstants.DJ_FILE_EXTENSION;
259-
}
260-
else if (fileName.endsWith(OptionConstants.OLD_DJ1_FILE_EXTENSION)) {
261-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ1_FILE_EXTENSION))
262-
+ OptionConstants.DJ_FILE_EXTENSION;
263-
}
264-
else if (fileName.endsWith(OptionConstants.OLD_DJ2_FILE_EXTENSION)) {
265-
return fileName.substring(0, fileName.lastIndexOf(OptionConstants.OLD_DJ2_FILE_EXTENSION))
266-
+ OptionConstants.JAVA_FILE_EXTENSION;
267-
}
268-
else return fileName;
269-
}
270-
271-
/** @return new language level file matching an old language level file. */
272-
public static File getNewLLForOldLLFile(File f) {
273-
File canonicalFile = IOUtil.attemptCanonicalFile(f);
274-
String fileName = canonicalFile.getPath();
275-
return new File(getNewLLForOldLLFile(fileName));
276-
}
277-
278125
/** getFileWithDifferentExt("A.java", ".java", ".dj") --> "A.dj"
279126
* @return matching file with extension dest for a file with extension source. */
280127
public static String getFileWithDifferentExt(String fileName, String source, String dest) {
@@ -291,8 +138,7 @@ public static File getFileWithDifferentExt(File f, String source, String dest) {
291138
String fileName = canonicalFile.getPath();
292139
return new File(getFileWithDifferentExt(fileName, source, dest));
293140
}
294-
295-
141+
296142
/** Returns the relative directory (from the source root) that the source file with this qualifed name will be in,
297143
* given its package. Returns the empty string for classes without packages.
298144
* @param className The fully qualified class name

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ public List<OpenDefinitionsDocument> getOpenDefinitionsDocuments() {
548548
throw new UnsupportedOperationException("Tried to getOpenDefinitionsDocuments on a Dummy!");
549549
}
550550

551-
public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments() {
552-
throw new UnsupportedOperationException("Tried to getOpenDefinitionsDocuments on a Dummy!");
553-
}
551+
// public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments() {
552+
// throw new UnsupportedOperationException("Tried to getOpenDefinitionsDocuments on a Dummy!");
553+
// }
554554

555555
public List<OpenDefinitionsDocument> getAuxiliaryDocuments() {
556556
throw new UnsupportedOperationException("Tried to getAuxiliaryDocuments on a Dummy!");

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ public InteractionsScriptModel loadHistoryAsScript(FileOpenSelector selector)
547547
* @return a List of the open definitions documents.
548548
*/
549549
public List<OpenDefinitionsDocument> getOpenDefinitionsDocuments();
550-
/** Returns a collection of language level documents. */
551-
public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments();
550+
551+
// Java language levels processing is disabled
552+
// /** Returns a collection of language level documents. */
553+
// public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments();
554+
552555
public List<OpenDefinitionsDocument> getAuxiliaryDocuments();
553556

554557
/** Checks if any open definitions documents have been modified since last being saved.

0 commit comments

Comments
 (0)