Browse Source

Improved lazy-loading: fixed loading of BackendBindings when text editor was opened.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@597 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
9f60eac3d0
  1. 5
      src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingDoozer.cs
  2. 27
      src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs
  3. 21
      src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs
  4. 4
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

5
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingDoozer.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.Core @@ -31,7 +31,7 @@ namespace ICSharpCode.Core
/// </attribute>
/// <attribute name="languagePattern" use="optional">
/// Regular expression that specifies the language for which the display binding
/// will be used. Example: "\Resource Files$"
/// will be used. Only used for primary display bindings. Example: "\Resource Files$"
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/DisplayBindings</usage>
/// <returns>
@ -52,8 +52,7 @@ namespace ICSharpCode.Core @@ -52,8 +52,7 @@ namespace ICSharpCode.Core
/// &lt;DisplayBinding id = "FormDesigner"
/// type = "Secondary"
/// class = "ICSharpCode.FormDesigner.FormDesignerSecondaryDisplayBinding"
/// fileNamePattern = "\.(cs|vb)$"
/// languagePattern = "^(C#|VBNet)$" /&gt;
/// fileNamePattern = "\.(cs|vb)$" /&gt;
/// &lt;/Path&gt;
/// </example>
public class DisplayBindingDoozer : IDoozer

27
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs

@ -43,8 +43,10 @@ namespace ICSharpCode.Core @@ -43,8 +43,10 @@ namespace ICSharpCode.Core
static DisplayBindingDescriptor GetCodonPerFileName(string filename)
{
foreach (DisplayBindingDescriptor binding in bindings) {
if (!binding.IsSecondary && binding.CanAttachToFile(filename) && binding.Binding.CanCreateContentForFile(filename)) {
return binding;
if (!binding.IsSecondary && binding.CanAttachToFile(filename)) {
if (binding.Binding != null && binding.Binding.CanCreateContentForFile(filename)) {
return binding;
}
}
}
return null;
@ -53,8 +55,10 @@ namespace ICSharpCode.Core @@ -53,8 +55,10 @@ namespace ICSharpCode.Core
static DisplayBindingDescriptor GetCodonPerLanguageName(string languagename)
{
foreach (DisplayBindingDescriptor binding in bindings) {
if (binding.Binding != null && binding.CanAttachToLanguage(languagename) && binding.Binding.CanCreateContentForLanguage(languagename)) {
return binding;
if (!binding.IsSecondary && binding.CanAttachToLanguage(languagename)) {
if (binding.Binding != null && binding.Binding.CanCreateContentForLanguage(languagename)) {
return binding;
}
}
}
return null;
@ -63,12 +67,15 @@ namespace ICSharpCode.Core @@ -63,12 +67,15 @@ namespace ICSharpCode.Core
public static void AttachSubWindows(IViewContent viewContent)
{
foreach (DisplayBindingDescriptor binding in bindings) {
if (binding.IsSecondary && binding.SecondaryBinding.CanAttachTo(viewContent)) {
ISecondaryViewContent[] subViewContents = binding.SecondaryBinding.CreateSecondaryViewContent(viewContent);
if (subViewContents != null) {
viewContent.SecondaryViewContents.AddRange(subViewContents);
} else {
MessageService.ShowError("Can't attach secondary view content. " + binding.SecondaryBinding + " returned null for " + viewContent + ".\n(should never happen)");
if (binding.IsSecondary && binding.CanAttachToFile(viewContent.FileName ?? viewContent.UntitledName)) {
ISecondaryDisplayBinding displayBinding = binding.SecondaryBinding;
if (displayBinding != null && displayBinding.CanAttachTo(viewContent)) {
ISecondaryViewContent[] subViewContents = binding.SecondaryBinding.CreateSecondaryViewContent(viewContent);
if (subViewContents != null) {
viewContent.SecondaryViewContents.AddRange(subViewContents);
} else {
MessageService.ShowError("Can't attach secondary view content. " + binding.SecondaryBinding + " returned null for " + viewContent + ".\n(should never happen)");
}
}
}
}

21
src/Main/Base/Project/Src/TextEditor/Codons/SyntaxModeDoozer.cs

@ -23,19 +23,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons @@ -23,19 +23,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons
{
public class AddInTreeSyntaxMode : SyntaxMode
{
Assembly[] assemblies;
Runtime[] runtimes;
public AddInTreeSyntaxMode(Assembly[] assemblies, string fileName, string name, string[] extensions) : base(fileName, name, extensions)
public AddInTreeSyntaxMode(Runtime[] runtimes, string fileName, string name, string[] extensions) : base(fileName, name, extensions)
{
this.assemblies = assemblies;
this.runtimes = runtimes;
}
public XmlTextReader CreateTextReader()
{
foreach (Assembly assembly in assemblies) {
Stream stream = assembly.GetManifestResourceStream(FileName);
if (stream != null) {
return new XmlTextReader(stream);
foreach (Runtime runtime in runtimes) {
Assembly assembly = runtime.LoadedAssembly;
if (assembly != null) {
Stream stream = assembly.GetManifestResourceStream(FileName);
if (stream != null) {
return new XmlTextReader(stream);
}
}
}
return null;
@ -78,10 +81,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons @@ -78,10 +81,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons
string[] extensions = codon.Properties["extensions"].Split(';');
string resource = codon.Properties["resource"];
Assembly[] assemblies = new Assembly[codon.AddIn.Runtimes.Count];
Runtime[] assemblies = new Runtime[codon.AddIn.Runtimes.Count];
int i = 0;
foreach (Runtime library in codon.AddIn.Runtimes) {
assemblies[i++] = library.LoadedAssembly;
assemblies[i++] = library;
}
return new AddInTreeSyntaxMode(assemblies, resource, highlightingName, extensions);
}

4
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -424,8 +424,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -424,8 +424,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
if (fileName == null || fileName.Length == 0) {
if (language == "C#") {
parseInfo = ParserService.ParseFile("a.cs", textAreaControl.Document.TextContent, false, false);
} else {
} else if (language == "VBNet") {
parseInfo = ParserService.ParseFile("a.vb", textAreaControl.Document.TextContent, false, false);
} else {
return;
}
} else {
parseInfo = ParserService.GetParseInformation(fileName);

Loading…
Cancel
Save