More comments in the grammar

"used by" navigation
This commit is contained in:
Andrey Breslav
2011-06-28 21:05:09 +04:00
parent 8c64490700
commit e3b36bf5a4
9 changed files with 80 additions and 10 deletions
+9
View File
@@ -16,6 +16,15 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../idea/idea.app/lib/guava-r09.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
+2
View File
@@ -1,5 +1,7 @@
/**
h2. Classes
*Relevant pages:* [Classes and Inheritance]
*/
/*
+1 -1
View File
@@ -41,7 +41,7 @@ memberDeclaration
: function
: property
: class
: extension §
: extension
: typedef
: anonymousInitializer
;
+32 -7
View File
@@ -2,13 +2,6 @@
h1. Lexical structure
*/
SimpleName
: <java identifier>;
FieldName
: "$" SimpleName;
LabelName
: "@" SimpleName;
[helper]
Digit
: ["0".."9"];
@@ -29,15 +22,47 @@ HexadecimalLiteral
CharacterLiteral
: <character as in Java>;
/**
bq. See [Basic types]
*/
StringWithTemplates
: <single-quoted string, $ can be escaped>;
NoEscapeString
: <"""-quoted string>;
/**
bq. See [String templates]
*/
SEMI
: <semicolon or newline>;
SimpleName
: <java identifier>
: "`" <java identifier> "`"
;
/**
bq. See [Java interoperability]
*/
FieldName
: "$" SimpleName;
/**
bq. See [Properties And Fields]
*/
LabelName
: "@" SimpleName;
/**
bq. See [Nonlocal returns and jumps]
*/
/* Symbols:
[](){}<>
-1
View File
@@ -13,7 +13,6 @@ modifier
: memberModifier
: parameterKind
: attributes
// sealed by default
;
classModifier
@@ -1,5 +1,11 @@
package org.jetbrains.jet.grammar;
import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
@@ -88,7 +94,14 @@ public class ConfluenceHyperlinksGenerator {
Set<String> declaredSymbols = new HashSet<String>();
Set<String> usedSymbols = new HashSet<String>();
Multimap<String, String> usages = Multimaps.newListMultimap(Maps.<String, Collection<String>>newHashMap(), new Supplier<List<String>>() {
@Override
public List<String> get() {
return Lists.newArrayList();
}
});
List<Token> tokens = new ArrayList<Token>();
Declaration lastDeclaration = null;
while (true) {
Token advance = grammarLexer.advance();
@@ -97,10 +110,13 @@ public class ConfluenceHyperlinksGenerator {
}
if (advance instanceof Declaration) {
Declaration declaration = (Declaration) advance;
lastDeclaration = declaration;
declaredSymbols.add(declaration.getName());
}
else if (advance instanceof Identifier) {
Identifier identifier = (Identifier) advance;
assert lastDeclaration != null;
usages.put(identifier.getName(), lastDeclaration.getName());
usedSymbols.add(identifier.getName());
}
tokens.add(advance);
@@ -109,10 +125,25 @@ public class ConfluenceHyperlinksGenerator {
for (Token token : tokens) {
if (token instanceof Declaration) {
Declaration declaration = (Declaration) token;
result.append("{anchor:").append(declaration.getName()).append("}");
if (!usedSymbols.contains(declaration.getName())) {
// result.append("(!) *Unused!* ");
System.out.println("Unused: " + token);
}
Collection<String> myUsages = usages.get(declaration.getName());
if (!myUsages.isEmpty()) {
result.append("\\[{color:grey}Used by ");
for (Iterator<String> iterator = myUsages.iterator(); iterator.hasNext(); ) {
String usage = iterator.next();
result.append("[#").append(usage).append("]");
if (iterator.hasNext()) {
result.append(", ");
}
}
result.append("{color}\\]\n");
}
result.append(token);
continue;
}
else if (token instanceof Identifier) {
Identifier identifier = (Identifier) token;
@@ -13,7 +13,7 @@ public class Declaration extends Token {
@Override
public String toString() {
return "{anchor:" + name + "}*" + name + "*";
return "*" + name + "*";
}
public String getName() {
+2
View File
@@ -1,5 +1,7 @@
/**
h1. Syntax
*Relevant pages:* [Namespaces]
*/
+2
View File
@@ -1,5 +1,7 @@
/**
h4. Pattern matching
*Relevant pages:* [Pattern matching]
*/
when