本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver类的典型用法代码示例。如果您正苦于以下问题:C# CSharpResolver类的具体用法?C# CSharpResolver怎么用?C# CSharpResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CSharpResolver类属于ICSharpCode.NRefactory.CSharp.Resolver命名空间,在下文中一共展示了CSharpResolver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResolveConstructor
public IMethod ResolveConstructor(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
IType type = attributeType.Resolve(context);
int totalArgumentCount = 0;
if (positionalArguments != null)
totalArgumentCount += positionalArguments.Count;
if (namedCtorArguments != null)
totalArgumentCount += namedCtorArguments.Count;
ResolveResult[] arguments = new ResolveResult[totalArgumentCount];
string[] argumentNames = new string[totalArgumentCount];
int i = 0;
if (positionalArguments != null) {
while (i < positionalArguments.Count) {
IConstantValue cv = positionalArguments[i];
arguments[i] = cv.Resolve(context);
i++;
}
}
if (namedCtorArguments != null) {
foreach (var pair in namedCtorArguments) {
argumentNames[i] = pair.Key;
arguments[i] = pair.Value.Resolve(context);
i++;
}
}
MemberResolveResult mrr = r.ResolveObjectCreation(type, arguments, argumentNames) as MemberResolveResult;
return mrr != null ? mrr.Member as IMethod : null;
}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:29,代码来源:CSharpAttribute.cs
示例2: TypeSystemAstBuilder
/// <summary>
/// Creates a new TypeSystemAstBuilder.
/// </summary>
/// <param name="resolver">
/// A resolver initialized for the position where the type will be inserted.
/// </param>
public TypeSystemAstBuilder(CSharpResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
this.resolver = resolver;
InitProperties();
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:13,代码来源:TypeSystemAstBuilder.cs
示例3: GetShortType
protected string GetShortType (IType type)
{
if (builder == null) {
var ctx = ext.CSharpUnresolvedFile.GetTypeResolveContext (ext.UnresolvedFileCompilation, ext.Document.Editor.Caret.Location) as CSharpTypeResolveContext;
var state = new CSharpResolver (ctx);
builder = new TypeSystemAstBuilder (state);
var dt = state.CurrentTypeDefinition;
var declaring = ctx.CurrentTypeDefinition != null ? ctx.CurrentTypeDefinition.DeclaringTypeDefinition : null;
if (declaring != null) {
while (dt != null) {
if (dt.Equals (declaring)) {
builder.AlwaysUseShortTypeNames = true;
break;
}
dt = dt.DeclaringTypeDefinition;
}
}
}
try {
return GLib.Markup.EscapeText (builder.ConvertType(type).ToString (ext.FormattingPolicy.CreateOptions ()));
} catch (Exception e) {
LoggingService.LogError ("Exception while getting short type.", e);
return "";
}
}
开发者ID:segaman,项目名称:monodevelop,代码行数:25,代码来源:AbstractParameterDataProvider.cs
示例4: ResolveCref
public override IEntity ResolveCref(string cref)
{
if (cref.Length > 2 && cref[1] == ':') {
// resolve ID string
return base.ResolveCref(cref);
}
var documentationReference = new CSharpParser().ParseDocumentationReference(cref);
var csharpContext = context as CSharpTypeResolveContext;
CSharpResolver resolver;
if (csharpContext != null) {
resolver = new CSharpResolver(csharpContext);
} else {
resolver = new CSharpResolver(context.Compilation);
}
var astResolver = new CSharpAstResolver(resolver, documentationReference);
var rr = astResolver.Resolve(documentationReference);
MemberResolveResult mrr = rr as MemberResolveResult;
if (mrr != null)
return mrr.Member;
TypeResolveResult trr = rr as TypeResolveResult;
if (trr != null)
return trr.Type.GetDefinition();
return null;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:25,代码来源:CSharpDocumentationComment.cs
示例5: CSharpCompletionDataFactory
public CSharpCompletionDataFactory(CSharpCompletionContext completionContext, CSharpResolver contextAtCaret)
{
Debug.Assert(completionContext != null);
Debug.Assert(contextAtCaret != null);
this.completionContext = completionContext;
this.contextAtCaret = contextAtCaret;
this.builder = new TypeSystemAstBuilder(contextAtCaret);
}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:8,代码来源:CSharpCompletionDataFactory.cs
示例6: Resolve
public override ResolveResult Resolve(CSharpResolver resolver)
{
ResolveResult targetRR = target.Resolve(resolver);
if (targetRR.IsError)
return targetRR;
IList<IType> typeArgs = typeArguments.Resolve(resolver.CurrentTypeResolveContext);
return resolver.ResolveMemberAccess(targetRR, identifier, typeArgs, lookupMode);
}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:8,代码来源:MemberTypeOrNamespaceReference.cs
示例7: OverrideCompletionData
public OverrideCompletionData(int declarationBegin, IMember m, CSharpResolver contextAtCaret)
: base(m)
{
this.declarationBegin = declarationBegin;
this.contextAtCaret = contextAtCaret;
var ambience = new CSharpAmbience();
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames;
this.CompletionText = ambience.ConvertSymbol(m);
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:9,代码来源:OverrideCompletionData.cs
示例8: Resolve
public static ResolveResult Resolve(ICompilation compilation, CSharpParsedFile parsedFile, CompilationUnit cu, TextLocation location,
CancellationToken cancellationToken = default(CancellationToken))
{
AstNode node = cu.GetNodeAt(location);
if (node == null)
return null;
AstNode resolvableNode;
if (node is AstType) {
resolvableNode = node;
if (resolvableNode.Parent is ComposedType) {
while (resolvableNode.Parent is ComposedType)
resolvableNode = resolvableNode.Parent;
//node is preffered over the resolvable node. Which shouldn't be done in the case of nullables, arrays etc.
node = resolvableNode;
}
} else if (node is Identifier) {
resolvableNode = node.Parent;
} else if (node.NodeType == NodeType.Token) {
if (node.Parent is ConstructorInitializer) {
resolvableNode = node.Parent;
} else {
return null;
}
} else {
// don't resolve arbitrary nodes - we don't want to show tooltips for everything
return null;
}
if (resolvableNode != null && resolvableNode.Parent is ObjectCreateExpression) {
resolvableNode = resolvableNode.Parent;
}
InvocationExpression parentInvocation = null;
if ((resolvableNode is IdentifierExpression || resolvableNode is MemberReferenceExpression || resolvableNode is PointerReferenceExpression)) {
// we also need to resolve the invocation
parentInvocation = resolvableNode.Parent as InvocationExpression;
}
IResolveVisitorNavigator navigator;
if (parentInvocation != null)
navigator = new NodeListResolveVisitorNavigator(new[] { resolvableNode, parentInvocation });
else
navigator = new NodeListResolveVisitorNavigator(new[] { resolvableNode });
CSharpResolver resolver = new CSharpResolver(compilation);
ResolveVisitor v = new ResolveVisitor(resolver, parsedFile, navigator);
v.Scan(cu);
// Prefer the RR from the token itself, if it was assigned a ResolveResult
// (this can happen with the identifiers in various nodes such as catch clauses or foreach statements)
ResolveResult rr = v.GetResolveResult(node) ?? v.GetResolveResult(resolvableNode);
if (rr is MethodGroupResolveResult && parentInvocation != null)
return v.GetResolveResult(parentInvocation);
else
return rr;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:56,代码来源:ResolveAtLocation.cs
示例9: EventCreationCompletionData
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret)
{
if (string.IsNullOrEmpty(handlerName)) {
handlerName = (evt != null ? evt.Name : "Handle");
}
this.handlerName = handlerName;
this.DisplayText = "<Create " + handlerName + ">";
this.delegateTypeReference = delegateType.ToTypeReference();
this.isStatic = callingMember != null && callingMember.IsStatic;
}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:10,代码来源:EventCreationCompletionData.cs
示例10: EventCreationCompletionData
public EventCreationCompletionData(string handlerName, IType delegateType, IEvent evt, string parameterList, IUnresolvedMember callingMember, IUnresolvedTypeDefinition declaringType, CSharpResolver contextAtCaret)
{
if (string.IsNullOrEmpty(handlerName)) {
handlerName = (evt != null ? evt.Name : "Handle");
}
this.handlerName = handlerName;
this.DisplayText = StringParser.Parse("${res:CSharpBinding.Refactoring.EventCreation.EventHandlerText}", new[] { new StringTagPair("HandlerName", handlerName) });
this.delegateTypeReference = delegateType.ToTypeReference();
this.isStatic = callingMember != null && callingMember.IsStatic;
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:10,代码来源:EventCreationCompletionData.cs
示例11: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// </summary>
/// <param name="resolver">The resolver state at the root node.</param>
/// <param name="rootNode">The root node of the resolved tree.</param>
/// <param name="parsedFile">The parsed file for the nodes being resolved. This parameter is used only
/// when the root node is on the type level; it is not necessary when an expression is passed.
/// This parameter may be null.</param>
public CSharpAstResolver(CSharpResolver resolver, AstNode rootNode, CSharpParsedFile parsedFile = null)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
if (rootNode == null)
throw new ArgumentNullException("rootNode");
this.initialResolverState = resolver;
this.rootNode = rootNode;
this.parsedFile = parsedFile;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:18,代码来源:CSharpAstResolver.cs
示例12: SignatureMarkupCreator
public SignatureMarkupCreator (CSharpResolver resolver, CSharpFormattingOptions formattingOptions)
{
this.colorStyle = SyntaxModeService.GetColorStyle (MonoDevelop.Ide.IdeApp.Preferences.ColorScheme);
this.resolver = resolver;
this.astBuilder = new TypeSystemAstBuilder (resolver) {
ConvertUnboundTypeArguments = true,
UseAliases = false
};
this.formattingOptions = formattingOptions;
}
开发者ID:Chertolom,项目名称:monodevelop,代码行数:11,代码来源:SignatureMarkupCreator.cs
示例13: DoResolve
public ResolveResult DoResolve(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
r.CurrentTypeDefinition = parentTypeDefinition != null ? parentTypeDefinition.GetCompoundClass() : null;
r.UsingScope = parentUsingScope;
IType[] typeArgs = new IType[typeArguments.Count];
for (int i = 0; i < typeArgs.Length; i++) {
typeArgs[i] = typeArguments[i].Resolve(context);
}
return r.LookupSimpleNamespaceOrTypeName(identifier, typeArgs, isInUsingDeclaration);
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:11,代码来源:SimpleTypeOrNamespaceReference.cs
示例14: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// Use this overload if you are resolving within a complete C# file.
/// </summary>
/// <param name="compilation">The current compilation.</param>
/// <param name="syntaxTree">The syntax tree to be resolved.</param>
/// <param name="unresolvedFile">
/// Optional: Result of <see cref="SyntaxTree.ToTypeSystem()"/> for the file being resolved.
/// <para>
/// This is used for setting up the context on the resolver. The unresolved file must be registered in the compilation.
/// </para>
/// <para>
/// When a unresolvedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
/// member declarations in the AST with members in the type system.
/// When no unresolvedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
/// member's signature in the AST with the signature in the type system.
/// </para>
/// </param>
public CSharpAstResolver(ICompilation compilation, SyntaxTree syntaxTree, CSharpUnresolvedFile unresolvedFile = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (syntaxTree == null)
throw new ArgumentNullException("syntaxTree");
this.initialResolverState = new CSharpResolver(compilation);
this.rootNode = syntaxTree;
this.unresolvedFile = unresolvedFile;
this.resolveVisitor = new ResolveVisitor(initialResolverState, unresolvedFile);
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:29,代码来源:CSharpAstResolver.cs
示例15: CSharpAstResolver
/// <summary>
/// Creates a new C# AST resolver.
/// Use this overload if you are resolving within a complete C# file.
/// </summary>
/// <param name="compilation">The current compilation.</param>
/// <param name="compilationUnit">The compilation unit corresponding to the specified parsed file.</param>
/// <param name="parsedFile">
/// Optional: Result of the <see cref="TypeSystemConvertVisitor"/> for the file being resolved.
/// <para>
/// This is used for setting up the context on the resolver. The parsed file must be registered in the compilation.
/// </para>
/// <para>
/// When a parsedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
/// member declarations in the AST with members in the type system.
/// When no parsedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
/// member's signature in the AST with the signature in the type system.
/// </para>
/// </param>
public CSharpAstResolver(ICompilation compilation, CompilationUnit compilationUnit, CSharpParsedFile parsedFile = null)
{
if (compilation == null)
throw new ArgumentNullException("compilation");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
this.initialResolverState = new CSharpResolver(compilation);
this.rootNode = compilationUnit;
this.parsedFile = parsedFile;
this.resolveVisitor = new ResolveVisitor(initialResolverState, parsedFile);
}
开发者ID:M1C,项目名称:monodevelop,代码行数:29,代码来源:CSharpAstResolver.cs
示例16: DoResolve
public ResolveResult DoResolve(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
r.CurrentTypeDefinition = parentTypeDefinition;
r.UsingScope = parentUsingScope;
IType[] typeArgs = new IType[typeArguments.Count];
for (int i = 0; i < typeArgs.Length; i++) {
typeArgs[i] = typeArguments[i].Resolve(context);
}
return r.LookupSimpleNameOrTypeName(identifier, typeArgs, lookupMode);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:11,代码来源:SimpleTypeOrNamespaceReference.cs
示例17: ConvertHelper
string ConvertHelper(AstNode node, Action<CSharpCodeProvider, CodeObject, TextWriter, CodeGeneratorOptions> action)
{
CSharpResolver resolver = new CSharpResolver(compilation);
resolver = resolver.WithCurrentUsingScope(unresolvedFile.RootUsingScope.Resolve(compilation));
resolver = resolver.WithCurrentTypeDefinition(compilation.FindType(KnownTypeCode.Object).GetDefinition());
var codeObj = convertVisitor.Convert(node, new CSharpAstResolver(resolver, node));
StringWriter writer = new StringWriter();
writer.NewLine = " ";
action(new CSharpCodeProvider(), codeObj, writer, new CodeGeneratorOptions { IndentString = " " });
return Regex.Replace(writer.ToString(), @"\s+", " ").Trim();
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:CodeDomConvertVisitorTests.cs
示例18: Convert
string Convert(Expression expr)
{
CSharpResolver resolver = new CSharpResolver(compilation);
resolver = resolver.WithCurrentUsingScope(parsedFile.RootUsingScope.Resolve(compilation));
resolver = resolver.WithCurrentTypeDefinition(compilation.FindType(KnownTypeCode.Object).GetDefinition());
var codeExpr = (CodeExpression)convertVisitor.Convert(expr, new CSharpAstResolver(resolver, expr, parsedFile));
StringWriter writer = new StringWriter();
writer.NewLine = " ";
new CSharpCodeProvider().GenerateCodeFromExpression(codeExpr, writer, new CodeGeneratorOptions { IndentString = " " });
return Regex.Replace(writer.ToString(), @"\s+", " ");
}
开发者ID:N3X15,项目名称:ILSpy,代码行数:12,代码来源:CodeDomConvertVisitorTests.cs
示例19: ImportCompletionData
public ImportCompletionData(ITypeDefinition typeDef, CSharpResolver contextAtCaret, bool useFullName)
: base(typeDef)
{
this.Description = "using " + typeDef.Namespace + ";";
if (useFullName) {
var astBuilder = new TypeSystemAstBuilder(contextAtCaret);
insertionText = astBuilder.ConvertType(typeDef).ToString();
} else {
insertionText = typeDef.Name;
insertUsing = typeDef.Namespace;
}
}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:12,代码来源:ImportCompletionData.cs
示例20: Resolve
public override ResolveResult Resolve(CSharpResolver resolver)
{
ResolveResult[] elements = new ResolveResult[arrayElements.Count];
for (int i = 0; i < elements.Length; i++) {
elements[i] = arrayElements[i].Resolve(resolver);
}
if (elementType != null) {
return resolver.ResolveArrayCreation(elementType.Resolve(resolver.CurrentTypeResolveContext), 1, null, elements);
} else {
return resolver.ResolveArrayCreation(null, 1, null, elements);
}
}
开发者ID:holmak,项目名称:NRefactory,代码行数:12,代码来源:ConstantValues.cs
注:本文中的ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论