本文整理汇总了C#中ParsedDocument类的典型用法代码示例。如果您正苦于以下问题:C# ParsedDocument类的具体用法?C# ParsedDocument怎么用?C# ParsedDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParsedDocument类属于命名空间,在下文中一共展示了ParsedDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RefillOutlineStore
//copied from MoonlightEditorExtension
#region Document outline
protected override void RefillOutlineStore (ParsedDocument doc, Gtk.TreeStore store)
{
XDocument xdoc = ((MonoDevelop.Xml.Editor.XmlParsedDocument)doc).XDocument;
if (xdoc == null)
return;
// Gtk.TreeIter iter = outlineTreeStore.AppendValues (System.IO.Path.GetFileName (CU.Document.FilePath), p);
BuildTreeChildren (store, Gtk.TreeIter.Zero, xdoc);
}
开发者ID:brantwedel,项目名称:monodevelop,代码行数:11,代码来源:HtmlEditorExtension.cs
示例2: before_each_test_setup
public void before_each_test_setup()
{
TargetContainer = new SummarizationInformationContainer();
TargetParsedDocument = new ParsedDocument();
TargetParsedDocument.Sentences = new List<Sentence>()
{
TargetContainer.sentence
};
TargetContentAnalyzer = Substitute.For<IContentAnalyzer>();
TargetContentAnalyzer.GetImportantTextUnits(Arg.Any<List<Sentence>>()).Returns(TargetContainer.scoredTextUnits);
TargetContentAnalyzer.ScoreSentences(Arg.Any<List<Sentence>>(), Arg.Any<List<TextUnitScore>>()).Returns(TargetContainer.scoredSentences);
}
开发者ID:ArsenShnurkov,项目名称:OpenTextSummarizer,代码行数:14,代码来源:SummarizingEngine.cs
示例3: Initialize
public override void Initialize ()
{
base.Initialize ();
Parser parser = new Parser (CreateRootState (), false);
tracker = new DocumentStateTracker<Parser> (parser, Editor);
Document.DocumentParsed += delegate {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
};
if (Document.ParsedDocument != null) {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
}
}
开发者ID:fedorw,项目名称:monodevelop,代码行数:15,代码来源:BaseXmlEditorExtension.cs
示例4: SearchMember
IEnumerable<DomRegion> SearchMember (IEntity member, ITypeResolveContext dom, FilePath fileName, Mono.TextEditor.TextEditorData editor, Mono.TextEditor.TextDocument buildDocument, List<LocalDocumentInfo.OffsetInfo> offsetInfos, ParsedDocument parsedDocument)
{ // TODO: Type system conversion.
yield break;
// var resolver = new NRefactoryResolver (dom, parsedDocument.CompilationUnit, ICSharpCode.OldNRefactory.SupportedLanguage.CSharp, editor, fileName);
//
// var visitor = new FindMemberAstVisitor (buildDocument, member);
// visitor.IncludeXmlDocumentation = IncludeDocumentation;
// visitor.RunVisitor (resolver);
//
// foreach (var result in visitor.FoundReferences) {
// var offsetInfo = offsetInfos.FirstOrDefault (info => info.ToOffset <= result.Position && result.Position < info.ToOffset + info.Length);
// if (offsetInfo == null)
// continue;
// var offset = offsetInfo.FromOffset + result.Position - offsetInfo.ToOffset;
// var loc = editor.OffsetToLocation (offset);
// yield return new DomRegion (fileName, loc.Line, loc.Column, loc.Line, loc.Column + result.Name.Lenhth);
// }
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:18,代码来源:ASPNetReferenceFinder.cs
示例5: Initialize
public override void Initialize ()
{
base.Initialize ();
UpdateOwnerProjects ();
Parser parser = new Parser (CreateRootState (), false);
tracker = new DocumentStateTracker<Parser> (parser, Editor);
Document.DocumentParsed += delegate {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
};
if (Document.ParsedDocument != null) {
lastCU = Document.ParsedDocument;
OnParsedDocumentUpdated ();
}
if (IdeApp.Workspace != null) {
IdeApp.Workspace.FileAddedToProject += HandleProjectChanged;
IdeApp.Workspace.FileRemovedFromProject += HandleProjectChanged;
}
}
开发者ID:alexrp,项目名称:monodevelop,代码行数:20,代码来源:BaseXmlEditorExtension.cs
示例6: RefillOutlineStore
protected virtual void RefillOutlineStore (ParsedDocument doc, TreeStore store)
{
XDocument xdoc = ((XmlParsedDocument)doc).XDocument;
if (xdoc == null)
return;
BuildTreeChildren (store, TreeIter.Zero, xdoc);
}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:7,代码来源:BaseXmlEditorExtension.cs
示例7: UpdateParsedDocument
void UpdateParsedDocument (object sender, EventArgs args)
{
lastCU = DocumentContext.ParsedDocument;
OnParsedDocumentUpdated ();
}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:5,代码来源:BaseXmlEditorExtension.cs
示例8: Initialize
protected override void Initialize ()
{
base.Initialize ();
// Delay the execution of UpdateOwnerProjects since it may end calling Document.AttachToProject,
// which shouldn't be called while the extension chain is being initialized.
// TODO: Move handling of owner projects to Document
Application.Invoke (delegate {
UpdateOwnerProjects ();
});
var parser = new XmlParser (CreateRootState (), false);
tracker = new DocumentStateTracker<XmlParser> (parser, Editor);
DocumentContext.DocumentParsed += UpdateParsedDocument;
Editor.CaretPositionChanged += HandleCaretPositionChanged;
if (DocumentContext.ParsedDocument != null) {
lastCU = DocumentContext.ParsedDocument;
OnParsedDocumentUpdated ();
}
if (IdeApp.Workspace != null) {
IdeApp.Workspace.FileAddedToProject += HandleProjectChanged;
IdeApp.Workspace.FileRemovedFromProject += HandleProjectChanged;
}
}
开发者ID:gAdrev,项目名称:monodevelop,代码行数:26,代码来源:BaseXmlEditorExtension.cs
示例9: ImportSymbolCompletionData
public ImportSymbolCompletionData (MonoDevelop.Ide.Gui.Document doc, ImportSymbolCache cache, IType type)
{
this.doc = doc;
this.cache = cache;
// this.data = doc.Editor;
this.ambience = AmbienceService.GetAmbience (doc.Editor.MimeType);
this.type = type;
this.unit = doc.ParsedDocument;
}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:9,代码来源:ImportSymbolHandler.cs
示例10: UpdateDocumentOutline
void UpdateDocumentOutline (object sender, EventArgs args)
{
lastCU = Document.ParsedDocument;
//limit update rate to 3s
if (!refreshingOutline) {
refreshingOutline = true;
refillOutlineStoreId = GLib.Timeout.Add (3000, RefillOutlineStore);
}
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:9,代码来源:ClassOutlineTextEditorExtension.cs
示例11: SetParsedDocument
internal void SetParsedDocument (ParsedDocument newDocument, bool runInThread)
{
this.parsedDocument = newDocument;
if (parsedDocument == null || parseInformationUpdaterWorkerThread == null)
return;
StopParseInfoThread ();
if (runInThread) {
parseInformationUpdaterWorkerThread.RunWorkerAsync (parsedDocument);
} else {
HandleParseInformationUpdaterWorkerThreadDoWork (null, new DoWorkEventArgs (parsedDocument));
}
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:12,代码来源:SourceEditorWidget.cs
示例12: throws_if_null_arguments_are_passed
public void throws_if_null_arguments_are_passed(ParsedDocument parsedDocument,
IContentAnalyzer contentAnalyzer)
{
Assert.Throws<ArgumentNullException>(
() => { Target.AnalyzeParsedContent(parsedDocument, contentAnalyzer); });
}
开发者ID:arjunkrishna,项目名称:OpenTextSummarizer,代码行数:6,代码来源:SummarizingEngine.cs
示例13: MDRefactoringContext
public MDRefactoringContext (DotNetProject project, TextEditorData data, ParsedDocument parsedDocument, CSharpAstResolver resolver, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken)) : base (resolver, cancellationToken)
{
this.TextEditor = data;
this.ParsedDocument = parsedDocument;
this.Project = project;
var policy = Project.Policies.Get<CSharpFormattingPolicy> ();
this.formattingOptions = policy.CreateOptions ();
this.location = loc;
var namingPolicy = Project.Policies.Get<NameConventionPolicy> ();
Services.AddService (typeof(NamingConventionService), namingPolicy.CreateNRefactoryService ());
}
开发者ID:riverans,项目名称:monodevelop,代码行数:11,代码来源:MDRefactoringContext.cs
示例14: HandleParseInformationUpdaterWorkerThreadDoWork
void HandleParseInformationUpdaterWorkerThreadDoWork (bool firstTime, ParsedDocument parsedDocument, CancellationToken token = default(CancellationToken))
{
var doc = Document;
if (doc == null || parsedDocument == null)
return;
UpdateErrorUndelines (parsedDocument);
if (!options.ShowFoldMargin)
return;
// don't update parsed documents that contain errors - the foldings from there may be invalid.
if (parsedDocument.HasErrors)
return;
try {
List<FoldSegment > foldSegments = new List<FoldSegment> ();
bool updateSymbols = parsedDocument.Defines.Count != symbols.Count;
if (!updateSymbols) {
foreach (PreProcessorDefine define in parsedDocument.Defines) {
if (token.IsCancellationRequested)
return;
if (!symbols.Contains (define.Define)) {
updateSymbols = true;
break;
}
}
}
if (updateSymbols) {
symbols.Clear ();
foreach (PreProcessorDefine define in parsedDocument.Defines) {
symbols.Add (define.Define);
}
}
foreach (FoldingRegion region in parsedDocument.Foldings) {
if (token.IsCancellationRequested)
return;
FoldingType type = FoldingType.None;
bool setFolded = false;
bool folded = false;
//decide whether the regions should be folded by default
switch (region.Type) {
case FoldType.Member:
type = FoldingType.TypeMember;
break;
case FoldType.Type:
type = FoldingType.TypeDefinition;
break;
case FoldType.UserRegion:
type = FoldingType.Region;
setFolded = options.DefaultRegionsFolding;
folded = true;
break;
case FoldType.Comment:
type = FoldingType.Comment;
setFolded = options.DefaultCommentFolding;
folded = true;
break;
case FoldType.CommentInsideMember:
type = FoldingType.Comment;
setFolded = options.DefaultCommentFolding;
folded = false;
break;
case FoldType.Undefined:
setFolded = true;
folded = region.IsFoldedByDefault;
break;
}
//add the region
FoldSegment marker = AddMarker (foldSegments, region.Name,
region.Region, type);
//and, if necessary, set its fold state
if (marker != null && setFolded && firstTime) {
// only fold on document open, later added folds are NOT folded by default.
marker.IsFolded = folded;
continue;
}
if (marker != null && region.Region.IsInside (textEditorData.Caret.Line, textEditorData.Caret.Column))
marker.IsFolded = false;
}
doc.UpdateFoldSegments (foldSegments, false, true, token);
if (reloadSettings) {
reloadSettings = false;
Application.Invoke (delegate {
if (isDisposed)
return;
view.LoadSettings ();
mainsw.QueueDraw ();
});
}
} catch (Exception ex) {
LoggingService.LogError ("Unhandled exception in ParseInformationUpdaterWorkerThread", ex);
}
}
开发者ID:newky2k,项目名称:monodevelop,代码行数:97,代码来源:SourceEditorWidget.cs
示例15: SetParsedDocument
internal void SetParsedDocument (ParsedDocument newDocument, bool runInThread)
{
this.parsedDocument = newDocument;
if (parsedDocument == null)
return;
StopParseInfoThread ();
if (runInThread) {
var token = parserInformationUpdateSrc.Token;
System.Threading.Tasks.Task.Factory.StartNew (delegate {
HandleParseInformationUpdaterWorkerThreadDoWork (false, parsedDocument, token);
});
} else {
HandleParseInformationUpdaterWorkerThreadDoWork (true, parsedDocument);
}
}
开发者ID:newky2k,项目名称:monodevelop,代码行数:15,代码来源:SourceEditorWidget.cs
示例16: Parse
public override ParsedDocument Parse(bool storeAst, string file, TextReader content, Project prj = null)
{
if (!storeAst)
return null;
ProjectFile pf = null;
if (prj == null)
{
var sln = Ide.IdeApp.ProjectOperations.CurrentSelectedSolution;
if (sln != null)
foreach (var proj in sln.GetAllProjects())
if (proj.IsFileInProject(file))
{
prj = proj;
pf = proj.GetProjectFile(file);
break;
}
}
else if(prj.IsFileInProject(file))
{
pf = prj.GetProjectFile(file);
}
// HACK(?) The folds are parsed before the document gets loaded
// - so reuse the last parsed document to save time
// -- What if multiple docs are opened?
var d = LastParsedMod as ParsedDModule;
if (d != null && d.FileName == file)
{
LastParsedMod = null;
return d;
}
else
LastParsedMod = null;
var dprj = prj as AbstractDProject;
// Remove obsolete ast from cache
if(file != null)
GlobalParseCache.RemoveModule (file);
DModule ast;
var doc = new ParsedDModule(file);
var parser = DParser.Create(content);
// Also put attention on non-ddoc comments; These will be used to generate foldable comment regions then
parser.Lexer.OnlyEnlistDDocComments = false;
// Parse the code
try
{
ast = parser.Parse();
}
catch (TooManyErrorsException)
{
ast = parser.Document;
}
catch(System.Exception ex) {
doc.ErrorList.Add(new Error(ErrorType.Error, ex.Message));
return doc;
}
if(ast == null)
return doc;
// Update project owner information / Build appropriate module name
if(string.IsNullOrEmpty(ast.ModuleName))
{
if(pf == null)
ast.ModuleName = file != null ? Path.GetFileNameWithoutExtension(file) : string.Empty;
else
ast.ModuleName = BuildModuleName(pf);
}
ast.FileName = file;
// Assign new ast to the ParsedDDocument object
doc.DDom = ast;
// Add parser errors to the parser output
foreach (var parserError in parser.ParseErrors)
doc.ErrorList.Add(new Error(
ErrorType.Error,
parserError.Message,
parserError.Location.Line,
parserError.Location.Column));
#region Provide comment fold support by addin them to the IDE document object
foreach (var cm in parser.Comments)
{
var c = new MonoDevelop.Ide.TypeSystem.Comment(cm.CommentText){
CommentStartsLine = cm.CommentStartsLine,
CommentType = (cm.CommentType & D_Parser.Parser.Comment.Type.Block) != 0 ? CommentType.Block : CommentType.SingleLine,
IsDocumentation = cm.CommentType.HasFlag(D_Parser.Parser.Comment.Type.Documentation),
};
if (c.CommentType == CommentType.SingleLine)
{
if (c.IsDocumentation)
c.OpenTag = "///";
//.........这里部分代码省略.........
开发者ID:foerdi,项目名称:Mono-D,代码行数:101,代码来源:DParserWrapper.cs
示例17: AddTreeClassContents
static void AddTreeClassContents (TreeStore store, TreeIter parent, ParsedDocument parsedDocument, ITypeDefinition cls, IUnresolvedTypeDefinition part)
{
List<object> items = new List<object> ();
if (cls.Kind != TypeKind.Delegate) {
foreach (var o in cls.GetMembers (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
items.Add (o);
}
foreach (var o in cls.GetNestedTypes (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
if (o.DeclaringType == cls)
items.Add (o);
}
foreach (var o in cls.GetConstructors (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
if (o.IsSynthetic)
continue;
items.Add (o);
}
}
items.Sort (ClassOutlineNodeComparer.CompareRegion);
List<FoldingRegion> regions = new List<FoldingRegion> ();
foreach (FoldingRegion fr in parsedDocument.UserRegions)
//check regions inside class
if (cls.BodyRegion.IsInside (fr.Region.Begin) && cls.BodyRegion.IsInside (fr.Region.End))
regions.Add (fr);
regions.Sort (delegate(FoldingRegion x, FoldingRegion y) { return x.Region.Begin.CompareTo (y.Region.Begin); });
IEnumerator<FoldingRegion> regionEnumerator = regions.GetEnumerator ();
if (!regionEnumerator.MoveNext ())
regionEnumerator = null;
FoldingRegion currentRegion = null;
TreeIter currentParent = parent;
foreach (object item in items) {
//no regions left; quick exit
if (regionEnumerator != null) {
DomRegion itemRegion = ClassOutlineNodeComparer.GetRegion (item);
//advance to a region that could potentially contain this member
while (regionEnumerator != null && !OuterEndsAfterInner (regionEnumerator.Current.Region, itemRegion))
if (!regionEnumerator.MoveNext ())
regionEnumerator = null;
//if member is within region, make sure it's the current parent.
//If not, move target iter back to class parent
if (regionEnumerator != null && regionEnumerator.Current.Region.IsInside (itemRegion.Begin)) {
if (currentRegion != regionEnumerator.Current) {
currentParent = store.AppendValues (parent, regionEnumerator.Current);
currentRegion = regionEnumerator.Current;
}
} else {
currentParent = parent;
}
}
TreeIter childIter = store.AppendValues (currentParent, item);
if (item is ITypeDefinition)
AddTreeClassContents (store, childIter, parsedDocument, (ITypeDefinition)item, part);
}
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:60,代码来源:ClassOutlineTextEditorExtension.cs
示例18: BuildTreeChildren
void BuildTreeChildren (TreeStore store, TreeIter parent, ParsedDocument parsedDocument)
{
if (parsedDocument == null)
return;
foreach (var unresolvedCls in parsedDocument.TopLevelTypeDefinitions) {
var cls = document.Compilation.MainAssembly.GetTypeDefinition (unresolvedCls.FullTypeName);
if (cls == null)
continue;
TreeIter childIter;
if (!parent.Equals (TreeIter.Zero))
childIter = store.AppendValues (parent, cls);
else
childIter = store.AppendValues (cls);
AddTreeClassContents (store, childIter, parsedDocument, cls, unresolvedCls);
}
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:18,代码来源:ClassOutlineTextEditorExtension.cs
示例19: GetInsertionPoints
public static List<InsertionPoint> GetInsertionPoints (TextEditorData data, ParsedDocument parsedDocument, IUnresolvedTypeDefinition type)
{
if (data == null)
throw new ArgumentNullException ("data");
if (parsedDocument == null)
throw new ArgumentNullException ("parsedDocument");
if (type == null)
throw new ArgumentNullException ("type");
// update type from parsed document, since this is always newer.
//type = parsedDocument.GetInnermostTypeDefinition (type.GetLocation ()) ?? type;
List<InsertionPoint> result = new List<InsertionPoint> ();
int offset = data.LocationToOffset (type.Region.Begin);
if (offset < 0 || type.BodyRegion.IsEmpty)
return result;
while (offset < data.Length && data.GetCharAt (offset) != '{') {
offset++;
}
var realStartLocation = data.OffsetToLocation (offset);
result.Add (GetInsertionPosition (data.Document, realStartLocation.Line, realStartLocation.Column));
result [0].LineBefore = NewLineInsertion.None;
foreach (var member in type.Members) {
TextLocation domLocation = member.BodyRegion.End;
if (domLocation.Line <= 0) {
DocumentLine lineSegment = data.GetLine (member.Region.BeginLine);
if (lineSegment == null)
continue;
domLocation = new TextLocation (member.Region.BeginLine, lineSegment.Length + 1);
}
result.Add (GetInsertionPosition (data.Document, domLocation.Line, domLocation.Column));
}
foreach (var nestedType in type.NestedTypes) {
TextLocation domLocation = nestedType.BodyRegion.End;
if (domLocation.Line <= 0) {
DocumentLine lineSegment = data.GetLine (nestedType.Region.BeginLine);
if (lineSegment == null)
continue;
domLocation = new TextLocation (nestedType.Region.BeginLine, lineSegment.Length + 1);
}
result.Add (GetInsertionPosition (data.Document, domLocation.Line, domLocation.Column));
}
result [result.Count - 1].LineAfter = NewLineInsertion.None;
CheckStartPoint (data.Document, result [0], result.Count == 1);
if (result.Count > 1) {
result.RemoveAt (result.Count - 1);
NewLineInsertion insertLine;
var lineBefore = data.GetLine (type.BodyRegion.EndLine - 1);
if (lineBefore != null && lineBefore.Length == lineBefore.GetIndentation (data.Document).Length) {
insertLine = NewLineInsertion.None;
} else {
insertLine = NewLineInsertion.Eol;
}
// search for line start
int col = type.BodyRegion.EndColumn - 1;
var line = data.GetLine (type.BodyRegion.EndLine);
if (line != null) {
while (col > 1 && char.IsWhiteSpace (data.GetCharAt (line.Offset + col - 2)))
col--;
}
result.Add (new InsertionPoint (new DocumentLocation (type.BodyRegion.EndLine, col), insertLine, NewLineInsertion.Eol));
CheckEndPoint (data.Document, result [result.Count - 1], result.Count == 1);
}
foreach (var region in parsedDocument.UserRegions.Where (r => type.BodyRegion.IsInside (r.Region.Begin))) {
result.Add (new InsertionPoint (new DocumentLocation (region.Region.BeginLine + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol));
result.Add (new InsertionPoint (new DocumentLocation (region.Region.EndLine, 1), NewLineInsertion.Eol, NewLineInsertion.Eol));
result.Add (new InsertionPoint (new DocumentLocation (region.Region.EndLine + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol));
}
result.Sort ((left, right) => left.Location.CompareTo (right.Location));
return result;
}
开发者ID:dodev,项目名称:monodevelop,代码行数:74,代码来源:CodeGenerationService.cs
示例20: GetRegionEntry
async static Task<PathEntry> GetRegionEntry (ParsedDocument unit, DocumentLocation loc)
{
PathEntry entry;
FoldingRegion reg;
try {
var regions = await unit.GetUserRegionsAsync ().ConfigureAwait (false);
if (unit == null || !regions.Any ())
return null;
reg = regions.LastOrDefault (r => r.Region.Contains (loc));
} catch (AggregateException) {
return null;
} catch (OperationCanceledException) {
return null;
}
if (reg == null) {
entry = new PathEntry (GettextCatalog.GetString ("No region"));
} else {
entry = new PathEntry (CompilationUnitDataProvider.Pixbuf, GLib.Markup.EscapeText (reg.Name));
}
entry.Position = EntryPosition.Right;
return entry;
}
开发者ID:ZZHGit,项目名称:monodevelop,代码行数:22,代码来源:PathedDocumentTextEditorExtension.cs
注:本文中的ParsedDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论