Skip to content

Commit

Permalink
Remove ReSharper 8.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ulex committed Apr 28, 2015
1 parent 15bf310 commit 55e56cf
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 1,484 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ How it's work:
How do I get it?
---
You can install directly into ReSharper 8.2 or 9.0 via the Extension Manager in the
ReSharper menu.
ReSharper menu. (8.2 support removed, but binary version still available in R# gallery)

Predifined templates
---
Expand Down
69 changes: 44 additions & 25 deletions ZenSharp.Integration/CSharpExtendedScopeProvider.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;

using JetBrains.Application;
using JetBrains.DocumentModel;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.CSharp.CodeCompletion;
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Context;
using JetBrains.ReSharper.Feature.Services.LiveTemplates.LiveTemplates;
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Scope;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.CSharp.Impl.Tree;
using JetBrains.ReSharper.Psi.CSharp.Parsing;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using JetBrains.ReSharper.Psi.Files;
using JetBrains.ReSharper.Psi.Tree;

#if RESHARPER_91
using JetBrains.ReSharper.Resources.Shell;
#endif

#if RESHARPER_82
using JetBrains.ReSharper.Psi.Services.CSharp;
#endif

#if RESHARPER_90
using JetBrains.ReSharper.Resources.Shell;
using IDocCommentBlockNode = JetBrains.ReSharper.Psi.Tree.IDocCommentBlock;

#endif

namespace Github.Ulex.ZenSharp.Integration
Expand All @@ -35,15 +22,21 @@ namespace Github.Ulex.ZenSharp.Integration
public sealed class CSharpExtendedScopeProvider
{
/// <summary>
/// Too lazy to implement full ITemplateScopePoint
/// Too lazy to implement full ITemplateScopePoint
/// </summary>
public IEnumerable<string> ProvideScopePoints(TemplateAcceptanceContext tacContext)
{
var solution = tacContext.Solution;
var document = tacContext.Document;
if (document == null) yield break;
if (document == null)
{
yield break;
}
var psiSource = document.GetPsiSourceFile(solution);
if (psiSource == null) yield break;
if (psiSource == null)
{
yield break;
}

using (ReadLockCookie.Create())
{
Expand All @@ -60,24 +53,36 @@ public IEnumerable<string> ProvideScopePoints(TemplateAcceptanceContext tacConte
yield break;
}
var file = psiSource.GetPsiFile<CSharpLanguage>(documentRange);
if (file == null || !Equals(file.Language, CSharpLanguage.Instance)) yield break;
if (file == null || !Equals(file.Language, CSharpLanguage.Instance))
{
yield break;
}
var element = file.FindTokenAt(document, caretOffset - prefix.Length);
if (element == null) yield break;
if (element == null)
{
yield break;
}

yield return "InCSharpFile";
var treeNode = element;

#if RESHARPER_91
if (treeNode.GetContainingNode<IDocCommentNode>(true) != null) yield break;
#else
if (treeNode.GetContainingNode<IDocCommentBlockNode>(true) != null) yield break;
if (treeNode.GetContainingNode<IDocCommentBlockNode>(true) != null)
{
yield break;
}
#endif

if (treeNode is ICSharpCommentNode || treeNode is IPreprocessorDirective)
{
treeNode = treeNode.PrevSibling;
}
if (treeNode == null) yield break;
if (treeNode == null)
{
yield break;
}

var context = CSharpReparseContext.FindContext(treeNode);
if (context == null)
Expand All @@ -86,7 +91,9 @@ public IEnumerable<string> ProvideScopePoints(TemplateAcceptanceContext tacConte
}

if (treeNode.GetContainingNode<IEnumDeclaration>() != null)
{
yield return "InCSharpEnum";
}

var containingType = treeNode.GetContainingNode<ICSharpTypeDeclaration>(true);
if (containingType == null && TestNode<ICSharpNamespaceDeclaration>(context, "namespace N {}", false))
Expand All @@ -98,22 +105,34 @@ public IEnumerable<string> ProvideScopePoints(TemplateAcceptanceContext tacConte
yield return "InCSharpTypeMember";
// Extend here:
// Already in type member,
if (treeNode.GetContainingNode<IInterfaceDeclaration>() != null)
if (treeNode.GetContainingNode<IInterfaceDeclaration>() != null)
{
yield return "InCSharpInterface";
}
if (treeNode.GetContainingNode<IClassDeclaration>() != null)
{
yield return "InCSharpClass";
}
if (treeNode.GetContainingNode<IStructDeclaration>() != null)
{
yield return "InCSharpStruct";
}
}
else
{
bool acceptsExpression = TestNode<IPostfixOperatorExpression>(context, "a++", true);
if (TestNode<IBreakStatement>(context, "break;", false))
{
yield return "InCSharpStatement";
}
else if (acceptsExpression)
{
yield return "InCSharpExpression";
}
if (!acceptsExpression && TestNode<IQuerySelectClause>(context, "select x", false))
{
yield return "InCSharpQuery";
}
}
}
}
Expand Down Expand Up @@ -148,4 +167,4 @@ private static bool TestNode<T>(CSharpReparseContext context, string text, bool
return true;
}
}
}
}
23 changes: 7 additions & 16 deletions ZenSharp.Integration/EditConfigActionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
using JetBrains.ActionManagement;
using JetBrains.Application;
using JetBrains.Application.DataContext;
using JetBrains.Application.Settings;
using JetBrains.IDE;
using JetBrains.Util;

using DataConstants = JetBrains.ProjectModel.DataContext.DataConstants;

#if RESHARPER_90 || RESHARPER_91
using JetBrains.UI.MenuGroups;
using JetBrains.ReSharper.Resources.Shell;
using JetBrains.UI.ActionsRevised;
using JetBrains.ReSharper.Feature.Services.Menu;
#endif
using JetBrains.UI.MenuGroups;
using JetBrains.Util;

using DataConstants = JetBrains.ProjectModel.DataContext.DataConstants;

namespace Github.Ulex.ZenSharp.Integration
{
#if RESHARPER_90 || RESHARPER_91
[ActionGroup(ActionGroupInsertStyles.Embedded)]
public class ZenSharpGroup : IAction, IInsertLast<VsMainMenuGroup>
{
Expand All @@ -28,11 +21,6 @@ public ZenSharpGroup(Separator sep, EditConfigActionHandler handler)

[Action("Edit ZenSharp templates", Id = 11122233)]
public class EditConfigActionHandler : IExecutableAction
#else

[ActionHandler("ZenSharp.EditConfig")]
public class EditConfigActionHandler : IActionHandler
#endif
{
public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
{
Expand All @@ -48,7 +36,10 @@ public void Execute(IDataContext context, DelegateExecute nextExecute)

var solution = context.GetData(DataConstants.SOLUTION);
EditorManager.GetInstance(solution)
.OpenFile(FileSystemPath.CreateByCanonicalPath(ZenSharpSettings.GetTreePath(settings.TreeFilename)), true, TabOptions.Default);
.OpenFile(
FileSystemPath.CreateByCanonicalPath(ZenSharpSettings.GetTreePath(settings.TreeFilename)),
true,
TabOptions.Default);
}
}
}
10 changes: 0 additions & 10 deletions ZenSharp.Integration/LtgConfigWatcher.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
using System;
using System.IO;
using System.Linq;

#if !RESHARPER_91
using System.Windows.Annotations;
#endif

using Github.Ulex.ZenSharp.Core;

using JetBrains.Application;
using JetBrains.Application.Settings;
using JetBrains.DataFlow;
using JetBrains.IDE;
using JetBrains.ProjectModel;
using JetBrains.TextControl;
using JetBrains.TextControl.Coords;
using JetBrains.Util;

using NLog;
Expand Down
65 changes: 21 additions & 44 deletions ZenSharp.Integration/Option/ZenSettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;

using Github.Ulex.ZenSharp.Core;

using JetBrains.Application;
using JetBrains.Application.Components;
using JetBrains.Application.DataContext;
using JetBrains.Application.Settings;
using JetBrains.DataFlow;
using JetBrains.ReSharper.Resources.Shell;
using JetBrains.UI.CrossFramework;
using JetBrains.UI.Options;
using JetBrains.UI.Options.OptionPages;
Expand All @@ -20,29 +16,16 @@

using NLog;

#if RESHARPER_82
using JetBrains.UI.Application.PluginSupport;
#endif
#if RESHARPER_90
using JetBrains.ReSharper.Resources.Shell;
#endif

#if RESHARPER_91
using JetBrains.ReSharper.Resources.Shell;
#endif


using DataConstants = JetBrains.ProjectModel.DataContext.DataConstants;

namespace Github.Ulex.ZenSharp.Integration
{
/// <summary>
/// Interaction logic for ZenSettingsPage.xaml
/// Interaction logic for ZenSettingsPage.xaml
/// </summary>
[OptionsPage(pageId, "ZenSharp", typeof(OptionsThemedIcons.Plugins), ParentId = EnvironmentPage.Pid)]
public partial class ZenSettingsPage : IOptionsPage
{
private const string pageId = "ZenSettingsPageId";

private static readonly Logger Log = LogManager.GetCurrentClassLogger();

public ZenSettingsPage(Lifetime lifetime, OptionsSettingsSmartContext settings, IComponentContainer container)
Expand All @@ -55,34 +38,31 @@ public ZenSettingsPage(Lifetime lifetime, OptionsSettingsSmartContext settings,
OnOk();
}

private LtgConfigWatcher _zenWatcher;
private readonly LtgConfigWatcher _zenWatcher;

public static readonly DependencyProperty PathProperty = DependencyProperty.Register("Path", typeof(string), typeof(ZenSettingsPage), new PropertyMetadata(default(string)));
public static readonly DependencyProperty PathProperty = DependencyProperty.Register(
"Path",
typeof(string),
typeof(ZenSettingsPage),
new PropertyMetadata(default(string)));

public string Path
{
get
{
return (string)GetValue(PathProperty);
}
set
{
SetValue(PathProperty, value);
}
get { return (string)GetValue(PathProperty); }
set { SetValue(PathProperty, value); }
}

public static readonly DependencyProperty PostValidationErrorProperty = DependencyProperty.Register("PostValidationError", typeof(Exception), typeof(ZenSettingsPage), new PropertyMetadata(default(Exception)));
public static readonly DependencyProperty PostValidationErrorProperty =
DependencyProperty.Register(
"PostValidationError",
typeof(Exception),
typeof(ZenSettingsPage),
new PropertyMetadata(default(Exception)));

public Exception PostValidationError
{
get
{
return (Exception)GetValue(PostValidationErrorProperty);
}
set
{
SetValue(PostValidationErrorProperty, value);
}
get { return (Exception)GetValue(PostValidationErrorProperty); }
set { SetValue(PostValidationErrorProperty, value); }
}

public string Id { get; private set; }
Expand Down Expand Up @@ -111,10 +91,7 @@ public bool ValidatePage()

public EitherControl Control
{
get
{
return this;
}
get { return this; }
}

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
Expand All @@ -139,4 +116,4 @@ private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs
e.Handled = true;
}
}
}
}
8 changes: 0 additions & 8 deletions ZenSharp.Integration/Target_7.1/Plugin.Common.Targets

This file was deleted.

Loading

0 comments on commit 55e56cf

Please sign in to comment.