Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2012-07-24 11:26:58 +0400
committerMike Krüger <mkrueger@xamarin.com>2012-07-24 11:27:13 +0400
commit2f5b3e909503348a2397c4b227f76206acdc0576 (patch)
treed32522b0cfad0a245be246cea3f5b0ef7941b418 /main/contrib
parente74ab81ad8efcda8f3343391dba78a642263f5a5 (diff)
[CSharpBinding] EditorBrowsableState.Advanced members are now at the
end of the parameter completion list.
Diffstat (limited to 'main/contrib')
-rw-r--r--main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs34
-rw-r--r--main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs79
-rw-r--r--main/contrib/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj1
3 files changed, 89 insertions, 25 deletions
diff --git a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
index 9bb11b6010..df30402046 100644
--- a/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
+++ b/main/contrib/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
@@ -75,40 +75,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
}
HashSet<string> usedTypes = new HashSet<string> ();
-
- static bool IsBrowsable(IEntity entity)
- {
- var browsable = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "BrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel");
- if (browsable != null && browsable.PositionalArguments.Count == 1 && browsable.PositionalArguments [0].ConstantValue is bool)
- return (bool)browsable.PositionalArguments [0].ConstantValue;
-
- var browsableState = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "EditorBrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel");
- if (browsableState != null && browsableState.PositionalArguments.Count == 1) {
- try {
- var state = (System.ComponentModel.EditorBrowsableState)browsableState.PositionalArguments [0].ConstantValue;
- return state != System.ComponentModel.EditorBrowsableState.Never;
- } catch (Exception) {}
- }
- return true;
- }
-
+
public ICompletionData AddType(IType type, string shortType)
{
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType))
return null;
if (type.Name == "Void" && type.Namespace == "System")
return null;
-
+
var def = type.GetDefinition ();
- if (def != null && !IsBrowsable (def))
+ if (def != null && !def.IsBrowsable ())
return null;
-
+
usedTypes.Add(shortType);
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType);
result.Add(iCompletionData);
return iCompletionData;
}
-
+
Dictionary<string, List<ICompletionData>> data = new Dictionary<string, List<ICompletionData>> ();
public ICompletionData AddVariable(IVariable variable)
@@ -142,18 +126,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
data [variable.Name] = new List<ICompletionData> ();
result.Add (Factory.CreateVariableCompletionData (variable));
}
-
+
public ICompletionData AddMember (IMember member)
{
var newData = Factory.CreateEntityCompletionData (member);
- if (!IsBrowsable (member))
+ if (!member.IsBrowsable ())
return null;
-
+
string memberKey = newData.DisplayText;
if (memberKey == null)
return null;
-
+
if (member is IMember) {
newData.CompletionCategory = GetCompletionCategory (member.DeclaringTypeDefinition);
}
diff --git a/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs b/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs
new file mode 100644
index 0000000000..5f407b6318
--- /dev/null
+++ b/main/contrib/ICSharpCode.NRefactory/Completion/CompletionExtensionMethods.cs
@@ -0,0 +1,79 @@
+//
+// CompletionExtensionMethods.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
+//
+// 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.NRefactory.TypeSystem;
+using System.Linq;
+
+namespace ICSharpCode.NRefactory.Completion
+{
+ public static class CompletionExtensionMethods
+ {
+ /// <summary>
+ /// Gets the EditorBrowsableState of an entity.
+ /// </summary>
+ /// <returns>
+ /// The editor browsable state.
+ /// </returns>
+ /// <param name='entity'>
+ /// Entity.
+ /// </param>
+ public static System.ComponentModel.EditorBrowsableState GetEditorBrowsableState(this IEntity entity)
+ {
+ if (entity == null)
+ throw new ArgumentNullException ("entity");
+
+ var browsable = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "BrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel");
+ if (browsable != null && browsable.PositionalArguments.Count == 1 && browsable.PositionalArguments [0].ConstantValue is bool) {
+ if (!((bool)browsable.PositionalArguments [0].ConstantValue))
+ return System.ComponentModel.EditorBrowsableState.Never;
+ }
+
+ var browsableState = entity.Attributes.FirstOrDefault(attr => attr.AttributeType.Name == "EditorBrowsableAttribute" && attr.AttributeType.Namespace == "System.ComponentModel");
+ if (browsableState != null && browsableState.PositionalArguments.Count == 1) {
+ try {
+ return (System.ComponentModel.EditorBrowsableState)browsableState.PositionalArguments [0].ConstantValue;
+ } catch (Exception) {}
+ }
+ return System.ComponentModel.EditorBrowsableState.Always;
+ }
+
+ /// <summary>
+ /// Determines if an entity should be shown in the code completion window. This is the same as:
+ /// <c>GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never</c>
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the entity should be shown; otherwise, <c>false</c>.
+ /// </returns>
+ /// <param name='entity'>
+ /// The entity.
+ /// </param>
+ public static bool IsBrowsable(this IEntity entity)
+ {
+ return GetEditorBrowsableState (entity) != System.ComponentModel.EditorBrowsableState.Never;
+ }
+ }
+}
+
diff --git a/main/contrib/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/main/contrib/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
index 0cf13f5291..7876b4fc0b 100644
--- a/main/contrib/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
+++ b/main/contrib/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
@@ -235,6 +235,7 @@
<Compile Include="Semantics\InitializedObjectResolveResult.cs" />
<Compile Include="TypeSystem\SimpleTypeResolveContext.cs" />
<Compile Include="TypeSystem\Implementation\AccessorOwnerMemberReference.cs" />
+ <Compile Include="Completion\CompletionExtensionMethods.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>