mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
Fixed stale code on .java tabs.
This commit is contained in:
@@ -361,15 +361,7 @@ public class PreprocService {
|
||||
tabLineStarts.add(numLines);
|
||||
|
||||
StringBuilder newPiece = new StringBuilder();
|
||||
if (sc.getDocument() != null) {
|
||||
try {
|
||||
newPiece.append(sc.getDocumentText());
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
newPiece.append(sc.getProgram());
|
||||
}
|
||||
newPiece.append(getSketchTabContents(sc));
|
||||
newPiece.append('\n');
|
||||
|
||||
String newPieceBuilt = newPiece.toString();
|
||||
@@ -552,6 +544,29 @@ public class PreprocService {
|
||||
return result.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updated (and possibly unsaved) code from a sketch tab.
|
||||
*
|
||||
* @param sketchCode The tab from which to content program contents.
|
||||
* @return Updated program contents.
|
||||
*/
|
||||
private String getSketchTabContents(SketchCode sketchCode) {
|
||||
String code = null;
|
||||
if (sketchCode.getDocument() != null) {
|
||||
try {
|
||||
code = sketchCode.getDocumentText();
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (code == null) {
|
||||
code = sketchCode.getProgram();
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/// COMPILATION -----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -614,9 +629,10 @@ public class PreprocService {
|
||||
final String mainSource = mainTemporaryFile.toString();
|
||||
temporaryFilesList.add(mainTemporaryFile);
|
||||
|
||||
// Write temporary java files
|
||||
// Write temporary java files as tab may be unsaved
|
||||
for (JavaSketchCode javaFile : javaFiles) {
|
||||
Path newPath = createTemporaryFile(javaFile.getSketchCode().getProgram());
|
||||
String tabContents = getSketchTabContents(javaFile.getSketchCode());
|
||||
Path newPath = createTemporaryFile(tabContents);
|
||||
javaFileMapping.put(newPath.toString(), javaFile.getTabIndex());
|
||||
temporaryFilesList.add(newPath);
|
||||
}
|
||||
|
||||
@@ -74,9 +74,10 @@ public class PreprocSketch {
|
||||
|
||||
public SketchInterval mapJavaToSketch(IProblem iproblem) {
|
||||
String originalFile = new String(iproblem.getOriginatingFileName());
|
||||
boolean isJavaFile = javaFileMapping.containsKey(originalFile);
|
||||
boolean isJavaTab = javaFileMapping.containsKey(originalFile);
|
||||
|
||||
if (isJavaFile) {
|
||||
// If is a ".java" tab, do not need to map into combined sketch source.
|
||||
if (isJavaTab) {
|
||||
return new SketchInterval(
|
||||
javaFileMapping.get(originalFile),
|
||||
iproblem.getSourceStart(),
|
||||
|
||||
Reference in New Issue
Block a user