Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Merge branch '4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Nov 23, 2010
2 parents 1b2c8b4 + 32c1efa commit 76f2093
Show file tree
Hide file tree
Showing 41 changed files with 456 additions and 351 deletions.
3 changes: 3 additions & 0 deletions data/resources/StringResources.resx
Expand Up @@ -8030,6 +8030,9 @@ The resources files have been renamed/moved accordingly.</value>
<value>Open new buffer</value>
</data>
<data name="XML.MainMenu.FileMenu.New.Project" xml:space="preserve">
<value>&amp;Project...</value>
</data>
<data name="XML.MainMenu.FileMenu.New.Solution" xml:space="preserve">
<value>&amp;Solution...</value>
</data>
<data name="XML.MainMenu.FileMenu.Open" xml:space="preserve">
Expand Down
3 changes: 1 addition & 2 deletions data/templates/file/CSharp/CSharp.UnitTest.xft
Expand Up @@ -53,8 +53,7 @@
<Files>
<File name="${FullName}" language="C#"><![CDATA[${StandardHeader.C#}
<% if (ConditionalClass) { %>#if TEST
<% } %>
using System;
<% } %>using System;
using NUnit.Framework;
namespace ${StandardNamespace}
Expand Down
Expand Up @@ -313,7 +313,7 @@ void FormatLineInternal(ITextEditor textArea, int lineNr, int cursorOffset, char
case '>':
if (IsInsideDocumentationComment(textArea, curLine, cursorOffset)) {
curLineText = curLine.Text;
int column = textArea.Caret.Offset - curLine.Offset;
int column = cursorOffset - curLine.Offset;
int index = Math.Min(column - 1, curLineText.Length - 1);

while (index >= 0 && curLineText[index] != '<') {
Expand All @@ -332,9 +332,7 @@ void FormatLineInternal(ITextEditor textArea, int lineNr, int cursorOffset, char
tag += ">";
}
if (!tag.StartsWith("/")) {
int caretOffset = textArea.Caret.Offset;
textArea.Document.Insert(caretOffset, "</" + tag.Substring(1));
textArea.Caret.Offset = caretOffset;
textArea.Document.Insert(cursorOffset, "</" + tag.Substring(1), AnchorMovementType.BeforeInsertion);
}
}
}
Expand Down
Expand Up @@ -67,6 +67,11 @@ public void Insert(int offset, string text)
throw new NotImplementedException();
}

public void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType)
{
throw new NotImplementedException();
}

public void Remove(int offset, int length)
{
throw new NotImplementedException();
Expand Down
Expand Up @@ -2,7 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
Expand All @@ -17,18 +20,12 @@ public class TParser : IParser
string[] lexerTags;

public string[] LexerTags {
get {
return lexerTags;
}
set {
lexerTags = value;
}
get { return lexerTags; }
set { lexerTags = value; }
}

public LanguageProperties Language {
get {
return LanguageProperties.VBNet;
}
get { return LanguageProperties.VBNet; }
}

public IExpressionFinder CreateExpressionFinder(string fileName)
Expand All @@ -48,42 +45,36 @@ public bool CanParse(IProject project)

static void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker)
{
for (int i = 0; i < tracker.CurrentSpecials.Count; ++i)
{
ICSharpCode.NRefactory.PreprocessingDirective directive = tracker.CurrentSpecials[i] as ICSharpCode.NRefactory.PreprocessingDirective;
if (directive != null)
{
if (directive.Cmd.Equals("#region", StringComparison.OrdinalIgnoreCase))
{
int deep = 1;
for (int j = i + 1; j < tracker.CurrentSpecials.Count; ++j)
{
ICSharpCode.NRefactory.PreprocessingDirective nextDirective = tracker.CurrentSpecials[j] as ICSharpCode.NRefactory.PreprocessingDirective;
if (nextDirective != null)
{
switch (nextDirective.Cmd.ToUpperInvariant())
{
case "#REGION":
++deep;
break;
case "#END":
if (nextDirective.Arg.Equals("region", StringComparison.OrdinalIgnoreCase)) {
--deep;
if (deep == 0) {
cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim('"'), DomRegion.FromLocation(directive.StartPosition, nextDirective.EndPosition)));
goto end;
}
}
break;
}
}
}
end: ;
}
Stack<ICSharpCode.NRefactory.PreprocessingDirective> regionStartDirectives = new Stack<ICSharpCode.NRefactory.PreprocessingDirective>();

foreach (ICSharpCode.NRefactory.PreprocessingDirective directive in tracker.CurrentSpecials.OfType<ICSharpCode.NRefactory.PreprocessingDirective>()) {
if (directive.Cmd.Equals("#region", StringComparison.OrdinalIgnoreCase))
regionStartDirectives.Push(directive);
if (directive.Cmd.Equals("#end", StringComparison.OrdinalIgnoreCase)
// using StartsWith allows comments at end of line
// fixes http://community.sharpdevelop.net/forums/t/12252.aspx
&& directive.Arg.StartsWith("region", StringComparison.OrdinalIgnoreCase)
&& regionStartDirectives.Any()) {
ICSharpCode.NRefactory.PreprocessingDirective start = regionStartDirectives.Pop();
cu.FoldingRegions.Add(new FoldingRegion(TrimComment(start.Arg).Trim('"'), DomRegion.FromLocation(start.StartPosition, directive.EndPosition)));
}
}
}

static string TrimComment(string argument)
{
bool inStr = false;

for (int i = 0; i < argument.Length; i++) {
if (argument[i] == '"')
inStr = !inStr;
if (argument[i] == '\'' && !inStr)
return argument.Substring(0, i).Trim();
}

return argument;
}

public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ICSharpCode.SharpDevelop.ITextBuffer fileContent)
{
using (ICSharpCode.NRefactory.IParser p = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet, fileContent.CreateReader())) {
Expand Down
Expand Up @@ -143,8 +143,10 @@ public void Execute(object parameter)
if (snippet != null) {
snippet.TrackUsage("CustomTabCommand");

editor.Adapter.Document.Remove(wordStart, editor.CaretOffset - wordStart);
snippet.CreateAvalonEditSnippet(editor.Adapter).Insert(editor.TextArea);
using (editor.Document.RunUpdate()) {
editor.Adapter.Document.Remove(wordStart, editor.CaretOffset - wordStart);
snippet.CreateAvalonEditSnippet(editor.Adapter).Insert(editor.TextArea);
}
return;
}
}
Expand Down
Expand Up @@ -81,6 +81,11 @@ public void Insert(int offset, string text)
throw new NotImplementedException();
}

public void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType)
{
throw new NotImplementedException();
}

public void Remove(int offset, int length)
{
throw new NotImplementedException();
Expand Down
2 changes: 1 addition & 1 deletion src/AddIns/Misc/AddInManager/Project/Src/Commands.cs
Expand Up @@ -139,7 +139,7 @@ public override void Run()
AddInTreeNode dummyNode = new AddInTreeNode();
foreach (KeyValuePair<string, ExtensionPath> pair in addIn.Paths) {
if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) {
dummyNode.Codons.AddRange(pair.Value.Codons);
dummyNode.AddCodons(pair.Value.Codons);
}
}
ICSharpCode.SharpDevelop.Commands.OptionsCommand.ShowTabbedOptions(addIn.Name + " " + ResourceService.GetString("AddInManager.Options"),
Expand Down
2 changes: 1 addition & 1 deletion src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs
Expand Up @@ -145,7 +145,7 @@ public SearchResultMatch FindNext(int offset, int length)
if (documentIterator.MoveForward()) {
info = documentIterator.Current;
// document is valid for searching -> set iterator & fileName
if (info != null && info.EndOffset >= 0 && info.EndOffset <= info.Document.TextLength) {
if (info != null && info.EndOffset >= 0 && info.EndOffset < info.Document.TextLength) {
textIterator = textIteratorBuilder.BuildTextIterator(info);
} else {
textIterator = null;
Expand Down
Expand Up @@ -432,8 +432,7 @@ void RunAllInSelection(int action)
SearchReplaceManager.MarkAll(startOffset, endOffset - startOffset, monitor);
else if (action == 2)
SearchReplaceManager.ReplaceAll(startOffset, endOffset - startOffset, monitor);

textEditor.Select(startOffset, textEditor.SelectionLength);
textEditor.Select(startOffset, endOffset - startOffset);
} finally {
ignoreSelectionChanges = false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/AddIns/Misc/SearchAndReplace/Test/MockDocument.cs
Expand Up @@ -62,6 +62,11 @@ public void Insert(int offset, string text)
throw new NotImplementedException();
}

public void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType)
{
throw new NotImplementedException();
}

public void Remove(int offset, int length)
{
throw new NotImplementedException();
Expand Down
Expand Up @@ -63,10 +63,12 @@ protected virtual void OKButtonClick(object sender, RoutedEventArgs e)
LanguageProperties language = parseInfo.CompilationUnit.Language;
IClass current = parseInfo.CompilationUnit.GetInnermostClass(anchor.Line, anchor.Column);

// GenerateCode could modify the document.
// So read anchor.Offset after code generation.
string code = GenerateCode(language, current) ?? "";
editor.Document.Insert(anchor.Offset, code);
using (editor.Document.OpenUndoGroup()) {
// GenerateCode could modify the document.
// So read anchor.Offset after code generation.
string code = GenerateCode(language, current) ?? "";
editor.Document.Insert(anchor.Offset, code);
}
}

Deactivate();
Expand Down
42 changes: 33 additions & 9 deletions src/AddIns/VersionControl/GitAddIn/Src/RegisterEventsCommand.cs
Expand Up @@ -14,23 +14,47 @@ public class RegisterEventsCommand : AbstractCommand
{
public override void Run()
{
FileService.FileCreated += (sender, args) => {
Git.Add(args.FileName,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, args.FileName)
);
FileService.FileCreated += (sender, e) => {
AddFile(e.FileName);
};
FileService.FileRemoved += (sender, args) => {
if (GitStatusCache.GetFileStatus(args.FileName) == GitStatus.Added) {
Git.Remove(args.FileName, true,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, args.FileName));
}
FileService.FileCopied += (sender, e) => {
AddFile(e.TargetFile);
};
FileService.FileRemoved += (sender, e) => {
RemoveFile(e.FileName);
};
FileService.FileRenamed += (sender, e) => {
RenameFile(e.SourceFile, e.TargetFile);
};
FileUtility.FileSaved += (sender, e) => {
ClearStatusCacheAndEnqueueFile(e.FileName);
};
AbstractProjectBrowserTreeNode.OnNewNode += TreeNodeCreated;
}

void AddFile(string fileName)
{
Git.Add(fileName,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, fileName)
);
}

void RemoveFile(string fileName)
{
if (GitStatusCache.GetFileStatus(fileName) == GitStatus.Added) {
Git.Remove(fileName, true,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, fileName));
}
}

void RenameFile(string sourceFileName, string targetFileName)
{
Git.Add(targetFileName,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(RemoveFile, sourceFileName)
);
WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, targetFileName);
}

void TreeNodeCreated(object sender, TreeViewEventArgs e)
{
SolutionNode sn = e.Node as SolutionNode;
Expand Down
Expand Up @@ -314,6 +314,8 @@ void FileCopying(object sender, FileRenamingEventArgs e)
if (!AddInOptions.AutomaticallyRenameFiles) return;
string fullSource = Path.GetFullPath(e.SourceFile);
if (!CanBeVersionControlledFile(fullSource)) return;
string fullTarget = Path.GetFullPath(e.TargetFile);
if (!CanBeVersionControlledFile(fullTarget)) return;
try {
using (SvnClientWrapper client = new SvnClientWrapper()) {
SvnMessageView.HandleNotifications(client);
Expand All @@ -335,9 +337,7 @@ void FileCopying(object sender, FileRenamingEventArgs e)
return;
}
e.OperationAlreadyDone = true;
client.Copy(fullSource,
Path.GetFullPath(e.TargetFile)
);
client.Copy(fullSource, fullTarget);
}
} catch (Exception ex) {
MessageService.ShowError("File renamed exception: " + ex);
Expand Down
Expand Up @@ -23,6 +23,7 @@ public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs ch
public void Undo(UndoStack stack)
{
Debug.Assert(stack.state == UndoStack.StatePlayback);
stack.RegisterAffectedDocument(document);
stack.state = UndoStack.StatePlaybackModifyDocument;
this.Undo();
stack.state = UndoStack.StatePlayback;
Expand All @@ -31,6 +32,7 @@ public void Undo(UndoStack stack)
public void Redo(UndoStack stack)
{
Debug.Assert(stack.state == UndoStack.StatePlayback);
stack.RegisterAffectedDocument(document);
stack.state = UndoStack.StatePlaybackModifyDocument;
this.Redo();
stack.state = UndoStack.StatePlayback;
Expand Down
Expand Up @@ -98,7 +98,6 @@ public TextDocument(IEnumerable<char> initialText)

anchorTree = new TextAnchorTree(this);
undoStack = new UndoStack();
undoStack.AttachToDocument(this);
FireChangeEvents();
}

Expand Down Expand Up @@ -354,6 +353,7 @@ public void BeginUpdate()
throw new InvalidOperationException("Cannot change document within another document change.");
beginUpdateCount++;
if (beginUpdateCount == 1) {
undoStack.StartUndoGroup();
if (UpdateStarted != null)
UpdateStarted(this, EventArgs.Empty);
}
Expand All @@ -374,6 +374,7 @@ public void EndUpdate()
// fire change events inside the change group - event handlers might add additional
// document changes to the change group
FireChangeEvents();
undoStack.EndUndoGroup();
beginUpdateCount = 0;
if (UpdateFinished != null)
UpdateFinished(this, EventArgs.Empty);
Expand Down Expand Up @@ -590,6 +591,8 @@ void DoReplace(int offset, int length, string newText, OffsetChangeMap offsetCha
if (Changing != null)
Changing(this, args);

undoStack.Push(this, args);

cachedText = null; // reset cache of complete document text
fireTextChanged = true;
DelayedEvents delayedEvents = new DelayedEvents();
Expand Down
Expand Up @@ -22,9 +22,8 @@ public UndoOperationGroup(Deque<IUndoableOperation> stack, int numops)
}

Debug.Assert(numops > 0 , "UndoOperationGroup : numops should be > 0");
if (numops > stack.Count) {
numops = stack.Count;
}
Debug.Assert(numops <= stack.Count);

undolist = new IUndoableOperation[numops];
for (int i = 0; i < numops; ++i) {
undolist[i] = stack.PopBack();
Expand Down

0 comments on commit 76f2093

Please sign in to comment.