本文整理汇总了C#中ITextBuffer.GetFileName方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.GetFileName方法的具体用法?C# ITextBuffer.GetFileName怎么用?C# ITextBuffer.GetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextBuffer
的用法示例。
在下文中一共展示了ITextBuffer.GetFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSmartTagActions
public override IEnumerable<ISmartTagAction> GetSmartTagActions(JSONMember item, ITextBuffer buffer)
{
string directory = Path.GetDirectoryName(buffer.GetFileName());
if (item.Value != null && item.Value.Text.Trim('"').Length > 0)
yield return new UpdatePackageAction(item.UnquotedNameText, directory);
}
示例2: GetVersion
public Version GetVersion(ITextBuffer textBuffer)
{
Version version = null;
if (textBuffer != null)
{
bool fromCache = false;
foreach (var buffer in textBuffer.GetContributingBuffers())
{
if (buffer.Properties.TryGetProperty(RazorSupportedRuntimeVersion2, out version))
{
fromCache = true;
break;
}
}
if (!fromCache)
{
var getExplicitWebPagesVersionMethod = _getExplicitWebPagesVersionMethod.Value;
if (getExplicitWebPagesVersionMethod != null)
{
var fileName = textBuffer.GetFileName();
var projectData = Microsoft.VisualStudio.Html.Package.Project.ProjectData.FromFileNameAndPath(fileName);
if (projectData != null)
{
var absolutePath = VsWebUrl.CreateAppUrl(projectData.Hierarchy, projectData.ItemID).AbsolutePath;
try
{
version = (Version)getExplicitWebPagesVersionMethod.Invoke(null, new object[] { absolutePath });
}
catch
{
}
}
}
textBuffer.Properties[RazorSupportedRuntimeVersion2] = version;
}
if (version != null)
{
if (_inner != null)
{
var innerType = _inner.GetType();
var setCachedVersionMethod = _setCachedVersionMethodCache.GetOrAdd(innerType,
type => type.GetMethod("SetCachedVersion", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(ITextBuffer), typeof(Version) }, null));
if (setCachedVersionMethod != null)
{
try
{
setCachedVersionMethod.Invoke(_inner, new object[] { textBuffer, version });
}
catch (TargetInvocationException)
{
}
}
}
return version;
}
}
if (_inner != null)
version = _inner.GetVersion(textBuffer);
return version;
}
示例3: GetSmartTagActions
public override IEnumerable<ISmartTagAction> GetSmartTagActions(JSONMember item, ITextBuffer buffer)
{
string directory = Path.GetDirectoryName(buffer.GetFileName());
string node_module = Path.Combine(directory, "node_modules", item.UnquotedNameText);
if (item.Value != null && item.Value.Text.Trim('"').Length > 0 && Directory.Exists(node_module))
yield return new UpdatePackageAction(item.UnquotedNameText, directory);
}
示例4: GetErrors
/// <summary>
/// Gets the errors of the text buffer
/// </summary>
/// <param name="textBuffer"></param>
/// <returns></returns>
internal IList<ValidationError> GetErrors(ITextBuffer textBuffer)
{
var sink = new PyErrorListCompilerSink(textBuffer);
var modules = new Microsoft.VisualStudio.IronPythonInference.Modules();
modules.AnalyzeModule(sink, textBuffer.GetFileName(), textBuffer.CurrentSnapshot.GetText());
return sink.Errors.ToList();
}
示例5: GetSmartTagActions
public override IEnumerable<ISmartTagAction> GetSmartTagActions(JSONMember item, ITextBuffer buffer)
{
// TODO: Check if the bower package is already installed and if so, don't show this SmartTag
string directory = Path.GetDirectoryName(buffer.GetFileName());
if (item.Value != null && item.Value.Text.Trim('"').Length > 0)
yield return new InstallPackageAction(item, directory);
}
示例6: TryCreateCompletionSource
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) {
var filename = textBuffer.GetFileName();
if (filename != null) {
var project = DjangoPackage.GetProject(_serviceProvider, filename);
if (project != null) {
return new DjangoCompletionSource(_glyphService, project.Analyzer, _serviceProvider, textBuffer);
}
}
return null;
}
示例7: TryCreateCompletionSource
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
{
string filename = System.IO.Path.GetFileName(textBuffer.GetFileName());
var textType = RobotsTxtClassifierProvider.GetTextType(filename);
if (textType == TextType.Robots || textType == TextType.Humans)
{
return new RobotsTxtCompletionSource(textBuffer);
}
return null;
}
示例8: TryCreateCompletionSource
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
{
string filename = System.IO.Path.GetFileName(textBuffer.GetFileName());
var textType = DockerfileClassifierProvider.GetTextType(filename);
if (textType == TextType.Dockerfile)
{
return new DockerfileCompletionSource(textBuffer);
}
return null;
}
示例9: UnusedCssClassifier
internal UnusedCssClassifier(IClassificationTypeRegistryService registry, ITextBuffer buffer)
{
var currentFile = buffer.GetFileName().ToLowerInvariant();
_buffer = buffer;
_decClassification = registry.GetClassificationType(UnusedCssClassificationTypes.Declaration);
if (!string.IsNullOrEmpty(currentFile))
{
UsageRegistry.UsageDataUpdated += ResyncClassificationSpans;
}
}
示例10: TryCreateCompletionSource
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
{
string filename = System.IO.Path.GetFileName(textBuffer.GetFileName());
if (PaketClassifierProvider.IsPaketFile(filename))
{
return new PaketCompletionSource(glyphService, textBuffer, NavigatorService.GetTextStructureNavigator(textBuffer));
}
return null;
}
示例11: AddItem
public SourceItem AddItem(ITextBuffer textBuffer)
{
SourceItem srcItem = null;
if (textBuffer == null)
return null;
string filepath = textBuffer.GetFileName();
if (!_sources.ContainsKey(filepath))
{
srcItem = new SourceItem(textBuffer);
_sources.Add(filepath, srcItem);
}
return srcItem;
}
示例12: GetClassifier
public IClassifier GetClassifier(ITextBuffer textBuffer)
{
string fileName = textBuffer.GetFileName();
if (string.IsNullOrEmpty(fileName))
return null;
if (Path.GetFileName(fileName).Equals("gulpfile.js", StringComparison.OrdinalIgnoreCase))
{
return textBuffer.Properties.GetOrCreateSingletonProperty(() => new TaskClassifier(Registry, "gulp.task(", _gulp));
}
else if (Path.GetFileName(fileName).Equals("gruntfile.js", StringComparison.OrdinalIgnoreCase))
{
return textBuffer.Properties.GetOrCreateSingletonProperty(() => new TaskClassifier(Registry, "grunt.registerTask(", _grunt));
}
return null;
}
示例13: ProjectBlockCompletionContext
public ProjectBlockCompletionContext(DjangoAnalyzer analyzer, ITextBuffer buffer)
: base(analyzer, buffer, buffer.GetFileName()) {
var doc = HtmlEditorDocument.FromTextBuffer(buffer);
if (doc == null) {
return;
}
var artifacts = doc.HtmlEditorTree.ArtifactCollection;
foreach (var artifact in artifacts.OfType<TemplateBlockArtifact>()) {
var artifactText = doc.HtmlEditorTree.ParseTree.Text.GetText(artifact.InnerRange);
artifact.Parse(artifactText);
if (artifact.Block != null) {
var varNames = artifact.Block.GetVariables();
foreach (var varName in varNames) {
AddLoopVariable(varName);
}
}
}
}
示例14: GetSmartTagActions
public override IEnumerable<ISmartTagAction> GetSmartTagActions(JSONMember item, ITextBuffer buffer)
{
string directory = Path.GetDirectoryName(buffer.GetFileName());
yield return new UpdatePackageAction(item.UnquotedNameText, directory);
}
示例15: ReplaceUrlValue
private static void ReplaceUrlValue(string fileName, ITextBuffer buffer, AttributeNode src)
{
string relative = FileHelpers.RelativePath(buffer.GetFileName(), fileName);
Span span = new Span(src.ValueRangeUnquoted.Start, src.ValueRangeUnquoted.Length);
buffer.Replace(span, relative.ToLowerInvariant());
}