本文整理汇总了C#中VBAParser.GetSelection方法的典型用法代码示例。如果您正苦于以下问题:C# VBAParser.GetSelection方法的具体用法?C# VBAParser.GetSelection怎么用?C# VBAParser.GetSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VBAParser
的用法示例。
在下文中一共展示了VBAParser.GetSelection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExitOptionPrivateModuleStmt
public override void ExitOptionPrivateModuleStmt(VBAParser.OptionPrivateModuleStmtContext context)
{
OnNewDeclaration(CreateDeclaration(context.GetText(), string.Empty, Accessibility.Implicit, DeclarationType.ModuleOption, context, context.GetSelection()));
}
示例2: EnterOptionExplicitStmt
public override void EnterOptionExplicitStmt(VBAParser.OptionExplicitStmtContext context)
{
_declarations.Add(CreateDeclaration(context.GetText(), string.Empty, Accessibility.Implicit, DeclarationType.ModuleOption, context, context.GetSelection()));
}
示例3: RewriteSignature
private void RewriteSignature(Declaration target, VBAParser.ArgListContext paramList, CodeModule module)
{
var argList = paramList.arg();
var newContent = GetOldSignature(target);
var lineNum = paramList.GetSelection().LineCount;
var parameterIndex = 0;
var currentStringIndex = 0;
for (var i = parameterIndex; i < _model.Parameters.Count; i++)
{
var oldParam = argList.ElementAt(parameterIndex).GetText();
var newParam = argList.ElementAt(_model.Parameters.ElementAt(parameterIndex).Index).GetText();
var parameterStringIndex = newContent.IndexOf(oldParam, currentStringIndex, StringComparison.Ordinal);
if (parameterStringIndex > -1)
{
var beginningSub = newContent.Substring(0, parameterStringIndex);
var replaceSub = newContent.Substring(parameterStringIndex).Replace(oldParam, newParam);
newContent = beginningSub + replaceSub;
parameterIndex++;
currentStringIndex = beginningSub.Length + newParam.Length;
}
}
module.ReplaceLine(paramList.Start.Line, newContent.Replace(" _" + Environment.NewLine, string.Empty));
module.DeleteLines(paramList.Start.Line + 1, lineNum - 1);
}
示例4: RemoveSignatureParameters
private void RemoveSignatureParameters(Declaration target, VBAParser.ArgListContext paramList, CodeModule module)
{
var paramNames = paramList.arg();
var paramsRemoved = _model.Parameters.Where(item => item.IsRemoved).ToList();
var signature = GetOldSignature(target);
foreach (var param in paramsRemoved)
{
try
{
signature = ReplaceCommas(signature.Replace(paramNames.ElementAt(param.Index).GetText(), ""), _model.Parameters.FindIndex(item => item == param) - paramsRemoved.FindIndex(item => item == param));
}
catch (ArgumentOutOfRangeException)
{
}
}
var lineNum = paramList.GetSelection().LineCount;
module.ReplaceLine(paramList.Start.Line, signature);
for (var line = paramList.Start.Line + 1; line < paramList.Start.Line + lineNum; line++)
{
module.ReplaceLine(line, "");
}
}