本文整理汇总了C#中CodeLocation类的典型用法代码示例。如果您正苦于以下问题:C# CodeLocation类的具体用法?C# CodeLocation怎么用?C# CodeLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeLocation类属于命名空间,在下文中一共展示了CodeLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
internal override void Read(NetIncomingMessage Message)
{
base.Read(Message);
Language = (CodeLanguage)Enum.Parse(typeof(CodeLanguage), Message.ReadString());
Location = (CodeLocation)Enum.Parse(typeof(CodeLocation), Message.ReadString());
Source = Message.ReadString();
}
示例2: Whitespace
/// <summary>
/// Initializes a new instance of the Whitespace class.
/// </summary>
/// <param name="text">The whitespace text.</param>
/// <param name="location">The location of the whitespace in the code.</param>
/// <param name="parent">The parent code unit.</param>
/// <param name="generated">True if the token is inside of a block of generated code.</param>
internal Whitespace(
string text,
CodeLocation location,
Reference<ICodePart> parent,
bool generated)
: base(text,
CsTokenType.WhiteSpace,
CsTokenClass.Whitespace,
location,
parent,
generated)
{
Param.AssertValidString(text, "text");
Param.AssertNotNull(location, "location");
Param.AssertNotNull(parent, "parent");
Param.Ignore(generated);
for (int i = 0; i < text.Length; ++i)
{
if (text[i] == ' ')
{
++this.spaceCount;
}
else if (text[i] == '\t')
{
++this.tabCount;
}
}
}
示例3: SearchBackward
static DToken SearchBackward(TextDocument doc, int caretOffset, CodeLocation caret,out DToken lastToken)
{
var ttp = doc.GetText(0, caretOffset);
var sr = new StringReader(ttp);
var lexer = new Lexer(sr);
lexer.NextToken();
var stk=new Stack<DToken>();
while (lexer.LookAhead.Kind!=DTokens.EOF)
{
if (lexer.LookAhead.Kind == DTokens.OpenParenthesis || lexer.LookAhead.Kind==DTokens.OpenSquareBracket || lexer.LookAhead.Kind==DTokens.OpenCurlyBrace)
stk.Push(lexer.LookAhead);
else if (lexer.LookAhead.Kind == DTokens.CloseParenthesis || lexer.LookAhead.Kind == DTokens.CloseSquareBracket || lexer.LookAhead.Kind == DTokens.CloseCurlyBrace)
{
if (stk.Peek().Kind == getOppositeBracketToken( lexer.LookAhead.Kind))
stk.Pop();
}
lexer.NextToken();
}
lastToken = lexer.CurrentToken;
sr.Close();
lexer.Dispose();
if (stk.Count < 1)
return null;
return stk.Pop();
}
示例4: ParserError
public ParserError(bool IsSemanticError, string Message, int KeyToken, CodeLocation ErrorLocation)
{
IsSemantic = IsSemanticError;
this.Message = Message;
this.Token = KeyToken;
this.Location = ErrorLocation;
}
示例5: Constructor
public void Constructor(string filename, int line, int column)
{
var location = new CodeLocation(filename, line, column);
Assert.AreEqual(filename, location.Path);
Assert.AreEqual(line, location.Line);
Assert.AreEqual(column, location.Column);
}
示例6: Argument
/// <summary>
/// Initializes a new instance of the Argument class.
/// </summary>
/// <param name="name">The optional name of the argument.</param>
/// <param name="modifiers">Modifers applied to this argument.</param>
/// <param name="argumentExpression">The expression that forms the body of the argument.</param>
/// <param name="location">The location of the argument in the code.</param>
/// <param name="parent">The parent code part.</param>
/// <param name="tokens">The tokens that form the argument.</param>
/// <param name="generated">Indicates whether the argument is located within a block of generated code.</param>
internal Argument(
CsToken name,
ParameterModifiers modifiers,
Expression argumentExpression,
CodeLocation location,
Reference<ICodePart> parent,
CsTokenList tokens,
bool generated)
{
Param.Ignore(name);
Param.Ignore(modifiers);
Param.AssertNotNull(argumentExpression, "argumentExpression");
Param.AssertNotNull(location, "location");
Param.AssertNotNull(parent, "parent");
Param.Ignore(tokens);
Param.Ignore(generated);
this.name = name;
this.modifiers = modifiers;
this.argumentExpression = argumentExpression;
this.location = location;
this.parent = parent;
this.tokens = tokens;
this.generated = generated;
}
示例7: GetNextMetaBlockOrStatStmt
public ISyntaxRegion GetNextMetaBlockOrStatStmt(CodeLocation until)
{
if (nextStatStmt == null && StaticStatementEnum != null) {
if (StaticStatementEnum.MoveNext ())
nextStatStmt = StaticStatementEnum.Current;
else
StaticStatementEnum = null;
}
if (nextMetaDecl == null && MetaBlockEnum != null) {
if (MetaBlockEnum.MoveNext ())
nextMetaDecl = MetaBlockEnum.Current;
else
MetaBlockEnum = null;
}
ISyntaxRegion sr;
if (nextStatStmt != null) {
if (nextMetaDecl == null)
sr = nextStatStmt;
else
sr = nextStatStmt.First (nextMetaDecl);
} else if (nextMetaDecl != null)
sr = nextMetaDecl;
else
return null;
return sr.Location < until ? sr : null;
}
示例8: ForStatement
public void ForStatement()
{
var code = @"module A; // 1
void main(){
for(
int
i= // 5
0;
i<100;
i++)
{ // 10
}";
var mod = DParser.ParseString(code);
var main = mod["main"].First() as DMethod;
var l = new CodeLocation(1,4);
var off = DocumentHelper.LocationToOffset(code,l);
ParserTrackerVariables ptr;
CodeLocation caretLoc;
//var parsedBlock = AbstractCompletionProvider.FindCurrentCaretContext(code,main, off,l,out ptr, out caretLoc);
/*
* a) Test if completion popup would open in each code situation
* b) Test in which case iteration variables can be found.
*/
//TODO
}
示例9: SearchBrackets
public static BracketSearchResult SearchBrackets(TextDocument doc, int caretOffset, TextLocation caret)
{
var caretLocation = new CodeLocation(caret.Column, caret.Line);
try
{
if (caretOffset < 1 || caretOffset>=doc.TextLength-2)
return null;
// Search backward
DToken lastToken=null;
var tk_start = SearchBackward(doc, caretOffset, caretLocation,out lastToken);
if (tk_start == null)
return null;
// Search forward
var tk_end = SearchForward(doc,
doc.GetOffset(lastToken.EndLocation.Line,lastToken.EndLocation.Column),
lastToken.EndLocation,
getOppositeBracketToken(tk_start.Kind));
if (tk_end == null)
return null;
int start = doc.GetOffset(tk_start.Location.Line, tk_start.Location.Column),
end = doc.GetOffset(tk_end.Location.Line, tk_end.Location.Column);
return new BracketSearchResult(start, 1, end, 1);
}
catch { return null; }
}
示例10: Set
public void Set(IBlockNode b, CodeLocation caret)
{
scopedBlock = b;
Caret = caret;
ConditionalCompilation.EnumConditions(DeclarationCondititons, b, ctxt, caret);
}
示例11: EVException
public EVException([CallerFilePath] string callerFilePath = "",
[CallerLineNumber] int callerLineNumber = 0,
[CallerMemberName] string callerMemberName = "")
{
CodeLocation codeLocation = new CodeLocation(callerFilePath, callerLineNumber, callerMemberName);
this.AddNamedProperty("EVExceptionConstructionLocation", codeLocation.ToString());
}
示例12: FindFitting
public IEnumerable<DMethod> FindFitting(ResolverContextStack ctxt, CodeLocation currentLocation, ISemantic firstArgument, string nameFilter = null)
{
if (IsProcessing)
return null;
var preMatchList = new List<DMethod>();
bool dontUseNameFilter = nameFilter == null;
lock(CachedMethods)
foreach (var kv in CachedMethods)
{
// First test if arg is matching the parameter
if ((dontUseNameFilter || kv.Key.Name == nameFilter) &&
ResultComparer.IsImplicitlyConvertible(firstArgument, kv.Value, ctxt))
preMatchList.Add(kv.Key);
}
// Then filter out methods which cannot be accessed in the current context
// (like when the method is defined in a module that has not been imported)
var mv = new MatchFilterVisitor<DMethod>(ctxt, preMatchList);
mv.IterateThroughScopeLayers(currentLocation);
return mv.filteredList;
}
示例13: ApplySolution
/// <summary>
/// Inserts import statement into correct place
/// </summary>
static void ApplySolution(string import, Document doc)
{
var eData = DResolverWrapper.GetEditorData(doc);
var loc = new CodeLocation(0, DParser.FindLastImportStatementEndLocation(eData.SyntaxTree, eData.ModuleCode).Line + 1);
doc.Editor.Insert(doc.Editor.GetLine(loc.Line).Offset, import.Trim() + doc.Editor.EolMarker);
//IOInterface.InsertIntoCode(loc, "import " + mod.ModuleName + ";\n");
}
示例14: MultiplicationOperator
/// <summary>
/// Initializes a new instance of the MultiplicationOperator class.
/// </summary>
/// <param name="document">The parent document.</param>
/// <param name="text">The text of the item.</param>
/// <param name="location">The location of the item.</param>
/// <param name="generated">Indicates whether the item is generated.</param>
internal MultiplicationOperator(CsDocument document, string text, CodeLocation location, bool generated)
: base(document, text, OperatorCategory.Arithmetic, OperatorType.Multiplication, location, generated)
{
Param.AssertNotNull(document, "document");
Param.AssertValidString(text, "text");
Param.AssertNotNull(location, "location");
Param.Ignore(generated);
}
示例15: Comment
public Comment(Type commentType, string comment, bool commentStartsLine, CodeLocation startPosition, CodeLocation endPosition)
{
this.CommentType = commentType;
this.CommentText = comment;
this.CommentStartsLine = commentStartsLine;
this.StartPosition = startPosition;
this.EndPosition = endPosition;
}