|
|
|
@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
{ |
|
|
|
{ |
|
|
|
CSharpCompletionEngine completion; |
|
|
|
CSharpCompletionEngine completion; |
|
|
|
List<ICompletionData> result = new List<ICompletionData> (); |
|
|
|
List<ICompletionData> result = new List<ICompletionData> (); |
|
|
|
|
|
|
|
|
|
|
|
public List<ICompletionData> Result { |
|
|
|
public List<ICompletionData> Result { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
@ -48,24 +48,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
return completion.factory; |
|
|
|
return completion.factory; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public CompletionDataWrapper (CSharpCompletionEngine completion) |
|
|
|
public CompletionDataWrapper (CSharpCompletionEngine completion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.completion = completion; |
|
|
|
this.completion = completion; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Add (ICompletionData data) |
|
|
|
public void Add (ICompletionData data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result.Add (data); |
|
|
|
result.Add (data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void AddCustom (string displayText, string description = null, string completionText = null) |
|
|
|
public void AddCustom (string displayText, string description = null, string completionText = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result.Add (Factory.CreateLiteralCompletionData (displayText, description, completionText)); |
|
|
|
result.Add (Factory.CreateLiteralCompletionData (displayText, description, completionText)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> usedNamespaces = new HashSet<string> (); |
|
|
|
HashSet<string> usedNamespaces = new HashSet<string> (); |
|
|
|
|
|
|
|
|
|
|
|
public void AddNamespace (string name) |
|
|
|
public void AddNamespace (string name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty (name) || usedNamespaces.Contains (name)) |
|
|
|
if (string.IsNullOrEmpty (name) || usedNamespaces.Contains (name)) |
|
|
|
@ -73,13 +73,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
usedNamespaces.Add (name); |
|
|
|
usedNamespaces.Add (name); |
|
|
|
result.Add (Factory.CreateNamespaceCompletionData (name)); |
|
|
|
result.Add (Factory.CreateNamespaceCompletionData (name)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> usedTypes = new HashSet<string> (); |
|
|
|
HashSet<string> usedTypes = new HashSet<string> (); |
|
|
|
|
|
|
|
|
|
|
|
public ICompletionData AddType(IType type, string shortType) |
|
|
|
public ICompletionData AddType(IType type, string shortType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) |
|
|
|
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
if (type.Name == "Void" && type.Namespace == "System") |
|
|
|
|
|
|
|
return null; |
|
|
|
usedTypes.Add(shortType); |
|
|
|
usedTypes.Add(shortType); |
|
|
|
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); |
|
|
|
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); |
|
|
|
result.Add(iCompletionData); |
|
|
|
result.Add(iCompletionData); |
|
|
|
@ -90,14 +92,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) |
|
|
|
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
if (type.Name == "Void" && type.Namespace == "System") |
|
|
|
|
|
|
|
return null; |
|
|
|
usedTypes.Add(shortType); |
|
|
|
usedTypes.Add(shortType); |
|
|
|
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); |
|
|
|
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); |
|
|
|
result.Add(iCompletionData); |
|
|
|
result.Add(iCompletionData); |
|
|
|
return iCompletionData; |
|
|
|
return iCompletionData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, List<ICompletionData>> data = new Dictionary<string, List<ICompletionData>> (); |
|
|
|
Dictionary<string, List<ICompletionData>> data = new Dictionary<string, List<ICompletionData>> (); |
|
|
|
|
|
|
|
|
|
|
|
public ICompletionData AddVariable(IVariable variable) |
|
|
|
public ICompletionData AddVariable(IVariable variable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (data.ContainsKey(variable.Name)) |
|
|
|
if (data.ContainsKey(variable.Name)) |
|
|
|
@ -107,14 +111,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
result.Add(cd); |
|
|
|
result.Add(cd); |
|
|
|
return cd; |
|
|
|
return cd; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ICompletionData AddNamedParameterVariable(IVariable variable) |
|
|
|
public ICompletionData AddNamedParameterVariable(IVariable variable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var name = variable.Name + ":"; |
|
|
|
var name = variable.Name + ":"; |
|
|
|
if (data.ContainsKey(name)) |
|
|
|
if (data.ContainsKey(name)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
data [name] = new List<ICompletionData>(); |
|
|
|
data [name] = new List<ICompletionData>(); |
|
|
|
|
|
|
|
|
|
|
|
var cd = Factory.CreateVariableCompletionData(variable); |
|
|
|
var cd = Factory.CreateVariableCompletionData(variable); |
|
|
|
cd.CompletionText += ":"; |
|
|
|
cd.CompletionText += ":"; |
|
|
|
cd.DisplayText += ":"; |
|
|
|
cd.DisplayText += ":"; |
|
|
|
@ -129,12 +133,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
data [variable.Name] = new List<ICompletionData> (); |
|
|
|
data [variable.Name] = new List<ICompletionData> (); |
|
|
|
result.Add (Factory.CreateVariableCompletionData (variable)); |
|
|
|
result.Add (Factory.CreateVariableCompletionData (variable)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ICompletionData AddMember (IUnresolvedMember member) |
|
|
|
public ICompletionData AddMember (IUnresolvedMember member) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var newData = Factory.CreateEntityCompletionData (member); |
|
|
|
var newData = Factory.CreateEntityCompletionData (member); |
|
|
|
|
|
|
|
|
|
|
|
// newData.HideExtensionParameter = HideExtensionParameter;
|
|
|
|
// newData.HideExtensionParameter = HideExtensionParameter;
|
|
|
|
string memberKey = newData.DisplayText; |
|
|
|
string memberKey = newData.DisplayText; |
|
|
|
if (memberKey == null) |
|
|
|
if (memberKey == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
@ -143,7 +147,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
List<ICompletionData> existingData; |
|
|
|
List<ICompletionData> existingData; |
|
|
|
data.TryGetValue (memberKey, out existingData); |
|
|
|
data.TryGetValue (memberKey, out existingData); |
|
|
|
|
|
|
|
|
|
|
|
if (existingData != null) { |
|
|
|
if (existingData != null) { |
|
|
|
var a = member as IEntity; |
|
|
|
var a = member as IEntity; |
|
|
|
foreach (var d in existingData) { |
|
|
|
foreach (var d in existingData) { |
|
|
|
@ -171,7 +175,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
{ |
|
|
|
{ |
|
|
|
var newData = Factory.CreateEntityCompletionData (member); |
|
|
|
var newData = Factory.CreateEntityCompletionData (member); |
|
|
|
|
|
|
|
|
|
|
|
// newData.HideExtensionParameter = HideExtensionParameter;
|
|
|
|
// newData.HideExtensionParameter = HideExtensionParameter;
|
|
|
|
string memberKey = newData.DisplayText; |
|
|
|
string memberKey = newData.DisplayText; |
|
|
|
if (memberKey == null) |
|
|
|
if (memberKey == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
@ -180,7 +184,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
List<ICompletionData> existingData; |
|
|
|
List<ICompletionData> existingData; |
|
|
|
data.TryGetValue (memberKey, out existingData); |
|
|
|
data.TryGetValue (memberKey, out existingData); |
|
|
|
|
|
|
|
|
|
|
|
if (existingData != null) { |
|
|
|
if (existingData != null) { |
|
|
|
var a = member as IEntity; |
|
|
|
var a = member as IEntity; |
|
|
|
foreach (var d in existingData) { |
|
|
|
foreach (var d in existingData) { |
|
|
|
@ -203,7 +207,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
} |
|
|
|
} |
|
|
|
return newData; |
|
|
|
return newData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal CompletionCategory GetCompletionCategory (IType type) |
|
|
|
internal CompletionCategory GetCompletionCategory (IType type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (type == null) |
|
|
|
if (type == null) |
|
|
|
@ -212,7 +216,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
completionCategories [type] = new TypeCompletionCategory (type); |
|
|
|
completionCategories [type] = new TypeCompletionCategory (type); |
|
|
|
return completionCategories [type]; |
|
|
|
return completionCategories [type]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Dictionary<IType, CompletionCategory> completionCategories = new Dictionary<IType, CompletionCategory> (); |
|
|
|
Dictionary<IType, CompletionCategory> completionCategories = new Dictionary<IType, CompletionCategory> (); |
|
|
|
class TypeCompletionCategory : CompletionCategory |
|
|
|
class TypeCompletionCategory : CompletionCategory |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -231,10 +235,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
var compareCategory = other as TypeCompletionCategory; |
|
|
|
var compareCategory = other as TypeCompletionCategory; |
|
|
|
if (compareCategory == null) |
|
|
|
if (compareCategory == null) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (Type.ReflectionName == compareCategory.Type.ReflectionName) |
|
|
|
if (Type.ReflectionName == compareCategory.Type.ReflectionName) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
if (Type.GetAllBaseTypes ().Any (t => t.ReflectionName == compareCategory.Type.ReflectionName)) |
|
|
|
if (Type.GetAllBaseTypes ().Any (t => t.ReflectionName == compareCategory.Type.ReflectionName)) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
@ -254,8 +258,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion |
|
|
|
Result.Add(Factory.CreateEntityCompletionData( |
|
|
|
Result.Add(Factory.CreateEntityCompletionData( |
|
|
|
field, |
|
|
|
field, |
|
|
|
typeString + "." + field.Name |
|
|
|
typeString + "." + field.Name |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|