本文整理汇总了C#中MonoDevelop.Projects.Dom.Parser.ProjectDom类的典型用法代码示例。如果您正苦于以下问题:C# ProjectDom类的具体用法?C# ProjectDom怎么用?C# ProjectDom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectDom类属于MonoDevelop.Projects.Dom.Parser命名空间,在下文中一共展示了ProjectDom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResult
public GenerateNamespaceImport GetResult (ProjectDom dom, ICompilationUnit unit, IType type, TextEditorData data)
{
GenerateNamespaceImport result;
if (cache.TryGetValue (type.Namespace, out result))
return result;
result = new GenerateNamespaceImport ();
cache[type.Namespace] = result;
result.InsertNamespace = false;
DomLocation location = new DomLocation (data.Caret.Line, data.Caret.Column);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
if (u.Namespaces.Any (ns => type.Namespace == ns)) {
result.GenerateUsing = false;
return result;
}
}
result.GenerateUsing = true;
string name = type.DecoratedFullName.Substring (type.Namespace.Length + 1);
foreach (IUsing u in unit.Usings.Where (u => u.ValidRegion.Contains (location))) {
foreach (string ns in u.Namespaces) {
if (dom.SearchType (unit, unit.GetTypeAt (location), unit.GetMemberAt (location), ns + "." + name) != null) {
result.GenerateUsing = false;
result.InsertNamespace = true;
return result;
}
}
}
return result;
}
示例2: Format
public static void Format (TextEditorData data, ProjectDom dom, DomLocation location, bool correctBlankLines)
{
PolicyContainer policyParent = dom != null && dom.Project != null? dom.Project.Policies
: PolicyService.DefaultPolicies;
var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
Format (policyParent, mimeTypeChain, data, dom, location, correctBlankLines);
}
示例3: FindReferences
public override IEnumerable<MemberReference> FindReferences (ProjectDom dom, FilePath fileName, IEnumerable<INode> searchedMembers)
{
var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
AspNetAppProject project = dom.Project as AspNetAppProject;
if (project == null)
yield break;
var unit = AspNetParserService.GetCompileUnit (project, fileName, true);
if (unit == null)
yield break;
var refman = new DocumentReferenceManager (project);
var parsedAspDocument = (AspNetParsedDocument)new AspNetParser ().Parse (dom, fileName, editor.Text);
refman.Doc = parsedAspDocument;
var usings = refman.GetUsings ();
var documentInfo = new DocumentInfo (dom, unit, usings, refman.GetDoms ());
var builder = new AspLanguageBuilder ();
var buildDocument = new Mono.TextEditor.Document ();
var offsetInfos = new List<LocalDocumentInfo.OffsetInfo> ();
buildDocument.Text = builder.BuildDocumentString (documentInfo, editor, offsetInfos, true);
var parsedDocument = AspLanguageBuilder.Parse (dom, fileName, buildDocument.Text);
foreach (var member in searchedMembers) {
foreach (var reference in SearchMember (member, dom, fileName, editor, buildDocument, offsetInfos, parsedDocument)) {
yield return reference;
}
}
}
示例4: Parse
public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
{
XmlParsedDocument doc = new XmlParsedDocument (fileName);
doc.Flags |= ParsedDocumentFlags.NonSerializable;
TextReader tr = new StringReader (fileContent);
try {
Parser xmlParser = new Parser (new XmlFreeState (), true);
xmlParser.Parse (tr);
doc.XDocument = xmlParser.Nodes.GetRoot ();
doc.Add (xmlParser.Errors);
if (doc.XDocument != null && doc.XDocument.RootElement != null) {
if (!doc.XDocument.RootElement.IsEnded)
doc.XDocument.RootElement.End (xmlParser.Location);
}
}
catch (Exception ex) {
MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
}
finally {
if (tr != null)
tr.Dispose ();
}
return doc;
}
示例5: InstantiatedParameterType
public InstantiatedParameterType (ProjectDom dom, ITypeParameterMember typeParameterMember, ITypeParameter tp)
{
IType outerType = typeParameterMember as IType ?? typeParameterMember.DeclaringType;
typeparam = tp;
compilationUnit = outerType.CompilationUnit;
ClassType = ClassType.Class;
Modifiers = Modifiers.Public;
Name = tp.Name;
Namespace = outerType.DecoratedFullName;
Location = outerType.Location;
DeclaringType = outerType;
if (tp.Constraints.Count > 0)
ClassType = ClassType.Interface;
foreach (IReturnType rt in tp.Constraints) {
if (FindCyclicReference (new HashSet<ITypeParameter> () { tp }, outerType, ((DomReturnType)rt).DecoratedFullName))
continue;
IType bt = dom.SearchType (typeParameterMember, rt);
IReturnType resolvedType = rt;
if (bt != null) {
resolvedType = new DomReturnType (bt);
if (bt.ClassType == ClassType.Interface || BaseType != null) {
AddInterfaceImplementation (resolvedType);
} else {
ClassType = bt.ClassType;
BaseType = resolvedType;
}
} else {
AddInterfaceImplementation (resolvedType);
}
}
if (BaseType == null)
BaseType = DomReturnType.Object;
}
示例6: Parse
public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
{
XmlParsedDocument doc = new XmlParsedDocument (fileName);
doc.Flags = ParsedDocumentFlags.NonSerializable;
TextReader tr = new StringReader (fileContent);
try {
Parser xmlParser = new Parser (
new XmlFreeState (new HtmlTagState (true), new HtmlClosingTagState (true)),
true);
xmlParser.Parse (tr);
doc.XDocument = xmlParser.Nodes.GetRoot ();
doc.Add (xmlParser.Errors);
if (doc.XDocument != null)
doc.Add (Validate (doc.XDocument));
}
catch (Exception ex) {
MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing HTML document", ex);
}
finally {
if (tr != null)
tr.Dispose ();
}
return doc;
}
示例7: RefactorerContext
public RefactorerContext (ProjectDom ctx, ITextFileProvider files, IType cls)
{
this.files = files;
this.ctx = ctx;
if (cls != null)
typeResolver = GetTypeNameResolver (cls);
}
示例8: Format
public static void Format (MonoDevelop.Ide.Gui.Document data, ProjectDom dom, DomLocation location, bool correctBlankLines, bool runAferCR = false)
{
PolicyContainer policyParent = dom != null && dom.Project != null ? dom.Project.Policies
: PolicyService.DefaultPolicies;
var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
Format (policyParent, mimeTypeChain, data, dom, location, correctBlankLines, runAferCR);
}
示例9: FindReferences
public override IEnumerable<MemberReference> FindReferences (ProjectDom dom, FilePath fileName, IEnumerable<INode> searchedMembers)
{
HashSet<int > positions = new HashSet<int> ();
var editor = TextFileProvider.Instance.GetTextEditorData (fileName);
FindMemberAstVisitor visitor = new FindMemberAstVisitor (editor.Document);
visitor.IncludeXmlDocumentation = IncludeDocumentation;
visitor.Init (searchedMembers);
if (!visitor.FileContainsMemberName ()) {
yield break;
}
var doc = ProjectDomService.ParseFile (dom, fileName, () => editor.Text);
if (doc == null || doc.CompilationUnit == null)
yield break;
var resolver = new NRefactoryResolver (dom, doc.CompilationUnit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);
visitor.ParseFile (resolver);
visitor.RunVisitor (resolver);
foreach (var reference in visitor.FoundReferences) {
if (positions.Contains (reference.Position))
continue;
positions.Add (reference.Position);
yield return reference;
}
visitor.ClearParsers ();
}
示例10: GetCompatibleMemberInClass
public static IMember GetCompatibleMemberInClass (ProjectDom ctx, IType cls, CodeTypeMember member)
{
//check for identical property names
foreach (IProperty prop in cls.Properties) {
if (string.Compare (prop.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
EnsureClassExists (ctx, prop.ReturnType.FullName, GetValidRegion (prop));
CodeMemberProperty memProp = member as CodeMemberProperty;
if (memProp == null || !IsTypeCompatible (ctx, prop.ReturnType.FullName, memProp.Type.BaseType))
throw new MemberExistsException (cls.FullName, MemberType.Property, member, GetValidRegion (prop), cls.CompilationUnit.FileName);
return prop;
}
}
//check for identical method names
foreach (IMethod meth in cls.Methods) {
if (string.Compare (meth.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
EnsureClassExists (ctx, meth.ReturnType.FullName, GetValidRegion (meth));
CodeMemberMethod memMeth = member as CodeMemberMethod;
if (memMeth == null || !IsTypeCompatible (ctx, meth.ReturnType.FullName, memMeth.ReturnType.BaseType))
throw new MemberExistsException (cls.FullName, MemberType.Method, member, GetValidRegion (meth), cls.CompilationUnit.FileName);
return meth;
}
}
//check for identical event names
foreach (IEvent ev in cls.Events) {
if (string.Compare (ev.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
EnsureClassExists (ctx, ev.ReturnType.FullName, GetValidRegion (ev));
CodeMemberEvent memEv = member as CodeMemberEvent;
if (memEv == null || !IsTypeCompatible (ctx, ev.ReturnType.FullName, memEv.Type.BaseType))
throw new MemberExistsException (cls.FullName, MemberType.Event, member, GetValidRegion (ev), cls.CompilationUnit.FileName);
return ev;
}
}
//check for identical field names
foreach (IField field in cls.Fields) {
if (string.Compare (field.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
EnsureClassExists (ctx, field.ReturnType.FullName, GetValidRegion (field));
CodeMemberField memField = member as CodeMemberField;
if (memField == null || !IsTypeCompatible (ctx, field.ReturnType.FullName, memField.Type.BaseType))
throw new MemberExistsException (cls.FullName, MemberType.Field, member, GetValidRegion (field), cls.CompilationUnit.FileName);
return field;
}
}
//walk down into base classes, if any
foreach (IReturnType baseType in cls.BaseTypes) {
IType c = ctx.GetType (baseType);
if (c == null)
throw new TypeNotFoundException (baseType.FullName, cls.BodyRegion, cls.CompilationUnit.FileName);
IMember mem = GetCompatibleMemberInClass (ctx, c, member);
if (mem != null)
return mem;
}
//return null if no match
return null;
}
示例11: FindReferences
public override IEnumerable<MemberReference> FindReferences (ProjectDom dom, FilePath fileName, IEnumerable<INode> searchedMembers)
{
foreach (var member in searchedMembers) {
foreach (var reference in FindReferences (dom, fileName, member)) {
yield return reference;
}
}
}
示例12: CreateResolver
public override IResolver CreateResolver (ProjectDom dom, object editor, string fileName)
{
MonoDevelop.Ide.Gui.Document doc = (MonoDevelop.Ide.Gui.Document)editor;
if (doc.Editor == null)
return null;
return new NRefactoryResolver (dom, doc.CompilationUnit, ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, doc.Editor, fileName);
}
示例13: Parse
public static ParsedDocument Parse (ProjectDom dom, string fileName, string text)
{
var result = new MonoDevelop.CSharp.Parser.McsParser ().Parse (null, fileName, text);
foreach (DomType type in result.CompilationUnit.Types) {
type.SourceProjectDom = dom;
}
return result;
}
示例14: GetFullClass
IType GetFullClass (out ProjectDom ctx)
{
if (project == null || className == null) {
ctx = null;
return null;
}
ctx = MonoDevelop.Projects.Dom.Parser.ProjectDomService.GetProjectDom (project);
return ctx.GetType (className, false, false);
}
示例15: OutputNode
public string OutputNode (ProjectDom dom, INode node, string indent)
{
CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor ();
CSharpFormatter.SetFormatOptions (outputVisitor, dom != null && dom.Project != null ? dom.Project.Policies : null);
int col = CSharpFormatter.GetColumn (indent, 0, 4);
outputVisitor.OutputFormatter.IndentationLevel = System.Math.Max (0, col / 4);
node.AcceptVisitor (outputVisitor, null);
return outputVisitor.Text;
}