本文整理汇总了C#中ICSharpCode.SharpDevelop.Dom.LanguageProperties类的典型用法代码示例。如果您正苦于以下问题:C# LanguageProperties类的具体用法?C# LanguageProperties怎么用?C# LanguageProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageProperties类属于ICSharpCode.SharpDevelop.Dom命名空间,在下文中一共展示了LanguageProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NRefactoryInsightWindowHandler
public NRefactoryInsightWindowHandler(SupportedLanguage language)
{
this.language = language;
if (language == SupportedLanguage.CSharp) {
eofToken = CSTokens.EOF;
commaToken = CSTokens.Comma;
openParensToken = CSTokens.OpenParenthesis;
closeParensToken = CSTokens.CloseParenthesis;
openBracketToken = CSTokens.OpenSquareBracket;
closeBracketToken = CSTokens.CloseSquareBracket;
openBracesToken = CSTokens.OpenCurlyBrace;
closeBracesToken = CSTokens.CloseCurlyBrace;
statementEndToken = CSTokens.Semicolon;
languageProperties = LanguageProperties.CSharp;
} else {
eofToken = VBTokens.EOF;
commaToken = VBTokens.Comma;
openParensToken = VBTokens.OpenParenthesis;
closeParensToken = VBTokens.CloseParenthesis;
openBracketToken = -1;
closeBracketToken = -1;
openBracesToken = VBTokens.OpenCurlyBrace;
closeBracesToken = VBTokens.CloseCurlyBrace;
statementEndToken = VBTokens.EOL;
languageProperties = LanguageProperties.VBNet;
}
}
示例2: GetCompletionData
protected ArrayList GetCompletionData(LanguageProperties language, bool showStatic)
{
if (resolvedType == null) return null;
ArrayList res = new ArrayList();
bool isClassInInheritanceTree = false;
if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(resolvedType.GetUnderlyingClass());
foreach (IMethod m in resolvedType.GetMethods()) {
if (language.ShowMember(m, showStatic) && m.IsAccessible(callingClass, isClassInInheritanceTree))
res.Add(m);
}
foreach (IEvent e in resolvedType.GetEvents()) {
if (language.ShowMember(e, showStatic) && e.IsAccessible(callingClass, isClassInInheritanceTree))
res.Add(e);
}
foreach (IField f in resolvedType.GetFields()) {
if (language.ShowMember(f, showStatic) && f.IsAccessible(callingClass, isClassInInheritanceTree))
res.Add(f);
}
foreach (IProperty p in resolvedType.GetProperties()) {
if (language.ShowMember(p, showStatic) && p.IsAccessible(callingClass, isClassInInheritanceTree))
res.Add(p);
}
if (!showStatic && callingClass != null) {
AddExtensions(language, res, callingClass, resolvedType);
}
return res;
}
示例3: NRefactoryCodeCompletionBinding
protected NRefactoryCodeCompletionBinding(SupportedLanguage language)
{
this.language = language;
if (language == SupportedLanguage.CSharp) {
eofToken = CSTokens.EOF;
commaToken = CSTokens.Comma;
openParensToken = CSTokens.OpenParenthesis;
closeParensToken = CSTokens.CloseParenthesis;
openBracketToken = CSTokens.OpenSquareBracket;
closeBracketToken = CSTokens.CloseSquareBracket;
openBracesToken = CSTokens.OpenCurlyBrace;
closeBracesToken = CSTokens.CloseCurlyBrace;
languageProperties = LanguageProperties.CSharp;
} else {
eofToken = VBTokens.EOF;
commaToken = VBTokens.Comma;
openParensToken = VBTokens.OpenParenthesis;
closeParensToken = VBTokens.CloseParenthesis;
openBracketToken = -1;
closeBracketToken = -1;
openBracesToken = VBTokens.OpenCurlyBrace;
closeBracesToken = VBTokens.CloseCurlyBrace;
languageProperties = LanguageProperties.VBNet;
}
}
示例4: NRefactoryCodeCompletionBinding
protected NRefactoryCodeCompletionBinding(SupportedLanguage language)
{
this.language = language;
if (language == SupportedLanguage.CSharp) {
languageProperties = LanguageProperties.CSharp;
} else {
languageProperties = LanguageProperties.VBNet;
}
insightHandler = new NRefactoryInsightWindowHandler(language);
}
示例5: CheckNamespace
void CheckNamespace(string @namespace, string className, LanguageProperties language)
{
ICompilationUnit cu = Prepare(language);
string ns = cu.ProjectContent.SearchType(new SearchTypeRequest(@namespace, 0, null, cu, 1, 1)).NamespaceResult;
Assert.IsNotNull(ns, @namespace + " not found");
foreach (object o in cu.ProjectContent.GetNamespaceContents(ns)) {
IClass c = o as IClass;
if (c != null && c.Name == className)
return;
}
}
示例6: Prepare
ICompilationUnit Prepare(LanguageProperties language)
{
DefaultProjectContent pc = new DefaultProjectContent();
pc.ReferencedContents.Add(projectContentRegistry.Mscorlib);
pc.Language = language;
DefaultCompilationUnit cu = new DefaultCompilationUnit(pc);
if (language == LanguageProperties.VBNet)
cu.UsingScope.Usings.Add(CreateUsing(pc, "syStEm"));
else
cu.UsingScope.Usings.Add(CreateUsing(pc, "System"));
return cu;
}
示例7: GenerateCode
protected override string GenerateCode(LanguageProperties language, IClass currentClass)
{
StringBuilder builder = new StringBuilder();
IDocumentLine line = editor.Document.GetLineForOffset(anchor.Offset);
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, line.Offset);
bool implementInterface = this.implementInterface.IsChecked == true;
bool hasOnPropertyChanged = HasOnPropertyChanged(currentClass);
bool useEventArgs = false;
if (implementInterface && !currentClass.IsStatic) {
if (!hasOnPropertyChanged) {
var nodes = new List<AbstractNode>();
var rt = new GetClassReturnType(currentClass.ProjectContent, "System.ComponentModel.INotifyPropertyChanged", 0);
if (!currentClass.ClassInheritanceTree.Any(bt => bt.FullyQualifiedName == "System.ComponentModel.INotifyPropertyChanged")) {
int insertion = editor.Document.PositionToOffset(currentClass.BodyRegion.BeginLine, currentClass.BodyRegion.BeginColumn);
if (currentClass.BaseTypes.Count > 0)
editor.Document.Insert(insertion, ", INotifyPropertyChanged");
else
editor.Document.Insert(insertion, " : INotifyPropertyChanged");
}
language.CodeGenerator.ImplementInterface(nodes, rt, false, currentClass);
var ev = rt.GetEvents().First(e => e.Name == "PropertyChanged");
MethodDeclaration onEvent = language.CodeGenerator.CreateOnEventMethod(new DefaultEvent(ev.Name, ev.ReturnType, ev.Modifiers, ev.Region, ev.BodyRegion, currentClass));
nodes.Add(onEvent);
onEvent.Parameters[0].TypeReference = new TypeReference("string", true);
onEvent.Parameters[0].ParameterName = "propertyName";
((RaiseEventStatement)onEvent.Body.Children[0]).Arguments[1] = new ObjectCreateExpression(new TypeReference("PropertyChangedEventArgs"), new List<Expression> { new IdentifierExpression("propertyName") });
foreach (var node in nodes)
builder.AppendLine(language.CodeGenerator.GenerateCode(node, indent));
useEventArgs = false;
} else {
useEventArgs = currentClass.DefaultReturnType.GetMethods().First(m => m.Name == "OnPropertyChanged").Parameters[0].ReturnType.FullyQualifiedName != "System.String";
}
}
foreach (FieldWrapper field in listBox.SelectedItems) {
var prop = language.CodeGenerator.CreateProperty(field.Field, true, field.AddSetter);
if (!field.Field.IsStatic && !currentClass.IsStatic && field.AddSetter && implementInterface) {
var invocation = new ExpressionStatement(CreateInvocation(field.PropertyName, useEventArgs));
var assignment = prop.SetRegion.Block.Children[0];
prop.SetRegion.Block.Children.Clear();
prop.SetRegion.Block.AddChild(
new IfElseStatement(
new BinaryOperatorExpression(new IdentifierExpression(field.MemberName), BinaryOperatorType.InEquality, new IdentifierExpression("value")),
new BlockStatement { Children = { assignment, invocation } }
)
);
}
builder.AppendLine(language.CodeGenerator.GenerateCode(prop, indent));
}
return builder.ToString().Trim();
}
示例8: GenerateCode
protected override string GenerateCode(LanguageProperties language, IClass currentClass)
{
string[] fields = listBox.SelectedItems.OfType<PropertyOrFieldWrapper>().Select(f2 => f2.MemberName).ToArray();
Ast.PrimitiveExpression formatString = new Ast.PrimitiveExpression(GenerateFormatString(currentClass, language.CodeGenerator, fields));
List<Ast.Expression> param = new List<Ast.Expression>() { formatString };
Ast.ReturnStatement ret = new Ast.ReturnStatement(new Ast.InvocationExpression(
new Ast.MemberReferenceExpression(new Ast.TypeReferenceExpression(new Ast.TypeReference("System.String", true)), "Format"),
param.Concat(fields.Select(f => new Ast.IdentifierExpression(f))).ToList()
));
insertedCode = language.CodeGenerator.GenerateCode(ret, "").Trim();
return insertedCode;
}
示例9: GetClasses
/// <summary>
/// Gets the class dictionary that uses the name comparison rules of <paramref name="language"/>.
/// </summary>
protected Dictionary<string, IClass> GetClasses(LanguageProperties language)
{
for (int i = 0; i < classLists.Count; ++i) {
if (classLists[i].Comparer == language.NameComparer)
return classLists[i];
}
Dictionary<string, IClass> d;
if (classLists.Count > 0) {
Dictionary<string, IClass> oldList = classLists[0];
d = new Dictionary<string, IClass>(oldList.Count, language.NameComparer);
foreach (KeyValuePair<string, IClass> pair in oldList) {
d.Add(pair.Key, pair.Value);
}
} else {
d = new Dictionary<string, IClass>(language.NameComparer);
}
classLists.Add(d);
return d;
}
示例10: Prepare
// usingMode: 0 = one using-statement for each namespace (correctly cased)
// 1 = mixture of using statements and default imports (incorrectly cased)
// 2 = all default imports (incorrectly cased)
ICompilationUnit Prepare(LanguageProperties language, int usingMode)
{
DefaultProjectContent pc = new DefaultProjectContent();
pc.ReferencedContents.Add(projectContentRegistry.Mscorlib);
pc.Language = language;
DefaultCompilationUnit cu = new DefaultCompilationUnit(pc);
if (usingMode == 1) {
cu.UsingScope.Usings.Add(CreateUsing(pc, "syStEm.coLLectIons"));
pc.DefaultImports = new DefaultUsing(pc);
pc.DefaultImports.Usings.Add("syStEm");
pc.DefaultImports.Usings.Add("syStEm.coLLEctionS.GeNeRic");
} else if (usingMode == 2) {
pc.DefaultImports = new DefaultUsing(pc);
pc.DefaultImports.Usings.Add("syStEm");
pc.DefaultImports.Usings.Add("syStEm.coLLEctioNs");
pc.DefaultImports.Usings.Add("syStEm.coLLEctionS.GeNeRic");
} else { // usingMode == 0
cu.UsingScope.Usings.Add(CreateUsing(pc, "System"));
cu.UsingScope.Usings.Add(CreateUsing(pc, "System.Collections"));
cu.UsingScope.Usings.Add(CreateUsing(pc, "System.Collections.Generic"));
}
return cu;
}
示例11: AddNamespaceContents
/// <summary>
/// Adds the contents of the specified <paramref name="nameSpace"/> to the <paramref name="list"/>.
/// </summary>
/// <param name="lookInReferences">If true, contents of referenced projects will be added as well (not recursive - just 1 level deep).</param>
public void AddNamespaceContents(List<ICompletionEntry> list, string nameSpace, LanguageProperties language, bool lookInReferences)
{
if (nameSpace == null) {
return;
}
if (lookInReferences) {
lock (referencedContents) {
foreach (IProjectContent content in referencedContents) {
content.AddNamespaceContents(list, nameSpace, language, false);
}
}
}
lock (namespaces) {
Dictionary<string, NamespaceStruct> dict = GetNamespaces(language);
if (dict.ContainsKey(nameSpace)) {
NamespaceStruct ns = dict[nameSpace];
AddNamespaceStructContents(list, ns, language, lookInReferences);
}
}
}
示例12: AddAllContents
/// <summary>
/// Adds the contents of all namespaces in this project to the <paramref name="list"/>.
/// </summary>
/// <param name="lookInReferences">If true, contents of referenced projects will be added as well (not recursive - just 1 level deep).</param>
public void AddAllContents(List<ICompletionEntry> list, LanguageProperties language, bool lookInReferences)
{
if (lookInReferences) {
lock (referencedContents) {
foreach (IProjectContent content in referencedContents) {
content.AddAllContents(list, language, false);
}
}
}
lock (namespaces) {
Dictionary<string, NamespaceStruct> dict = GetNamespaces(language);
foreach (var namespaceStruct in dict.Values) {
AddNamespaceStructContents(list, namespaceStruct, language, lookInReferences);
}
}
}
示例13: GetClass
public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options)
{
IClass c = GetClassInternal(typeName, typeParameterCount, language);
if (c != null && c.TypeParameters.Count == typeParameterCount) {
return c;
}
// Search in references:
if ((options & GetClassOptions.LookInReferences) != 0) {
lock (referencedContents) {
foreach (IProjectContent content in referencedContents) {
// Look for the class in the referenced content.
// Don't do a inner-class search in the recursive call - one search
// done by this GetClass call is sufficient.
IClass contentClass = content.GetClass(
typeName, typeParameterCount, language,
options & ~(GetClassOptions.LookInReferences | GetClassOptions.LookForInnerClass));
if (contentClass != null) {
if (contentClass.TypeParameters.Count == typeParameterCount
&& IsAccessibleClass(contentClass))
{
return contentClass;
} else {
c = contentClass;
}
}
}
}
}
if ((options & GetClassOptions.LookForInnerClass) != 0) {
// not found -> maybe nested type -> trying to find class that contains this one.
int lastIndex = typeName.LastIndexOf('.');
if (lastIndex > 0) {
string outerName = typeName.Substring(0, lastIndex);
IClass upperClass = GetClass(outerName, typeParameterCount, language, options);
if (upperClass != null) {
foreach (IClass upperBaseClass in upperClass.ClassInheritanceTree) {
IList<IClass> innerClasses = upperBaseClass.InnerClasses;
if (innerClasses != null) {
string innerName = typeName.Substring(lastIndex + 1);
foreach (IClass innerClass in innerClasses) {
if (language.NameComparer.Equals(innerClass.Name, innerName)) {
if (innerClass.TypeParameters.Count == typeParameterCount) {
return innerClass;
} else {
// store match
c = innerClass;
}
}
}
}
}
}
}
}
if ((options & GetClassOptions.ExactMatch) == GetClassOptions.ExactMatch) {
return null;
} else {
// no matching class found - we'll return a class with different type paramter count
return c;
}
}
示例14: GetClassInternal
protected IClass GetClassInternal(string typeName, int typeParameterCount, LanguageProperties language)
{
CheckNotDisposed();
#if DEBUG
if (System.Text.RegularExpressions.Regex.IsMatch (typeName, "`[0-9]+$"))
Debug.Assert(false, "how did a Reflection type name get here?");
#endif
lock (namespaces) {
IClass c;
if (GetClasses(language).TryGetValue(typeName, out c)) {
GenericClassContainer gcc = c as GenericClassContainer;
if (gcc != null) {
return gcc.GetBest(typeParameterCount);
}
return c;
}
return null;
}
}
示例15: GetNamespaces
/// <summary>
/// Gets the namespace dictionary that uses the name comparison rules of <paramref name="language"/>.
/// </summary>
protected Dictionary<string, NamespaceStruct> GetNamespaces(LanguageProperties language)
{
for (int i = 0; i < namespaces.Count; ++i) {
if (namespaces[i].Comparer == language.NameComparer)
return namespaces[i];
}
Dictionary<string, NamespaceStruct> d;
if (namespaces.Count > 0) {
Dictionary<string, NamespaceStruct> oldList = namespaces[0];
d = new Dictionary<string, NamespaceStruct>(oldList.Count, language.NameComparer);
foreach (KeyValuePair<string, NamespaceStruct> pair in oldList) {
NamespaceStruct ns;
if (d.TryGetValue(pair.Key, out ns)) {
// we got a name conflict due to the new NameComparer.
// This happens if a C# assembly contains the namespace "a" and "A",
// and now we're trying to get a dictionary for use in VB.
d[pair.Key] = ns.MergeWith(pair.Value);
} else {
d.Add(pair.Key, pair.Value);
}
}
} else {
d = new Dictionary<string, NamespaceStruct>(language.NameComparer);
}
namespaces.Add(d);
return d;
}