You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.196
Former-commit-id: a9bb725ccbe0b8bfe8370b968c9f33f1558e1a2b
This commit is contained in:
parent
fad71374d0
commit
bdb6e93184
@@ -1,6 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly:AssemblyVersion("1.0.0.0")]
|
||||
[assembly:AssemblyDelaySign(false)]
|
||||
[assembly:AssemblyKeyFile("../../class/mono.snk")]
|
4
external/api-doc-tools/monodoc/Makefile
vendored
4
external/api-doc-tools/monodoc/Makefile
vendored
@@ -1,4 +0,0 @@
|
||||
CONFIGURATION = Release
|
||||
|
||||
check:
|
||||
mono ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe Test/bin/$(CONFIGURATION)/Monodoc.Test.dll
|
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
public class ManifestResourceResolver : XmlUrlResolver {
|
||||
private string[] dirs;
|
||||
|
||||
public ManifestResourceResolver (params string[] dirs)
|
||||
{
|
||||
this.dirs = (string[]) dirs.Clone ();
|
||||
}
|
||||
|
||||
public override Uri ResolveUri (Uri baseUri, string relativeUri)
|
||||
{
|
||||
if (Array.IndexOf (
|
||||
Assembly.GetExecutingAssembly ().GetManifestResourceNames (),
|
||||
relativeUri) >= 0)
|
||||
return new Uri ("x-resource:///" + relativeUri);
|
||||
foreach (var dir in dirs) {
|
||||
if (File.Exists (Path.Combine (dir, relativeUri)))
|
||||
return base.ResolveUri (new Uri ("file://" + new DirectoryInfo (dir).FullName + "/"),
|
||||
relativeUri);
|
||||
}
|
||||
return base.ResolveUri (baseUri, relativeUri);
|
||||
}
|
||||
|
||||
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
|
||||
{
|
||||
if (ofObjectToReturn == null)
|
||||
ofObjectToReturn = typeof(Stream);
|
||||
if (ofObjectToReturn != typeof(Stream))
|
||||
throw new XmlException ("This object type is not supported.");
|
||||
if (absoluteUri.Scheme != "x-resource")
|
||||
return base.GetEntity (absoluteUri, role, ofObjectToReturn);
|
||||
return Assembly.GetExecutingAssembly().GetManifestResourceStream (
|
||||
absoluteUri.Segments [1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,200 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
|
||||
public delegate XmlDocument DocLoader (string escapedTypeName);
|
||||
|
||||
public static class XmlDocUtils
|
||||
{
|
||||
public static XmlNodeList GetMemberGenericParameters (XmlNode member)
|
||||
{
|
||||
return member.SelectNodes ("Docs/typeparam");
|
||||
}
|
||||
|
||||
public static XmlNodeList GetTypeGenericParameters (XmlNode member)
|
||||
{
|
||||
return member.SelectNodes ("/Type/TypeParameters/TypeParameter");
|
||||
}
|
||||
|
||||
public static string ToTypeName (string type, XmlNode member)
|
||||
{
|
||||
return ToTypeName (type, GetTypeGenericParameters (member),
|
||||
GetMemberGenericParameters (member));
|
||||
}
|
||||
|
||||
public static string ToTypeName (string type, XmlNodeList typeGenParams, XmlNodeList memberGenParams)
|
||||
{
|
||||
type = type.Replace ("&", "@").Replace ("<", "{").Replace (">", "}");
|
||||
for (int i = 0; i < typeGenParams.Count; ++i) {
|
||||
string name = typeGenParams [i].InnerText;
|
||||
type = Regex.Replace (type, @"\b" + name + @"\b", "`" + i);
|
||||
}
|
||||
for (int i = 0; i < memberGenParams.Count; ++i) {
|
||||
string name = memberGenParams [i].Attributes ["name"].Value;
|
||||
type = Regex.Replace (type, @"\b" + name + @"\b", "``" + i);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public static string ToEscapedTypeName (string name)
|
||||
{
|
||||
return GetCountedName (name, "`");
|
||||
}
|
||||
|
||||
private static string GetCountedName (string name, string escape)
|
||||
{
|
||||
int lt = name.IndexOf ("<");
|
||||
if (lt == -1)
|
||||
return name;
|
||||
StringBuilder type = new StringBuilder (name.Length);
|
||||
int start = 0;
|
||||
do {
|
||||
type.Append (name.Substring (start, lt - start));
|
||||
type.Append (escape);
|
||||
type.Append (GetGenericCount (name, lt, out start));
|
||||
} while ((lt = name.IndexOf ('<', start)) >= 0);
|
||||
if (start < name.Length)
|
||||
type.Append (name.Substring (start));
|
||||
return type.ToString ().Replace ("+", ".");
|
||||
}
|
||||
|
||||
private static int GetGenericCount (string name, int start, out int end)
|
||||
{
|
||||
int n = 1;
|
||||
bool r = true;
|
||||
int i = start;
|
||||
int depth = 1;
|
||||
for ( ++i; r && i < name.Length; ++i) {
|
||||
switch (name [i]) {
|
||||
case ',': if (depth == 1) ++n; break;
|
||||
case '<': ++depth; break;
|
||||
case '>': --depth; if (depth == 0) r = false; break;
|
||||
}
|
||||
}
|
||||
end = i;
|
||||
return n;
|
||||
}
|
||||
|
||||
public static string ToEscapedMemberName (string member)
|
||||
{
|
||||
// Explicitly implemented interface members contain '.'s in the member
|
||||
// name, e.g. System.Collections.Generic.IEnumerable<A>.GetEnumerator.
|
||||
// CSC does a s/\./#/g for these.
|
||||
member = member.Replace (".", "#");
|
||||
if (member [member.Length-1] == '>') {
|
||||
int i = member.LastIndexOf ("<");
|
||||
int ignore;
|
||||
return member.Substring (0, i).Replace ("<", "{").Replace (">", "}") +
|
||||
"``" + GetGenericCount (member, i, out ignore);
|
||||
}
|
||||
return member.Replace ("<", "{").Replace (">", "}");
|
||||
}
|
||||
|
||||
public static void AddExtensionMethods (XmlDocument typexml, ArrayList/*<XmlNode>*/ extensions, DocLoader loader)
|
||||
{
|
||||
// if no members (enum, delegate) don't add extensions
|
||||
XmlNode m = typexml.SelectSingleNode ("/Type/Members");
|
||||
if (m == null)
|
||||
return;
|
||||
|
||||
// static classes can't be targets:
|
||||
if (typexml.SelectSingleNode (
|
||||
"/Type/TypeSignature[@Language='C#']/@Value")
|
||||
.Value.IndexOf (" static ") >= 0)
|
||||
return;
|
||||
|
||||
foreach (string s in GetSupportedTypes (typexml, loader)) {
|
||||
foreach (XmlNode extension in extensions) {
|
||||
bool add = false;
|
||||
foreach (XmlNode target in extension.SelectNodes ("Targets/Target")) {
|
||||
if (target.Attributes ["Type"].Value == s) {
|
||||
add = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!add) {
|
||||
continue;
|
||||
}
|
||||
foreach (XmlNode c in extension.SelectNodes ("Member")) {
|
||||
XmlNode cm = typexml.ImportNode (c, true);
|
||||
m.AppendChild (cm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable GetSupportedTypes (XmlDocument type, DocLoader loader)
|
||||
{
|
||||
yield return "System.Object";
|
||||
yield return GetEscapedPath (type, "Type/@FullName");
|
||||
|
||||
Hashtable h = new Hashtable ();
|
||||
GetInterfaces (h, type, loader);
|
||||
|
||||
string s = GetEscapedPath (type, "Type/Base/BaseTypeName");
|
||||
if (s != null) {
|
||||
yield return s;
|
||||
XmlDocument d;
|
||||
string p = s;
|
||||
while (s != null && (d = loader (s)) != null) {
|
||||
GetInterfaces (h, d, loader);
|
||||
s = GetEscapedPath (d, "Type/Base/BaseTypeName");
|
||||
if (p == s)
|
||||
break;
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (object o in h.Keys)
|
||||
yield return o.ToString ();
|
||||
}
|
||||
|
||||
private static string GetEscapedPath (XmlDocument d, string path)
|
||||
{
|
||||
XmlNode n = d.SelectSingleNode (path);
|
||||
if (n == null)
|
||||
return null;
|
||||
return "T:" + ToEscapedTypeName (n.InnerText);
|
||||
}
|
||||
|
||||
private static void GetInterfaces (Hashtable ifaces, XmlDocument doc, DocLoader loader)
|
||||
{
|
||||
foreach (XmlNode n in doc.SelectNodes ("Type/Interfaces/Interface/InterfaceName")) {
|
||||
string t = ToEscapedTypeName (n.InnerText);
|
||||
string tk = "T:" + t;
|
||||
if (!ifaces.ContainsKey (tk)) {
|
||||
ifaces.Add (tk, null);
|
||||
try {
|
||||
XmlDocument d = loader (t);
|
||||
if (d != null)
|
||||
GetInterfaces (ifaces, d, loader);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
// ignore; interface documentation couldn't be found.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Turns e.g. sources/netdocs into sources/cache/netdocs
|
||||
public static string GetCacheDirectory (string assembledBase)
|
||||
{
|
||||
return Path.Combine (
|
||||
Path.Combine (Path.GetDirectoryName (assembledBase), "cache"),
|
||||
Path.GetFileName (assembledBase));
|
||||
}
|
||||
|
||||
public static string GetCachedFileName (string cacheDir, string url)
|
||||
{
|
||||
return Path.Combine (cacheDir,
|
||||
Uri.EscapeUriString (url).Replace ('/', '+').Replace ("*", "%2a"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mono.Utilities
|
||||
{
|
||||
public class LRUCache<TKey, TValue>
|
||||
{
|
||||
[ThreadStatic]
|
||||
static LRUCache<TKey, TValue> deflt;
|
||||
|
||||
public static LRUCache<TKey, TValue> Default {
|
||||
get {
|
||||
return deflt != null ? deflt : (deflt = new LRUCache<TKey, TValue> (5));
|
||||
}
|
||||
}
|
||||
|
||||
int capacity;
|
||||
LinkedList<ListValueEntry<TKey, TValue>> list;
|
||||
Dictionary<TKey, LinkedListNode<ListValueEntry<TKey, TValue>>> lookup;
|
||||
LinkedListNode<ListValueEntry<TKey, TValue>> openNode;
|
||||
|
||||
public LRUCache (int capacity)
|
||||
{
|
||||
this.capacity = capacity;
|
||||
this.list = new LinkedList<ListValueEntry<TKey, TValue>>();
|
||||
this.lookup = new Dictionary<TKey, LinkedListNode<ListValueEntry<TKey, TValue>>> (capacity + 1);
|
||||
this.openNode = new LinkedListNode<ListValueEntry<TKey, TValue>>(new ListValueEntry<TKey, TValue> (default(TKey), default(TValue)));
|
||||
}
|
||||
|
||||
public void Put (TKey key, TValue value)
|
||||
{
|
||||
if (Get(key) == null) {
|
||||
this.openNode.Value.ItemKey = key;
|
||||
this.openNode.Value.ItemValue = value;
|
||||
this.list.AddFirst (this.openNode);
|
||||
this.lookup.Add (key, this.openNode);
|
||||
|
||||
if (this.list.Count > this.capacity) {
|
||||
// last node is to be removed and saved for the next addition to the cache
|
||||
this.openNode = this.list.Last;
|
||||
|
||||
// remove from list & dictionary
|
||||
this.list.RemoveLast();
|
||||
this.lookup.Remove(this.openNode.Value.ItemKey);
|
||||
} else {
|
||||
// still filling the cache, create a new open node for the next time
|
||||
this.openNode = new LinkedListNode<ListValueEntry<TKey, TValue>>(new ListValueEntry<TKey, TValue>(default(TKey), default(TValue)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TValue Get (TKey key)
|
||||
{
|
||||
LinkedListNode<ListValueEntry<TKey, TValue>> node = null;
|
||||
if (!this.lookup.TryGetValue (key, out node))
|
||||
return default (TValue);
|
||||
this.list.Remove (node);
|
||||
this.list.AddFirst (node);
|
||||
return node.Value.ItemValue;
|
||||
}
|
||||
|
||||
class ListValueEntry<K, V> where K : TKey
|
||||
where V : TValue
|
||||
{
|
||||
internal V ItemValue;
|
||||
internal K ItemKey;
|
||||
|
||||
internal ListValueEntry(K key, V value)
|
||||
{
|
||||
this.ItemKey = key;
|
||||
this.ItemValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mono.Utilities
|
||||
{
|
||||
public class LRUCache<TKey, TValue>
|
||||
{
|
||||
[ThreadStatic]
|
||||
static LRUCache<TKey, TValue> deflt;
|
||||
|
||||
public static LRUCache<TKey, TValue> Default {
|
||||
get {
|
||||
return deflt != null ? deflt : (deflt = new LRUCache<TKey, TValue> (5));
|
||||
}
|
||||
}
|
||||
|
||||
int capacity;
|
||||
LinkedList<ListValueEntry<TKey, TValue>> list;
|
||||
Dictionary<TKey, LinkedListNode<ListValueEntry<TKey, TValue>>> lookup;
|
||||
LinkedListNode<ListValueEntry<TKey, TValue>> openNode;
|
||||
|
||||
public LRUCache (int capacity)
|
||||
{
|
||||
this.capacity = capacity;
|
||||
this.list = new LinkedList<ListValueEntry<TKey, TValue>>();
|
||||
this.lookup = new Dictionary<TKey, LinkedListNode<ListValueEntry<TKey, TValue>>> (capacity + 1);
|
||||
this.openNode = new LinkedListNode<ListValueEntry<TKey, TValue>>(new ListValueEntry<TKey, TValue> (default(TKey), default(TValue)));
|
||||
}
|
||||
|
||||
public void Put (TKey key, TValue value)
|
||||
{
|
||||
if (Get(key) == null) {
|
||||
this.openNode.Value.Itemkey = key;
|
||||
this.openNode.Value.Itemvalue = value;
|
||||
this.list.AddFirst (this.openNode);
|
||||
this.lookup.Add (key, this.openNode);
|
||||
|
||||
if (this.list.Count > this.capacity) {
|
||||
// last node is to be removed and saved for the next addition to the cache
|
||||
this.openNode = this.list.Last;
|
||||
|
||||
// remove from list & dictionary
|
||||
this.list.RemoveLast();
|
||||
this.lookup.Remove(this.openNode.Value.Itemkey);
|
||||
} else {
|
||||
// still filling the cache, create a new open node for the next time
|
||||
this.openNode = new LinkedListNode<ListValueEntry<Tkey, Tvalue>>(new ListValueEntry<Tkey, Tvalue>(default(Tkey), default(Tvalue)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TValue Get (TKey key)
|
||||
{
|
||||
LinkedListNode<ListValueEntry<TKey, TValue>> node = null;
|
||||
if (!this.lookup.TryGetValue (key, out node))
|
||||
return default (TValue);
|
||||
this.list.Remove (node);
|
||||
this.list.AddFirst (node);
|
||||
return node.Value.ItemValue;
|
||||
}
|
||||
|
||||
class ListValueEntry<K, V> where K : TKey
|
||||
where V : TValue
|
||||
{
|
||||
internal V ItemValue;
|
||||
internal K ItemKey;
|
||||
|
||||
internal ListValueEntry(K key, V value)
|
||||
{
|
||||
this.ItemKey = key;
|
||||
this.ItemValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,171 +0,0 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Utilities {
|
||||
public class Colorizer {
|
||||
//
|
||||
// Syntax coloring
|
||||
//
|
||||
|
||||
static string keywords_cs =
|
||||
"(\\babstract\\b|\\bevent\\b|\\bnew\\b|\\bstruct\\b|\\bas\\b|\\bexplicit\\b|\\bnull\\b|\\bswitch\\b|\\bbase\\b|\\bextern\\b|"
|
||||
+
|
||||
"\\bobject\\b|\\bthis\\b|\\bbool\\b|\\bfalse\\b|\\boperator\\b|\\bthrow\\b|\\bbreak\\b|\\bfinally\\b|\\bout\\b|\\btrue\\b|"
|
||||
+
|
||||
"\\bbyte\\b|\\bfixed\\b|\\boverride\\b|\\btry\\b|\\bcase\\b|\\bfloat\\b|\\bparams\\b|\\btypeof\\b|\\bcatch\\b|\\bfor\\b|"
|
||||
+
|
||||
"\\bprivate\\b|\\buint\\b|\\bchar\\b|\\bforeach\\b|\\bprotected\\b|\\bulong\\b|\\bchecked\\b|\\bgoto\\b|\\bpublic\\b|"
|
||||
+
|
||||
"\\bunchecked\\b|\\bclass\\b|\\bif\\b|\\breadonly\\b|\\bunsafe\\b|\\bconst\\b|\\bimplicit\\b|\\bref\\b|\\bushort\\b|"
|
||||
+
|
||||
"\\bcontinue\\b|\\bin\\b|\\breturn\\b|\\busing\\b|\\bdecimal\\b|\\bint\\b|\\bsbyte\\b|\\bvirtual\\b|\\bdefault\\b|"
|
||||
+
|
||||
"\\binterface\\b|\\bsealed\\b|\\bvolatile\\b|\\bdelegate\\b|\\binternal\\b|\\bshort\\b|\\bvoid\\b|\\bdo\\b|\\bis\\b|"
|
||||
+
|
||||
"\\bsizeof\\b|\\bwhile\\b|\\bdouble\\b|\\block\\b|\\bstackalloc\\b|\\belse\\b|\\blong\\b|\\bstatic\\b|\\benum\\b|"
|
||||
+ "\\bnamespace\\b|\\bstring\\b)";
|
||||
|
||||
#if false
|
||||
// currently not in use
|
||||
static string keywords_vb =
|
||||
"(\\bAddHandler\\b|\\bAddressOf\\b|\\bAlias\\b|\\bAnd\\b|\\bAndAlso\\b|\\bAnsi\\b|\\bAs\\b|\\bAssembly\\b|"
|
||||
+
|
||||
"\\bAuto\\b|\\bBoolean\\b|\\bByRef\\b|\\bByte\\b|\\bByVal\\b|\\bCall\\b|\\bCase\\b|\\bCatch\\b|"
|
||||
+
|
||||
"\\bCBool\\b|\\bCByte\\b|\\bCChar\\b|\\bCDate\\b|\\bCDec\\b|\\bCDbl\\b|\\bChar\\b|\\bCInt\\b|"
|
||||
+
|
||||
"\\bClass\\b|\\bCLng\\b|\\bCObj\\b|\\bConst\\b|\\bCShort\\b|\\bCSng\\b|\\bCStr\\b|\\bCType\\b|"
|
||||
+
|
||||
"\\bDate\\b|\\bDecimal\\b|\\bDeclare\\b|\\bDefault\\b|\\bDelegate\\b|\\bDim\\b|\\bDirectCast\\b|\\bDo\\b|"
|
||||
+
|
||||
"\\bDouble\\b|\\bEach\\b|\\bElse\\b|\\bElseIf\\b|\\bEnd\\b|\\bEnum\\b|\\bErase\\b|\\bError\\b|"
|
||||
+
|
||||
"\\bEvent\\b|\\bExit\\b|\\bFalse\\b|\\bFinally\\b|\\bFor\\b|\\bFriend\\b|\\bFunction\\b|\\bGet\\b|"
|
||||
+
|
||||
"\\bGetType\\b|\\bGoSub\\b|\\bGoTo\\b|\\bHandles\\b|\\bIf\\b|\\bImplements\\b|\\bImports\\b|\\bIn\\b|"
|
||||
+
|
||||
"\\bInherits\\b|\\bInteger\\b|\\bInterface\\b|\\bIs\\b|\\bLet\\b|\\bLib\\b|\\bLike\\b|\\bLong\\b|"
|
||||
+
|
||||
"\\bLoop\\b|\\bMe\\b|\\bMod\\b|\\bModule\\b|\\bMustInherit\\b|\\bMustOverride\\b|\\bMyBase\\b|\\bMyClass\\b|"
|
||||
+
|
||||
"\\bNamespace\\b|\\bNew\\b|\\bNext\\b|\\bNot\\b|\\bNothing\\b|\\bNotInheritable\\b|\\bNotOverridable\\b|\\bObject\\b|"
|
||||
+
|
||||
"\\bOn\\b|\\bOption\\b|\\bOptional\\b|\\bOr\\b|\\bOrElse\\b|\\bOverloads\\b|\\bOverridable\\b|\\bOverrides\\b|"
|
||||
+
|
||||
"\\bParamArray\\b|\\bPreserve\\b|\\bPrivate\\b|\\bProperty\\b|\\bProtected\\b|\\bPublic\\b|\\bRaiseEvent\\b|\\bReadOnly\\b|"
|
||||
+
|
||||
"\\bReDim\\b|\\bREM\\b|\\bRemoveHandler\\b|\\bResume\\b|\\bReturn\\b|\\bSelect\\b|\\bSet\\b|\\bShadows\\b|"
|
||||
+
|
||||
"\\bShared\\b|\\bShort\\b|\\bSingle\\b|\\bStatic\\b|\\bStep\\b|\\bStop\\b|\\bString\\b|\\bStructure\\b|"
|
||||
+
|
||||
"\\bSub\\b|\\bSyncLock\\b|\\bThen\\b|\\bThrow\\b|\\bTo\\b|\\bTrue\\b|\\bTry\\b|\\bTypeOf\\b|"
|
||||
+
|
||||
"\\bUnicode\\b|\\bUntil\\b|\\bVariant\\b|\\bWhen\\b|\\bWhile\\b|\\bWith\\b|\\bWithEvents\\b|\\bWriteOnly\\b|\\bXor\\b)";
|
||||
#endif
|
||||
|
||||
public static string Colorize(string text, string lang)
|
||||
{
|
||||
lang = lang.Trim().ToLower();
|
||||
switch (lang) {
|
||||
case "xml":
|
||||
return ColorizeXml(text);
|
||||
case "cs": case "c#": case "csharp":
|
||||
return ColorizeCs(text);
|
||||
case "vb":
|
||||
return ColorizeVb(text);
|
||||
}
|
||||
return Escape (text);
|
||||
}
|
||||
|
||||
static string ColorizeXml(string text)
|
||||
{
|
||||
// Order is highly important.
|
||||
|
||||
// s/ / /g must be first, as later substitutions add required spaces
|
||||
text = text.Replace(" ", " ");
|
||||
|
||||
// Find & mark XML elements
|
||||
Regex re = new Regex("<\\s*(\\/?)\\s*([\\s\\S]*?)\\s*(\\/?)\\s*>");
|
||||
text = re.Replace(text, "{blue:<$1}{maroon:$2}{blue:$3>}");
|
||||
|
||||
// Colorize attribute strings; must be done before colorizing marked XML
|
||||
// elements so that we don't clobber the colorized XML tags.
|
||||
re = new Regex ("([\"'])(.*?)\\1");
|
||||
text = re.Replace (text,
|
||||
"$1<font color=\"purple\">$2</font>$1");
|
||||
|
||||
// Colorize marked XML elements
|
||||
re = new Regex("\\{(\\w*):([\\s\\S]*?)\\}");
|
||||
//text = re.Replace(text, "<span style='color:$1'>$2</span>");
|
||||
text = re.Replace(text, "<font color=\"$1\">$2</font>");
|
||||
|
||||
// Standard Structure
|
||||
text = text.Replace("\t", " ");
|
||||
re = new Regex("\r\n|\r|\n");
|
||||
text = re.Replace(text, "<br/>");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
static string ColorizeCs(string text)
|
||||
{
|
||||
text = text.Replace(" ", " ");
|
||||
|
||||
text = text.Replace("<", "<");
|
||||
text = text.Replace(">", ">");
|
||||
|
||||
Regex re = new Regex("\"((((?!\").)|\\\")*?)\"");
|
||||
|
||||
text =
|
||||
re.Replace(text,
|
||||
"<font color=\"purple\">\"$1\"</font>");
|
||||
//"<span style='color:purple'>\"$1\"</span>");
|
||||
|
||||
re = new
|
||||
Regex
|
||||
("//(((.(?!\"</font>))|\"(((?!\").)*)\"</font>)*)(\r|\n|\r\n)");
|
||||
//("//(((.(?!\"</span>))|\"(((?!\").)*)\"</span>)*)(\r|\n|\r\n)");
|
||||
text =
|
||||
re.Replace(text,
|
||||
"<font color=\"green\">//$1</font><br/>");
|
||||
// "<span style='color:green'>//$1</span><br/>");
|
||||
|
||||
re = new Regex(keywords_cs);
|
||||
text = re.Replace(text, "<font color=\"blue\">$1</font>");
|
||||
//text = re.Replace(text, "<span style='color:blue'>$1</span>");
|
||||
|
||||
text = text.Replace("\t", " ");
|
||||
text = text.Replace("\n", "<br/>");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
static string ColorizeVb(string text) {
|
||||
text = text.Replace(" ", " ");
|
||||
|
||||
/* Regex re = new Regex ("\"((((?!\").)|\\\")*?)\"");
|
||||
text = re.Replace (text,"<span style='color:purple'>\"$1\"</span>");
|
||||
|
||||
re = new Regex ("'(((.(?!\"\\<\\/span\\>))|\"(((?!\").)*)\"\\<\\/span\\>)*)(\r|\n|\r\n)");
|
||||
text = re.Replace (text,"<span style='color:green'>//$1</span><br/>");
|
||||
|
||||
re = new Regex (keywords_vb);
|
||||
text = re.Replace (text,"<span style='color:blue'>$1</span>");
|
||||
*/
|
||||
text = text.Replace("\t", " ");
|
||||
text = text.Replace("\n", "<br/>");
|
||||
return text;
|
||||
}
|
||||
|
||||
static string Escape(string text)
|
||||
{
|
||||
text = text.Replace("&", "&");
|
||||
text = text.Replace(" ", " ");
|
||||
text = text.Replace("<", "<");
|
||||
text = text.Replace(">", ">");
|
||||
text = text.Replace("\n", "<br/>");
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1 +0,0 @@
|
||||
/EcmaUrlParser.cs
|
@@ -1,419 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Ecma
|
||||
{
|
||||
/* Some properties might not be filled/meaningful depending on kind
|
||||
* like a namespace EcmaUrl won't have a valid TypeName
|
||||
*/
|
||||
public class EcmaDesc : IEquatable<EcmaDesc>
|
||||
{
|
||||
public enum Kind
|
||||
{
|
||||
Type,
|
||||
Constructor,
|
||||
Method,
|
||||
Namespace,
|
||||
Field,
|
||||
Property,
|
||||
Event,
|
||||
Operator
|
||||
}
|
||||
|
||||
public enum Mod
|
||||
{
|
||||
Normal,
|
||||
Pointer,
|
||||
Ref,
|
||||
Out
|
||||
}
|
||||
|
||||
public enum Format
|
||||
{
|
||||
WithArgs,
|
||||
WithoutArgs
|
||||
}
|
||||
|
||||
public Kind DescKind {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Mod DescModifier {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Namespace {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string TypeName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string MemberName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public EcmaDesc NestedType {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* A list of the array dimensions attached to this type.
|
||||
* The list count corresponds to the number of recursive
|
||||
* array definition (jagged arrays) the value of the
|
||||
* corresponding list item is the number of dimension
|
||||
* attached to that array definition instance
|
||||
*/
|
||||
public IList<int> ArrayDimensions {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* Depending on the form of the url, we might not have the type
|
||||
* of the argument but only how many the type/member has i.e.
|
||||
* when such number is specified with a backtick
|
||||
*/
|
||||
public IList<EcmaDesc> GenericTypeArguments {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* The GenericTypeArguments list may be null, in which case, this
|
||||
* is an easier/safer way to check the count.
|
||||
*/
|
||||
public int GenericTypeArgumentsCount {
|
||||
get { return GenericTypeArguments != null ? GenericTypeArguments.Count : 0; }
|
||||
}
|
||||
|
||||
/* This property tells if the above collections only correct value
|
||||
* is the number of item in it to represent generic arguments
|
||||
*/
|
||||
public bool GenericTypeArgumentsIsNumeric {
|
||||
get {
|
||||
return GenericTypeArguments != null && GenericTypeArguments.FirstOrDefault () == null;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<EcmaDesc> GenericMemberArguments {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* The GenericMemberArguments list may be null, in which case, this
|
||||
* is an easier/safer way to check the count.
|
||||
*/
|
||||
public int GenericMemberArgumentsCount {
|
||||
get { return GenericMemberArguments != null ? GenericMemberArguments.Count : 0; }
|
||||
}
|
||||
|
||||
public bool GenericMemberArgumentsIsNumeric {
|
||||
get {
|
||||
return GenericMemberArguments != null && GenericMemberArguments.FirstOrDefault () == null;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<EcmaDesc> MemberArguments {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* The GenericTypeArguments list may be null, in which case, this
|
||||
* is an easier/safer way to check the count.
|
||||
*/
|
||||
public int MemberArgumentsCount {
|
||||
get { return MemberArguments != null ? MemberArguments.Count : 0; }
|
||||
}
|
||||
|
||||
/* This indicates that we actually want an inner part of the ecmadesc
|
||||
* i.e. in case of T: we could want the members (*), ctor (C), methods (M), ...
|
||||
*/
|
||||
public char Etc {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool IsEtc {
|
||||
get {
|
||||
return Etc != (char)0;
|
||||
}
|
||||
}
|
||||
|
||||
/* EtcFilter is only valid in some case of IsEtc when the inner part needs
|
||||
* to be further filtered e.g. in case we want a listing of the type overloads
|
||||
* Equals
|
||||
*/
|
||||
public string EtcFilter {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/* When a member is an explicit implementation of an interface member, we register
|
||||
* the member EcmaDesc with its interface parent here
|
||||
*/
|
||||
public EcmaDesc ExplicitImplMember {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// Returns the TypeName and the generic/inner type information if existing
|
||||
public string ToCompleteTypeName (char innerTypeSeparator = '.')
|
||||
{
|
||||
var result = TypeName;
|
||||
if (GenericTypeArguments != null)
|
||||
result += FormatGenericArgs (GenericTypeArguments);
|
||||
if (NestedType != null)
|
||||
result += innerTypeSeparator + NestedType.ToCompleteTypeName ();
|
||||
if (ArrayDimensions != null && ArrayDimensions.Count > 0)
|
||||
result += ArrayDimensions.Select (dim => "[" + new string (',', dim - 1) + "]").Aggregate (string.Concat);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns the member name with its generic types if existing
|
||||
public string ToCompleteMemberName (Format format)
|
||||
{
|
||||
/* We special process two cases:
|
||||
* - Explicit member implementation which append a full type specification
|
||||
* - Conversion operator which are exposed as normal method but have specific captioning in the end
|
||||
*/
|
||||
if (ExplicitImplMember != null) {
|
||||
var impl = ExplicitImplMember;
|
||||
return impl.FormattedNamespace + impl.ToCompleteTypeName () + "." + impl.ToCompleteMemberName (format);
|
||||
} else if (format == Format.WithArgs && DescKind == Kind.Operator && MemberName.EndsWith ("Conversion")) {
|
||||
var type1 = MemberArguments[0].FormattedNamespace + MemberArguments[0].ToCompleteTypeName () + ModToString (MemberArguments[0]);
|
||||
var type2 = MemberArguments[1].FormattedNamespace + MemberArguments[1].ToCompleteTypeName () + ModToString (MemberArguments[1]);
|
||||
return type1 + " to " + type2;
|
||||
}
|
||||
|
||||
var result = IsEtc && !string.IsNullOrEmpty (EtcFilter) ? EtcFilter : MemberName;
|
||||
|
||||
// Temporary hack for monodoc produced inner type ctor
|
||||
//if (DescKind == Kind.Constructor && NestedType != null)
|
||||
//result = ToCompleteTypeName ();
|
||||
|
||||
if (GenericMemberArguments != null)
|
||||
result += FormatGenericArgs (GenericMemberArguments);
|
||||
|
||||
if (format == Format.WithArgs) {
|
||||
result += '(';
|
||||
if (MemberArguments != null && MemberArguments.Count > 0) {
|
||||
var args = MemberArguments.Select (a => FormatNamespace (a) + a.ToCompleteTypeName ('+') + ModToString (a));
|
||||
result += string.Join (",", args);
|
||||
}
|
||||
result += ')';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public string ToEcmaCref ()
|
||||
{
|
||||
var sb = new StringBuilder ();
|
||||
// Cref type
|
||||
sb.Append (DescKind.ToString ()[0]);
|
||||
sb.Append (":");
|
||||
// Create the rest
|
||||
ConstructCRef (sb);
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
void ConstructCRef (StringBuilder sb, bool skipLeadingDot = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty (Namespace))
|
||||
skipLeadingDot = true;
|
||||
|
||||
sb.Append (Namespace);
|
||||
if (DescKind == Kind.Namespace)
|
||||
return;
|
||||
|
||||
if (!skipLeadingDot)
|
||||
sb.Append ('.');
|
||||
|
||||
sb.Append (TypeName);
|
||||
AppendGenericArguments (sb, GenericTypeArguments, GenericTypeArgumentsIsNumeric, GenericTypeArgumentsCount);
|
||||
|
||||
if (NestedType != null) {
|
||||
sb.Append ('+');
|
||||
NestedType.ConstructCRef (sb, skipLeadingDot: true);
|
||||
}
|
||||
if (ArrayDimensions != null && ArrayDimensions.Count > 0) {
|
||||
for (int i = 0; i < ArrayDimensions.Count; i++) {
|
||||
sb.Append ('[');
|
||||
sb.Append (new string (',', ArrayDimensions[i] - 1));
|
||||
sb.Append (']');
|
||||
}
|
||||
}
|
||||
if (DescKind == Kind.Type)
|
||||
return;
|
||||
|
||||
if (ExplicitImplMember != null) {
|
||||
sb.Append ('$');
|
||||
ExplicitImplMember.DescKind = this.DescKind;
|
||||
ExplicitImplMember.ConstructCRef (sb, skipLeadingDot: false);
|
||||
return;
|
||||
}
|
||||
|
||||
sb.Append (".");
|
||||
sb.Append (MemberName);
|
||||
|
||||
AppendGenericArguments (sb, GenericMemberArguments, GenericMemberArgumentsIsNumeric, GenericMemberArgumentsCount);
|
||||
|
||||
if (MemberArguments != null && MemberArgumentsCount > 0) {
|
||||
sb.Append ("(");
|
||||
int i=0;
|
||||
foreach (var a in MemberArguments) {
|
||||
if (i > 0) {
|
||||
sb.Append(",");
|
||||
}
|
||||
a.ConstructCRef (sb);
|
||||
i++;
|
||||
}
|
||||
sb.Append (")");
|
||||
}
|
||||
}
|
||||
|
||||
void AppendGenericArguments (StringBuilder sb, IEnumerable<EcmaDesc> arguments, bool isNumeric, int argumentsCount)
|
||||
{
|
||||
if (arguments != null && isNumeric) {
|
||||
sb.AppendFormat ("`{0}", argumentsCount);
|
||||
} else if (arguments != null) {
|
||||
sb.Append ('<');
|
||||
int i=0;
|
||||
foreach (var t in arguments) {
|
||||
if (i > 0) {
|
||||
sb.Append (",");
|
||||
}
|
||||
t.ConstructCRef (sb);
|
||||
|
||||
i++;
|
||||
}
|
||||
sb.Append ('>');
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9} {10}",
|
||||
Namespace,
|
||||
TypeName,
|
||||
FormatGenericArgsFull (GenericTypeArguments),
|
||||
NestedType != null ? "+" + NestedType.ToString () : string.Empty,
|
||||
MemberName ?? string.Empty,
|
||||
FormatGenericArgsFull (GenericMemberArguments),
|
||||
MemberArguments != null ? "(" + string.Join (",", MemberArguments.Select (m => m.ToString ())) + ")" : string.Empty,
|
||||
ArrayDimensions != null && ArrayDimensions.Count > 0 ? ArrayDimensions.Select (dim => "[" + new string (',', dim - 1) + "]").Aggregate (string.Concat) : string.Empty,
|
||||
DescKind.ToString ()[0],
|
||||
Etc != 0 ? '(' + Etc.ToString () + ')' : string.Empty,
|
||||
ExplicitImplMember != null ? "$" + ExplicitImplMember.ToString () : string.Empty);
|
||||
|
||||
}
|
||||
|
||||
public override bool Equals (object other)
|
||||
{
|
||||
var otherDesc = other as EcmaDesc;
|
||||
return otherDesc != null && Equals (otherDesc);
|
||||
}
|
||||
|
||||
public bool Equals (EcmaDesc other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
if (NestedType == null ^ other.NestedType == null
|
||||
|| ArrayDimensions == null ^ other.ArrayDimensions == null
|
||||
|| GenericTypeArguments == null ^ other.GenericTypeArguments == null
|
||||
|| GenericMemberArguments == null ^ other.GenericMemberArguments == null
|
||||
|| MemberArguments == null ^ other.MemberArguments == null
|
||||
|| ExplicitImplMember == null ^ other.ExplicitImplMember == null)
|
||||
return false;
|
||||
|
||||
return other != null
|
||||
&& DescKind == other.DescKind
|
||||
&& TypeName == other.TypeName
|
||||
&& Namespace == other.Namespace
|
||||
&& MemberName == other.MemberName
|
||||
&& (NestedType == null || NestedType.Equals (other.NestedType))
|
||||
&& (ArrayDimensions == null || ArrayDimensions.SequenceEqual (other.ArrayDimensions))
|
||||
&& (GenericTypeArguments == null || GenericTypeArguments.SequenceEqual (other.GenericTypeArguments))
|
||||
&& (GenericMemberArguments == null || GenericMemberArguments.SequenceEqual (other.GenericMemberArguments))
|
||||
&& (MemberArguments == null || MemberArguments.SequenceEqual (other.MemberArguments))
|
||||
&& Etc == other.Etc
|
||||
&& EtcFilter == other.EtcFilter
|
||||
&& (ExplicitImplMember == null || ExplicitImplMember.Equals (other.ExplicitImplMember));
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return DescKind.GetHashCode ()
|
||||
^ TypeName.GetHashCode ()
|
||||
^ Namespace.GetHashCode ()
|
||||
^ MemberName.GetHashCode ();
|
||||
}
|
||||
|
||||
bool What (bool input)
|
||||
{
|
||||
if (!input)
|
||||
throw new Exception ("Not equal");
|
||||
return input;
|
||||
}
|
||||
|
||||
bool WhatT (bool input)
|
||||
{
|
||||
if (input)
|
||||
throw new Exception ("Not equal");
|
||||
return input;
|
||||
}
|
||||
|
||||
string FormatNamespace (EcmaDesc desc)
|
||||
{
|
||||
return string.IsNullOrEmpty (desc.Namespace) ? string.Empty : desc.Namespace + ".";
|
||||
}
|
||||
|
||||
string FormatGenericArgs (IEnumerable<EcmaDesc> args)
|
||||
{
|
||||
if (args == null || !args.Any ())
|
||||
return string.Empty;
|
||||
// If we only have the number of generic arguments, use ` notation
|
||||
if (args.First () == null)
|
||||
return "`" + args.Count ();
|
||||
|
||||
IEnumerable<string> argsList = args.Select (t => FormatNamespace (t) + t.ToCompleteTypeName ());
|
||||
|
||||
return "<" + string.Join (",", argsList) + ">";
|
||||
}
|
||||
|
||||
string FormatGenericArgsFull (IEnumerable<EcmaDesc> genericArgs)
|
||||
{
|
||||
return genericArgs != null ? "<" + string.Join (",", genericArgs.Select (t => t.ToString ())) + ">" : string.Empty;
|
||||
}
|
||||
|
||||
string ModToString (EcmaDesc desc)
|
||||
{
|
||||
switch (desc.DescModifier) {
|
||||
case Mod.Pointer:
|
||||
return "*";
|
||||
case Mod.Ref:
|
||||
return "&";
|
||||
case Mod.Out:
|
||||
return "@";
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
string FormattedNamespace {
|
||||
get {
|
||||
return !string.IsNullOrEmpty (Namespace) ? Namespace + "." : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,263 +0,0 @@
|
||||
%{
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Ecma
|
||||
{
|
||||
public class EcmaUrlParser
|
||||
{
|
||||
int yacc_verbose_flag = 0;
|
||||
|
||||
public void IsValid (string input)
|
||||
{
|
||||
var lexer = new EcmaUrlTokenizer (input);
|
||||
this.yyparse (lexer);
|
||||
}
|
||||
|
||||
public EcmaDesc Parse (string input)
|
||||
{
|
||||
var lexer = new EcmaUrlTokenizer (input);
|
||||
return (EcmaDesc)this.yyparse (lexer);
|
||||
}
|
||||
|
||||
public bool TryParse (string input, out EcmaDesc desc)
|
||||
{
|
||||
desc = null;
|
||||
try {
|
||||
desc = Parse (input);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
EcmaDesc SetEcmaDescType (object result, EcmaDesc.Kind kind)
|
||||
{
|
||||
var desc = result as EcmaDesc;
|
||||
desc.DescKind = kind;
|
||||
return desc;
|
||||
}
|
||||
|
||||
List<T> SafeReverse<T> (List<T> input)
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
input.Reverse ();
|
||||
return input;
|
||||
}
|
||||
%}
|
||||
|
||||
%token ERROR
|
||||
%token IDENTIFIER
|
||||
%token DIGIT
|
||||
%token DOT
|
||||
%token COMMA
|
||||
%token COLON
|
||||
%token INNER_TYPE_SEPARATOR
|
||||
%token OP_GENERICS_LT
|
||||
%token OP_GENERICS_GT
|
||||
%token OP_GENERICS_BACKTICK
|
||||
%token OP_OPEN_PAREN
|
||||
%token OP_CLOSE_PAREN
|
||||
%token OP_ARRAY_OPEN
|
||||
%token OP_ARRAY_CLOSE
|
||||
%token SLASH_SEPARATOR
|
||||
%token STAR
|
||||
%token REF_ARG
|
||||
%token OUT_ARG
|
||||
%token EXPLICIT_IMPL_SEP
|
||||
|
||||
%start expression
|
||||
|
||||
%%
|
||||
|
||||
expression
|
||||
: 'T' COLON type_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Type); }
|
||||
| 'N' COLON namespace_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Namespace); }
|
||||
| 'M' COLON method_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Method); }
|
||||
| 'F' COLON simple_member_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Field); }
|
||||
| 'C' COLON constructor_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Constructor); }
|
||||
| 'P' COLON property_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Property); }
|
||||
| 'E' COLON simple_member_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Event); }
|
||||
| 'O' COLON operator_expression { $$ = SetEcmaDescType ($3, EcmaDesc.Kind.Operator); }
|
||||
|
||||
/* i.e. id.id.id or id */
|
||||
dot_expression
|
||||
: IDENTIFIER { $$ = new List<string> { (string)$1 }; }
|
||||
| IDENTIFIER DOT dot_expression { ((ICollection<string>)$3).Add ((string)$1); $$ = $3; }
|
||||
|
||||
namespace_expression
|
||||
: dot_expression { $$ = new EcmaDesc { Namespace = string.Join (".", ((IEnumerable<string>)$1).Reverse ()) }; }
|
||||
|
||||
type_expression
|
||||
: dot_expression type_expression_suffix {
|
||||
var dotExpr = ((List<string>)$1);
|
||||
dotExpr.Reverse ();
|
||||
var desc = $2 as EcmaDesc;
|
||||
desc.DescKind = EcmaDesc.Kind.Type;
|
||||
desc.Namespace = string.Join (".", dotExpr.Take (dotExpr.Count - 1));
|
||||
desc.TypeName = dotExpr.Last ();
|
||||
$$ = desc;
|
||||
}
|
||||
|
||||
/* To be used in types with no namespaces attached to them like an inner type*/
|
||||
reduced_type_expression
|
||||
: IDENTIFIER type_expression_suffix {
|
||||
var desc = $2 as EcmaDesc;
|
||||
desc.DescKind = EcmaDesc.Kind.Type;
|
||||
desc.TypeName = $1 as string;
|
||||
$$ = desc;
|
||||
}
|
||||
|
||||
type_expression_suffix
|
||||
: opt_generic_type_suffix opt_inner_type_description opt_array_definition opt_etc {
|
||||
bool nestedDescHasEtc = $2 != null && ((EcmaDesc)$2).IsEtc;
|
||||
EcmaDesc nestedType = (EcmaDesc)$2;
|
||||
$$ = new EcmaDesc {
|
||||
GenericTypeArguments = $1 as List<EcmaDesc>,
|
||||
NestedType = nestedType,
|
||||
ArrayDimensions = SafeReverse ($3 as List<int>),
|
||||
Etc = $4 != null ? ((Tuple<char, string>)$4).Item1 : nestedDescHasEtc ? nestedType.Etc : (char)0,
|
||||
EtcFilter = $4 != null ? ((Tuple<char, string>)$4).Item2 : nestedDescHasEtc ? nestedType.EtcFilter : null
|
||||
};
|
||||
if (nestedDescHasEtc) {
|
||||
nestedType.Etc = (char)0;
|
||||
nestedType.EtcFilter = null;
|
||||
}
|
||||
}
|
||||
|
||||
opt_inner_type_description
|
||||
: /* empty */ { $$ = null; }
|
||||
| INNER_TYPE_SEPARATOR reduced_type_expression { $$ = $2; }
|
||||
|
||||
opt_generic_type_suffix
|
||||
: /* empty */ { $$ = null; }
|
||||
| OP_GENERICS_BACKTICK DIGIT { $$ = Enumerable.Repeat<EcmaDesc> (null, (int)$2).ToList (); }
|
||||
| OP_GENERICS_LT generic_type_arg_list OP_GENERICS_GT { $$ = $2; }
|
||||
|
||||
generic_type_arg_list
|
||||
: type_expression { $$ = new List<EcmaDesc> () { (EcmaDesc)$1 }; }
|
||||
| generic_type_arg_list COMMA type_expression { ((List<EcmaDesc>)$1).Add ((EcmaDesc)$3); $$ = $1; }
|
||||
|
||||
opt_array_definition
|
||||
: /* empty */ { $$ = null; }
|
||||
| OP_ARRAY_OPEN opt_array_definition_list OP_ARRAY_CLOSE opt_array_definition {
|
||||
var dims = ((IList<int>)$4) ?? new List<int> (2);
|
||||
dims.Add ((int)$2);
|
||||
$$ = dims;
|
||||
}
|
||||
|
||||
opt_array_definition_list
|
||||
: /* empty */ { $$ = 1; }
|
||||
| COMMA opt_array_definition_list { $$ = ((int)$2) + 1; }
|
||||
|
||||
opt_etc
|
||||
: /* empty */ { $$ = null; }
|
||||
| SLASH_SEPARATOR etc_identifier { $$ = Tuple.Create<char, string> (((string)$2)[0], null); }
|
||||
| SLASH_SEPARATOR etc_identifier SLASH_SEPARATOR reduced_member_expression { $$ = Tuple.Create<char, string> (((string)$2)[0], (string)$4); }
|
||||
/* | SLASH_SEPARATOR etc_identifier SLASH_SEPARATOR IDENTIFIER opt_generic_type_suffix { $$ = Tuple.Create<char, string> (((string)$2)[0], (string)$4 + ($5 == null ? string.Empty : "<" + string.Join (",", ((IEnumerable<EcmaDesc>)$5).Select (t => t.ToCompleteTypeName ())) + ">")); } */
|
||||
|
||||
etc_identifier
|
||||
: STAR { $$ = "*"; }
|
||||
| IDENTIFIER { $$ = $1; }
|
||||
|
||||
method_expression
|
||||
: type_expression DOT IDENTIFIER opt_generic_type_suffix opt_arg_list_suffix {
|
||||
var desc = $1 as EcmaDesc;
|
||||
desc.MemberName = $3 as string;
|
||||
desc.GenericMemberArguments = $4 as List<EcmaDesc>;
|
||||
desc.MemberArguments = SafeReverse ($5 as List<EcmaDesc>);
|
||||
$$ = desc;
|
||||
}
|
||||
| dot_expression opt_generic_type_suffix opt_arg_list_suffix {
|
||||
var dotExpr = ((List<string>)$1);
|
||||
$$ = new EcmaDesc {
|
||||
Namespace = string.Join (".", dotExpr.Skip (2).DefaultIfEmpty (string.Empty).Reverse ()),
|
||||
TypeName = dotExpr.Skip (1).First (),
|
||||
MemberName = dotExpr.First (),
|
||||
GenericMemberArguments = $2 as List<EcmaDesc>,
|
||||
MemberArguments = SafeReverse ($3 as List<EcmaDesc>)
|
||||
};
|
||||
}
|
||||
| type_expression EXPLICIT_IMPL_SEP method_expression {
|
||||
var desc = $1 as EcmaDesc;
|
||||
desc.ExplicitImplMember = $3 as EcmaDesc;
|
||||
$$ = desc;
|
||||
}
|
||||
|
||||
/* To be used with members that may have no type/namespace attached */
|
||||
reduced_member_expression
|
||||
: IDENTIFIER opt_generic_type_suffix { $$ = (string)$1 + ($2 == null ? string.Empty : "<" + string.Join (",", ((IEnumerable<EcmaDesc>)$2).Select (t => t.ToCompleteTypeName ())) + ">"); }
|
||||
| IDENTIFIER opt_generic_type_suffix DOT reduced_member_expression {
|
||||
var existing = $4 as string;
|
||||
var expr = (string)$1 + ($2 == null ? string.Empty : "<" + string.Join (",", ((IEnumerable<EcmaDesc>)$2).Select (t => t.ToCompleteTypeName ())) + ">");
|
||||
$$ = expr + "." + existing;
|
||||
}
|
||||
|
||||
arg_type_expression
|
||||
: type_expression opt_arg_type_suffix { var desc = (EcmaDesc)$1; desc.DescModifier = (EcmaDesc.Mod)$2; $$ = desc; }
|
||||
|
||||
opt_arg_type_suffix
|
||||
: /* empty */ { $$ = EcmaDesc.Mod.Normal; }
|
||||
| STAR { $$ = EcmaDesc.Mod.Pointer; }
|
||||
| REF_ARG { $$ = EcmaDesc.Mod.Ref; }
|
||||
| OUT_ARG { $$ = EcmaDesc.Mod.Out; }
|
||||
|
||||
type_expression_list
|
||||
: /* empty */ { $$ = null; }
|
||||
| arg_type_expression { $$ = new List<EcmaDesc> () { (EcmaDesc)$1 }; }
|
||||
| arg_type_expression COMMA type_expression_list { ((List<EcmaDesc>)$3).Add ((EcmaDesc)$1); $$ = $3; }
|
||||
|
||||
simple_member_expression
|
||||
: dot_expression {
|
||||
var dotExpr = ((List<string>)$1);
|
||||
dotExpr.Reverse ();
|
||||
|
||||
$$ = new EcmaDesc {
|
||||
Namespace = dotExpr.Count > 2 ? string.Join (".", dotExpr.Take (dotExpr.Count - 2)) : string.Empty,
|
||||
TypeName = dotExpr.Count > 1 ? dotExpr[dotExpr.Count - 2] : string.Empty,
|
||||
MemberName = dotExpr[dotExpr.Count - 1]
|
||||
};
|
||||
}
|
||||
| type_expression DOT IDENTIFIER {
|
||||
var desc = $1 as EcmaDesc;
|
||||
desc.MemberName = $3 as string;
|
||||
$$ = desc;
|
||||
}
|
||||
| type_expression EXPLICIT_IMPL_SEP simple_member_expression {
|
||||
var desc = $1 as EcmaDesc;
|
||||
desc.ExplicitImplMember = $3 as EcmaDesc;
|
||||
$$ = desc;
|
||||
}
|
||||
|
||||
constructor_expression
|
||||
: method_expression { $$ = $1; }
|
||||
|
||||
operator_expression
|
||||
: method_expression { $$ = $1; }
|
||||
|
||||
property_expression
|
||||
: simple_member_expression opt_property_indexer {
|
||||
var desc = $1 as EcmaDesc;
|
||||
(desc.ExplicitImplMember ?? desc).MemberArguments = SafeReverse ($2 as List<EcmaDesc>);
|
||||
$$ = desc;
|
||||
}
|
||||
|
||||
opt_property_indexer
|
||||
: opt_arg_list_suffix { $$ = $1; }
|
||||
|
||||
/*simple_member_expression opt_arg_list_suffix { $$ = CopyFromEcmaDesc (new EcmaDesc {
|
||||
MemberArguments = SafeReverse ($2 as List<EcmaDesc>)
|
||||
}, (EcmaDesc)$1);
|
||||
}*/
|
||||
|
||||
opt_arg_list_suffix
|
||||
: /* empty */ { $$ = null; }
|
||||
| OP_OPEN_PAREN type_expression_list OP_CLOSE_PAREN { $$ = $2; }
|
||||
|
||||
%%
|
||||
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Monodoc.Ecma
|
||||
{
|
||||
public class EcmaUrlParserDriver
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
var input = new StringReader (args[0]);
|
||||
var lexer = new EcmaUrlTokenizer (input);
|
||||
var parser = new EcmaUrlParser ();
|
||||
|
||||
Console.WriteLine (parser.yyparse (lexer));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,171 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Monodoc.Ecma
|
||||
{
|
||||
public class EcmaUrlTokenizer : yyParser.yyInput
|
||||
{
|
||||
const char EndOfStream = (char)0;
|
||||
string input;
|
||||
object val;
|
||||
int current_token;
|
||||
int current_pos;
|
||||
int real_current_pos;
|
||||
int identCount = 0;
|
||||
|
||||
public EcmaUrlTokenizer (string input)
|
||||
{
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
static bool is_identifier_start_character (char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || Char.IsLetter (c);
|
||||
}
|
||||
|
||||
static bool is_identifier_part_character (char c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return true;
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return true;
|
||||
|
||||
if (c == '_' || (c >= '0' && c <= '9'))
|
||||
return true;
|
||||
|
||||
if (c < 0x80)
|
||||
return false;
|
||||
|
||||
return Char.IsLetter (c) || Char.GetUnicodeCategory (c) == UnicodeCategory.ConnectorPunctuation;
|
||||
}
|
||||
|
||||
public bool advance ()
|
||||
{
|
||||
return Peek () != EndOfStream;
|
||||
}
|
||||
|
||||
public Object Value {
|
||||
get {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
public Object value ()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
public int token ()
|
||||
{
|
||||
int token = xtoken ();
|
||||
//Console.WriteLine ("Current token {0} with value {1}", token, val == null ? "(none)" : val.ToString ());
|
||||
if (token == Token.ERROR) {
|
||||
throw new Exception (string.Format ("Error at position {0} parsing url '{0}'", current_pos, input));
|
||||
}
|
||||
current_token = token;
|
||||
return token;
|
||||
}
|
||||
|
||||
int xtoken ()
|
||||
{
|
||||
char next = Read ();
|
||||
while (char.IsWhiteSpace (next))
|
||||
next = Read ();
|
||||
current_pos++;
|
||||
val = null;
|
||||
|
||||
switch (next) {
|
||||
case ',':
|
||||
return Token.COMMA;
|
||||
case '.':
|
||||
return Token.DOT;
|
||||
case '{':
|
||||
case '<':
|
||||
return Token.OP_GENERICS_LT;
|
||||
case '}':
|
||||
case '>':
|
||||
return Token.OP_GENERICS_GT;
|
||||
case '`':
|
||||
return Token.OP_GENERICS_BACKTICK;
|
||||
case '(':
|
||||
return Token.OP_OPEN_PAREN;
|
||||
case ')':
|
||||
return Token.OP_CLOSE_PAREN;
|
||||
case '+':
|
||||
return Token.INNER_TYPE_SEPARATOR;
|
||||
case ':':
|
||||
return Token.COLON;
|
||||
case '/':
|
||||
return Token.SLASH_SEPARATOR;
|
||||
case '[':
|
||||
return Token.OP_ARRAY_OPEN;
|
||||
case ']':
|
||||
return Token.OP_ARRAY_CLOSE;
|
||||
case '*':
|
||||
return Token.STAR;
|
||||
case '&':
|
||||
return Token.REF_ARG;
|
||||
case '@':
|
||||
return Token.OUT_ARG;
|
||||
case '$':
|
||||
return Token.EXPLICIT_IMPL_SEP;
|
||||
default:
|
||||
return TokenizeIdentifierOrNumber (next);
|
||||
}
|
||||
}
|
||||
|
||||
int TokenizeIdentifierOrNumber (char current)
|
||||
{
|
||||
// We must first return the expression type which is a uppercase letter and a colon
|
||||
if (current_pos < 2) {
|
||||
val = null;
|
||||
return (int)current;
|
||||
}
|
||||
|
||||
if (is_identifier_start_character (current) || current == '*') {
|
||||
unsafe {
|
||||
// identifier length is artificially limited to 1024 bytes by implementations
|
||||
char* pIdent = stackalloc char[512];
|
||||
*pIdent = current;
|
||||
identCount = 1;
|
||||
|
||||
char peek;
|
||||
while ((peek = Peek ()) != EndOfStream && is_identifier_part_character (peek)) {
|
||||
*(pIdent + identCount) = Read ();
|
||||
++current_pos;
|
||||
++identCount;
|
||||
}
|
||||
|
||||
val = new string ((char*)pIdent, 0, identCount);
|
||||
return Token.IDENTIFIER;
|
||||
}
|
||||
} else if (char.IsDigit (current)) {
|
||||
val = current - '0';
|
||||
return Token.DIGIT;
|
||||
} else {
|
||||
val = null;
|
||||
return Token.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
char Read ()
|
||||
{
|
||||
try {
|
||||
return input[real_current_pos++];
|
||||
} catch {
|
||||
return EndOfStream;
|
||||
}
|
||||
}
|
||||
|
||||
char Peek ()
|
||||
{
|
||||
try {
|
||||
return input[real_current_pos];
|
||||
} catch {
|
||||
return EndOfStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
357
external/api-doc-tools/monodoc/Monodoc/HelpSource.cs
vendored
357
external/api-doc-tools/monodoc/Monodoc/HelpSource.cs
vendored
@@ -1,357 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Utilities;
|
||||
using Lucene.Net.Index;
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
public enum SortType {
|
||||
Caption,
|
||||
Element
|
||||
}
|
||||
|
||||
//
|
||||
// The HelpSource class keeps track of the archived data, and its
|
||||
// tree
|
||||
//
|
||||
public
|
||||
#if LEGACY_MODE
|
||||
partial
|
||||
#endif
|
||||
class HelpSource
|
||||
{
|
||||
static int id;
|
||||
|
||||
//
|
||||
// The unique ID for this HelpSource.
|
||||
//
|
||||
int source_id;
|
||||
|
||||
// The name of the HelpSource, used by all the file (.tree, .zip, ...) used by it
|
||||
string name;
|
||||
// The full directory path where the HelpSource files are located
|
||||
string basePath;
|
||||
|
||||
// The tree of this help source
|
||||
Tree tree;
|
||||
string treeFilePath;
|
||||
RootTree rootTree;
|
||||
|
||||
IDocCache cache;
|
||||
IDocStorage storage;
|
||||
|
||||
public HelpSource (string base_filename, bool create)
|
||||
{
|
||||
this.name = Path.GetFileName (base_filename);
|
||||
this.basePath = Path.GetDirectoryName (base_filename);
|
||||
this.treeFilePath = base_filename + ".tree";
|
||||
this.storage = new Monodoc.Storage.ZipStorage (base_filename + ".zip");
|
||||
this.cache = DocCacheHelper.GetDefaultCache (Name);
|
||||
|
||||
tree = create ? new Tree (this, string.Empty, string.Empty) : new Tree (this, treeFilePath);
|
||||
|
||||
source_id = id++;
|
||||
}
|
||||
|
||||
public HelpSource ()
|
||||
{
|
||||
tree = new Tree (this, "Blah", "Blah");
|
||||
source_id = id++;
|
||||
this.cache = new Caches.NullCache ();
|
||||
}
|
||||
|
||||
public int SourceID {
|
||||
get {
|
||||
return source_id;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/* This gives the full path of the source/ directory */
|
||||
public string BaseFilePath {
|
||||
get {
|
||||
return basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public TraceLevel TraceLevel {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string BaseDir {
|
||||
get {
|
||||
return basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public Tree Tree {
|
||||
get {
|
||||
return tree;
|
||||
}
|
||||
}
|
||||
|
||||
public RootTree RootTree {
|
||||
get {
|
||||
return rootTree;
|
||||
}
|
||||
set {
|
||||
rootTree = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IDocCache Cache {
|
||||
get {
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
public IDocStorage Storage {
|
||||
get {
|
||||
return storage;
|
||||
}
|
||||
protected set {
|
||||
storage = value;
|
||||
}
|
||||
}
|
||||
|
||||
// A HelpSource may have a common prefix to its URL, give it here
|
||||
protected virtual string UriPrefix {
|
||||
get {
|
||||
return "dummy:";
|
||||
}
|
||||
}
|
||||
|
||||
public virtual SortType SortType {
|
||||
get {
|
||||
return SortType.Caption;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a stream from the packaged help source archive
|
||||
/// </summary>
|
||||
public virtual Stream GetHelpStream (string id)
|
||||
{
|
||||
return storage.Retrieve (id);
|
||||
}
|
||||
|
||||
public virtual Stream GetCachedHelpStream (string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty (id))
|
||||
throw new ArgumentNullException ("id");
|
||||
if (!cache.CanCache (DocEntity.Text))
|
||||
return GetHelpStream (id);
|
||||
if (!cache.IsCached (id))
|
||||
cache.CacheText (id, GetHelpStream (id));
|
||||
return cache.GetCachedStream (id);
|
||||
}
|
||||
|
||||
public XmlReader GetHelpXml (string id)
|
||||
{
|
||||
var url = "monodoc:///" + SourceID + "@" + Uri.EscapeDataString (id) + "@";
|
||||
var stream = cache.IsCached (id) ? cache.GetCachedStream (id) : storage.Retrieve (id);
|
||||
|
||||
return stream == null ? null : new XmlTextReader (url, stream);
|
||||
}
|
||||
|
||||
public virtual XmlDocument GetHelpXmlWithChanges (string id)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
if (!storage.SupportRevision) {
|
||||
doc.Load (GetHelpXml (id));
|
||||
} else {
|
||||
var revManager = storage.RevisionManager;
|
||||
doc.Load (revManager.RetrieveLatestRevision (id));
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
public virtual string GetCachedText (string id)
|
||||
{
|
||||
if (!cache.CanCache (DocEntity.Text))
|
||||
return GetText (id);
|
||||
if (!cache.IsCached (id))
|
||||
cache.CacheText (id, GetText (id));
|
||||
return cache.GetCachedString (id);
|
||||
}
|
||||
|
||||
public virtual string GetText (string id)
|
||||
{
|
||||
return new StreamReader (GetHelpStream (id)).ReadToEnd ();
|
||||
}
|
||||
|
||||
// Tells if the result for the provided id is generated dynamically
|
||||
// by the help source
|
||||
public virtual bool IsGeneratedContent (string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tells if the content of the provided id is meant to be returned raw
|
||||
public virtual bool IsRawContent (string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tells if provided id refers to a multi-content-type document if it's case
|
||||
// tells the ids it's formed of
|
||||
public virtual bool IsMultiPart (string id, out IEnumerable<string> parts)
|
||||
{
|
||||
parts = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the tree and the archive
|
||||
/// </summary>
|
||||
public void Save ()
|
||||
{
|
||||
tree.Save (treeFilePath);
|
||||
storage.Dispose ();
|
||||
}
|
||||
|
||||
public virtual void RenderPreviewDocs (XmlNode newNode, XmlWriter writer)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual string GetPublicUrl (Node node)
|
||||
{
|
||||
return node.GetInternalUrl ();
|
||||
}
|
||||
|
||||
public virtual bool CanHandleUrl (string url)
|
||||
{
|
||||
return url.StartsWith (UriPrefix, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public virtual string GetInternalIdForUrl (string url, out Node node, out Dictionary<string, string> context)
|
||||
{
|
||||
context = null;
|
||||
node = MatchNode (url);
|
||||
return node == null ? null : url.Substring (UriPrefix.Length);
|
||||
}
|
||||
|
||||
public virtual Node MatchNode (string url)
|
||||
{
|
||||
Node current = null;
|
||||
|
||||
var matchCache = LRUCache<string, Node>.Default;
|
||||
if ((current = matchCache.Get (url)) != null)
|
||||
return current;
|
||||
|
||||
current = Tree.RootNode;
|
||||
var strippedUrl = url.StartsWith (UriPrefix, StringComparison.OrdinalIgnoreCase) ? url.Substring (UriPrefix.Length) : url;
|
||||
var searchNode = new Node () { Element = strippedUrl };
|
||||
|
||||
do {
|
||||
int index = current.ChildNodes.BinarySearch (searchNode, NodeElementComparer.Instance);
|
||||
if (index >= 0) {
|
||||
Node n = current.ChildNodes[index];
|
||||
matchCache.Put (url, n);
|
||||
return n;
|
||||
}
|
||||
index = ~index;
|
||||
if (index == current.ChildNodes.Count) {
|
||||
return SlowMatchNode (Tree.RootNode, matchCache, strippedUrl);
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
return null;
|
||||
|
||||
current = current.ChildNodes [index - 1];
|
||||
} while (true);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* That slow path is mainly here to handle ecmaspec type of url which are composed of hard to sort numbers
|
||||
* because they don't have the same amount of digit. We could use a regex to harmonise the various number
|
||||
* parts but then it would be quite specific. Since in the case of ecmaspec the tree is well-formed enough
|
||||
* the "Slow" match should still be fast enough
|
||||
*/
|
||||
Node SlowMatchNode (Node current, LRUCache<string, Node> matchCache, string url)
|
||||
{
|
||||
//Console.WriteLine ("Entering slow path for {0} starting from {1}", url, current.Element);
|
||||
while (current != null) {
|
||||
bool stop = true;
|
||||
foreach (Node n in current.ChildNodes) {
|
||||
var element = n.Element.StartsWith (UriPrefix, StringComparison.OrdinalIgnoreCase) ? n.Element.Substring (UriPrefix.Length) : n.Element;
|
||||
if (url.Equals (element, StringComparison.Ordinal)) {
|
||||
matchCache.Put (url, n);
|
||||
return n;
|
||||
} else if (url.StartsWith (element + ".", StringComparison.OrdinalIgnoreCase) && !n.IsLeaf) {
|
||||
current = n;
|
||||
stop = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stop)
|
||||
current = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
class NodeElementComparer : IComparer<Node>
|
||||
{
|
||||
public static NodeElementComparer Instance = new NodeElementComparer ();
|
||||
|
||||
public int Compare (Node n1, Node n2)
|
||||
{
|
||||
return string.Compare (Cleanup (n1), Cleanup (n2), StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
string Cleanup (Node n)
|
||||
{
|
||||
var prefix = n.Tree != null && n.Tree.HelpSource != null ? n.Tree.HelpSource.UriPrefix : string.Empty;
|
||||
var element = n.Element.StartsWith (prefix, StringComparison.OrdinalIgnoreCase) ? n.Element.Substring (prefix.Length) : n.Element;
|
||||
if (char.IsDigit (element, 0)) {
|
||||
var count = element.TakeWhile (char.IsDigit).Count ();
|
||||
element = element.PadLeft (Math.Max (0, 3 - count) + element.Length, '0');
|
||||
}
|
||||
//Console.WriteLine ("Cleaned up {0} to {1}", n.Element, element);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual DocumentType GetDocumentTypeForId (string id)
|
||||
{
|
||||
return DocumentType.PlainText;
|
||||
}
|
||||
|
||||
public virtual Stream GetImage (string url)
|
||||
{
|
||||
Stream result = null;
|
||||
storage.TryRetrieve (url, out result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Populates the index.
|
||||
//
|
||||
public virtual void PopulateIndex (IndexMaker index_maker)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Create different Documents for adding to Lucene search index
|
||||
// The default action is do nothing. Subclasses should add the docs
|
||||
//
|
||||
public virtual void PopulateSearchableIndex (IndexWriter writer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Utilities;
|
||||
using Lucene.Net.Index;
|
||||
|
||||
#if LEGACY_MODE
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
using Generators;
|
||||
|
||||
public partial class HelpSource
|
||||
{
|
||||
static HtmlGenerator htmlGenerator = new HtmlGenerator (null);
|
||||
|
||||
[Obsolete]
|
||||
public static bool use_css;
|
||||
[Obsolete]
|
||||
public static bool FullHtml = true;
|
||||
[Obsolete]
|
||||
public static bool UseWebdocCache;
|
||||
|
||||
[Obsolete ("Use Monodoc.Providers.HtmlGenerator.InlineCss")]
|
||||
public string InlineCss {
|
||||
get { return Monodoc.Generators.HtmlGenerator.InlineCss; }
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public string InlineJavaScript {
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
[Obsolete ("Use RenderUrl")]
|
||||
public string GetText (string url, out Node node)
|
||||
{
|
||||
return rootTree.RenderUrl (url, htmlGenerator, out node, this);
|
||||
}
|
||||
|
||||
[Obsolete ("Use RenderUrl")]
|
||||
public string RenderNamespaceLookup (string url, out Node node)
|
||||
{
|
||||
return rootTree.RenderUrl (url, htmlGenerator, out node, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
384
external/api-doc-tools/monodoc/Monodoc/Node.cs
vendored
384
external/api-doc-tools/monodoc/Monodoc/Node.cs
vendored
@@ -1,384 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
public
|
||||
#if LEGACY_MODE
|
||||
partial
|
||||
#endif
|
||||
class Node : IComparable<Node>, IComparable
|
||||
{
|
||||
readonly Tree parentTree;
|
||||
string caption, element, pubUrl;
|
||||
public bool Documented;
|
||||
bool loaded;
|
||||
Node parent;
|
||||
List<Node> nodes;
|
||||
#if LEGACY_MODE
|
||||
ArrayList legacyNodes;
|
||||
#endif
|
||||
Dictionary<string, Node> childrenLookup;
|
||||
bool elementSort;
|
||||
/* Address has three types of value,
|
||||
* _ 0 is for no on-disk representation
|
||||
* _ >0 is a valid address that is loaded immediately
|
||||
* _ <0 is a valid negated address to indicate lazy loading
|
||||
*/
|
||||
int address;
|
||||
|
||||
#if LEGACY_MODE
|
||||
[Obsolete ("Tree inheriting Node is being phased out. Use the `Tree.RootNode' property instead")]
|
||||
public Node (string caption, string element)
|
||||
{
|
||||
this.parentTree = (Tree) this;
|
||||
this.caption = caption;
|
||||
this.element = element;
|
||||
parent = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
public Node (Node parent, string caption, string element) : this (parent.Tree, caption, element)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
internal Node (Tree tree, string caption, string element)
|
||||
{
|
||||
this.parentTree = tree;
|
||||
this.caption = caption;
|
||||
this.element = element;
|
||||
this.elementSort = parentTree.HelpSource != null && parentTree.HelpSource.SortType == SortType.Element;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a node from an on-disk representation
|
||||
/// </summary>
|
||||
internal Node (Node parent, int address) : this (parent.parentTree, address)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
internal Node (Tree tree, int address)
|
||||
{
|
||||
this.address = address;
|
||||
this.parentTree = tree;
|
||||
this.elementSort = parentTree.HelpSource != null && parentTree.HelpSource.SortType == SortType.Element;
|
||||
if (address > 0)
|
||||
LoadNode ();
|
||||
}
|
||||
|
||||
/* This is solely used for MatchNode to check for equality */
|
||||
internal Node ()
|
||||
{
|
||||
}
|
||||
|
||||
void LoadNode ()
|
||||
{
|
||||
parentTree.InflateNode (this);
|
||||
if (parent != null)
|
||||
parent.RegisterFullNode (this);
|
||||
}
|
||||
|
||||
public void AddNode (Node n)
|
||||
{
|
||||
nodes.Add (n);
|
||||
n.parent = this;
|
||||
n.Documented = true;
|
||||
RegisterFullNode (n);
|
||||
}
|
||||
|
||||
public void DeleteNode (Node n)
|
||||
{
|
||||
nodes.Remove (n);
|
||||
if (!string.IsNullOrEmpty (n.element))
|
||||
childrenLookup.Remove (n.element);
|
||||
}
|
||||
|
||||
// When a child node is inflated, it calls this method
|
||||
// so that we can add it to our lookup for quick search
|
||||
void RegisterFullNode (Node child)
|
||||
{
|
||||
if (childrenLookup == null)
|
||||
childrenLookup = new Dictionary<string, Node> ();
|
||||
if (!string.IsNullOrEmpty (child.element))
|
||||
childrenLookup[child.element] = child;
|
||||
}
|
||||
|
||||
#if LEGACY_MODE
|
||||
[Obsolete ("Use ChildNodes")]
|
||||
public ArrayList Nodes {
|
||||
get {
|
||||
if (legacyNodes == null)
|
||||
legacyNodes = new ArrayList (ChildNodes as ICollection);
|
||||
return legacyNodes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public IList<Node> ChildNodes {
|
||||
get {
|
||||
EnsureLoaded ();
|
||||
return nodes != null ? nodes : new List<Node> ();
|
||||
}
|
||||
}
|
||||
|
||||
public string Element {
|
||||
get {
|
||||
EnsureLoaded ();
|
||||
return element;
|
||||
}
|
||||
set {
|
||||
element = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Caption {
|
||||
get {
|
||||
EnsureLoaded ();
|
||||
return caption;
|
||||
}
|
||||
internal set {
|
||||
caption = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Node Parent {
|
||||
get {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
public Tree Tree {
|
||||
get {
|
||||
return parentTree;
|
||||
}
|
||||
}
|
||||
|
||||
internal int Address {
|
||||
get {
|
||||
return address;
|
||||
}
|
||||
#if LEGACY_MODE
|
||||
set {
|
||||
address = value;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new node, in the locator entry point, and with
|
||||
/// a user visible caption of @caption
|
||||
/// </summary>
|
||||
public Node CreateNode (string c_caption, string c_element)
|
||||
{
|
||||
EnsureNodes ();
|
||||
if (string.IsNullOrEmpty (c_caption))
|
||||
throw new ArgumentNullException ("c_caption");
|
||||
if (string.IsNullOrEmpty (c_element))
|
||||
throw new ArgumentNullException ("c_element");
|
||||
|
||||
Node t = new Node (this, c_caption, c_element);
|
||||
nodes.Add (t);
|
||||
childrenLookup[c_element] = t;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public Node GetOrCreateNode (string c_caption, string c_element)
|
||||
{
|
||||
if (nodes == null)
|
||||
return CreateNode (c_caption, c_element);
|
||||
if (childrenLookup.Count != nodes.Count || (nodes.Count == 0 && childrenLookup.Count != nodes.Capacity))
|
||||
UpdateLookup ();
|
||||
|
||||
Node result;
|
||||
if (!childrenLookup.TryGetValue (c_element, out result))
|
||||
result = CreateNode (c_caption, c_element);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void EnsureNodes ()
|
||||
{
|
||||
if (nodes == null) {
|
||||
nodes = new List<Node> ();
|
||||
childrenLookup = new Dictionary<string, Node> ();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureLoaded ()
|
||||
{
|
||||
if (address < 0 && !loaded) {
|
||||
LoadNode ();
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLookup ()
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
childrenLookup[node.Element] = node;
|
||||
}
|
||||
|
||||
public bool IsLeaf {
|
||||
get {
|
||||
return nodes == null || nodes.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
void EncodeInt (BinaryWriter writer, int value)
|
||||
{
|
||||
do {
|
||||
int high = (value >> 7) & 0x01ffffff;
|
||||
byte b = (byte)(value & 0x7f);
|
||||
|
||||
if (high != 0) {
|
||||
b = (byte)(b | 0x80);
|
||||
}
|
||||
|
||||
writer.Write(b);
|
||||
value = high;
|
||||
} while(value != 0);
|
||||
}
|
||||
|
||||
int DecodeInt (BinaryReader reader)
|
||||
{
|
||||
int ret = 0;
|
||||
int shift = 0;
|
||||
byte b;
|
||||
|
||||
do {
|
||||
b = reader.ReadByte();
|
||||
|
||||
ret = ret | ((b & 0x7f) << shift);
|
||||
shift += 7;
|
||||
} while ((b & 0x80) == 0x80);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal void Deserialize (BinaryReader reader)
|
||||
{
|
||||
int count = DecodeInt (reader);
|
||||
element = reader.ReadString ();
|
||||
caption = reader.ReadString ();
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
nodes = new List<Node> (count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
int child_address = DecodeInt (reader);
|
||||
|
||||
Node t = new Node (this, -child_address);
|
||||
nodes.Add (t);
|
||||
}
|
||||
|
||||
if (parentTree.ForceResort)
|
||||
nodes.Sort ();
|
||||
}
|
||||
|
||||
internal void Serialize (FileStream output, BinaryWriter writer)
|
||||
{
|
||||
if (nodes != null)
|
||||
foreach (Node child in nodes)
|
||||
child.Serialize (output, writer);
|
||||
|
||||
address = (int) output.Position;
|
||||
EncodeInt (writer, nodes == null ? 0 : (int) nodes.Count);
|
||||
writer.Write (element);
|
||||
writer.Write (caption);
|
||||
|
||||
if (nodes != null)
|
||||
foreach (Node child in nodes)
|
||||
EncodeInt (writer, child.address);
|
||||
}
|
||||
|
||||
public void Sort ()
|
||||
{
|
||||
if (nodes != null)
|
||||
nodes.Sort ();
|
||||
}
|
||||
|
||||
internal string GetInternalUrl ()
|
||||
{
|
||||
EnsureLoaded ();
|
||||
if (element.IndexOf (":") != -1 || parent == null)
|
||||
return element;
|
||||
|
||||
var parentUrl = parent.GetInternalUrl ();
|
||||
return parentUrl.EndsWith ("/") ? parentUrl + element : parentUrl + "/" + element;
|
||||
}
|
||||
|
||||
public string PublicUrl {
|
||||
get {
|
||||
if (pubUrl != null)
|
||||
return pubUrl;
|
||||
return pubUrl = parentTree.HelpSource != null ? parentTree.HelpSource.GetPublicUrl (this) : GetInternalUrl ();
|
||||
}
|
||||
}
|
||||
|
||||
int IComparable.CompareTo (object obj)
|
||||
{
|
||||
Node other = obj as Node;
|
||||
if (other == null)
|
||||
return -1;
|
||||
return CompareToInternal (other);
|
||||
}
|
||||
|
||||
int IComparable<Node>.CompareTo (Node obj)
|
||||
{
|
||||
return CompareToInternal (obj);
|
||||
}
|
||||
|
||||
int CompareToInternal (Node other)
|
||||
{
|
||||
EnsureLoaded ();
|
||||
other.EnsureLoaded ();
|
||||
|
||||
var cap1 = elementSort ? element : caption;
|
||||
var cap2 = elementSort ? other.element : other.caption;
|
||||
|
||||
/* Some node (notably from ecmaspec) have number prepended to them
|
||||
* which we need to sort better by padding them to the same number
|
||||
* of digits
|
||||
*/
|
||||
if (char.IsDigit (cap1[0]) && char.IsDigit (cap2[0])) {
|
||||
int c1 = cap1.TakeWhile (char.IsDigit).Count ();
|
||||
int c2 = cap2.TakeWhile (char.IsDigit).Count ();
|
||||
|
||||
if (c1 != c2) {
|
||||
cap1 = cap1.PadLeft (cap1.Length + Math.Max (0, c2 - c1), '0');
|
||||
cap2 = cap2.PadLeft (cap2.Length + Math.Max (0, c1 - c2), '0');
|
||||
}
|
||||
}
|
||||
|
||||
return string.Compare (cap1, cap2, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class IListExtensions
|
||||
{
|
||||
// TODO: if the backing store ever change from List<T>, we need to tune these methods to have a fallback mechanism
|
||||
public static int BinarySearch<T> (this IList<T> ilist, T item)
|
||||
{
|
||||
var list = ilist as List<T>;
|
||||
if (list == null)
|
||||
throw new NotSupportedException ();
|
||||
return list.BinarySearch (item);
|
||||
}
|
||||
|
||||
public static int BinarySearch<T> (this IList<T> ilist, T item, IComparer<T> comparer)
|
||||
{
|
||||
var list = ilist as List<T>;
|
||||
if (list == null)
|
||||
throw new NotSupportedException ();
|
||||
return list.BinarySearch (item, comparer);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if LEGACY_MODE
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
public partial class Node
|
||||
{
|
||||
[Obsolete ("Use `Tree' instead of 'tree'")]
|
||||
public Tree tree {
|
||||
get {
|
||||
return this.Tree;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete ("Use TreeDumper")]
|
||||
public static void PrintTree (Tree t)
|
||||
{
|
||||
TreeDumper.PrintTree (t.RootNode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
public abstract class Provider
|
||||
{
|
||||
//
|
||||
// This code is used to "tag" all the different sources
|
||||
//
|
||||
static short serial;
|
||||
|
||||
public int Code { get; set; }
|
||||
|
||||
public Provider ()
|
||||
{
|
||||
Code = serial++;
|
||||
}
|
||||
|
||||
public abstract void PopulateTree (Tree tree);
|
||||
|
||||
//
|
||||
// Called at shutdown time after the tree has been populated to perform
|
||||
// any fixups or final tasks.
|
||||
//
|
||||
public abstract void CloseTree (HelpSource hs, Tree tree);
|
||||
}
|
||||
}
|
545
external/api-doc-tools/monodoc/Monodoc/RootTree.cs
vendored
545
external/api-doc-tools/monodoc/Monodoc/RootTree.cs
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Utilities;
|
||||
using Lucene.Net.Index;
|
||||
|
||||
#if LEGACY_MODE
|
||||
|
||||
namespace Monodoc
|
||||
{
|
||||
using Generators;
|
||||
|
||||
public partial class RootTree
|
||||
{
|
||||
static IDocGenerator<string> rawGenerator = new RawGenerator ();
|
||||
static HtmlGenerator htmlGenerator = new HtmlGenerator (null);
|
||||
|
||||
[Obsolete ("Use RawGenerator directly")]
|
||||
public XmlDocument GetHelpXml (string id)
|
||||
{
|
||||
var rendered = RenderUrl (id, rawGenerator);
|
||||
if (rendered == null)
|
||||
return null;
|
||||
var doc = new XmlDocument ();
|
||||
doc.LoadXml (RenderUrl (id, rawGenerator));
|
||||
return doc;
|
||||
}
|
||||
|
||||
[Obsolete ("Use the RenderUrl variant accepting a generator")]
|
||||
public string RenderUrl (string url, out Node n)
|
||||
{
|
||||
return RenderUrl (url, htmlGenerator, out n);
|
||||
}
|
||||
|
||||
[Obsolete ("Use GenerateIndex")]
|
||||
public static void MakeIndex (RootTree root)
|
||||
{
|
||||
root.GenerateIndex ();
|
||||
}
|
||||
|
||||
[Obsolete ("Use GenerateSearchIndex")]
|
||||
public static void MakeSearchIndex (RootTree root)
|
||||
{
|
||||
root.GenerateSearchIndex ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user