royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [royale-compiler] 02/02: GoogDepsWriter: addRestOfDeps() rewrites source map file for main class so that debugging works with remove-circulars
Date Wed, 24 Oct 2018 21:23:34 GMT
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 94fc6910828447ddc8e0124e4ddc249dfc323d83
Author: Josh Tynjala <joshtynjala@apache.org>
AuthorDate: Wed Oct 24 14:23:25 2018 -0700

    GoogDepsWriter: addRestOfDeps() rewrites source map file for main class so that debugging
works with remove-circulars
---
 .../compiler/internal/graph/GoogDepsWriter.java    | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
index 900d2c8..db6867e 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/GoogDepsWriter.java
@@ -413,21 +413,48 @@ public class GoogDepsWriter {
 	{
         List<String> fileLines;
 		try {
-			fileLines = Files.readLines(new File(main.filePath), Charset.defaultCharset());
+			File mainFile = new File(main.filePath);
+			fileLines = Files.readLines(mainFile, Charset.defaultCharset());
+
+			SourceMapConsumerV3 sourceMapConsumer = null;
+			File sourceMapFile = new File(main.filePath + ".map");
+			if (sourceMapFile.exists())
+			{
+				String sourceMapContents = FileUtils.readFileToString(sourceMapFile);
+				sourceMapConsumer = new SourceMapConsumerV3();
+				try
+				{
+					sourceMapConsumer.parse(sourceMapContents);
+				}
+				catch(SourceMapParseException e)
+				{
+					sourceMapConsumer = null;
+				}
+			}
+
 			int n = restOfDeps.size();
 			for (int i = n - 1; i >= 0; i--)
 			{
 				String dep = restOfDeps.get(i);
 				//if (!main.deps.contains(dep))
 					fileLines.add(main.fileInfo.googProvideLine + 1, JSGoogEmitterTokens.GOOG_REQUIRE.getToken()
+ "('" + dep + "');");
+					sourceMapConsumer = addLineToSourceMap(sourceMapConsumer, mainFile.getName(), main.fileInfo.googProvideLine
+ 1);
 			}
-            File file = new File(main.filePath);  
-            PrintWriter out = new PrintWriter(new FileWriter(file));  
+
+			PrintWriter out = new PrintWriter(new FileWriter(mainFile));  
             for (String s : fileLines)
             {
                 out.println(s);
             }
             out.close();
+
+			if (sourceMapConsumer != null)
+			{
+				String newSourceMap = sourceMapConsumerToString(sourceMapConsumer, mainFile.getName());
+				PrintWriter sourceMapOut = new PrintWriter(new FileWriter(sourceMapFile));  
+				sourceMapOut.print(newSourceMap);
+				sourceMapOut.close();
+			}
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();


Mime
View raw message