Fixes several checkstyle violations.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5012 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/CompilationAnalysis.java b/dev/core/src/com/google/gwt/core/ext/linker/CompilationAnalysis.java
index 3ee4d18..8496f0c 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/CompilationAnalysis.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/CompilationAnalysis.java
@@ -16,8 +16,7 @@
package com.google.gwt.core.ext.linker;
import com.google.gwt.core.ext.Linker;
-import com.google.gwt.core.ext.soyc.Range;
-import com.google.gwt.core.ext.soyc.Story;
+
import java.io.File;
/**
@@ -35,68 +34,68 @@
public abstract File getDepFile();
/**
- * @return a file of stories
- */
- public abstract File getStoriesFile();
-
- /**
* @return a file of split points
*/
public abstract File getSplitPointsFile();
+ /**
+ * @return a file of stories
+ */
+ public abstract File getStoriesFile();
+
+ @Override
+ public final int hashCode() {
+
+ assert (getDepFile() != null);
+ assert (getStoriesFile() != null);
+ assert (getSplitPointsFile() != null);
+
+ return 17 * (37 + getDepFile().getName().hashCode())
+ + (37 + getStoriesFile().getName().hashCode())
+ + (37 + getSplitPointsFile().getName().hashCode());
+ }
+
@Override
protected final int compareToComparableArtifact(CompilationAnalysis o) {
-
- if ((getDepFile() == null)&&(o.getDepFile()==null)){
+
+ if ((getDepFile() == null) && (o.getDepFile() == null)) {
return 0;
- }
- else if ((getDepFile() == null)&&(o.getDepFile() != null)){
+ } else if ((getDepFile() == null) && (o.getDepFile() != null)) {
return 1;
- }
- else if ((getDepFile() != null)&&(o.getDepFile() == null)){
+ } else if ((getDepFile() != null) && (o.getDepFile() == null)) {
return -1;
- }
- else if (getDepFile().getName().compareTo(o.getDepFile().getName()) == 0){
- if ((getStoriesFile() == null)&&(o.getStoriesFile() == null)){
+ } else if (getDepFile().getName().compareTo(o.getDepFile().getName()) == 0) {
+ if ((getStoriesFile() == null) && (o.getStoriesFile() == null)) {
return 0;
- }
- else if ((getStoriesFile() == null)&&(o.getStoriesFile() != null)){
+ } else if ((getStoriesFile() == null) && (o.getStoriesFile() != null)) {
return 1;
- }
- else if ((getStoriesFile() != null)&&(o.getStoriesFile() == null)){
+ } else if ((getStoriesFile() != null) && (o.getStoriesFile() == null)) {
return -1;
- }
- else if (getStoriesFile().getName().compareTo(o.getStoriesFile().getName()) == 0){
- if ((getSplitPointsFile() == null)&&(o.getSplitPointsFile() == null)){
+ } else if (getStoriesFile().getName().compareTo(
+ o.getStoriesFile().getName()) == 0) {
+ if ((getSplitPointsFile() == null) && (o.getSplitPointsFile() == null)) {
return 0;
}
- if ((getSplitPointsFile() == null)&&(o.getSplitPointsFile() != null)){
+ if ((getSplitPointsFile() == null) && (o.getSplitPointsFile() != null)) {
return 1;
- }
- else if ((getSplitPointsFile() != null)&&(o.getSplitPointsFile() == null)){
+ } else if ((getSplitPointsFile() != null)
+ && (o.getSplitPointsFile() == null)) {
return -1;
+ } else {
+ return getSplitPointsFile().getName().compareTo(
+ o.getSplitPointsFile().getName());
}
- else return getSplitPointsFile().getName().compareTo(o.getSplitPointsFile().getName());
+ } else {
+ return getStoriesFile().getName().compareTo(
+ o.getStoriesFile().getName());
}
- else{
- return getStoriesFile().getName().compareTo(o.getStoriesFile().getName());
- }
+ } else {
+ return getDepFile().getName().compareTo(o.getDepFile().getName());
}
- else return getDepFile().getName().compareTo(o.getDepFile().getName());
}
@Override
protected final Class<CompilationAnalysis> getComparableArtifactType() {
return CompilationAnalysis.class;
}
-
- @Override
- public final int hashCode() {
-
- assert(getDepFile() != null);
- assert(getStoriesFile() != null);
- assert(getSplitPointsFile() != null);
-
- return 17 * (37 + getDepFile().getName().hashCode()) + (37 + getStoriesFile().getName().hashCode()) + (37 + getSplitPointsFile().getName().hashCode());
- }
}
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationAnalysis.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationAnalysis.java
index 45ff2f6..839bb8e 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationAnalysis.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationAnalysis.java
@@ -18,6 +18,7 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.CompilationAnalysis;
+
import java.io.File;
/**
@@ -28,29 +29,29 @@
public class StandardCompilationAnalysis extends CompilationAnalysis {
/**
- * File containing method-level control-flow dependencies (corresponding to the current report)
+ * File containing method-level control-flow dependencies (corresponding to
+ * the current report).
*/
private File depFile;
-
+
/**
- * File containing stories
- */
- private File storiesFile;
-
- /**
- * File containing split points
+ * File containing split points.
*/
private File splitPointsFile;
-
+
+ /**
+ * File containing stories.
+ */
+ private File storiesFile;
+
/**
* Constructed by PermutationCompiler.
*/
- public StandardCompilationAnalysis(TreeLogger logger, File depFile, File storiesFile, File splitPointsFile)
- throws UnableToCompleteException {
+ public StandardCompilationAnalysis(TreeLogger logger, File depFile,
+ File storiesFile, File splitPointsFile) throws UnableToCompleteException {
super(StandardLinkerContext.class);
- logger = logger.branch(TreeLogger.INFO,
- "Creating CompilationAnalysis");
-
+ logger = logger.branch(TreeLogger.INFO, "Creating CompilationAnalysis");
+
this.depFile = depFile;
this.storiesFile = storiesFile;
this.splitPointsFile = splitPointsFile;
@@ -64,12 +65,12 @@
}
@Override
- public File getStoriesFile() {
- return storiesFile;
+ public File getSplitPointsFile() {
+ return splitPointsFile;
}
@Override
- public File getSplitPointsFile() {
- return splitPointsFile;
+ public File getStoriesFile() {
+ return storiesFile;
}
}
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
index 0980040..cad3118 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
@@ -456,17 +456,20 @@
outFile.setLastModified(artifact.getLastModified());
}
}
- for (StandardCompilationAnalysis soycFiles : artifacts.find(StandardCompilationAnalysis.class)){
- TreeLogger artifactLogger = logger.branch(TreeLogger.DEBUG,
- "Emitting soyc resources.", null);
- File depFile = new File(extraPath + "/soycReport", soycFiles.getDepFile().getName());
- Util.copy(artifactLogger, soycFiles.getDepFile(), depFile);
+ for (StandardCompilationAnalysis soycFiles : artifacts.find(StandardCompilationAnalysis.class)) {
+ TreeLogger artifactLogger = logger.branch(TreeLogger.DEBUG,
+ "Emitting soyc resources.", null);
+ File depFile = new File(extraPath + "/soycReport",
+ soycFiles.getDepFile().getName());
+ Util.copy(artifactLogger, soycFiles.getDepFile(), depFile);
- File storiesFile = new File(extraPath + "/soycReport", soycFiles.getStoriesFile().getName());
- Util.copy(artifactLogger, soycFiles.getStoriesFile(), storiesFile);
+ File storiesFile = new File(extraPath + "/soycReport",
+ soycFiles.getStoriesFile().getName());
+ Util.copy(artifactLogger, soycFiles.getStoriesFile(), storiesFile);
- File splitPointsFile = new File(extraPath + "/soycReport", soycFiles.getSplitPointsFile().getName());
- Util.copy(artifactLogger, soycFiles.getSplitPointsFile(), splitPointsFile);
+ File splitPointsFile = new File(extraPath + "/soycReport",
+ soycFiles.getSplitPointsFile().getName());
+ Util.copy(artifactLogger, soycFiles.getSplitPointsFile(), splitPointsFile);
}
}
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/SplitPointRecorder.java b/dev/core/src/com/google/gwt/core/ext/soyc/SplitPointRecorder.java
index 7acdd04..2d36a98 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/SplitPointRecorder.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/SplitPointRecorder.java
@@ -21,16 +21,10 @@
import java.io.File;
+/**
+ * Used to record (runAsync) split points of a program.
+ */
public interface SplitPointRecorder {
- /**
- * Used to record (runAsync) split points of a program
- *
- * @param jprogram
- * @param workDir
- * @param permutationId
- * @param logger
- * @return The file that the dependencies are recorded in
- */
- public File recordSplitPoints(JProgram jprogram, File workDir, int permutationId, TreeLogger logger);
-
+ File recordSplitPoints(JProgram jprogram, File workDir, int permutationId,
+ TreeLogger logger);
}
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/Story.java b/dev/core/src/com/google/gwt/core/ext/soyc/Story.java
index 7805c26..e0f3ad4 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/Story.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/Story.java
@@ -31,7 +31,6 @@
package com.google.gwt.core.ext.soyc;
import java.io.Serializable;
-import java.util.List;
import java.util.SortedSet;
/**
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/StoryRecorder.java b/dev/core/src/com/google/gwt/core/ext/soyc/StoryRecorder.java
index 85737a5..38cfa6a 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/StoryRecorder.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/StoryRecorder.java
@@ -24,17 +24,11 @@
import java.util.List;
import java.util.Map;
+/**
+ * Used to record dependencies of a program.
+ */
public interface StoryRecorder {
- /**
- * Used to record dependencies of a program
- *
- * @param jprogram
- * @param workDir
- * @param permutationId
- * @param logger
- * @return The file that the dependencies are recorded in
- */
- public File recordStories(JProgram jprogram, File workDir, int permutationId,
+ File recordStories(JProgram jprogram, File workDir, int permutationId,
TreeLogger logger, List<Map<Range, SourceInfo>> sourceInfoMaps,
String[] js);
}
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/impl/DependencyRecorderImpl.java b/dev/core/src/com/google/gwt/core/ext/soyc/impl/DependencyRecorderImpl.java
index 1880947..8f729f9 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/impl/DependencyRecorderImpl.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/impl/DependencyRecorderImpl.java
@@ -30,14 +30,18 @@
import java.util.ArrayList;
import java.util.zip.GZIPOutputStream;
-public class DependencyRecorderImpl implements ControlFlowAnalyzer.DependencyRecorder {
+/**
+ * The control-flow dependency recorder for SOYC.
+ */
+public class DependencyRecorderImpl implements
+ ControlFlowAnalyzer.DependencyRecorder {
- private OutputStreamWriter writer;
- private PrintWriter pw;
private HtmlTextOutput htmlOut;
+ private PrintWriter pw;
+ private OutputStreamWriter writer;
/**
- * Used to record the dependencies of a specific method
+ * Used to record the dependencies of a specific method.
*
* @param liveMethod
* @param dependencyChain
@@ -48,7 +52,7 @@
}
/**
- * Used to record dependencies of a program
+ * Used to record dependencies of a program.
*
* @param jprogram
* @param workDir
@@ -58,12 +62,13 @@
*/
public File recordDependencies(JProgram jprogram, File workDir,
int permutationId, TreeLogger logger) {
-
- logger = logger.branch(TreeLogger.INFO, "Creating Dependencies file for SOYC");
-
+
+ logger = logger.branch(TreeLogger.INFO,
+ "Creating Dependencies file for SOYC");
+
ControlFlowAnalyzer dependencyAnalyzer = new ControlFlowAnalyzer(jprogram);
dependencyAnalyzer.setDependencyRecorder(this);
-
+
File appendDepFile = new File(workDir, "dependencies" + permutationId
+ ".xml.gz");
try {
@@ -83,14 +88,14 @@
printPost();
pw.close();
Utility.close(writer);
-
+
logger.log(TreeLogger.INFO, "Done");
-
+
return appendDepFile;
}
/**
- * Prints the control-flow dependencies to a file in a specific format
+ * Prints the control-flow dependencies to a file in a specific format.
*
* @param liveMethod
* @param dependencyChain
@@ -125,7 +130,18 @@
}
/**
- * Prints the preamble necessary for the dependencies file
+ * Prints the closing lines necessary for the dependencies file.
+ */
+ private void printPost() {
+ String curLine = "</soyc-dependencies>";
+ htmlOut.indentOut();
+ htmlOut.indentOut();
+ htmlOut.printRaw(curLine);
+ htmlOut.newline();
+ }
+
+ /**
+ * Prints the preamble necessary for the dependencies file.
*/
private void printPre() {
String curLine = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
@@ -137,15 +153,4 @@
htmlOut.indentIn();
htmlOut.indentIn();
}
-
- /**
- * Prints the closing lines necessary for the dependencies file
- */
- private void printPost() {
- String curLine = "</soyc-dependencies>";
- htmlOut.indentOut();
- htmlOut.indentOut();
- htmlOut.printRaw(curLine);
- htmlOut.newline();
- }
}
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorderImpl.java b/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorderImpl.java
index de08526..8c1172a 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorderImpl.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/impl/SplitPointRecorderImpl.java
@@ -29,6 +29,9 @@
import java.util.Map;
import java.util.zip.GZIPOutputStream;
+/**
+ * Records split points to a file for SOYC reports.
+ */
public class SplitPointRecorderImpl implements SplitPointRecorder {
private FileOutputStream stream;
@@ -37,7 +40,7 @@
private HtmlTextOutput htmlOut;
/**
- * Used to record (runAsync) split points of a program
+ * Used to record (runAsync) split points of a program.
*
* @param jprogram
* @param workDir
@@ -47,8 +50,9 @@
*/
public File recordSplitPoints(JProgram jprogram, File workDir,
int permutationId, TreeLogger logger) {
-
- logger = logger.branch(TreeLogger.INFO, "Creating Split Point Map file for SOYC");
+
+ logger = logger.branch(TreeLogger.INFO,
+ "Creating Split Point Map file for SOYC");
File splitPointsFile = new File(workDir, "splitPoints"
+ Integer.toString(permutationId) + ".xml.gz");
@@ -97,14 +101,13 @@
Utility.close(writer);
pw.close();
-
+
logger.log(TreeLogger.INFO, "Done");
-
+
} catch (Throwable e) {
logger.log(TreeLogger.ERROR, "Could not open dependency file.", e);
}
return splitPointsFile;
-
}
}
diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorderImpl.java b/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorderImpl.java
index b861c32..0682381 100644
--- a/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorderImpl.java
+++ b/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorderImpl.java
@@ -17,9 +17,13 @@
package com.google.gwt.core.ext.soyc.impl;
import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.soyc.ClassMember;
+import com.google.gwt.core.ext.soyc.FunctionMember;
+import com.google.gwt.core.ext.soyc.Member;
import com.google.gwt.core.ext.soyc.Range;
import com.google.gwt.core.ext.soyc.Story;
import com.google.gwt.core.ext.soyc.StoryRecorder;
+import com.google.gwt.core.ext.soyc.Story.Origin;
import com.google.gwt.dev.jjs.Correlation;
import com.google.gwt.dev.jjs.SourceInfo;
import com.google.gwt.dev.jjs.Correlation.Axis;
@@ -30,10 +34,6 @@
import com.google.gwt.dev.js.ast.JsFunction;
import com.google.gwt.dev.util.HtmlTextOutput;
import com.google.gwt.util.tools.Utility;
-import com.google.gwt.core.ext.soyc.ClassMember;
-import com.google.gwt.core.ext.soyc.FunctionMember;
-import com.google.gwt.core.ext.soyc.Member;
-import com.google.gwt.core.ext.soyc.Story.Origin;
import java.io.File;
import java.io.FileOutputStream;
@@ -51,19 +51,53 @@
import java.util.TreeSet;
import java.util.zip.GZIPOutputStream;
+/**
+ * Records {@link Story}s to a file for SOYC.
+ */
public class StoryRecorderImpl implements StoryRecorder {
- private FileOutputStream stream;
- private OutputStreamWriter writer;
- private PrintWriter pw;
- private HtmlTextOutput htmlOut;
+ /**
+ * Associates a SourceInfo with a Range.
+ */
+ private static class RangeInfo {
+ public final SourceInfo info;
+ public final Range range;
- private Map<Story, Integer> storyIds = new HashMap<Story, Integer>();
- private String[] js;
+ public RangeInfo(Range range, SourceInfo info) {
+ this.range = range;
+ this.info = info;
+ }
+ }
+
private int curHighestFragment = 0;
+ private HtmlTextOutput htmlOut;
+ private String[] js;
/**
- * Used to record dependencies of a program
+ * Used by {@link #popAndRecord(Stack)} to determine start and end ranges.
+ */
+ private int lastEnd = 0;
+ /**
+ * This is a class field for convenience, but it should be deleted at the end
+ * of the constructor.
+ */
+ private transient Map<Correlation, Member> membersByCorrelation = new IdentityHashMap<Correlation, Member>();
+ private PrintWriter pw;
+
+ /**
+ * This is a class field for convenience, but it should be deleted at the end
+ * of the constructor.
+ */
+ private transient Map<SourceInfo, StoryImpl> storyCache = new IdentityHashMap<SourceInfo, StoryImpl>();
+
+ private Map<Story, Integer> storyIds = new HashMap<Story, Integer>();
+
+ private FileOutputStream stream;
+
+ private OutputStreamWriter writer;
+
+ /**
+ * Used to record dependencies of a program.
*
* @param jprogram
* @param workDir
@@ -145,9 +179,9 @@
Utility.close(writer);
pw.close();
-
+
logger.log(TreeLogger.INFO, "Done");
-
+
} catch (Throwable e) {
logger.log(TreeLogger.ERROR, "Could not open dependency file.", e);
}
@@ -155,36 +189,6 @@
return storiesFile;
}
- /**
- * Associates a SourceInfo with a Range.
- */
- private static class RangeInfo {
- public final SourceInfo info;
- public final Range range;
-
- public RangeInfo(Range range, SourceInfo info) {
- this.range = range;
- this.info = info;
- }
- }
-
- /**
- * Used by {@link #popAndRecord(Stack)} to determine start and end ranges.
- */
- private int lastEnd = 0;
-
- /**
- * This is a class field for convenience, but it should be deleted at the end
- * of the constructor.
- */
- private transient Map<SourceInfo, StoryImpl> storyCache = new IdentityHashMap<SourceInfo, StoryImpl>();
-
- /**
- * This is a class field for convenience, but it should be deleted at the end
- * of the constructor.
- */
- private transient Map<Correlation, Member> membersByCorrelation = new IdentityHashMap<Correlation, Member>();
-
private void analyzeFragment(MemberFactory memberFactory,
TreeSet<ClassMember> classesMutable,
TreeSet<FunctionMember> functionsMutable,
@@ -287,89 +291,8 @@
assert dependencyOrder[0].getEnd() == lastEnd;
}
- /**
- * Remove an element from the RangeInfo stack and stare a new StoryImpl with
- * the right length, possibly sub-dividing the super-enclosing Range in the
- * process.
- */
- private void popAndRecord(Stack<RangeInfo> dependencyScope, int fragment) {
- RangeInfo rangeInfo = dependencyScope.pop();
- Range toStore = rangeInfo.range;
-
- /*
- * Make a new Range for the gap between the popped Range and whatever we
- * last stored.
- */
- if (lastEnd < toStore.getStart()) {
- Range newRange = new Range(lastEnd, toStore.getStart());
- assert !dependencyScope.isEmpty();
-
- SourceInfo gapInfo = dependencyScope.peek().info;
- recordStory(gapInfo, fragment, newRange.length(), newRange);
-
- lastEnd += newRange.length();
- }
-
- /*
- * Store as much of the current Range as we haven't previously stored. The
- * Max.max() is there to take care of the tail end of Ranges that have had a
- * sub-range previously stored.
- */
- if (lastEnd < toStore.getEnd()) {
- Range newRange = new Range(Math.max(lastEnd, toStore.getStart()),
- toStore.getEnd());
- recordStory(rangeInfo.info, fragment, newRange.length(), newRange);
- lastEnd += newRange.length();
- }
- }
-
- private void recordStory(SourceInfo info, int fragment, int length,
- Range range) {
- assert storyCache != null;
-
- if (fragment > curHighestFragment) {
- curHighestFragment = fragment;
- }
-
- StoryImpl theStory;
- if (!storyCache.containsKey(info)) {
-
- SortedSet<Member> members = new TreeSet<Member>(
- Member.TYPE_AND_SOURCE_NAME_COMPARATOR);
-
- if (info != null) {
- for (Correlation c : info.getAllCorrelations()) {
- Member m = membersByCorrelation.get(c);
- if (m != null) {
- members.add(m);
- }
- }
- }
-
- SortedSet<Origin> origins = new TreeSet<Origin>();
- for (Correlation c : info.getAllCorrelations(Axis.ORIGIN)) {
- origins.add(new OriginImpl(c.getOrigin()));
- }
-
- String literalType = null;
- Correlation literalCorrelation = info.getPrimaryCorrelation(Axis.LITERAL);
- if (literalCorrelation != null) {
- literalType = literalCorrelation.getLiteral().getDescription();
- }
-
- theStory = new StoryImpl(storyCache.size(), members, origins,
- literalType, fragment, length);
- storyCache.put(info, theStory);
- } else {
- // Use a copy-constructed instance
- theStory = new StoryImpl(storyCache.get(info), length);
- }
-
- emitStory(theStory, range);
- }
-
private void emitStory(StoryImpl story, Range range) {
-
+
int storyNum;
if (storyIds.containsKey(story)) {
storyNum = storyIds.get(story);
@@ -482,4 +405,85 @@
// escaped = escaped.replaceAll("\\'", "'");
return escaped;
}
+
+ /**
+ * Remove an element from the RangeInfo stack and stare a new StoryImpl with
+ * the right length, possibly sub-dividing the super-enclosing Range in the
+ * process.
+ */
+ private void popAndRecord(Stack<RangeInfo> dependencyScope, int fragment) {
+ RangeInfo rangeInfo = dependencyScope.pop();
+ Range toStore = rangeInfo.range;
+
+ /*
+ * Make a new Range for the gap between the popped Range and whatever we
+ * last stored.
+ */
+ if (lastEnd < toStore.getStart()) {
+ Range newRange = new Range(lastEnd, toStore.getStart());
+ assert !dependencyScope.isEmpty();
+
+ SourceInfo gapInfo = dependencyScope.peek().info;
+ recordStory(gapInfo, fragment, newRange.length(), newRange);
+
+ lastEnd += newRange.length();
+ }
+
+ /*
+ * Store as much of the current Range as we haven't previously stored. The
+ * Max.max() is there to take care of the tail end of Ranges that have had a
+ * sub-range previously stored.
+ */
+ if (lastEnd < toStore.getEnd()) {
+ Range newRange = new Range(Math.max(lastEnd, toStore.getStart()),
+ toStore.getEnd());
+ recordStory(rangeInfo.info, fragment, newRange.length(), newRange);
+ lastEnd += newRange.length();
+ }
+ }
+
+ private void recordStory(SourceInfo info, int fragment, int length,
+ Range range) {
+ assert storyCache != null;
+
+ if (fragment > curHighestFragment) {
+ curHighestFragment = fragment;
+ }
+
+ StoryImpl theStory;
+ if (!storyCache.containsKey(info)) {
+
+ SortedSet<Member> members = new TreeSet<Member>(
+ Member.TYPE_AND_SOURCE_NAME_COMPARATOR);
+
+ if (info != null) {
+ for (Correlation c : info.getAllCorrelations()) {
+ Member m = membersByCorrelation.get(c);
+ if (m != null) {
+ members.add(m);
+ }
+ }
+ }
+
+ SortedSet<Origin> origins = new TreeSet<Origin>();
+ for (Correlation c : info.getAllCorrelations(Axis.ORIGIN)) {
+ origins.add(new OriginImpl(c.getOrigin()));
+ }
+
+ String literalType = null;
+ Correlation literalCorrelation = info.getPrimaryCorrelation(Axis.LITERAL);
+ if (literalCorrelation != null) {
+ literalType = literalCorrelation.getLiteral().getDescription();
+ }
+
+ theStory = new StoryImpl(storyCache.size(), members, origins,
+ literalType, fragment, length);
+ storyCache.put(info, theStory);
+ } else {
+ // Use a copy-constructed instance
+ theStory = new StoryImpl(storyCache.get(info), length);
+ }
+
+ emitStory(theStory, range);
+ }
}
diff --git a/dev/core/src/com/google/gwt/dev/CompilePerms.java b/dev/core/src/com/google/gwt/dev/CompilePerms.java
index 2bfe862..e97579f 100644
--- a/dev/core/src/com/google/gwt/dev/CompilePerms.java
+++ b/dev/core/src/com/google/gwt/dev/CompilePerms.java
@@ -18,7 +18,6 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.dev.CompileTaskRunner.CompileTask;
-import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl;
import com.google.gwt.dev.jjs.JavaToJavaScriptCompiler;
import com.google.gwt.dev.jjs.UnifiedAst;
import com.google.gwt.dev.util.FileBackedObject;
diff --git a/dev/core/src/com/google/gwt/dev/jjs/SourceInfo.java b/dev/core/src/com/google/gwt/dev/jjs/SourceInfo.java
index e9a47f4..cdbfef5 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/SourceInfo.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/SourceInfo.java
@@ -114,18 +114,6 @@
}
}
- private boolean isAlreadyInAllCorrelations(Correlation c) {
- //make sure this correlations is not yet in the allCorrelations list
- boolean alreadyThere = false;
- Iterator<Correlation> it = allCorrelations.iterator();
- while((alreadyThere == false)&&(it.hasNext())){
- if (it.next().equals(c)){
- alreadyThere = true;
- }
- }
- return alreadyThere;
- }
-
private SourceInfo(SourceInfo parent, String mutation, String caller,
SourceInfo... additionalAncestors) {
assert parent != null;
@@ -150,9 +138,9 @@
if (!accumulateData) {
return;
}
- if (! isAlreadyInAllCorrelations(c)){
+ if (!isAlreadyInAllCorrelations(c)) {
allCorrelations.add(c);
- }
+ }
if (!primaryCorrelations.containsKey(c.getAxis())) {
primaryCorrelations.put(c.getAxis(), c);
}
@@ -184,10 +172,9 @@
* ancestor SourceInfo, and any supertype SourceInfos.
*/
public List<Correlation> getAllCorrelations() {
- if (accumulateData){
+ if (accumulateData) {
return allCorrelations;
- }
- else{
+ } else {
return Collections.<Correlation> emptyList();
}
}
@@ -288,8 +275,8 @@
continue;
}
- for (Correlation c : info.getAllCorrelations()){
- if (! isAlreadyInAllCorrelations(c)){
+ for (Correlation c : info.getAllCorrelations()) {
+ if (!isAlreadyInAllCorrelations(c)) {
allCorrelations.add(c);
}
}
@@ -307,4 +294,16 @@
public String toString() {
return origin.toString();
}
+
+ private boolean isAlreadyInAllCorrelations(Correlation c) {
+ // make sure this correlations is not yet in the allCorrelations list
+ boolean alreadyThere = false;
+ Iterator<Correlation> it = allCorrelations.iterator();
+ while ((alreadyThere == false) && (it.hasNext())) {
+ if (it.next().equals(c)) {
+ alreadyThere = true;
+ }
+ }
+ return alreadyThere;
+ }
}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
index eb09959..5158466 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
@@ -75,7 +75,7 @@
public interface DependencyRecorder {
/**
- * Used to record the dependencies of a specific method
+ * Used to record the dependencies of a specific method.
*/
void methodIsLiveBecause(JMethod liveMethod,
ArrayList<JMethod> dependencyChain);
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java b/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java
index 27ae797..618e303 100644
--- a/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java
+++ b/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java
@@ -18,31 +18,22 @@
import java.util.TreeSet;
+/**
+ * Holds a set of all classes in a SOYC report, and can calculate size summaries
+ * for them.
+ */
public class CodeCollection {
- public String codeType = "";
public TreeSet<String> classes = new TreeSet<String>();
- public TreeSet<String> stories = new TreeSet<String>();
+ public String codeType = "";
public float cumPartialSize = 0f;
public int cumSize = 0;
+ public TreeSet<String> stories = new TreeSet<String>();
public CodeCollection(String type) {
codeType = type;
}
- public int getCumSize() {
- cumSize = 0;
- for (String className : classes) {
- if (!GlobalInformation.classToSize.containsKey(className)) {
- System.err.println("*** NO SIZE FOUND FOR CLASS " + className
- + " *****");
- } else {
- cumSize += GlobalInformation.classToSize.get(className);
- }
- }
- return cumSize;
- }
-
public float getCumPartialSize() {
cumPartialSize = 0f;
for (String className : classes) {
@@ -55,4 +46,17 @@
}
return cumPartialSize;
}
+
+ public int getCumSize() {
+ cumSize = 0;
+ for (String className : classes) {
+ if (!GlobalInformation.classToSize.containsKey(className)) {
+ System.err.println("*** NO SIZE FOUND FOR CLASS " + className
+ + " *****");
+ } else {
+ cumSize += GlobalInformation.classToSize.get(className);
+ }
+ }
+ return cumSize;
+ }
}
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java b/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
index bc2c418..d82f45d 100644
--- a/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
+++ b/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
@@ -21,6 +21,9 @@
import java.util.HashSet;
import java.util.TreeSet;
+/**
+ * Information global to the entire SOYC report generator.
+ */
public class GlobalInformation {
public static Boolean displayDependencies = false;
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java b/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
index 3f71ef1..36a984f 100644
--- a/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
+++ b/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
@@ -21,36 +21,36 @@
import java.util.HashSet;
import java.util.TreeMap;
+/**
+ * A collection of literals.
+ */
public class LiteralsCollection {
public int cumSize = 0;
public int cumStringSize = 0;
public String literalType = "";
public Map<String, HashSet<String>> literalToLocations = new TreeMap<String, HashSet<String>>();
- public Map<String, HashSet<String> > storyToLocations = new HashMap<String, HashSet<String>>();
+ public Map<String, HashSet<String>> storyToLocations = new HashMap<String, HashSet<String>>();
public TreeMap<String, String> stringLiteralToType = new TreeMap<String, String>();
public Map<String, Integer> stringTypeToSize = new HashMap<String, Integer>();
public Map<String, Integer> stringTypeToCount = new HashMap<String, Integer>();
-
- /**
- * constructor
- */
- public LiteralsCollection(String type){
+
+ public LiteralsCollection(String type) {
literalType = type;
}
/**
- * Utility method
+ * Utility method.
*/
- public void printAllStrings(){
+ public void printAllStrings() {
int iSum = 0;
System.out.println("--- now printing strings ---");
- for (String st : stringLiteralToType.keySet()){
- int numBytes = st.getBytes().length;
- iSum += numBytes;
- System.out.println(st + "[" + numBytes + "]");
+ for (String st : stringLiteralToType.keySet()) {
+ int numBytes = st.getBytes().length;
+ iSum += numBytes;
+ System.out.println(st + "[" + numBytes + "]");
}
System.out.println("sum: " + iSum);
System.out.println("--- done printing strings ---");
}
-
+
}
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java b/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
index 8a3669f..ccefe95 100644
--- a/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
+++ b/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
@@ -33,447 +33,11 @@
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
+/**
+ * A utility to make the top level HTTML file for one permutation.
+ */
public class MakeTopLevelHtmlForPerm {
- private static void makePackageHtml(String outFileName) throws IOException {
-
- TreeMap<Float, String> sortedPackages = new TreeMap<Float, String>(
- Collections.reverseOrder());
- float maxSize = 0f;
- float sumSize = 0f;
- for (String packageName : GlobalInformation.packageToPartialSize.keySet()) {
- sortedPackages.put(
- GlobalInformation.packageToPartialSize.get(packageName), packageName);
- sumSize += GlobalInformation.packageToPartialSize.get(packageName);
- if (GlobalInformation.packageToPartialSize.get(packageName) > maxSize) {
- maxSize = GlobalInformation.packageToPartialSize.get(packageName);
- }
- }
-
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
-
- outFile.println("</head>");
- outFile.println("<body>");
-
- int yOffset = 0;
- for (Float size : sortedPackages.keySet()) {
-
- String packageName = sortedPackages.get(size);
- String drillDownFileName = packageName + "Classes.html";
-
- float ratio = (size / maxSize) * 79;
-
- if (ratio < 3) {
- ratio = 3;
- }
-
- float perc = (size / sumSize) * 100;
-
- outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
- + yOffset + "px; left: 110px;\">");
- outFile.println("<div id=\"lb\">");
- outFile.println("<div id=\"rb\">");
- outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
- outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
- outFile.println("<div id=\"content\">");
- outFile.println("</div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div>");
-
- int yOffsetText = yOffset + 8;
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:5px;\">%.1f</div>\n", size);
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:70px;\">%.1f", perc);
- outFile.println("%</div>\n");
- outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:110px;\"><a href=\"" + drillDownFileName
- + "\" target=\"_top\">" + packageName + "</a></div>");
-
- yOffset = yOffset + 25;
-
- }
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
-
- }
-
- private static void makeFragmentsHtml(String outFileName) throws IOException {
-
- // TreeMap<Float, Integer> sortedFragments = new TreeMap<Float,
- // Integer>(Collections.reverseOrder());
- TreeMap<Float, String> sortedSplitPoints = new TreeMap<Float, String>(
- Collections.reverseOrder());
- float maxSize = 0f;
- float sumSize = 0f;
-
- // initial fragment
- float initialSize = GlobalInformation.fragmentToPartialSize.get(0);
- sumSize += initialSize;
- maxSize = initialSize;
- sortedSplitPoints.put(initialSize, "initialDownload");
-
- // all fragments that are not in the initial load order
- float allOtherFragmentsSize = GlobalInformation.allOtherFragmentsPartialSize;
- sumSize += allOtherFragmentsSize;
- if (allOtherFragmentsSize > maxSize) {
- maxSize = allOtherFragmentsSize;
- }
- sortedSplitPoints.put(allOtherFragmentsSize, "allOtherFragments");
-
- // all exclusive fragments
- System.out.println("");
- for (Integer splitPointId : GlobalInformation.splitPointToLocation.keySet()) {
- System.out.println("splitPointId is: " + splitPointId);
- Float sizeOfCurExclusiveFrag = GlobalInformation.fragmentToPartialSize.get(splitPointId);
- sortedSplitPoints.put(sizeOfCurExclusiveFrag,
- GlobalInformation.splitPointToLocation.get(splitPointId));
- sumSize += sizeOfCurExclusiveFrag;
- if (sizeOfCurExclusiveFrag > maxSize) {
- maxSize = sizeOfCurExclusiveFrag;
- }
- }
-
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
- outFile.println("</head>");
- outFile.println("<body>");
-
- int yOffset = 0;
- for (Float size : sortedSplitPoints.keySet()) {
- String splitPointName = sortedSplitPoints.get(size);
- String drillDownFileName = "splitPoint" + splitPointName + "Classes.html";
-
- float ratio = (size / maxSize) * 79;
- if (ratio < 3) {
- ratio = 3;
- }
- float perc = (size / sumSize) * 100;
-
- outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
- + yOffset + "px; left: 110px;\">");
- outFile.println("<div id=\"lb\">");
- outFile.println("<div id=\"rb\">");
- outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
- outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
- outFile.println("<div id=\"content\">");
- outFile.println("</div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div>");
-
- int yOffsetText = yOffset + 8;
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:5px;\">%.1f</div>\n", size);
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:80px;\">%.1f", perc);
- outFile.println("%</div>\n");
- outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:120px;\"><a href=\"" + drillDownFileName
- + "\" target=\"_top\">" + splitPointName + "</a></div>");
-
- yOffset = yOffset + 25;
-
- }
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
-
- }
-
- private static void makeCodeTypeHtml(String outFileName,
- HashMap<String, CodeCollection> nameToCodeColl) throws IOException {
-
- float maxSize = 0f;
- float sumSize = 0f;
- TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>(
- Collections.reverseOrder());
-
- // TODO(kprobst): turn this into a multimap?
- // com.google.common.collect.TreeMultimap
- for (String codeType : nameToCodeColl.keySet()) {
- float curSize = nameToCodeColl.get(codeType).getCumPartialSize();
- sumSize += curSize;
-
- if (curSize != 0f) {
- sortedCodeTypes.put(curSize, codeType);
- if (curSize > maxSize) {
- maxSize = curSize;
- }
- }
- }
-
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
- outFile.println("</head>");
- outFile.println("<body>");
-
- int yOffset = 0;
- for (Float size : sortedCodeTypes.keySet()) {
-
- String codeType = sortedCodeTypes.get(size);
- String drillDownFileName = codeType + "Classes.html";
-
- float ratio = (size / maxSize) * 79;
- float perc = (size / sumSize) * 100;
-
- if (ratio < 3) {
- ratio = 3;
- }
-
- outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
- + yOffset + "px; left: 110px;\">");
- outFile.println("<div id=\"lb\">");
- outFile.println("<div id=\"rb\">");
- outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
- outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
- outFile.println("<div id=\"content\">");
- outFile.println("</div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div>");
-
- int yOffsetText = yOffset + 8;
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:5px;\">%.1f</div>\n", size);
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:70px;\">%.1f", perc);
- outFile.println("%</div>\n");
- outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:110px;\"><a href=\"" + drillDownFileName
- + "\" target=\"_top\">" + codeType + "</a></div>");
-
- yOffset = yOffset + 25;
-
- }
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
-
- }
-
- private static void makeLiteralsHtml(String outFileName,
- TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
-
- float maxSize = 0f;
- float sumSize = 0f;
- TreeMap<Float, String> sortedLitTypes = new TreeMap<Float, String>(
- Collections.reverseOrder());
-
- for (String literal : nameToLitColl.keySet()) {
- float curSize = nameToLitColl.get(literal).cumSize;
- sumSize += curSize;
-
- if (curSize != 0f) {
- sortedLitTypes.put(curSize, literal);
-
- if (curSize > maxSize) {
- maxSize = curSize;
- }
- }
- }
-
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
- outFile.println("</head>");
- outFile.println("<body>");
-
- int yOffset = 0;
- for (Float size : sortedLitTypes.keySet()) {
-
- String literal = sortedLitTypes.get(size);
- String drillDownFileName = literal + "Lits.html";
-
- float ratio = (size / maxSize) * 79;
- float perc = (size / sumSize) * 100;
-
- if (ratio < 3) {
- ratio = 3;
- }
-
- outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
- + yOffset + "px; left: 110px;\">");
- outFile.println("<div id=\"lb\">");
- outFile.println("<div id=\"rb\">");
- outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
- outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
- outFile.println("<div id=\"content\">");
- outFile.println("</div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div>");
-
- int yOffsetText = yOffset + 8;
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:5px;\">%.1f</div>\n", size);
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:70px;\">%.1f", perc);
- outFile.println("%</div>\n");
- outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:110px;\"><a href=\"" + drillDownFileName
- + "\" target=\"_top\">" + literal + "</a></div>");
-
- yOffset = yOffset + 25;
-
- }
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
-
- }
-
- private static void makeStringLiteralsHtml(String outFileName,
- TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
-
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
- outFile.println("</head>");
- outFile.println("<body>");
-
- if (nameToLitColl.get("string").stringTypeToSize.size() > 0) {
-
- float maxSize = 0f;
- float sumSize = 0f;
- TreeMap<Float, String> sortedStLitTypes = new TreeMap<Float, String>(
- Collections.reverseOrder());
-
- for (String stringLiteral : nameToLitColl.get("string").stringTypeToSize.keySet()) {
- float curSize = nameToLitColl.get("string").stringTypeToSize.get(stringLiteral);
- sumSize += curSize;
-
- if (curSize != 0f) {
- sortedStLitTypes.put(curSize, stringLiteral);
-
- if (curSize > maxSize) {
- maxSize = curSize;
- }
- }
- }
-
- int yOffset = 0;
- for (Float size : sortedStLitTypes.keySet()) {
-
- String stringLiteral = sortedStLitTypes.get(size);
- String drillDownFileName = stringLiteral + "Strings.html";
-
- float ratio = (size / maxSize) * 79;
- float perc = (size / sumSize) * 100;
-
- if (ratio < 3) {
- ratio = 3;
- }
-
- outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
- + yOffset + "px; left: 110px;\">");
- outFile.println("<div id=\"lb\">");
- outFile.println("<div id=\"rb\">");
- outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
- outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
- outFile.println("<div id=\"content\">");
- outFile.println("</div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div></div></div></div>");
- outFile.println("</div>");
-
- int yOffsetText = yOffset + 8;
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:5px;\">%.1f</div>\n", size);
- outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:70px;\">%.1f", perc);
- outFile.println("%</div>\n");
- outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
- + "px; left:110px;\"><a href=\"" + drillDownFileName
- + "\" target=\"_top\">" + stringLiteral + "</a></div>");
-
- yOffset = yOffset + 25;
-
- }
-
- }
-
- else {
- outFile.println("No string literals found for this application.");
-
- }
-
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
- }
-
- public static void copyFileOrDirectoryFromJar(String jarFileName,
- String inputFileName, File dstPath, boolean isDirectory)
- throws IOException {
-
- JarFile jarFile = new JarFile(jarFileName);
- if (isDirectory) {
- dstPath.mkdir();
-
- JarInputStream jarFileIS = new JarInputStream(new FileInputStream(
- jarFileName));
- JarEntry jarEntry = jarFileIS.getNextJarEntry();
- while (jarEntry != null) {
- if (!inputFileName.endsWith("/")) {
- inputFileName += "/";
- }
- if ((jarEntry.getName().compareTo(inputFileName) != 0)
- && (jarEntry.getName().startsWith(inputFileName))) {
- File newDstPath = new File(jarEntry.getName());
- copyFileOrDirectoryFromJar(jarFileName, jarEntry.getName(),
- newDstPath, false);
- }
- jarEntry = jarFileIS.getNextJarEntry();
- }
- jarFileIS.close();
- }
-
- else {
- InputStream in = jarFile.getInputStream(jarFile.getEntry(inputFileName));
- OutputStream out = new FileOutputStream(dstPath);
-
- int c;
- while ((c = in.read()) != -1) {
- out.write(c);
- }
- in.close();
- out.close();
- jarFile.close();
- }
- }
-
public static void copyFileOrDirectory(File srcPath, File dstPath,
String classPath, String inputFileName, boolean isDirectory)
throws IOException {
@@ -505,6 +69,44 @@
}
}
+ public static void copyFileOrDirectoryFromJar(String jarFileName,
+ String inputFileName, File dstPath, boolean isDirectory)
+ throws IOException {
+
+ JarFile jarFile = new JarFile(jarFileName);
+ if (isDirectory) {
+ dstPath.mkdir();
+
+ JarInputStream jarFileIS = new JarInputStream(new FileInputStream(
+ jarFileName));
+ JarEntry jarEntry = jarFileIS.getNextJarEntry();
+ while (jarEntry != null) {
+ if (!inputFileName.endsWith("/")) {
+ inputFileName += "/";
+ }
+ if ((jarEntry.getName().compareTo(inputFileName) != 0)
+ && (jarEntry.getName().startsWith(inputFileName))) {
+ File newDstPath = new File(jarEntry.getName());
+ copyFileOrDirectoryFromJar(jarFileName, jarEntry.getName(),
+ newDstPath, false);
+ }
+ jarEntry = jarFileIS.getNextJarEntry();
+ }
+ jarFileIS.close();
+ } else {
+ InputStream in = jarFile.getInputStream(jarFile.getEntry(inputFileName));
+ OutputStream out = new FileOutputStream(dstPath);
+
+ int c;
+ while ((c = in.read()) != -1) {
+ out.write(c);
+ }
+ in.close();
+ out.close();
+ jarFile.close();
+ }
+ }
+
public static String escapeXml(String unescaped) {
String escaped = unescaped.replaceAll("\\&", "&");
escaped = escaped.replaceAll("\\<", "<");
@@ -601,7 +203,6 @@
+ "px; left:70px;\">" + className + "</div>");
yOffset = yOffset + 25;
-
}
outFile.println("</div>");
@@ -611,6 +212,94 @@
}
}
+ public static void makeDependenciesHtml(
+ Map<String, ArrayList<String>> dependencies) throws IOException {
+
+ String origOutFileName = "methodDependencies-";
+ PrintWriter outFile = null;
+ String curPackageName = "";
+ String curClassName = "";
+
+ for (String method : dependencies.keySet()) {
+ // this key set is already in alphabetical order
+ // get the package of this method, i.e., everything up to .[A-Z]
+
+ String packageName = method;
+ packageName = packageName.replaceAll("\\.\\p{Upper}.*", "");
+
+ String className = method;
+ className = className.replaceAll("::.*", "");
+
+ if ((curPackageName.compareTo("") == 0)
+ || (curPackageName.compareTo(packageName) != 0)) {
+
+ curPackageName = packageName;
+ if (outFile != null) {
+ // finish up the current file
+ outFile.println("</table>");
+ outFile.println("<center>");
+
+ outFile.println("</div>");
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
+
+ String outFileName = origOutFileName + curPackageName + ".html";
+ outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<title>Method Dependencies</title>");
+ outFile.println("</head>");
+
+ outFile.println("<style type=\"text/css\">");
+ outFile.println("body {background-color: #728FCE}");
+ outFile.println("h2 {background-color: transparent}");
+ outFile.println("p {background-color: fuchsia}");
+ outFile.println("</style>");
+
+ outFile.println("<body>");
+ outFile.println("<center>");
+ outFile.println("<h2>Method Dependencies for package " + curPackageName
+ + "</h2>");
+ outFile.println("</center>");
+ outFile.println("<hr>");
+
+ outFile.println("<center>");
+ outFile.println("<table border=\"1\" width=\"80%\" style=\"font-size: 11pt;\" bgcolor=\"white\">");
+ }
+ outFile.println("<tr>");
+ if (curClassName.compareTo(className) != 0) {
+ outFile.println("<td width=\"80%\"><a name=\"" + className + "\">"
+ + "<a name=\"" + method + "\">" + method
+ + "</a></a><font color=\"green\"> called by</font></td>");
+ curClassName = className;
+ } else {
+ outFile.println("<td width=\"80%\"><a name=\"" + method + "\">"
+ + method + "</a><font color=\"green\"> called by</font></td>");
+ }
+ outFile.println("</tr>");
+
+ for (int i = 0; i < dependencies.get(method).size(); i++) {
+ String depMethod = dependencies.get(method).get(i);
+
+ outFile.println("<tr>");
+ outFile.println("<td width=\"20%\"></td>");
+ if (i != dependencies.get(method).size() - 1) {
+ outFile.println("<td width=\"60%\">" + depMethod
+ + "<font color=\"green\"> called by</font></td>");
+ } else {
+ outFile.println("<td width=\"60%\">" + depMethod + "</td>");
+ }
+ outFile.println("</tr>");
+ }
+ }
+ }
+
public static void makeHTMLShell(
HashMap<String, CodeCollection> nameToCodeColl,
TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
@@ -747,7 +436,105 @@
outFile.println(" </body>");
outFile.println("</html>");
outFile.close();
+ }
+ public static void makeLiteralsClassesHtmls(
+ TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
+
+ for (String literalType : nameToLitColl.keySet()) {
+
+ String outFileName = literalType + "Lits.html";
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<title>Literals of type \"" + literalType + "\"</title>");
+ outFile.println("</head>");
+
+ outFile.println("<style type=\"text/css\">");
+ outFile.println("body {background-color: #728FCE}");
+ outFile.println("h2 {background-color: transparent}");
+ outFile.println("p {background-color: fuchsia}");
+ outFile.println(".tablediv {");
+ outFile.println("display: table;");
+ outFile.println("width:100%;");
+ outFile.println("background-color:#eee;");
+ outFile.println("border:1px solid #666666;");
+ outFile.println("border-spacing:5px;/*cellspacing:poor IE support for this*/");
+ outFile.println("border-collapse:separate;");
+ outFile.println("}");
+ outFile.println(".celldiv {");
+ outFile.println("float:left;/*fix for buggy browsers*/");
+ outFile.println("display: table-cell;");
+ outFile.println("width:50%;");
+ outFile.println("font-size: 14px;");
+ outFile.println("background-color:white;");
+ outFile.println("}");
+ outFile.println(".rowdiv {");
+ outFile.println("display: table-row;");
+ outFile.println("}");
+ outFile.println("</style>");
+
+ outFile.println("<body>");
+ outFile.println("<center>");
+ outFile.println("<h2>Literals of type \"" + literalType + "\"</h2>");
+ outFile.println("</center>");
+ outFile.println("<hr>");
+
+ outFile.println("<div style=\"width:90%; height:80%; overflow-y:auto; overflow-x:auto; top: 30px; left:60px; position:relative; background-color:white\"");
+ outFile.println("<div class=\"tablediv\">");
+ for (String literal : nameToLitColl.get(literalType).literalToLocations.keySet()) {
+
+ if (literal.trim().compareTo("") == 0) {
+ literal = "[whitespace only string]";
+ }
+
+ String newLiteral = "";
+ if (literal.length() > 100) {
+ int i;
+ for (i = 100; i < literal.length(); i = i + 100) {
+ String part1 = literal.substring(i - 100, i);
+ newLiteral = newLiteral + part1 + " ";
+ }
+ if (i - 100 > 0) {
+ newLiteral = newLiteral + literal.substring(i - 100);
+ }
+ } else {
+ newLiteral = literal;
+ }
+
+ String escliteral = escapeXml(newLiteral);
+ outFile.println("<div class=\"rowdiv\">");
+ outFile.println("<div class=\"celldiv\">" + escliteral + "</div>");
+
+ for (String location : nameToLitColl.get(literalType).literalToLocations.get(literal)) {
+
+ String newLocation = "";
+ if (location.length() > 100) {
+ int i;
+ for (i = 100; i < location.length(); i = i + 100) {
+ String part1 = location.substring(i - 100, i);
+ newLocation = newLocation + part1 + " ";
+ }
+ if (i - 100 > 0) {
+ newLocation = newLocation + location.substring(i - 100);
+ }
+ } else {
+ newLocation = location;
+ }
+
+ outFile.println("<div class=\"celldiv\">" + newLocation + "</div>");
+ }
+ outFile.println("</div>");
+ }
+ outFile.println("</div>");
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
}
public static void makeLiteralsClassesTableHtmls(
@@ -843,7 +630,6 @@
}
outFile.println("</tr>");
-
}
outFile.println("</table>");
@@ -856,105 +642,6 @@
}
}
- public static void makeLiteralsClassesHtmls(
- TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
-
- for (String literalType : nameToLitColl.keySet()) {
-
- String outFileName = literalType + "Lits.html";
- final PrintWriter outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<title>Literals of type \"" + literalType + "\"</title>");
- outFile.println("</head>");
-
- outFile.println("<style type=\"text/css\">");
- outFile.println("body {background-color: #728FCE}");
- outFile.println("h2 {background-color: transparent}");
- outFile.println("p {background-color: fuchsia}");
- outFile.println(".tablediv {");
- outFile.println("display: table;");
- outFile.println("width:100%;");
- outFile.println("background-color:#eee;");
- outFile.println("border:1px solid #666666;");
- outFile.println("border-spacing:5px;/*cellspacing:poor IE support for this*/");
- outFile.println("border-collapse:separate;");
- outFile.println("}");
- outFile.println(".celldiv {");
- outFile.println("float:left;/*fix for buggy browsers*/");
- outFile.println("display: table-cell;");
- outFile.println("width:50%;");
- outFile.println("font-size: 14px;");
- outFile.println("background-color:white;");
- outFile.println("}");
- outFile.println(".rowdiv {");
- outFile.println("display: table-row;");
- outFile.println("}");
- outFile.println("</style>");
-
- outFile.println("<body>");
- outFile.println("<center>");
- outFile.println("<h2>Literals of type \"" + literalType + "\"</h2>");
- outFile.println("</center>");
- outFile.println("<hr>");
-
- outFile.println("<div style=\"width:90%; height:80%; overflow-y:auto; overflow-x:auto; top: 30px; left:60px; position:relative; background-color:white\"");
- outFile.println("<div class=\"tablediv\">");
- for (String literal : nameToLitColl.get(literalType).literalToLocations.keySet()) {
-
- if (literal.trim().compareTo("") == 0) {
- literal = "[whitespace only string]";
- }
-
- String newLiteral = "";
- if (literal.length() > 100) {
- int i;
- for (i = 100; i < literal.length(); i = i + 100) {
- String part1 = literal.substring(i - 100, i);
- newLiteral = newLiteral + part1 + " ";
- }
- if (i - 100 > 0) {
- newLiteral = newLiteral + literal.substring(i - 100);
- }
- } else {
- newLiteral = literal;
- }
-
- String escliteral = escapeXml(newLiteral);
- outFile.println("<div class=\"rowdiv\">");
- outFile.println("<div class=\"celldiv\">" + escliteral + "</div>");
-
- for (String location : nameToLitColl.get(literalType).literalToLocations.get(literal)) {
-
- String newLocation = "";
- if (location.length() > 100) {
- int i;
- for (i = 100; i < location.length(); i = i + 100) {
- String part1 = location.substring(i - 100, i);
- newLocation = newLocation + part1 + " ";
- }
- if (i - 100 > 0) {
- newLocation = newLocation + location.substring(i - 100);
- }
- } else {
- newLocation = location;
- }
-
- outFile.println("<div class=\"celldiv\">" + newLocation + "</div>");
- }
- outFile.println("</div>");
- }
- outFile.println("</div>");
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
- }
- }
-
public static void makePackageClassesHtmls() throws IOException {
for (String packageName : GlobalInformation.packageToClasses.keySet()) {
@@ -1082,7 +769,6 @@
* "\" target=\"_top\">Dependencies: " + depCount + "</a></div>");
*/
yOffset = yOffset + 25;
-
}
outFile.println("</div>");
@@ -1291,7 +977,6 @@
outFile.println("</body>");
outFile.println("</html>");
outFile.close();
-
}
public static void makeStringLiteralsClassesHtmls(
@@ -1398,7 +1083,6 @@
outFile.println("</html>");
outFile.close();
}
-
}
public static void makeStringLiteralsClassesTableHtmls(
@@ -1510,92 +1194,389 @@
}
}
- public static void makeDependenciesHtml(
- Map<String, ArrayList<String>> dependencies) throws IOException {
+ private static void makeCodeTypeHtml(String outFileName,
+ HashMap<String, CodeCollection> nameToCodeColl) throws IOException {
- String origOutFileName = "methodDependencies-";
- PrintWriter outFile = null;
- String curPackageName = "";
- String curClassName = "";
+ float maxSize = 0f;
+ float sumSize = 0f;
+ TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>(
+ Collections.reverseOrder());
- for (String method : dependencies.keySet()) {
- // this key set is already in alphabetical order
- // get the package of this method, i.e., everything up to .[A-Z]
+ // TODO(kprobst): turn this into a multimap?
+ // com.google.common.collect.TreeMultimap
+ for (String codeType : nameToCodeColl.keySet()) {
+ float curSize = nameToCodeColl.get(codeType).getCumPartialSize();
+ sumSize += curSize;
- String packageName = method;
- packageName = packageName.replaceAll("\\.\\p{Upper}.*", "");
-
- String className = method;
- className = className.replaceAll("::.*", "");
-
- if ((curPackageName.compareTo("") == 0)
- || (curPackageName.compareTo(packageName) != 0)) {
-
- curPackageName = packageName;
- if (outFile != null) {
- // finish up the current file
- outFile.println("</table>");
- outFile.println("<center>");
-
- outFile.println("</div>");
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
+ if (curSize != 0f) {
+ sortedCodeTypes.put(curSize, codeType);
+ if (curSize > maxSize) {
+ maxSize = curSize;
}
-
- String outFileName = origOutFileName + curPackageName + ".html";
- outFile = new PrintWriter(outFileName);
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<title>Method Dependencies</title>");
- outFile.println("</head>");
-
- outFile.println("<style type=\"text/css\">");
- outFile.println("body {background-color: #728FCE}");
- outFile.println("h2 {background-color: transparent}");
- outFile.println("p {background-color: fuchsia}");
- outFile.println("</style>");
-
- outFile.println("<body>");
- outFile.println("<center>");
- outFile.println("<h2>Method Dependencies for package " + curPackageName
- + "</h2>");
- outFile.println("</center>");
- outFile.println("<hr>");
-
- outFile.println("<center>");
- outFile.println("<table border=\"1\" width=\"80%\" style=\"font-size: 11pt;\" bgcolor=\"white\">");
-
- }
- outFile.println("<tr>");
- if (curClassName.compareTo(className) != 0) {
- outFile.println("<td width=\"80%\"><a name=\"" + className + "\">"
- + "<a name=\"" + method + "\">" + method
- + "</a></a><font color=\"green\"> called by</font></td>");
- curClassName = className;
- } else {
- outFile.println("<td width=\"80%\"><a name=\"" + method + "\">"
- + method + "</a><font color=\"green\"> called by</font></td>");
- }
- outFile.println("</tr>");
-
- for (int i = 0; i < dependencies.get(method).size(); i++) {
- String depMethod = dependencies.get(method).get(i);
-
- outFile.println("<tr>");
- outFile.println("<td width=\"20%\"></td>");
- if (i != dependencies.get(method).size() - 1) {
- outFile.println("<td width=\"60%\">" + depMethod
- + "<font color=\"green\"> called by</font></td>");
- } else {
- outFile.println("<td width=\"60%\">" + depMethod + "</td>");
- }
- outFile.println("</tr>");
}
}
+
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
+ outFile.println("</head>");
+ outFile.println("<body>");
+
+ int yOffset = 0;
+ for (Float size : sortedCodeTypes.keySet()) {
+
+ String codeType = sortedCodeTypes.get(size);
+ String drillDownFileName = codeType + "Classes.html";
+
+ float ratio = (size / maxSize) * 79;
+ float perc = (size / sumSize) * 100;
+
+ if (ratio < 3) {
+ ratio = 3;
+ }
+
+ outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+ + yOffset + "px; left: 110px;\">");
+ outFile.println("<div id=\"lb\">");
+ outFile.println("<div id=\"rb\">");
+ outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+ outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+ outFile.println("<div id=\"content\">");
+ outFile.println("</div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div>");
+
+ int yOffsetText = yOffset + 8;
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:5px;\">%.1f</div>\n", size);
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:70px;\">%.1f", perc);
+ outFile.println("%</div>\n");
+ outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:110px;\"><a href=\"" + drillDownFileName
+ + "\" target=\"_top\">" + codeType + "</a></div>");
+
+ yOffset = yOffset + 25;
+ }
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
+
+ private static void makeFragmentsHtml(String outFileName) throws IOException {
+
+ // TreeMap<Float, Integer> sortedFragments = new TreeMap<Float,
+ // Integer>(Collections.reverseOrder());
+ TreeMap<Float, String> sortedSplitPoints = new TreeMap<Float, String>(
+ Collections.reverseOrder());
+ float maxSize = 0f;
+ float sumSize = 0f;
+
+ // initial fragment
+ float initialSize = GlobalInformation.fragmentToPartialSize.get(0);
+ sumSize += initialSize;
+ maxSize = initialSize;
+ sortedSplitPoints.put(initialSize, "initialDownload");
+
+ // all fragments that are not in the initial load order
+ float allOtherFragmentsSize = GlobalInformation.allOtherFragmentsPartialSize;
+ sumSize += allOtherFragmentsSize;
+ if (allOtherFragmentsSize > maxSize) {
+ maxSize = allOtherFragmentsSize;
+ }
+ sortedSplitPoints.put(allOtherFragmentsSize, "allOtherFragments");
+
+ // all exclusive fragments
+ System.out.println("");
+ for (Integer splitPointId : GlobalInformation.splitPointToLocation.keySet()) {
+ System.out.println("splitPointId is: " + splitPointId);
+ Float sizeOfCurExclusiveFrag = GlobalInformation.fragmentToPartialSize.get(splitPointId);
+ sortedSplitPoints.put(sizeOfCurExclusiveFrag,
+ GlobalInformation.splitPointToLocation.get(splitPointId));
+ sumSize += sizeOfCurExclusiveFrag;
+ if (sizeOfCurExclusiveFrag > maxSize) {
+ maxSize = sizeOfCurExclusiveFrag;
+ }
+ }
+
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
+ outFile.println("</head>");
+ outFile.println("<body>");
+
+ int yOffset = 0;
+ for (Float size : sortedSplitPoints.keySet()) {
+ String splitPointName = sortedSplitPoints.get(size);
+ String drillDownFileName = "splitPoint" + splitPointName + "Classes.html";
+
+ float ratio = (size / maxSize) * 79;
+ if (ratio < 3) {
+ ratio = 3;
+ }
+ float perc = (size / sumSize) * 100;
+
+ outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+ + yOffset + "px; left: 110px;\">");
+ outFile.println("<div id=\"lb\">");
+ outFile.println("<div id=\"rb\">");
+ outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+ outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+ outFile.println("<div id=\"content\">");
+ outFile.println("</div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div>");
+
+ int yOffsetText = yOffset + 8;
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:5px;\">%.1f</div>\n", size);
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:80px;\">%.1f", perc);
+ outFile.println("%</div>\n");
+ outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:120px;\"><a href=\"" + drillDownFileName
+ + "\" target=\"_top\">" + splitPointName + "</a></div>");
+
+ yOffset = yOffset + 25;
+ }
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
+
+ private static void makeLiteralsHtml(String outFileName,
+ TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
+
+ float maxSize = 0f;
+ float sumSize = 0f;
+ TreeMap<Float, String> sortedLitTypes = new TreeMap<Float, String>(
+ Collections.reverseOrder());
+
+ for (String literal : nameToLitColl.keySet()) {
+ float curSize = nameToLitColl.get(literal).cumSize;
+ sumSize += curSize;
+
+ if (curSize != 0f) {
+ sortedLitTypes.put(curSize, literal);
+
+ if (curSize > maxSize) {
+ maxSize = curSize;
+ }
+ }
+ }
+
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
+ outFile.println("</head>");
+ outFile.println("<body>");
+
+ int yOffset = 0;
+ for (Float size : sortedLitTypes.keySet()) {
+
+ String literal = sortedLitTypes.get(size);
+ String drillDownFileName = literal + "Lits.html";
+
+ float ratio = (size / maxSize) * 79;
+ float perc = (size / sumSize) * 100;
+
+ if (ratio < 3) {
+ ratio = 3;
+ }
+
+ outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+ + yOffset + "px; left: 110px;\">");
+ outFile.println("<div id=\"lb\">");
+ outFile.println("<div id=\"rb\">");
+ outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+ outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+ outFile.println("<div id=\"content\">");
+ outFile.println("</div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div>");
+
+ int yOffsetText = yOffset + 8;
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:5px;\">%.1f</div>\n", size);
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:70px;\">%.1f", perc);
+ outFile.println("%</div>\n");
+ outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:110px;\"><a href=\"" + drillDownFileName
+ + "\" target=\"_top\">" + literal + "</a></div>");
+
+ yOffset = yOffset + 25;
+ }
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
+
+ private static void makePackageHtml(String outFileName) throws IOException {
+
+ TreeMap<Float, String> sortedPackages = new TreeMap<Float, String>(
+ Collections.reverseOrder());
+ float maxSize = 0f;
+ float sumSize = 0f;
+ for (String packageName : GlobalInformation.packageToPartialSize.keySet()) {
+ sortedPackages.put(
+ GlobalInformation.packageToPartialSize.get(packageName), packageName);
+ sumSize += GlobalInformation.packageToPartialSize.get(packageName);
+ if (GlobalInformation.packageToPartialSize.get(packageName) > maxSize) {
+ maxSize = GlobalInformation.packageToPartialSize.get(packageName);
+ }
+ }
+
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
+
+ outFile.println("</head>");
+ outFile.println("<body>");
+
+ int yOffset = 0;
+ for (Float size : sortedPackages.keySet()) {
+
+ String packageName = sortedPackages.get(size);
+ String drillDownFileName = packageName + "Classes.html";
+
+ float ratio = (size / maxSize) * 79;
+
+ if (ratio < 3) {
+ ratio = 3;
+ }
+
+ float perc = (size / sumSize) * 100;
+
+ outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+ + yOffset + "px; left: 110px;\">");
+ outFile.println("<div id=\"lb\">");
+ outFile.println("<div id=\"rb\">");
+ outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+ outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+ outFile.println("<div id=\"content\">");
+ outFile.println("</div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div>");
+
+ int yOffsetText = yOffset + 8;
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:5px;\">%.1f</div>\n", size);
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:70px;\">%.1f", perc);
+ outFile.println("%</div>\n");
+ outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:110px;\"><a href=\"" + drillDownFileName
+ + "\" target=\"_top\">" + packageName + "</a></div>");
+
+ yOffset = yOffset + 25;
+ }
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
+ }
+
+ private static void makeStringLiteralsHtml(String outFileName,
+ TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException {
+
+ final PrintWriter outFile = new PrintWriter(outFileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
+ outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">");
+ outFile.println("</head>");
+ outFile.println("<body>");
+
+ if (nameToLitColl.get("string").stringTypeToSize.size() > 0) {
+
+ float maxSize = 0f;
+ float sumSize = 0f;
+ TreeMap<Float, String> sortedStLitTypes = new TreeMap<Float, String>(
+ Collections.reverseOrder());
+
+ for (String stringLiteral : nameToLitColl.get("string").stringTypeToSize.keySet()) {
+ float curSize = nameToLitColl.get("string").stringTypeToSize.get(stringLiteral);
+ sumSize += curSize;
+
+ if (curSize != 0f) {
+ sortedStLitTypes.put(curSize, stringLiteral);
+
+ if (curSize > maxSize) {
+ maxSize = curSize;
+ }
+ }
+ }
+
+ int yOffset = 0;
+ for (Float size : sortedStLitTypes.keySet()) {
+
+ String stringLiteral = sortedStLitTypes.get(size);
+ String drillDownFileName = stringLiteral + "Strings.html";
+
+ float ratio = (size / maxSize) * 79;
+ float perc = (size / sumSize) * 100;
+
+ if (ratio < 3) {
+ ratio = 3;
+ }
+
+ outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+ + yOffset + "px; left: 110px;\">");
+ outFile.println("<div id=\"lb\">");
+ outFile.println("<div id=\"rb\">");
+ outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+ outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+ outFile.println("<div id=\"content\">");
+ outFile.println("</div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div></div></div></div>");
+ outFile.println("</div>");
+
+ int yOffsetText = yOffset + 8;
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:5px;\">%.1f</div>\n", size);
+ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:70px;\">%.1f", perc);
+ outFile.println("%</div>\n");
+ outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+ + "px; left:110px;\"><a href=\"" + drillDownFileName
+ + "\" target=\"_top\">" + stringLiteral + "</a></div>");
+
+ yOffset = yOffset + 25;
+ }
+ } else {
+ outFile.println("No string literals found for this application.");
+ }
+
+ outFile.println("</body>");
+ outFile.println("</html>");
+ outFile.close();
}
}
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java b/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
index 2d060fd..6f6f27a 100644
--- a/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
+++ b/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
@@ -16,20 +16,30 @@
package com.google.gwt.soyc;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
+import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import java.util.TreeSet;
import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.zip.GZIPInputStream;
-import javax.xml.parsers.*;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+/**
+ * The command-line entry point for creating a SOYC report.
+ */
public class SoycDashboard {
/**
@@ -53,11 +63,11 @@
depFileName = args[1];
} else if (args.length == 3) {
GlobalInformation.displayDependencies = true;
- GlobalInformation.displaySplitPoints = true;
+ GlobalInformation.displaySplitPoints = true;
depFileName = args[1];
splitPointsFileName = args[2];
}
-
+
} else {
System.err.println("Usage: java com/google/gwt/soyc/SoycDashboard soyc-report0.xml[.gz] [soyc-dependencies0.xml[.gz]] [soyc-splitpoints0.xml[.gz]]");
System.exit(1);
@@ -102,7 +112,8 @@
}
if (GlobalInformation.displaySplitPoints == true) {
- /** handle runAsync split points
+ /**
+ * handle runAsync split points
*/
DefaultHandler splitPointHandler = parseXMLDocumentSplitPoints();
@@ -128,8 +139,7 @@
throw new RuntimeException("Could not open file. ", e);
}
}
-
-
+
/**
* handle everything else
*/
@@ -207,84 +217,95 @@
System.out.println("Finished creating reports. To see the dashboard, open SoycDashboard-index.html in your browser.");
}
+ /*
+ * unescape the JS snippets - in the XML file they are XML encoded for correct
+ * display, but this will mess up the byte counts
+ */
+ public static String unEscapeXml(String escaped) {
+ String unescaped = escaped.replaceAll("&", "\\&");
+ unescaped = unescaped.replaceAll("<", "\\<");
+ unescaped = unescaped.replaceAll(">", "\\>");
+ unescaped = unescaped.replaceAll(""", "\\\"");
+ // escaped = escaped.replaceAll("\\n", "");
+ unescaped = unescaped.replaceAll("'", "\\'");
+ return unescaped;
+ }
+
+ /*
+ * cleans up the RPC code categories
+ */
+ private static void foldInRPCHeuristic(
+ final HashMap<String, CodeCollection> nameToCodeColl) {
+ /**
+ * Heuristic: this moves all classes that override serializable from RPC to
+ * "Other Code" *if* there is no RPC generated code, i.e., if the
+ * application really is not using RPC
+ */
+
+ if (nameToCodeColl.get("rpcGen").classes.size() == 0) {
+
+ for (String className : nameToCodeColl.get("rpcUser").classes) {
+
+ if ((!nameToCodeColl.get("widget").classes.contains(className))
+ && (!nameToCodeColl.get("jre").classes.contains(className))
+ && (!nameToCodeColl.get("gwtLang").classes.contains(className))) {
+ nameToCodeColl.get("allOther").classes.add(className);
+ }
+ }
+ nameToCodeColl.get("rpcUser").classes.clear();
+
+ for (String className : nameToCodeColl.get("rpcGwt").classes) {
+ if ((!nameToCodeColl.get("widget").classes.contains(className))
+ && (!nameToCodeColl.get("jre").classes.contains(className))
+ && (!nameToCodeColl.get("gwtLang").classes.contains(className))) {
+ nameToCodeColl.get("allOther").classes.add(className);
+ }
+ }
+ nameToCodeColl.get("rpcGwt").classes.clear();
+ }
+ }
+
+ /*
+ * generates all the HTML files
+ */
+ private static void makeHTMLFiles(
+ final TreeMap<String, LiteralsCollection> nameToLitColl,
+ final HashMap<String, CodeCollection> nameToCodeColl) {
+
+ try {
+ MakeTopLevelHtmlForPerm.makePackageClassesHtmls();
+ MakeTopLevelHtmlForPerm.makeCodeTypeClassesHtmls(nameToCodeColl);
+ MakeTopLevelHtmlForPerm.makeLiteralsClassesTableHtmls(nameToLitColl);
+ MakeTopLevelHtmlForPerm.makeStringLiteralsClassesTableHtmls(nameToLitColl);
+ MakeTopLevelHtmlForPerm.makeSplitPointClassesHtmls();
+
+ // make the shell last so we can display aggregate information here
+ MakeTopLevelHtmlForPerm.makeHTMLShell(nameToCodeColl, nameToLitColl);
+
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot open file. ", e);
+ }
+ }
+
private static DefaultHandler parseXMLDocument(
final TreeMap<String, LiteralsCollection> nameToLitColl,
final HashMap<String, CodeCollection> nameToCodeColl) {
DefaultHandler handler = new DefaultHandler() {
- String curStoryId;
- String curStoryLiteralType;
- String curLineNumber;
- String curLocation;
- String curStoryRef;
- HashSet<String> curRelevantLitTypes = new HashSet<String>();
- HashSet<String> curRelevantCodeTypes = new HashSet<String>();
+ int ct = 0;
String curClassId;
Integer curFragment;
+ String curLineNumber;
+ String curLocation;
+ HashSet<String> curRelevantCodeTypes = new HashSet<String>();
+ HashSet<String> curRelevantLitTypes = new HashSet<String>();
+ String curStoryId;
+ String curStoryLiteralType;
+ String curStoryRef;
+ boolean fragmentInLoadOrder = false;
boolean specialCodeType = false;
StringBuilder valueBuilder = new StringBuilder();
- int ct = 0;
- boolean fragmentInLoadOrder = false;
-
- /**
- * This method deals with the beginning of the XML element. It analyzes
- * the XML node and adds its information to the relevant literal or code
- * collection for later analysis.
- *
- * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
- * java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- @Override
- public void startElement(String nsUri, String strippedName,
- String tagName, Attributes attributes) {
-
- if ((ct % 10000) == 0) {
- System.out.println(ct);
- }
- ct++;
-
- valueBuilder.delete(0, valueBuilder.length());
-
- if (strippedName.compareTo("story") == 0) {
- parseStory(attributes);
- }
-
- else if (strippedName.compareTo("of") == 0) {
- parseOverrides(nameToCodeColl, attributes);
- }
-
- else if (strippedName.compareTo("by") == 0) {
- parseCorrelations(nameToCodeColl, attributes);
- }
-
- else if (strippedName.compareTo("origin") == 0) {
- parseOrigins(nameToLitColl, attributes);
- }
-
- else if (strippedName.compareTo("js") == 0) {
- if (attributes.getValue("fragment") != null) {
- // ignore all code that is not in the first load order
-
- curFragment = Integer.parseInt(attributes.getValue("fragment"));
- if ((curFragment == 0)
- || (curFragment == (GlobalInformation.numSplitPoints + 1))
- || (curFragment == (GlobalInformation.numSplitPoints + 2))
- || ((curFragment >= 2) && (curFragment <= GlobalInformation.numSplitPoints))) {
- fragmentInLoadOrder = true;
- } else {
- fragmentInLoadOrder = false;
- }
- } else {
-
- curFragment = -2;
- }
- }
-
- else if (strippedName.compareTo("storyref") == 0) {
- parseJs(nameToLitColl, nameToCodeColl, attributes, curFragment);
- }
- }
/**
* This method collects a block of the value of the current XML node that
@@ -298,29 +319,29 @@
/**
* This method marks the end of an XML element that the SAX parser parses.
- * It has access to the full value of the node and uses it to add information
- * to the relevant literal or code collections.
+ * It has access to the full value of the node and uses it to add
+ * information to the relevant literal or code collections.
*
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
* java.lang.String, java.lang.String)
*/
@Override
public void endElement(String nsUri, String strippedName, String qName) {
-
- if (strippedName.compareTo("storyref") == 0){
+
+ if (strippedName.compareTo("storyref") == 0) {
String value = valueBuilder.toString();
-
+
int numBytes = value.getBytes().length;
- if (curStoryRef != null) {
+ if (curStoryRef != null) {
if (!GlobalInformation.fragmentToPartialSize.containsKey(curFragment)) {
GlobalInformation.fragmentToPartialSize.put(curFragment,
- (float)numBytes);
+ (float) numBytes);
} else {
float newSize = GlobalInformation.fragmentToPartialSize.get(curFragment)
- + (float)numBytes;
+ + numBytes;
GlobalInformation.fragmentToPartialSize.put(curFragment, newSize);
}
-
+
// now do different things depending on whether this fragment is in
// the load order or not
if (fragmentInLoadOrder == false) {
@@ -328,21 +349,21 @@
} else {
GlobalInformation.cumSizeAllCode += numBytes;
}
-
-
+
// add this size to the classes associated with it
if (GlobalInformation.storiesToCorrClasses.containsKey(curStoryRef)) {
-
+
if ((GlobalInformation.storiesToLitType.containsKey(curStoryRef))
&& (GlobalInformation.storiesToCorrClasses.get(curStoryRef).size() > 0)) {
GlobalInformation.numBytesDoubleCounted += numBytes;
}
-
+
float partialSize = (float) numBytes
/ (float) GlobalInformation.storiesToCorrClasses.get(
curStoryRef).size();
-
- // now do different things depending on whether this fragment is in
+
+ // now do different things depending on whether this fragment is
+ // in
// the load order or not
if (fragmentInLoadOrder == true) {
if ((!GlobalInformation.storiesToLitType.containsKey(curStoryRef))
@@ -350,21 +371,19 @@
GlobalInformation.nonAttributedStories.add(curStoryRef);
GlobalInformation.nonAttributedBytes += numBytes;
}
-
+
// go through all the classes for this story
for (String className : GlobalInformation.storiesToCorrClasses.get(curStoryRef)) {
// get the corresponding package
-
+
String packageName = "";
-
-
+
if (!GlobalInformation.classToPackage.containsKey(className)) {
- //derive the package name from the class
+ // derive the package name from the class
packageName = className;
- packageName = packageName.replaceAll("\\.[A-Z].*","");
- GlobalInformation.classToPackage.put(className, packageName);
- }
- else{
+ packageName = packageName.replaceAll("\\.[A-Z].*", "");
+ GlobalInformation.classToPackage.put(className, packageName);
+ } else {
packageName = GlobalInformation.classToPackage.get(className);
}
parseClass(nameToCodeColl, className, packageName);
@@ -403,6 +422,245 @@
}
}
+ /**
+ * This method deals with the beginning of the XML element. It analyzes
+ * the XML node and adds its information to the relevant literal or code
+ * collection for later analysis.
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ @Override
+ public void startElement(String nsUri, String strippedName,
+ String tagName, Attributes attributes) {
+
+ if ((ct % 10000) == 0) {
+ System.out.println(ct);
+ }
+ ct++;
+
+ valueBuilder.delete(0, valueBuilder.length());
+
+ if (strippedName.compareTo("story") == 0) {
+ parseStory(attributes);
+ } else if (strippedName.compareTo("of") == 0) {
+ parseOverrides(nameToCodeColl, attributes);
+ } else if (strippedName.compareTo("by") == 0) {
+ parseCorrelations(nameToCodeColl, attributes);
+ } else if (strippedName.compareTo("origin") == 0) {
+ parseOrigins(nameToLitColl, attributes);
+ } else if (strippedName.compareTo("js") == 0) {
+ if (attributes.getValue("fragment") != null) {
+ // ignore all code that is not in the first load order
+
+ curFragment = Integer.parseInt(attributes.getValue("fragment"));
+ if ((curFragment == 0)
+ || (curFragment == (GlobalInformation.numSplitPoints + 1))
+ || (curFragment == (GlobalInformation.numSplitPoints + 2))
+ || ((curFragment >= 2) && (curFragment <= GlobalInformation.numSplitPoints))) {
+ fragmentInLoadOrder = true;
+ } else {
+ fragmentInLoadOrder = false;
+ }
+ } else {
+
+ curFragment = -2;
+ }
+ } else if (strippedName.compareTo("storyref") == 0) {
+ parseJs(nameToLitColl, nameToCodeColl, attributes, curFragment);
+ }
+ }
+
+ /*
+ * parses the "class" portion of the XML file
+ */
+ private void parseClass(
+ final HashMap<String, CodeCollection> nameToCodeColl,
+ String curClassId, String curPackage) {
+ // if (attributes.getValue("id") != null) {
+ // curClassId = attributes.getValue("id");
+
+ // GlobalInformation.classToPackage.put(curClassId, curPackage);
+
+ if (curPackage.startsWith("java")) {
+ nameToCodeColl.get("jre").classes.add(curClassId);
+ } else if (curPackage.startsWith("com.google.gwt.lang")) {
+ nameToCodeColl.get("gwtLang").classes.add(curClassId);
+ }
+ if (curClassId.contains("_CustomFieldSerializer")) {
+ nameToCodeColl.get("rpcUser").classes.add(curClassId);
+ } else if (curClassId.endsWith("_FieldSerializer")
+ || curClassId.endsWith("_Proxy")
+ || curClassId.endsWith("_TypeSerializer")) {
+ nameToCodeColl.get("rpcGen").classes.add(curClassId);
+ }
+ // }
+ }
+
+ /*
+ * parses the "correlations" portion of the XML file
+ */
+ private void parseCorrelations(
+ final HashMap<String, CodeCollection> nameToCodeColl,
+ Attributes attributes) {
+
+ if (attributes.getValue("idref") != null) {
+
+ String corrClassOrMethod = attributes.getValue("idref");
+ String corrClass = attributes.getValue("idref");
+
+ if (corrClass.contains(":")) {
+ corrClass = corrClass.replaceAll(":.*", "");
+ }
+
+ if (!GlobalInformation.storiesToCorrClassesAndMethods.containsKey(curStoryId)) {
+ HashSet<String> insertSet = new HashSet<String>();
+ insertSet.add(corrClassOrMethod);
+ GlobalInformation.storiesToCorrClassesAndMethods.put(curStoryId,
+ insertSet);
+ } else {
+ GlobalInformation.storiesToCorrClassesAndMethods.get(curStoryId).add(
+ corrClassOrMethod);
+ }
+
+ if (!GlobalInformation.storiesToCorrClasses.containsKey(curStoryId)) {
+ HashSet<String> insertSet = new HashSet<String>();
+ insertSet.add(corrClass);
+ GlobalInformation.storiesToCorrClasses.put(curStoryId, insertSet);
+ } else {
+ GlobalInformation.storiesToCorrClasses.get(curStoryId).add(
+ corrClass);
+ }
+
+ for (String codeType : nameToCodeColl.keySet()) {
+ if (nameToCodeColl.get(codeType).classes.contains(corrClass)) {
+ nameToCodeColl.get(codeType).stories.add(curStoryId);
+ }
+ }
+ }
+ }
+
+ /*
+ * parses the "JS" portion of the XML file
+ */
+ private void parseJs(
+ final TreeMap<String, LiteralsCollection> nameToLitColl,
+ final HashMap<String, CodeCollection> nameToCodeColl,
+ Attributes attributes, Integer curFragment) {
+ curRelevantLitTypes.clear();
+ curRelevantCodeTypes.clear();
+
+ if (attributes.getValue("idref") != null) {
+
+ curStoryRef = attributes.getValue("idref");
+
+ if (curFragment != -1) {
+ // add this to the stories for this fragment
+ if (!GlobalInformation.fragmentToStories.containsKey(curFragment)) {
+ HashSet<String> insertSet = new HashSet<String>();
+ insertSet.add(curStoryRef);
+ GlobalInformation.fragmentToStories.put(curFragment, insertSet);
+ } else {
+ GlobalInformation.fragmentToStories.get(curFragment).add(
+ curStoryRef);
+ }
+ }
+
+ for (String litType : nameToLitColl.keySet()) {
+ if (nameToLitColl.get(litType).storyToLocations.containsKey(curStoryRef)) {
+ curRelevantLitTypes.add(litType);
+ }
+ }
+
+ specialCodeType = false;
+ for (String codeType : nameToCodeColl.keySet()) {
+ if (nameToCodeColl.get(codeType).stories.contains(curStoryRef)) {
+ curRelevantCodeTypes.add(codeType);
+ specialCodeType = true;
+ }
+ }
+ if (specialCodeType == false) {
+
+ nameToCodeColl.get("allOther").stories.add(curStoryRef);
+ curRelevantCodeTypes.add("allOther");
+ }
+ }
+ }
+
+ /*
+ * parses the "origins" portion of the XML file
+ */
+ private void parseOrigins(
+ final TreeMap<String, LiteralsCollection> nameToLitColl,
+ Attributes attributes) {
+ if ((curStoryLiteralType.compareTo("") != 0)
+ && (attributes.getValue("lineNumber") != null)
+ && (attributes.getValue("location") != null)) {
+ curLineNumber = attributes.getValue("lineNumber");
+ curLocation = attributes.getValue("location");
+ String curOrigin = curLocation + ": Line " + curLineNumber;
+
+ if (!nameToLitColl.get(curStoryLiteralType).storyToLocations.containsKey(curStoryId)) {
+ HashSet<String> insertSet = new HashSet<String>();
+ insertSet.add(curOrigin);
+ nameToLitColl.get(curStoryLiteralType).storyToLocations.put(
+ curStoryId, insertSet);
+ } else {
+ nameToLitColl.get(curStoryLiteralType).storyToLocations.get(
+ curStoryId).add(curOrigin);
+ }
+ }
+ }
+
+ /*
+ * parses the "overrides" portion of the XML file
+ */
+ private void parseOverrides(
+ final HashMap<String, CodeCollection> nameToCodeColl,
+ Attributes attributes) {
+ if (attributes.getValue("idref") != null) {
+ String overriddenClass = attributes.getValue("idref");
+
+ // we either generalize to classes, or the
+ // numbers are messed up...
+ if (overriddenClass.contains(":")) {
+ overriddenClass = overriddenClass.replaceAll(":.*", "");
+ }
+
+ if (overriddenClass.compareTo("com.google.gwt.user.client.ui.UIObject") == 0) {
+ nameToCodeColl.get("widget").classes.add(curClassId);
+ } else if (overriddenClass.contains("java.io.Serializable")
+ || overriddenClass.contains("IsSerializable")) {
+ nameToCodeColl.get("rpcUser").classes.add(curClassId);
+ } else if (overriddenClass.contains("com.google.gwt.user.client.rpc.core.java")) {
+ nameToCodeColl.get("rpcGwt").classes.add(curClassId);
+ }
+ }
+ }
+
+ /*
+ * parses the "story" portion of the XML file
+ */
+ private void parseStory(Attributes attributes) {
+ if (attributes.getValue("id") != null) {
+ curStoryId = attributes.getValue("id");
+ if (attributes.getValue("literal") != null) {
+ curStoryLiteralType = attributes.getValue("literal");
+ GlobalInformation.storiesToLitType.put(curStoryId,
+ curStoryLiteralType);
+
+ if (!nameToLitColl.get(curStoryLiteralType).storyToLocations.containsKey(curStoryId)) {
+ HashSet<String> insertSet = new HashSet<String>();
+ nameToLitColl.get(curStoryLiteralType).storyToLocations.put(
+ curStoryId, insertSet);
+ }
+
+ } else {
+ curStoryLiteralType = "";
+ }
+ }
+ }
+
/*
* This method assigns strings to the appropriate category
*/
@@ -505,231 +763,32 @@
nameToLitColl.get(relLitType).literalToLocations.put(value,
insertSet);
}
-
}
}
}
}
/*
- * parses the "JS" portion of the XML file
- */
- private void parseJs(
- final TreeMap<String, LiteralsCollection> nameToLitColl,
- final HashMap<String, CodeCollection> nameToCodeColl,
- Attributes attributes, Integer curFragment) {
- curRelevantLitTypes.clear();
- curRelevantCodeTypes.clear();
-
- if (attributes.getValue("idref") != null) {
-
- curStoryRef = attributes.getValue("idref");
-
- if (curFragment != -1) {
- // add this to the stories for this fragment
- if (!GlobalInformation.fragmentToStories.containsKey(curFragment)) {
- HashSet<String> insertSet = new HashSet<String>();
- insertSet.add(curStoryRef);
- GlobalInformation.fragmentToStories.put(curFragment, insertSet);
- } else {
- GlobalInformation.fragmentToStories.get(curFragment).add(
- curStoryRef);
- }
- }
-
- for (String litType : nameToLitColl.keySet()) {
- if (nameToLitColl.get(litType).storyToLocations.containsKey(curStoryRef)) {
- curRelevantLitTypes.add(litType);
- }
- }
-
- specialCodeType = false;
- for (String codeType : nameToCodeColl.keySet()) {
- if (nameToCodeColl.get(codeType).stories.contains(curStoryRef)) {
- curRelevantCodeTypes.add(codeType);
- specialCodeType = true;
- }
- }
- if (specialCodeType == false) {
-
- nameToCodeColl.get("allOther").stories.add(curStoryRef);
- curRelevantCodeTypes.add("allOther");
- }
- }
- }
-
- /*
- * parses the "origins" portion of the XML file
- */
- private void parseOrigins(
- final TreeMap<String, LiteralsCollection> nameToLitColl,
- Attributes attributes) {
- if ((curStoryLiteralType.compareTo("") != 0)
- && (attributes.getValue("lineNumber") != null)
- && (attributes.getValue("location") != null)) {
- curLineNumber = attributes.getValue("lineNumber");
- curLocation = attributes.getValue("location");
- String curOrigin = curLocation + ": Line " + curLineNumber;
-
- if (!nameToLitColl.get(curStoryLiteralType).storyToLocations.containsKey(curStoryId)) {
- HashSet<String> insertSet = new HashSet<String>();
- insertSet.add(curOrigin);
- nameToLitColl.get(curStoryLiteralType).storyToLocations.put(
- curStoryId, insertSet);
- } else {
- nameToLitColl.get(curStoryLiteralType).storyToLocations.get(
- curStoryId).add(curOrigin);
- }
- }
- }
-
- /*
- * parses the "story" portion of the XML file
- */
- private void parseStory(Attributes attributes) {
- if (attributes.getValue("id") != null) {
- curStoryId = attributes.getValue("id");
- if (attributes.getValue("literal") != null) {
- curStoryLiteralType = attributes.getValue("literal");
- GlobalInformation.storiesToLitType.put(curStoryId,
- curStoryLiteralType);
-
- if (!nameToLitColl.get(curStoryLiteralType).storyToLocations.containsKey(curStoryId)) {
- HashSet<String> insertSet = new HashSet<String>();
- nameToLitColl.get(curStoryLiteralType).storyToLocations.put(
- curStoryId, insertSet);
- }
-
- } else {
- curStoryLiteralType = "";
- }
- }
- }
-
- /*
- * parses the "correlations" portion of the XML file
- */
- private void parseCorrelations(
- final HashMap<String, CodeCollection> nameToCodeColl,
- Attributes attributes) {
-
- if (attributes.getValue("idref") != null) {
-
- String corrClassOrMethod = attributes.getValue("idref");
- String corrClass = attributes.getValue("idref");
-
- if (corrClass.contains(":")) {
- corrClass = corrClass.replaceAll(":.*", "");
- }
-
- if (!GlobalInformation.storiesToCorrClassesAndMethods.containsKey(curStoryId)) {
- HashSet<String> insertSet = new HashSet<String>();
- insertSet.add(corrClassOrMethod);
- GlobalInformation.storiesToCorrClassesAndMethods.put(curStoryId,
- insertSet);
- } else {
- GlobalInformation.storiesToCorrClassesAndMethods.get(curStoryId).add(
- corrClassOrMethod);
- }
-
- if (!GlobalInformation.storiesToCorrClasses.containsKey(curStoryId)) {
- HashSet<String> insertSet = new HashSet<String>();
- insertSet.add(corrClass);
- GlobalInformation.storiesToCorrClasses.put(curStoryId, insertSet);
- } else {
- GlobalInformation.storiesToCorrClasses.get(curStoryId).add(
- corrClass);
- }
-
- for (String codeType : nameToCodeColl.keySet()) {
- if (nameToCodeColl.get(codeType).classes.contains(corrClass)) {
- nameToCodeColl.get(codeType).stories.add(curStoryId);
- }
- }
- }
- }
-
- /*
- * parses the "overrides" portion of the XML file
- */
- private void parseOverrides(
- final HashMap<String, CodeCollection> nameToCodeColl,
- Attributes attributes) {
- if (attributes.getValue("idref") != null) {
- String overriddenClass = attributes.getValue("idref");
-
- // we either generalize to classes, or the
- // numbers are messed up...
- if (overriddenClass.contains(":")) {
- overriddenClass = overriddenClass.replaceAll(":.*", "");
- }
-
- if (overriddenClass.compareTo("com.google.gwt.user.client.ui.UIObject") == 0) {
- nameToCodeColl.get("widget").classes.add(curClassId);
- } else if (overriddenClass.contains("java.io.Serializable")
- || overriddenClass.contains("IsSerializable")) {
- nameToCodeColl.get("rpcUser").classes.add(curClassId);
- } else if (overriddenClass.contains("com.google.gwt.user.client.rpc.core.java")) {
- nameToCodeColl.get("rpcGwt").classes.add(curClassId);
- }
- }
- }
-
- /*
- * parses the "class" portion of the XML file
- */
- private void parseClass(final HashMap<String, CodeCollection> nameToCodeColl,
- String curClassId, String curPackage) {
- //if (attributes.getValue("id") != null) {
- // curClassId = attributes.getValue("id");
-
- // GlobalInformation.classToPackage.put(curClassId, curPackage);
-
- if (curPackage.startsWith("java")) {
- nameToCodeColl.get("jre").classes.add(curClassId);
- } else if (curPackage.startsWith("com.google.gwt.lang")) {
- nameToCodeColl.get("gwtLang").classes.add(curClassId);
- }
- if (curClassId.contains("_CustomFieldSerializer")) {
- nameToCodeColl.get("rpcUser").classes.add(curClassId);
- } else if (curClassId.endsWith("_FieldSerializer")
- || curClassId.endsWith("_Proxy")
- || curClassId.endsWith("_TypeSerializer")) {
- nameToCodeColl.get("rpcGen").classes.add(curClassId);
- }
- //}
- }
-
- /*
* parses the "depends on" portion of the XML file
*/
-/* private void parseDependsOn(
- final HashMap<String, CodeCollection> nameToCodeColl,
- Attributes attributes) {
- if (curFunctionId.compareTo("") == 0) {
- if (attributes.getValue("idref") != null) {
- String curDepClassId = attributes.getValue("idref");
-
- if (curDepClassId.contains(":")) {
- // strip everything after the :: (to get to class, even if it's a
- // method)
- curDepClassId = curDepClassId.replaceAll(":.*", "");
- }
-
- if (curDepClassId.contains(".")) {
- if (!GlobalInformation.classToWhatItDependsOn.containsKey(curClassId)) {
- HashSet<String> insertSet = new HashSet<String>();
- insertSet.add(curDepClassId);
- GlobalInformation.classToWhatItDependsOn.put(curClassId,
- insertSet);
- } else {
- GlobalInformation.classToWhatItDependsOn.get(curClassId).add(
- curDepClassId);
- }
- }
- }
- }
- }*/
+ /*
+ * private void parseDependsOn( final HashMap<String, CodeCollection>
+ * nameToCodeColl, Attributes attributes) { if
+ * (curFunctionId.compareTo("") == 0) { if (attributes.getValue("idref")
+ * != null) { String curDepClassId = attributes.getValue("idref");
+ *
+ * if (curDepClassId.contains(":")) { // strip everything after the :: (to
+ * get to class, even if it's a // method) curDepClassId =
+ * curDepClassId.replaceAll(":.*", ""); }
+ *
+ * if (curDepClassId.contains(".")) { if
+ * (!GlobalInformation.classToWhatItDependsOn.containsKey(curClassId)) {
+ * HashSet<String> insertSet = new HashSet<String>();
+ * insertSet.add(curDepClassId);
+ * GlobalInformation.classToWhatItDependsOn.put(curClassId, insertSet); }
+ * else { GlobalInformation.classToWhatItDependsOn.get(curClassId).add(
+ * curDepClassId); } } } } }
+ */
};
return handler;
}
@@ -739,9 +798,9 @@
DefaultHandler handler = new DefaultHandler() {
- StringBuilder valueBuilder = new StringBuilder();
// may want to create a class for this later
String curMethod;
+ StringBuilder valueBuilder = new StringBuilder();
/**
* This method deals with the beginning of the XML element. It analyzes
@@ -796,7 +855,7 @@
parseSplitPoint(attributes);
}
}
-
+
/*
* parses the split points
*/
@@ -819,72 +878,10 @@
}
}
-
-
};
return handler;
}
-
-
- /*
- * cleans up the RPC code categories
- */
- private static void foldInRPCHeuristic(
- final HashMap<String, CodeCollection> nameToCodeColl) {
- /**
- * Heuristic: this moves all classes that override serializable from RPC to
- * "Other Code" *if* there is no RPC generated code, i.e., if the
- * application really is not using RPC
- */
-
- if (nameToCodeColl.get("rpcGen").classes.size() == 0) {
-
- for (String className : nameToCodeColl.get("rpcUser").classes) {
-
- if ((!nameToCodeColl.get("widget").classes.contains(className))
- && (!nameToCodeColl.get("jre").classes.contains(className))
- && (!nameToCodeColl.get("gwtLang").classes.contains(className))) {
- nameToCodeColl.get("allOther").classes.add(className);
- }
- }
- nameToCodeColl.get("rpcUser").classes.clear();
-
- for (String className : nameToCodeColl.get("rpcGwt").classes) {
- if ((!nameToCodeColl.get("widget").classes.contains(className))
- && (!nameToCodeColl.get("jre").classes.contains(className))
- && (!nameToCodeColl.get("gwtLang").classes.contains(className))) {
- nameToCodeColl.get("allOther").classes.add(className);
- }
-
- }
- nameToCodeColl.get("rpcGwt").classes.clear();
- }
-
- }
-
- /*
- * generates all the HTML files
- */
- private static void makeHTMLFiles(
- final TreeMap<String, LiteralsCollection> nameToLitColl,
- final HashMap<String, CodeCollection> nameToCodeColl) {
-
- try {
- MakeTopLevelHtmlForPerm.makePackageClassesHtmls();
- MakeTopLevelHtmlForPerm.makeCodeTypeClassesHtmls(nameToCodeColl);
- MakeTopLevelHtmlForPerm.makeLiteralsClassesTableHtmls(nameToLitColl);
- MakeTopLevelHtmlForPerm.makeStringLiteralsClassesTableHtmls(nameToLitColl);
- MakeTopLevelHtmlForPerm.makeSplitPointClassesHtmls();
-
- // make the shell last so we can display aggregate information here
- MakeTopLevelHtmlForPerm.makeHTMLShell(nameToCodeColl, nameToLitColl);
-
- } catch (IOException e) {
- throw new RuntimeException("Cannot open file. ", e);
- }
- }
-
/*
* assigns code to "all other code" if none of the special categories apply
*/
@@ -903,18 +900,4 @@
}
}
- /*
- * unescape the JS snippets - in the XML file they are XML encoded for correct
- * display, but this will mess up the byte counts
- */
- public static String unEscapeXml(String escaped) {
- String unescaped = escaped.replaceAll("&", "\\&");
- unescaped = unescaped.replaceAll("<", "\\<");
- unescaped = unescaped.replaceAll(">", "\\>");
- unescaped = unescaped.replaceAll(""", "\\\"");
- // escaped = escaped.replaceAll("\\n", "");
- unescaped = unescaped.replaceAll("'", "\\'");
- return unescaped;
- }
-
}