本文整理汇总了C#中CSharpUnresolvedFile类的典型用法代码示例。如果您正苦于以下问题:C# CSharpUnresolvedFile类的具体用法?C# CSharpUnresolvedFile怎么用?C# CSharpUnresolvedFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CSharpUnresolvedFile类属于命名空间,在下文中一共展示了CSharpUnresolvedFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateCompilationWithoutCorlib
public static ICompilation CreateCompilationWithoutCorlib(params IUnresolvedTypeDefinition[] unresolvedTypeDefinitions)
{
var unresolvedFile = new CSharpUnresolvedFile();
foreach (var typeDef in unresolvedTypeDefinitions)
unresolvedFile.TopLevelTypeDefinitions.Add(typeDef);
return CreateCompilation(unresolvedFile);
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:7,代码来源:TypeSystemHelper.cs
示例2: DelegateDataProvider
public DelegateDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType delegateType) : base (ext, startOffset)
{
compilation = ext.UnresolvedFileCompilation;
file = ext.CSharpUnresolvedFile;
// this.delegateType = delegateType;
this.delegateMethod = delegateType.GetDelegateInvokeMethod ();
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:DelegateDataProvider.cs
示例3: Resolve
public static ResolveResult Resolve(Lazy<ICompilation> compilation, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree, TextLocation location, out AstNode node,
CancellationToken cancellationToken = default(CancellationToken))
{
node = syntaxTree.GetNodeAt(location);
if (node == null || node is ArrayInitializerExpression)
return null;
if (node.Parent is UsingAliasDeclaration && node.Role == UsingAliasDeclaration.AliasRole) {
var r = new CSharpAstResolver(compilation.Value, syntaxTree, unresolvedFile);
return r.Resolve(((UsingAliasDeclaration)node.Parent).Import, cancellationToken);
}
if (CSharpAstResolver.IsUnresolvableNode(node)) {
if (node is Identifier) {
node = node.Parent;
} else if (node.NodeType == NodeType.Token) {
if (node.Parent is IndexerExpression || node.Parent is ConstructorInitializer) {
// There's no other place where one could hover to see the indexer's tooltip,
// so we need to resolve it when hovering over the '[' or ']'.
// For constructor initializer, the same applies to the 'base'/'this' token.
node = node.Parent;
} else {
return null;
}
} else {
// don't resolve arbitrary nodes - we don't want to show tooltips for everything
return null;
}
} else {
// It's a resolvable node.
// However, we usually don't want to show the tooltip everywhere
// For example, hovering with the mouse over an empty line between two methods causes
// node==TypeDeclaration, but we don't want to show any tooltip.
if (!node.GetChildByRole(Roles.Identifier).IsNull) {
// We'll suppress the tooltip for resolvable nodes if there is an identifier that
// could be hovered over instead:
return null;
}
}
if (node == null)
return null;
if (node.Parent is ObjectCreateExpression && node.Role == Roles.Type) {
node = node.Parent;
}
InvocationExpression parentInvocation = null;
if ((node is IdentifierExpression || node is MemberReferenceExpression || node is PointerReferenceExpression) && node.Role != Roles.Argument) {
// we also need to resolve the invocation
parentInvocation = node.Parent as InvocationExpression;
}
// TODO: I think we should provide an overload so that an existing CSharpAstResolver can be reused
CSharpAstResolver resolver = new CSharpAstResolver(compilation.Value, syntaxTree, unresolvedFile);
ResolveResult rr = resolver.Resolve(node, cancellationToken);
if (rr is MethodGroupResolveResult && parentInvocation != null)
return resolver.Resolve(parentInvocation);
else
return rr;
}
开发者ID:riviti,项目名称:NRefactory,代码行数:60,代码来源:ResolveAtLocation.cs
示例4: IndexerParameterDataProvider
public IndexerParameterDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType type, IEnumerable<IProperty> indexers, AstNode resolvedExpression) : base (ext, startOffset)
{
compilation = ext.UnresolvedFileCompilation;
file = ext.CSharpUnresolvedFile;
// this.resolvedExpression = resolvedExpression;
this.indexers = new List<IProperty> (indexers);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:IndexerParameterDataProvider.cs
示例5: Prepare
protected void Prepare(string source, bool minimizeNames = true, bool expectErrors = false) {
IProjectContent project = new CSharpProjectContent();
var parser = new CSharpParser();
using (var rdr = new StringReader(source)) {
var pf = new CSharpUnresolvedFile { FileName = "File.cs" };
var syntaxTree = parser.Parse(rdr, pf.FileName);
syntaxTree.AcceptVisitor(new TypeSystemConvertVisitor(pf));
project = project.AddOrUpdateFiles(pf);
}
project = project.AddAssemblyReferences(new[] { Files.Mscorlib });
_errorReporter = new MockErrorReporter(!expectErrors);
var compilation = project.CreateCompilation();
var s = new AttributeStore(compilation, _errorReporter);
RunAutomaticMetadataAttributeAppliers(s, compilation);
s.RunAttributeCode();
Metadata = new MetadataImporter(_errorReporter, compilation, s, new CompilerOptions { MinimizeScript = minimizeNames });
Metadata.Prepare(compilation.GetAllTypeDefinitions());
AllErrors = _errorReporter.AllMessages.ToList().AsReadOnly();
AllErrorTexts = _errorReporter.AllMessages.Select(m => m.FormattedMessage).ToList().AsReadOnly();
if (expectErrors) {
Assert.That(AllErrorTexts, Is.Not.Empty, "Compile should have generated errors");
}
else {
Assert.That(AllErrorTexts, Is.Empty, "Compile should not generate errors");
}
AllTypes = compilation.MainAssembly.TopLevelTypeDefinitions.SelectMany(SelfAndNested).ToDictionary(t => t.ReflectionName);
}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:34,代码来源:MetadataImporterTestBase.cs
示例6: CSharpFullParseInformation
public CSharpFullParseInformation(CSharpUnresolvedFile unresolvedFile, ITextSourceVersion parsedVersion, SyntaxTree compilationUnit)
: base(unresolvedFile, parsedVersion, isFullParseInformation: true)
{
if (unresolvedFile == null)
throw new ArgumentNullException("unresolvedFile");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
this.syntaxTree = compilationUnit;
}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:9,代码来源:CSharpFullParseInformation.cs
示例7: DefaultCompletionContextProvider
public DefaultCompletionContextProvider (IDocument document, CSharpUnresolvedFile unresolvedFile)
{
if (document == null)
throw new ArgumentNullException("document");
if (unresolvedFile == null)
throw new ArgumentNullException("unresolvedFile");
this.document = document;
this.unresolvedFile = unresolvedFile;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:9,代码来源:ICompletionContextProvider.cs
示例8: 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
示例9: CSharpFile
public CSharpFile(CSharpProject project, FileName fileName)
{
this.Project = project;
this.FileName = fileName;
this.OriginalText = File.ReadAllText(fileName);
CSharpParser p = new CSharpParser(project.CompilerSettings);
this.SyntaxTree = p.Parse(this.OriginalText, fileName);
this.UnresolvedTypeSystemForFile = SD.ParserService.GetExistingUnresolvedFile(fileName, null, project.IProject) as CSharpUnresolvedFile;
if (this.UnresolvedTypeSystemForFile == null)
throw new InvalidOperationException("LoadSolutionProjectsThread not yet finished?");
}
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:11,代码来源:Adapter.cs
示例10: SetUp
public override void SetUp()
{
base.SetUp();
unresolvedFile = new CSharpUnresolvedFile();
unresolvedFile.RootUsingScope.Usings.Add(MakeReference("System"));
unresolvedFile.RootUsingScope.Usings.Add(MakeReference("System.Collections.Generic"));
unresolvedFile.RootUsingScope.Usings.Add(MakeReference("System.Linq"));
convertVisitor = new CodeDomConvertVisitor();
convertVisitor.AllowSnippetNodes = false;
convertVisitor.UseFullyQualifiedTypeNames = true;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:CodeDomConvertVisitorTests.cs
示例11: CSharpCompletionContext
private CSharpCompletionContext(ITextEditor editor, IList<string> conditionalSymbols, ICompilation compilation, IProjectContent projectContent, IDocument document, CSharpUnresolvedFile unresolvedFile, TextLocation caretLocation)
{
Debug.Assert(editor != null);
Debug.Assert(unresolvedFile != null);
Debug.Assert(compilation != null);
Debug.Assert(projectContent != null);
Debug.Assert(document != null);
this.Editor = editor;
this.Document = document;
this.ConditionalSymbols = conditionalSymbols;
this.Compilation = compilation;
this.ProjectContent = projectContent;
this.TypeResolveContextAtCaret = unresolvedFile.GetTypeResolveContext(compilation, caretLocation);
this.CompletionContextProvider = new DefaultCompletionContextProvider(document, unresolvedFile);
this.CompletionContextProvider.ConditionalSymbols.AddRange(conditionalSymbols);
}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:16,代码来源:CSharpCompletionContext.cs
示例12: MethodParameterDataProvider
public MethodParameterDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IEnumerable<IMethod> m) : base (ext, startOffset)
{
compilation = ext.UnresolvedFileCompilation;
file = ext.CSharpUnresolvedFile;
HashSet<string> alreadyAdded = new HashSet<string> ();
foreach (var method in m) {
if (method.IsConstructor)
continue;
if (!method.IsBrowsable ())
continue;
string str = ambience.GetString (method, OutputFlags.IncludeParameters | OutputFlags.GeneralizeGenerics | OutputFlags.IncludeGenerics);
if (alreadyAdded.Contains (str))
continue;
alreadyAdded.Add (str);
methods.Add (method);
}
methods.Sort (MethodComparer);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:20,代码来源:MethodParameterDataProvider.cs
示例13: Prepare
private void Prepare(string source, Action preparer) {
IProjectContent project = new CSharpProjectContent();
var parser = new CSharpParser();
using (var rdr = new StringReader(source)) {
var pf = new CSharpUnresolvedFile("File.cs");
var syntaxTree = parser.Parse(rdr, pf.FileName);
syntaxTree.AcceptVisitor(new TypeSystemConvertVisitor(pf));
project = project.AddOrUpdateFiles(pf);
}
project = project.AddAssemblyReferences(new[] { Files.Mscorlib });
var compilation = project.CreateCompilation();
AllTypes = compilation.MainAssembly.TopLevelTypeDefinitions.SelectMany(SelfAndNested).ToDictionary(t => t.ReflectionName);
var er = new MockErrorReporter(true);
Metadata = new MetadataImporter(er, compilation, new CompilerOptions());
preparer();
Metadata.Prepare(compilation.GetAllTypeDefinitions());
Assert.That(er.AllMessages, Is.Empty, "Should not generate errrors");
}
开发者ID:pdavis68,项目名称:SaltarelleCompiler,代码行数:21,代码来源:ChainingTests.cs
示例14: CreateShortType
public AstType CreateShortType (ICompilation compilation, CSharpUnresolvedFile parsedFile, TextLocation loc, IType fullType)
{
var csResolver = parsedFile.GetResolver (compilation, loc);
var builder = new ICSharpCode.NRefactory.CSharp.Refactoring.TypeSystemAstBuilder (csResolver);
return builder.ConvertType (fullType);
}
开发者ID:ConorMurph1991,项目名称:monodevelop,代码行数:6,代码来源:CSharpCodeGenerator.cs
示例15: FindTypeParameterReferences
/// <summary>
/// Finds all references of a given type parameter.
/// </summary>
/// <param name="typeParameter">The type parameter for which to look.</param>
/// <param name="unresolvedFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree of the file being searched.</param>
/// <param name="compilation">The compilation.</param>
/// <param name="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
public void FindTypeParameterReferences(IType typeParameter, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
{
if (typeParameter == null)
throw new ArgumentNullException("typeParameter");
if (typeParameter.Kind != TypeKind.TypeParameter)
throw new ArgumentOutOfRangeException("typeParameter", "Only type parameters are allowed");
var searchScope = new SearchScope(c => new FindTypeParameterReferencesNavigator((ITypeParameter)typeParameter));
searchScope.declarationCompilation = compilation;
searchScope.accessibility = Accessibility.Private;
FindReferencesInFile(searchScope, unresolvedFile, syntaxTree, compilation, callback, cancellationToken);
}
开发者ID:artifexor,项目名称:NRefactory,代码行数:21,代码来源:FindReferences.cs
示例16: FindReferencesInFile
/// <summary>
/// Finds all references in the given file.
/// </summary>
/// <param name="searchScopes">The search scopes for which to look.</param>
/// <param name="unresolvedFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree of the file being searched.</param>
/// <param name="compilation">The compilation for the project that contains the file.</param>
/// <param name="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">CancellationToken that may be used to cancel the operation.</param>
public void FindReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
{
if (searchScopes == null)
throw new ArgumentNullException("searchScopes");
if (syntaxTree == null)
throw new ArgumentNullException("syntaxTree");
if (compilation == null)
throw new ArgumentNullException("compilation");
if (callback == null)
throw new ArgumentNullException("callback");
if (searchScopes.Count == 0)
return;
var navigators = new IResolveVisitorNavigator[searchScopes.Count];
for (int i = 0; i < navigators.Length; i++) {
navigators[i] = searchScopes[i].GetNavigator(compilation, callback);
}
IResolveVisitorNavigator combinedNavigator;
if (searchScopes.Count == 1) {
combinedNavigator = navigators[0];
} else {
combinedNavigator = new CompositeResolveVisitorNavigator(navigators);
}
cancellationToken.ThrowIfCancellationRequested();
combinedNavigator = new DetectSkippableNodesNavigator(combinedNavigator, syntaxTree);
cancellationToken.ThrowIfCancellationRequested();
CSharpAstResolver resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile);
resolver.ApplyNavigator(combinedNavigator, cancellationToken);
foreach (var n in navigators) {
var frn = n as FindReferenceNavigator;
if (frn != null)
frn.NavigatorDone(resolver, cancellationToken);
}
}
开发者ID:artifexor,项目名称:NRefactory,代码行数:45,代码来源:FindReferences.cs
示例17: FindLocalReferences
/// <summary>
/// Finds all references of a given variable.
/// </summary>
/// <param name="variable">The variable for which to look.</param>
/// <param name="unresolvedFile">The type system representation of the file being searched.</param>
/// <param name="syntaxTree">The syntax tree of the file being searched.</param>
/// <param name="compilation">The compilation.</param>
/// <param name="callback">Callback used to report the references that were found.</param>
/// <param name="cancellationToken">Cancellation token that may be used to cancel the operation.</param>
public void FindLocalReferences(IVariable variable, CSharpUnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
ICompilation compilation, FoundReferenceCallback callback, CancellationToken cancellationToken)
{
if (variable == null)
throw new ArgumentNullException("variable");
var searchScope = new SearchScope(c => new FindLocalReferencesNavigator(variable));
searchScope.declarationCompilation = compilation;
FindReferencesInFile(searchScope, unresolvedFile, syntaxTree, compilation, callback, cancellationToken);
}
开发者ID:artifexor,项目名称:NRefactory,代码行数:18,代码来源:FindReferences.cs
示例18: ParsedSourceFile
public ParsedSourceFile(SyntaxTree syntaxTree, CSharpUnresolvedFile parsedFile)
{
SyntaxTree = syntaxTree;
ParsedFile = parsedFile;
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:5,代码来源:ParsedSourceFile.cs
示例19: CreateCompilation
public static void CreateCompilation (string parsedText, out IProjectContent pctx, out SyntaxTree syntaxTree, out CSharpUnresolvedFile unresolvedFile, bool expectErrors, params IUnresolvedAssembly[] references)
{
pctx = new CSharpProjectContent();
var refs = new List<IUnresolvedAssembly> { mscorlib.Value, systemCore.Value, systemAssembly.Value, systemXmlLinq.Value };
if (references != null)
refs.AddRange (references);
pctx = pctx.AddAssemblyReferences(refs);
syntaxTree = new CSharpParser().Parse(parsedText, "program.cs");
syntaxTree.Freeze();
if (!expectErrors && syntaxTree.Errors.Count > 0) {
Console.WriteLine ("----");
Console.WriteLine (parsedText);
Console.WriteLine ("----");
foreach (var error in syntaxTree.Errors)
Console.WriteLine (error.Message);
Assert.Fail ("Parse error.");
}
unresolvedFile = syntaxTree.ToTypeSystem();
pctx = pctx.AddOrUpdateFiles(unresolvedFile);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:23,代码来源:CodeCompletionBugTests.cs
示例20: CreateTooltipInformation
public static TooltipInformation CreateTooltipInformation (ICompilation compilation, CSharpUnresolvedFile file, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IParameterizedMember entity, int currentParameter, bool smartWrap)
{
var tooltipInfo = new TooltipInformation ();
var resolver = file.GetResolver (compilation, textEditorData.Caret.Location);
var sig = new SignatureMarkupCreator (resolver, formattingPolicy.CreateOptions ());
sig.HighlightParameter = currentParameter;
sig.BreakLineAfterReturnType = smartWrap;
try {
tooltipInfo.SignatureMarkup = sig.GetMarkup (entity);
} catch (Exception e) {
LoggingService.LogError ("Got exception while creating markup for :" + entity, e);
return new TooltipInformation ();
}
tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup (entity) ?? "";
if (entity is IMethod) {
var method = (IMethod)entity;
if (method.IsExtensionMethod) {
tooltipInfo.AddCategory (GettextCatalog.GetString ("Extension Method from"), method.DeclaringTypeDefinition.FullName);
}
}
int paramIndex = currentParameter;
if (entity is IMethod && ((IMethod)entity).IsExtensionMethod)
paramIndex++;
paramIndex = Math.Min (entity.Parameters.Count - 1, paramIndex);
var curParameter = paramIndex >= 0 && paramIndex < entity.Parameters.Count ? entity.Parameters [paramIndex] : null;
if (curParameter != null) {
string docText = AmbienceService.GetDocumentation (entity);
if (!string.IsNullOrEmpty (docText)) {
string text = docText;
Regex paramRegex = new Regex ("(\\<param\\s+name\\s*=\\s*\"" + curParameter.Name + "\"\\s*\\>.*?\\</param\\>)", RegexOptions.Compiled);
Match match = paramRegex.Match (docText);
if (match.Success) {
text = AmbienceService.GetDocumentationMarkup (entity, match.Groups [1].Value);
if (!string.IsNullOrWhiteSpace (text))
tooltipInfo.AddCategory (GettextCatalog.GetString ("Parameter"), text);
}
}
if (curParameter.Type.Kind == TypeKind.Delegate)
tooltipInfo.AddCategory (GettextCatalog.GetString ("Delegate Info"), sig.GetDelegateInfo (curParameter.Type));
}
return tooltipInfo;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:48,代码来源:MethodParameterDataProvider.cs
注:本文中的CSharpUnresolvedFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论