|
|
@ -18,14 +18,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using ICSharpCode.NRefactory; |
|
|
|
using ICSharpCode.NRefactory; |
|
|
|
using ICSharpCode.SharpDevelop.Dom; |
|
|
|
using ICSharpCode.NRefactory.Editor; |
|
|
|
|
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.PackageManagement.EnvDTE |
|
|
|
namespace ICSharpCode.PackageManagement.EnvDTE |
|
|
|
{ |
|
|
|
{ |
|
|
|
public class EditPoint : TextPoint, global::EnvDTE.EditPoint |
|
|
|
public class EditPoint : TextPoint, global::EnvDTE.EditPoint |
|
|
|
{ |
|
|
|
{ |
|
|
|
// IRefactoringDocument document;
|
|
|
|
IDocument document; |
|
|
|
// IRefactoringDocumentView documentView;
|
|
|
|
IRefactoringDocumentView documentView; |
|
|
|
|
|
|
|
|
|
|
|
internal EditPoint(string fileName, TextLocation location, IDocumentLoader documentLoader) |
|
|
|
internal EditPoint(string fileName, TextLocation location, IDocumentLoader documentLoader) |
|
|
|
: base(fileName, location, documentLoader) |
|
|
|
: base(fileName, location, documentLoader) |
|
|
@ -39,47 +40,46 @@ namespace ICSharpCode.PackageManagement.EnvDTE |
|
|
|
|
|
|
|
|
|
|
|
void ReplaceText(TextPoint endPoint, string text, global::EnvDTE.vsEPReplaceTextOptions textFormatOptions) |
|
|
|
void ReplaceText(TextPoint endPoint, string text, global::EnvDTE.vsEPReplaceTextOptions textFormatOptions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
OpenDocument(); |
|
|
|
// OpenDocument();
|
|
|
|
int offset = GetStartOffset(); |
|
|
|
// int offset = GetStartOffset();
|
|
|
|
int endOffset = GetEndOffset(endPoint); |
|
|
|
// int endOffset = GetEndOffset(endPoint);
|
|
|
|
document.Replace(offset, endOffset - offset, text); |
|
|
|
// document.Replace(offset, endOffset - offset, text);
|
|
|
|
IndentReplacedText(text); |
|
|
|
// IndentReplacedText(text);
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OpenDocument() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
documentView = documentLoader.LoadRefactoringDocumentView(fileName); |
|
|
|
|
|
|
|
document = documentView.RefactoringDocument; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int GetStartOffset() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return document.PositionToOffset(Line, LineCharOffset); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int GetEndOffset(TextPoint endPoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return document.PositionToOffset(endPoint.Line, endPoint.LineCharOffset); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Indents all lines apart from the first one since it is assumed
|
|
|
|
|
|
|
|
/// that the first line had the correct indentation.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
void IndentReplacedText(string text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int lineCount = GetLineCount(text); |
|
|
|
|
|
|
|
if (lineCount > 1) { |
|
|
|
|
|
|
|
documentView.IndentLines(Line + 1, Line + lineCount); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int GetLineCount(string text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return text.Split('\n').Length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// void OpenDocument()
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// documentView = DocumentLoader.LoadRefactoringDocumentView(FilePosition.FileName);
|
|
|
|
|
|
|
|
// document = documentView.RefactoringDocument;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// int GetStartOffset()
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return document.PositionToOffset(Line, LineCharOffset);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// int GetEndOffset(TextPoint endPoint)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return document.PositionToOffset(endPoint.Line, endPoint.LineCharOffset);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// /// <summary>
|
|
|
|
|
|
|
|
// /// Indents all lines apart from the first one since it is assumed
|
|
|
|
|
|
|
|
// /// that the first line had the correct indentation.
|
|
|
|
|
|
|
|
// /// </summary>
|
|
|
|
|
|
|
|
// void IndentReplacedText(string text)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int lineCount = GetLineCount(text);
|
|
|
|
|
|
|
|
// if (lineCount > 1) {
|
|
|
|
|
|
|
|
// documentView.IndentLines(Line + 1, Line + lineCount);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// int GetLineCount(string text)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return text.Split('\n').Length;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
public void Insert(string text) |
|
|
|
public void Insert(string text) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
throw new NotImplementedException(); |
|
|
|