summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorcremet <cremet@epfl.ch>2004-01-27 09:43:50 +0000
committercremet <cremet@epfl.ch>2004-01-27 09:43:50 +0000
commitff4e27439635e45c3114e91ebddb1bf71ae92734 (patch)
tree5f63393fcfc062dc05276bee9b16488e4dc22747 /sources
parent3d7fe86ae7c38e430808f09ec61ba71ca4592bd2 (diff)
downloadscala-ff4e27439635e45c3114e91ebddb1bf71ae92734.tar.gz
scala-ff4e27439635e45c3114e91ebddb1bf71ae92734.tar.bz2
scala-ff4e27439635e45c3114e91ebddb1bf71ae92734.zip
- Now sort the symbols in the bottom-left frame.
- Added in ScalaSearch a function that convert a string to a type.
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scaladoc/HTMLGenerator.java4
-rw-r--r--sources/scala/tools/scaladoc/ScalaSearch.java43
2 files changed, 46 insertions, 1 deletions
diff --git a/sources/scala/tools/scaladoc/HTMLGenerator.java b/sources/scala/tools/scaladoc/HTMLGenerator.java
index 40c22c1ad2..99cea84b75 100644
--- a/sources/scala/tools/scaladoc/HTMLGenerator.java
+++ b/sources/scala/tools/scaladoc/HTMLGenerator.java
@@ -1098,8 +1098,10 @@ public class HTMLGenerator {
addSymbolTable(members[i], "All " + titles[i], true);
} else {
Symbol[][] members = ScalaSearch.splitMembers(ScalaSearch.members(sym, isDocumented));
- for (int i = 0; i < titles.length; i++)
+ for (int i = 0; i < titles.length; i++) {
+ Arrays.sort(members[i + 2], ScalaSearch.symAlphaOrder);
addSymbolTable(members[i + 2], titles[i], false);
+ }
}
if (validate)
diff --git a/sources/scala/tools/scaladoc/ScalaSearch.java b/sources/scala/tools/scaladoc/ScalaSearch.java
index fc84992dd9..7bee73520d 100644
--- a/sources/scala/tools/scaladoc/ScalaSearch.java
+++ b/sources/scala/tools/scaladoc/ScalaSearch.java
@@ -30,6 +30,12 @@ import scalac.util.Debug;
import scalac.util.Name;
import scalac.util.NameTransformer;
+import java.io.*;
+import scalac.ast.printer.*;
+import ch.epfl.lamp.util.SourceFile;
+import scalac.ast.parser.Parser;
+import scalac.Unit;
+
/**
* This class contains functions to retrieve information from a Scala
* library.
@@ -469,6 +475,43 @@ public class ScalaSearch {
Scope.EMPTY);
return sym.overriddenSymbol(base);
}
+
+ ////////////////////////// POST TYPECHECKING ////////////////////////
+
+ public static int queryCounter = 0;
+
+ /**
+ * Parse a string representing a Scala type and resolve its
+ * symbols. This function must be called after the typechecking
+ * phase. If parsing or type checking fails, return Type.NoType.
+ */
+ public static Type typeOfString(String typeString, Global global) {
+ int errorNumber = global.reporter.errors();
+ String unitString = "trait tmp$" + queryCounter +
+ " extends Option[unit] { def f" + typeString + "; }";
+ // Rem: we use a dummy extends clause, otherwise the compiler
+ // complains.
+ queryCounter = queryCounter + 1;
+ InputStream in =
+ new BufferedInputStream(new StringBufferInputStream(unitString));
+ SourceFile sourceFile = null;
+ try {
+ sourceFile = new SourceFile("tmp.scala", in);
+ } catch(IOException e) { }
+ Unit tmpUnit = new Unit(global, sourceFile, false);
+ tmpUnit.body = new Parser(tmpUnit).parse();
+ //TreePrinter treePrinter = new TextTreePrinter(System.out);
+ //treePrinter.print(tmpUnit);
+ global.PHASE.ANALYZER.phase().apply(new Unit[]{ tmpUnit });
+ if (global.reporter.errors() == errorNumber) {
+ Scope tmpScope = tmpUnit.body[0].symbol().members();
+ Type res = tmpScope.lookup(Name.fromString("f")).type();
+ return res;
+ }
+ else
+ return Type.NoType;
+ }
+
}
//////////////////////////// DOCUMENTED SYMBOLS //////////////////////////////