15 changed files with 143 additions and 309 deletions
@ -1,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class ClassKindUpdater : IClassKindUpdater
|
||||
// {
|
||||
// public ClassKindUpdater(IClass c)
|
||||
// : this(c, new DocumentLoader())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public ClassKindUpdater(IClass c, IDocumentLoader documentLoader)
|
||||
// {
|
||||
// this.Class = c;
|
||||
// this.DocumentLoader = documentLoader;
|
||||
// }
|
||||
//
|
||||
// IClass Class { get; set; }
|
||||
// IDocumentLoader DocumentLoader { get; set; }
|
||||
// IRefactoringDocument Document { get; set; }
|
||||
//
|
||||
// public void MakeClassPartial()
|
||||
// {
|
||||
// if (Class.IsPartial)
|
||||
// return;
|
||||
//
|
||||
// OpenFileContainingClass();
|
||||
// int offset = GetPartialKeywordInsertOffset();
|
||||
// InsertPartialKeyword(offset);
|
||||
// }
|
||||
//
|
||||
// void OpenFileContainingClass()
|
||||
// {
|
||||
// Document = DocumentLoader.LoadRefactoringDocument(Class.CompilationUnit.FileName);
|
||||
// }
|
||||
//
|
||||
// int GetPartialKeywordInsertOffset()
|
||||
// {
|
||||
// IRefactoringDocumentLine line = Document.GetLine(Class.Region.BeginLine);
|
||||
// int offset = line.Text.IndexOf(" class", StringComparison.OrdinalIgnoreCase);
|
||||
// if (offset >= 0) {
|
||||
// return offset + line.Offset + 1;
|
||||
// }
|
||||
// throw new ApplicationException("Unable to find 'class' declaration.");
|
||||
// }
|
||||
//
|
||||
// void InsertPartialKeyword(int offset)
|
||||
// {
|
||||
// string partialKeyword = GetLanguageSpecificPartialKeyword();
|
||||
// Document.Insert(offset, partialKeyword + " ");
|
||||
// }
|
||||
//
|
||||
// string GetLanguageSpecificPartialKeyword()
|
||||
// {
|
||||
// if (Class.ProjectContent.Language == LanguageProperties.VBNet) {
|
||||
// return "Partial";
|
||||
// }
|
||||
// return "partial";
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Refactoring; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class ThreadSafeCodeGenerator : ICodeGenerator |
||||
{ |
||||
readonly CodeGenerator codeGenerator; |
||||
readonly IMessageLoop mainThread; |
||||
|
||||
public ThreadSafeCodeGenerator(CodeGenerator codeGenerator) |
||||
{ |
||||
this.codeGenerator = codeGenerator; |
||||
this.mainThread = SD.MainThread; |
||||
} |
||||
|
||||
public void AddImport(FileName fileName, string name) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.AddImport(fileName, name)); |
||||
} |
||||
|
||||
public void MakePartial(ITypeDefinition typeDefinition) |
||||
{ |
||||
InvokeIfRequired(() => codeGenerator.MakePartial(typeDefinition)); |
||||
} |
||||
|
||||
void InvokeIfRequired(Action action) |
||||
{ |
||||
mainThread.InvokeIfRequired(action); |
||||
} |
||||
} |
||||
} |
@ -1,180 +0,0 @@
@@ -1,180 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
//using System;
|
||||
//using ICSharpCode.PackageManagement;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//using Rhino.Mocks;
|
||||
//
|
||||
//namespace PackageManagement.Tests
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class ClassKindUpdaterTests
|
||||
// {
|
||||
// ClassKindUpdater updater;
|
||||
// ClassHelper classHelper;
|
||||
// IRefactoringDocument document;
|
||||
// IDocumentLoader documentLoader;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// classHelper = new ClassHelper();
|
||||
// document = MockRepository.GenerateStub<IRefactoringDocument>();
|
||||
// documentLoader = MockRepository.GenerateStub<IDocumentLoader>();
|
||||
// }
|
||||
//
|
||||
// void CreatePublicCSharpClass()
|
||||
// {
|
||||
// classHelper.CreatePublicClass("MyClass");
|
||||
// classHelper.ProjectContentHelper.ProjectContentIsForCSharpProject();
|
||||
// }
|
||||
//
|
||||
// void CreatePublicVisualBasicClass()
|
||||
// {
|
||||
// classHelper.CreatePublicClass("MyClass");
|
||||
// classHelper.ProjectContentHelper.ProjectContentIsForVisualBasicProject();
|
||||
// }
|
||||
//
|
||||
// void SetDocumentFileName(string fileName)
|
||||
// {
|
||||
// documentLoader.Stub(loader => loader.LoadRefactoringDocument(fileName)).Return(document);
|
||||
// }
|
||||
//
|
||||
// void CreateClassKindUpdater()
|
||||
// {
|
||||
// updater = new ClassKindUpdater(classHelper.Class, documentLoader);
|
||||
// }
|
||||
//
|
||||
// void SetClassFileName(string fileName)
|
||||
// {
|
||||
// classHelper.SetClassFileName(fileName);
|
||||
// SetDocumentFileName(fileName);
|
||||
// }
|
||||
//
|
||||
// void SetClassDeclarationLineWithOffset(int line, string text, int offset)
|
||||
// {
|
||||
// classHelper.SetRegionBeginLine(line);
|
||||
// SetDocumentLineText(line, text, offset);
|
||||
// }
|
||||
//
|
||||
// void SetClassDeclarationLine(int line, string text)
|
||||
// {
|
||||
// SetClassDeclarationLineWithOffset(line, text, 0);
|
||||
// }
|
||||
//
|
||||
// void SetDocumentLineText(int lineNumber, string text, int offset)
|
||||
// {
|
||||
// IRefactoringDocumentLine documentLine = MockRepository.GenerateStub<IRefactoringDocumentLine>();
|
||||
// documentLine.Stub(line => line.Text).Return(text);
|
||||
// documentLine.Stub(line => line.Offset).Return(offset);
|
||||
// document.Stub(doc => doc.GetLine(lineNumber)).Return(documentLine);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassWithNoOtherModifiers_OpensFileContainingClassInSharpDevelop()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// string fileName = @"d:\projects\MyProject\MyClass.cs";
|
||||
// SetClassFileName(fileName);
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// documentLoader.AssertWasCalled(loader => loader.LoadRefactoringDocument(fileName));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassWithNoOtherModifiers_AddsPartialKeywordToClassDefinition()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(7, "partial "));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassThatIsAlreadyPartial_ClassDefinitionIsUnchanged()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// classHelper.MakeClassPartial();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasNotCalled(doc => doc.Insert(Arg<int>.Is.Anything, Arg<string>.Is.Anything));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicVisualBasicClassWithNoOtherModifiers_AddsVisualBasicPartialKeywordToClassDefinition()
|
||||
// {
|
||||
// CreatePublicVisualBasicClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.vb");
|
||||
// SetClassDeclarationLine(1, "Public Class MyClass");
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(7, "Partial "));
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_NoClassKeywordInClassDeclarationLine_ExceptionIsThrown()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\test.cs");
|
||||
// SetClassDeclarationLine(1, "public test");
|
||||
//
|
||||
// Assert.Throws<ApplicationException>(() => updater.MakeClassPartial());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_NoClassKeywordButClassNameIncludesClassKeyword_ExceptionIsThrown()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLine(1, "public MyClass");
|
||||
//
|
||||
// Assert.Throws<ApplicationException>(() => updater.MakeClassPartial());
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void MakeClassPartial_PublicCSharpClassNotOnFirstLine_AddsPartialKeywordToClassDefinitionAtCorrectOffset()
|
||||
// {
|
||||
// CreatePublicCSharpClass();
|
||||
// CreateClassKindUpdater();
|
||||
// SetClassFileName(@"d:\projects\MyProject\MyClass.cs");
|
||||
// SetClassDeclarationLineWithOffset(1, "public class MyClass", offset: 10);
|
||||
//
|
||||
// updater.MakeClassPartial();
|
||||
//
|
||||
// document.AssertWasCalled(doc => doc.Insert(17, "partial "));
|
||||
// }
|
||||
// }
|
||||
//}
|
Loading…
Reference in new issue