本文整理汇总了C#中MasterList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MasterList.Add方法的具体用法?C# MasterList.Add怎么用?C# MasterList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MasterList
的用法示例。
在下文中一共展示了MasterList.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGenericArgumentList
private MasterList<CsToken> GetGenericArgumentList(Reference<ICodePart> genericTypeReference, bool unsafeCode, CsToken name, int startIndex, out int endIndex)
{
Param.AssertNotNull(genericTypeReference, "genericTypeReference");
Param.Ignore(unsafeCode);
Param.Ignore(name);
Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
endIndex = -1;
MasterList<CsToken> genericArgumentListTokens = null;
// Move past whitespace and comments.
int index = startIndex;
while (true)
{
Symbol next = this.symbols.Peek(index);
if (next == null
|| (next.SymbolType != SymbolType.WhiteSpace && next.SymbolType != SymbolType.EndOfLine && next.SymbolType != SymbolType.SingleLineComment
&& next.SymbolType != SymbolType.MultiLineComment && next.SymbolType != SymbolType.PreprocessorDirective))
{
break;
}
++index;
}
// The next symbol should be an opening bracket, if this is a generic.
Symbol symbol = this.symbols.Peek(index);
if (symbol != null && symbol.SymbolType == SymbolType.LessThan)
{
// This might be a generic. Assume that it is and start creating tokens.
genericArgumentListTokens = new MasterList<CsToken>();
// Add the name if one was provided.
if (name != null)
{
genericArgumentListTokens.Add(name);
}
Node<CsToken> openingGenericBracketNode = null;
// Add everything up to the opening bracket into the token list.
for (int i = startIndex; i <= index; ++i)
{
symbol = this.symbols.Peek(i);
Debug.Assert(symbol != null, "The next symbol should not be null");
if (symbol.SymbolType == SymbolType.LessThan)
{
if (openingGenericBracketNode != null)
{
// This is not a generic statement.
return null;
}
Bracket openingGenericBracket = new Bracket(
symbol.Text, CsTokenType.OpenGenericBracket, symbol.Location, genericTypeReference, this.symbols.Generated);
openingGenericBracketNode = genericArgumentListTokens.InsertLast(openingGenericBracket);
}
else
{
genericArgumentListTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), genericTypeReference));
}
}
// Loop through the rest of the symbols.
while (true)
{
symbol = this.symbols.Peek(++index);
if (symbol == null)
{
// The code ran out before we found the end of the generic.
throw new SyntaxException(this.document.SourceCode, name.LineNumber);
}
else if (symbol.SymbolType == SymbolType.GreaterThan)
{
if (openingGenericBracketNode == null)
{
// This is not a generic statement.
return null;
}
// This is the end of the generic statement. Add the closing bracket to the token list.
Bracket closingGenericBracket = new Bracket(
symbol.Text, CsTokenType.CloseGenericBracket, symbol.Location, genericTypeReference, this.symbols.Generated);
Node<CsToken> closingGenericBracketNode = genericArgumentListTokens.InsertLast(closingGenericBracket);
((Bracket)openingGenericBracketNode.Value).MatchingBracketNode = closingGenericBracketNode;
closingGenericBracket.MatchingBracketNode = openingGenericBracketNode;
endIndex = index;
break;
}
else if (symbol.SymbolType == SymbolType.Out || symbol.SymbolType == SymbolType.In)
{
// Get the in or out keyword.
genericArgumentListTokens.Add(
this.ConvertSymbol(symbol, symbol.SymbolType == SymbolType.In ? CsTokenType.In : CsTokenType.Out, genericTypeReference));
}
else if (symbol.SymbolType == SymbolType.Other)
{
//.........这里部分代码省略.........
示例2: ParseTypeConstraintClauses
/// <summary>
/// Parses one or more type constraint clauses.
/// </summary>
/// <param name="elementReference">A reference to the element being created.</param>
/// <param name="unsafeCode">Indicates whether the code is marked as unsafe.</param>
/// <returns>Returns the clauses.</returns>
private ICollection<TypeParameterConstraintClause> ParseTypeConstraintClauses(
Reference<ICodePart> elementReference, bool unsafeCode)
{
Param.AssertNotNull(elementReference, "elementReference");
Param.Ignore(unsafeCode);
List<TypeParameterConstraintClause> constraintClauses = new List<TypeParameterConstraintClause>();
Symbol symbol = this.GetNextSymbol(elementReference);
while (symbol.Text == "where")
{
var constraintClauseReference = new Reference<ICodePart>();
Node<CsToken> firstToken = this.tokens.InsertLast(this.GetToken(CsTokenType.Where, SymbolType.Other, constraintClauseReference));
Node<CsToken> typeToken = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other, constraintClauseReference));
this.tokens.Add(this.GetToken(CsTokenType.WhereColon, SymbolType.Colon, constraintClauseReference));
List<CsToken> constraints = new List<CsToken>();
while (true)
{
symbol = this.GetNextSymbol(constraintClauseReference);
CsToken constraintToken = null;
if (symbol.SymbolType == SymbolType.Class ||
symbol.SymbolType == SymbolType.Struct)
{
// A constraint of type class or struct.
constraintToken = this.GetToken(CsTokenType.Other, symbol.SymbolType, constraintClauseReference);
}
else if (symbol.SymbolType == SymbolType.New)
{
var constructorConstraintReference = new Reference<ICodePart>();
// A constructor constraint.
MasterList<CsToken> childTokens = new MasterList<CsToken>();
childTokens.Add(this.GetToken(CsTokenType.Other, SymbolType.New, constraintClauseReference));
Bracket openParenthesis = this.GetBracketToken(CsTokenType.OpenParenthesis, SymbolType.OpenParenthesis, constraintClauseReference);
Bracket closeParenthesis = this.GetBracketToken(CsTokenType.CloseParenthesis, SymbolType.CloseParenthesis, constraintClauseReference);
Node<CsToken> openParenthesisNode = childTokens.InsertLast(openParenthesis);
Node<CsToken> closeParenthesisNode = childTokens.InsertLast(closeParenthesis);
openParenthesis.MatchingBracketNode = closeParenthesisNode;
closeParenthesis.MatchingBracketNode = openParenthesisNode;
constraintToken = new ConstructorConstraint(
childTokens,
CsToken.JoinLocations(childTokens.First, childTokens.Last),
constraintClauseReference,
childTokens.First.Value.Generated);
constructorConstraintReference.Target = constraintToken;
}
else
{
// A type constraint.
constraintToken = this.GetTypeToken(constraintClauseReference, unsafeCode, true);
}
this.tokens.Add(constraintToken);
constraints.Add(constraintToken);
symbol = this.GetNextSymbol(constraintClauseReference);
if (symbol.SymbolType != SymbolType.Comma)
{
break;
}
this.tokens.Add(this.GetToken(CsTokenType.Comma, SymbolType.Comma, constraintClauseReference));
}
// Add the constraints as a read-only collection in a constraint clause.
var constraintClause = new TypeParameterConstraintClause(
new CsTokenList(this.tokens, firstToken, this.tokens.Last), typeToken.Value, constraints.ToArray(), elementReference);
constraintClauseReference.Target = constraintClause;
constraintClauses.Add(constraintClause);
symbol = this.GetNextSymbol(elementReference);
}
// Return the constraint clauses as a read-only collection.
return constraintClauses.ToArray();
}
示例3: GetXmlHeader
/// <summary>
/// Gets an xml header.
/// </summary>
/// <param name="elementReference">A reference to the element being created.</param>
/// <returns>Returns the header or null if there is no header.</returns>
private XmlHeader GetXmlHeader(Reference<ICodePart> elementReference)
{
Param.AssertNotNull(elementReference, "elementReference");
// Get the first symbol and make sure it is the right type.
int index = 1;
Symbol firstSymbol = this.symbols.Peek(index);
Debug.Assert(firstSymbol != null && firstSymbol.SymbolType == SymbolType.XmlHeaderLine, "Expected an xml documentation header line");
// Marks the end of the header.
int end = -1;
int endOfLineCount = 0;
var xmlHeaderReference = new Reference<ICodePart>();
// Loop until the entire header is found.
Symbol symbol = firstSymbol;
while (symbol != null)
{
if (symbol.SymbolType == SymbolType.XmlHeaderLine)
{
// This type of token belongs in the header.
end = index;
endOfLineCount = 0;
}
else if (symbol.SymbolType == SymbolType.EndOfLine)
{
if (++endOfLineCount > 1)
{
// If there are two newlines in a row, this is the
// end of the Xml header.
break;
}
}
else if (symbol.SymbolType == SymbolType.WhiteSpace ||
symbol.SymbolType == SymbolType.SingleLineComment)
{
endOfLineCount = 0;
}
else
{
// This is the end of the header.
break;
}
// Advance the index and get the next symbol.
symbol = this.symbols.Peek(++index);
}
// Make sure we've advanced at least one symbol.
Debug.Assert(end != -1, "Should have advanced at least one symbol");
// Add all of the symbols for the header to a token list.
MasterList<CsToken> headerTokens = new MasterList<CsToken>();
for (int i = 1; i <= end; ++i)
{
this.symbols.Advance();
Debug.Assert(this.symbols.Current != null, "The current symbol should not be null");
headerTokens.Add(this.ConvertSymbol(this.symbols.Current, TokenTypeFromSymbolType(this.symbols.Current.SymbolType), xmlHeaderReference));
}
// Get the location of the header.
CodeLocation location = CodeLocation.Join(firstSymbol.Location, this.symbols.Current.Location);
// Create the Xml header object.
var xmlHeader = new XmlHeader(headerTokens, location, elementReference, this.symbols.Generated);
xmlHeaderReference.Target = xmlHeader;
return xmlHeader;
}
示例4: GetTypeTokenArrayBrackets
/// <summary>
/// Gets array brackets symbol for a type token, if they exist.
/// </summary>
/// <param name="typeTokenReference">A reference to the type token.</param>
/// <param name="typeTokens">The tokens within the type token.</param>
/// <param name="startIndex">The start index within the symbols.</param>
private void GetTypeTokenArrayBrackets(Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, ref int startIndex)
{
Param.AssertNotNull(typeTokenReference, "typeTokenReference");
Param.AssertNotNull(typeTokens, "typeTokens");
Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
int index = this.GetNextCodeSymbolIndex(startIndex);
if (index != -1)
{
Symbol symbol = this.symbols.Peek(index);
if (symbol.SymbolType == SymbolType.OpenSquareBracket)
{
// Add the tokens up to this point.
for (int i = startIndex; i <= index - 1; ++i)
{
Symbol symbolToConvert = this.symbols.Peek(startIndex);
typeTokens.Add(this.ConvertSymbol(symbolToConvert, TokenTypeFromSymbolType(symbolToConvert.SymbolType), typeTokenReference));
++startIndex;
}
// Now collect the brackets.
Node<CsToken> openingBracketNode = null;
while (true)
{
symbol = this.symbols.Peek(startIndex);
if (symbol.SymbolType == SymbolType.WhiteSpace ||
symbol.SymbolType == SymbolType.EndOfLine ||
symbol.SymbolType == SymbolType.SingleLineComment ||
symbol.SymbolType == SymbolType.MultiLineComment ||
symbol.SymbolType == SymbolType.PreprocessorDirective)
{
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
++startIndex;
}
else if (symbol.SymbolType == SymbolType.Number)
{
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Number, typeTokenReference));
++startIndex;
}
else if (symbol.SymbolType == SymbolType.Other)
{
// A const used in place of a number.
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Other, typeTokenReference));
++startIndex;
}
else if (symbol.SymbolType == SymbolType.Comma)
{
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Comma, typeTokenReference));
++startIndex;
}
else if (symbol.SymbolType == SymbolType.OpenSquareBracket)
{
if (openingBracketNode != null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
Bracket openingBracket = new Bracket(
symbol.Text, CsTokenType.OpenSquareBracket, symbol.Location, typeTokenReference, this.symbols.Generated);
openingBracketNode = typeTokens.InsertLast(openingBracket);
++startIndex;
}
else if (symbol.SymbolType == SymbolType.CloseSquareBracket)
{
if (openingBracketNode == null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
Bracket closingBracket = new Bracket(
symbol.Text, CsTokenType.CloseSquareBracket, symbol.Location, typeTokenReference, this.symbols.Generated);
Node<CsToken> closingBracketNode = typeTokens.InsertLast(closingBracket);
++startIndex;
((Bracket)openingBracketNode.Value).MatchingBracketNode = closingBracketNode;
closingBracket.MatchingBracketNode = openingBracketNode;
openingBracketNode = null;
// Check whether the next character is another opening bracket.
int temp = this.GetNextCodeSymbolIndex(startIndex);
if (temp != -1 && this.symbols.Peek(temp).SymbolType != SymbolType.OpenSquareBracket)
{
break;
}
}
else
{
if (openingBracketNode != null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
//.........这里部分代码省略.........
示例5: GetTypeTokenBaseName
/// <summary>
/// Gets the base name and generic symbols for a type token.
/// </summary>
/// <param name="typeTokenReference">A reference to the type token.</param>
/// <param name="typeTokens">The list of tokens in the type.</param>
/// <param name="startIndex">The start index within the symbol list.</param>
/// <param name="generic">Returns a value indicating whether the type is generic.</param>
/// <param name="unsafeCode">Indicates whether the type is within a block of unsafe code.</param>
private void GetTypeTokenBaseName(
Reference<ICodePart> typeTokenReference,
ref MasterList<CsToken> typeTokens,
ref int startIndex,
out GenericType generic,
bool unsafeCode)
{
Param.AssertNotNull(typeTokenReference, "typeTokenReference");
Param.AssertNotNull(typeTokens, "typeTokens");
Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
Param.Ignore(unsafeCode);
generic = null;
Symbol symbol = this.symbols.Peek(startIndex);
// First get the full name of the type.
int index = -1;
while (true)
{
// Add any whitespace.
while (symbol != null &&
(symbol.SymbolType == SymbolType.WhiteSpace ||
symbol.SymbolType == SymbolType.EndOfLine ||
symbol.SymbolType == SymbolType.SingleLineComment ||
symbol.SymbolType == SymbolType.MultiLineComment ||
symbol.SymbolType == SymbolType.PreprocessorDirective))
{
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
symbol = this.symbols.Peek(++startIndex);
}
// Add the next word. The type of the next word must either be an unknown
// word type, which will be the name of the next item in the type, or else
// it must be the 'this' keyword. This is used when implementing an explicit
// interface member which is an indexer.
if (symbol.SymbolType == SymbolType.Other || symbol.SymbolType == SymbolType.This)
{
typeTokens.Add(new CsToken(symbol.Text, CsTokenType.Other, symbol.Location, typeTokenReference, this.symbols.Generated));
}
else
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
++startIndex;
// Look at the type of the next non-whitespace character.
index = this.GetNextCodeSymbolIndex(startIndex);
if (index == -1)
{
break;
}
// If the next character is an opening generic bracket, get the generic.
symbol = this.symbols.Peek(index);
if (symbol.SymbolType == SymbolType.LessThan)
{
int end;
MasterList<CsToken> genericTypeTokens = this.GetGenericArgumentList(
typeTokenReference, unsafeCode, null, startIndex, out end);
if (genericTypeTokens != null)
{
// Add the tokens from this generic into our token list.
typeTokens.AddRange(genericTypeTokens);
// Create a new GenericTypeToken which represents this generic type.
CodeLocation genericTypeLocation = CsToken.JoinLocations(typeTokens.First, typeTokens.Last);
generic = new GenericType(typeTokens, genericTypeLocation, typeTokenReference, this.symbols.Generated);
Reference<ICodePart> genericReference = new Reference<ICodePart>(generic);
foreach (CsToken token in typeTokens)
{
token.ParentRef = genericReference;
}
// Reset the token list and add this generic token as the first item in the list.
typeTokens = new MasterList<CsToken>();
typeTokens.Add(generic);
// Advance the symbol index.
startIndex = end + 1;
// Look at the type of the next non-whitespace character.
index = this.GetNextCodeSymbolIndex(startIndex);
if (index == -1)
{
break;
}
}
}
//.........这里部分代码省略.........
示例6: GetTypeTokenDereferenceSymbols
/// <summary>
/// Gets the dereference symbols from a type token.
/// </summary>
/// <param name="typeTokenReference">A reference to the type token.</param>
/// <param name="typeTokens">The type tokens list.</param>
/// <param name="startIndex">The start index within the symbols list.</param>
/// <returns>Returns true if there were one or more dereference symbols.</returns>
private bool GetTypeTokenDereferenceSymbols(Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, ref int startIndex)
{
Param.AssertNotNull(typeTokenReference, "typeTokenReference");
Param.AssertNotNull(typeTokens, "typeTokens");
Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
bool foundDereferenceSymbol = false;
while (true)
{
// Look at the type of the next non-whitespace character.
int index = this.GetNextCodeSymbolIndex(startIndex);
if (index == -1)
{
break;
}
// If the next character is not a deference, break now.
Symbol symbol = this.symbols.Peek(index);
if (symbol.SymbolType != SymbolType.Multiplication)
{
break;
}
// Add any whitspace.
symbol = this.symbols.Peek(startIndex);
while (symbol != null &&
(symbol.SymbolType == SymbolType.WhiteSpace ||
symbol.SymbolType == SymbolType.EndOfLine ||
symbol.SymbolType == SymbolType.SingleLineComment ||
symbol.SymbolType == SymbolType.MultiLineComment ||
symbol.SymbolType == SymbolType.PreprocessorDirective))
{
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
symbol = this.symbols.Peek(++startIndex);
}
// Add the dereference symbol.
typeTokens.Add(new OperatorSymbol(
symbol.Text, OperatorCategory.Reference, OperatorType.Dereference, symbol.Location, typeTokenReference, this.symbols.Generated));
++startIndex;
// Nullable types are not allowed with dereferences.
foundDereferenceSymbol = true;
}
return foundDereferenceSymbol;
}
示例7: GetTypeTokenNullableTypeSymbol
/// <summary>
/// Gets a nullable type symbol for a type token, if one exists.
/// </summary>
/// <param name="typeTokenReference">A reference to the type token.</param>
/// <param name="typeTokens">The tokens within the type token.</param>
/// <param name="isExpression">Indicates whether this is in an is expression.</param>
/// <param name="startIndex">The start index within the symbols.</param>
private void GetTypeTokenNullableTypeSymbol(
Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, bool isExpression, ref int startIndex)
{
Param.AssertNotNull(typeTokenReference, "typeTokenReference");
Param.AssertNotNull(typeTokens, "typeTokens");
Param.Ignore(isExpression);
Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
// Look at the type of the next non-whitespace character and see if it is a nullable type symbol.
int index = this.GetNextCodeSymbolIndex(startIndex);
if (index == -1)
{
throw this.CreateSyntaxException();
}
Symbol symbol = this.symbols.Peek(index);
if (symbol.SymbolType == SymbolType.QuestionMark)
{
// If this type token resides within an 'is' expression, check to make sure
// that this is actually a nullable type symbol. In some cases, this can be a
// conditional question mark, not a nullable type symbol.
if (!isExpression || this.IsNullableTypeSymbolFromIsExpression(index))
{
// Add any whitspace.
symbol = this.symbols.Peek(startIndex);
while (symbol != null &&
(symbol.SymbolType == SymbolType.WhiteSpace ||
symbol.SymbolType == SymbolType.EndOfLine ||
symbol.SymbolType == SymbolType.SingleLineComment ||
symbol.SymbolType == SymbolType.MultiLineComment ||
symbol.SymbolType == SymbolType.PreprocessorDirective))
{
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
symbol = this.symbols.Peek(++startIndex);
}
// Add the nullable type symbol.
typeTokens.Add(new CsToken(
symbol.Text, CsTokenType.NullableTypeSymbol, symbol.Location, typeTokenReference, this.symbols.Generated));
++startIndex;
}
}
}
示例8: GetXmlHeader
private XmlHeader GetXmlHeader()
{
int count = 1;
Symbol symbol = this.symbols.Peek(count);
int num2 = -1;
int num3 = 0;
for (Symbol symbol2 = symbol; symbol2 != null; symbol2 = this.symbols.Peek(++count))
{
if (symbol2.SymbolType == SymbolType.XmlHeaderLine)
{
num2 = count;
num3 = 0;
}
else if (symbol2.SymbolType == SymbolType.EndOfLine)
{
if (++num3 > 1)
{
break;
}
}
else
{
if ((symbol2.SymbolType != SymbolType.WhiteSpace) && (symbol2.SymbolType != SymbolType.SingleLineComment))
{
break;
}
num3 = 0;
}
}
MasterList<CsToken> childTokens = new MasterList<CsToken>();
for (int i = 1; i <= num2; i++)
{
this.symbols.Advance();
childTokens.Add(this.ConvertSymbol(this.symbols.Current, TokenTypeFromSymbolType(this.symbols.Current.SymbolType)));
}
return new XmlHeader(childTokens, CodeLocation.Join(symbol.Location, this.symbols.Current.Location), this.symbols.Generated);
}
示例9: ParseTypeConstraintClauses
private ICollection<TypeParameterConstraintClause> ParseTypeConstraintClauses(bool unsafeCode)
{
List<TypeParameterConstraintClause> list = new List<TypeParameterConstraintClause>();
for (Symbol symbol = this.GetNextSymbol(); symbol.Text == "where"; symbol = this.GetNextSymbol())
{
Microsoft.StyleCop.Node<CsToken> firstItemNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other));
Microsoft.StyleCop.Node<CsToken> node2 = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other));
this.tokens.Add(this.GetToken(CsTokenType.WhereColon, SymbolType.Colon));
List<CsToken> list2 = new List<CsToken>();
Label_005A:
symbol = this.GetNextSymbol();
CsToken item = null;
if ((symbol.SymbolType == SymbolType.Class) || (symbol.SymbolType == SymbolType.Struct))
{
item = this.GetToken(CsTokenType.Other, symbol.SymbolType);
}
else if (symbol.SymbolType == SymbolType.New)
{
MasterList<CsToken> childTokens = new MasterList<CsToken>();
childTokens.Add(this.GetToken(CsTokenType.Other, SymbolType.New));
Bracket bracketToken = this.GetBracketToken(CsTokenType.OpenParenthesis, SymbolType.OpenParenthesis);
Bracket bracket2 = this.GetBracketToken(CsTokenType.CloseParenthesis, SymbolType.CloseParenthesis);
Microsoft.StyleCop.Node<CsToken> node3 = childTokens.InsertLast(bracketToken);
Microsoft.StyleCop.Node<CsToken> node4 = childTokens.InsertLast(bracket2);
bracketToken.MatchingBracketNode = node4;
bracket2.MatchingBracketNode = node3;
item = new ConstructorConstraint(childTokens, CodeLocation.Join<CsToken>(childTokens.First, childTokens.Last), childTokens.First.Value.Generated);
}
else
{
item = this.GetTypeToken(unsafeCode, true);
}
this.tokens.Add(item);
list2.Add(item);
if (this.GetNextSymbol().SymbolType == SymbolType.Comma)
{
this.tokens.Add(this.GetToken(CsTokenType.Comma, SymbolType.Comma));
goto Label_005A;
}
list.Add(new TypeParameterConstraintClause(new CsTokenList(this.tokens, firstItemNode, this.tokens.Last), node2.Value, list2.ToArray()));
}
return list.ToArray();
}
示例10: GetTypeTokenNullableTypeSymbol
private void GetTypeTokenNullableTypeSymbol(MasterList<CsToken> typeTokens, bool isExpression, ref int startIndex)
{
int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
if (nextCodeSymbolIndex == -1)
{
throw this.CreateSyntaxException();
}
if ((this.symbols.Peek(nextCodeSymbolIndex).SymbolType == SymbolType.QuestionMark) && (!isExpression || this.IsNullableTypeSymbolFromIsExpression(nextCodeSymbolIndex)))
{
Symbol symbol = this.symbols.Peek(startIndex);
while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
{
int num2;
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
startIndex = num2 = startIndex + 1;
symbol = this.symbols.Peek(num2);
}
typeTokens.Add(new CsToken(symbol.Text, CsTokenType.NullableTypeSymbol, symbol.Location, this.symbols.Generated));
startIndex++;
}
}
示例11: GetTypeTokenDereferenceSymbols
private bool GetTypeTokenDereferenceSymbols(MasterList<CsToken> typeTokens, ref int startIndex)
{
bool flag = false;
while (true)
{
int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
if ((nextCodeSymbolIndex == -1) || (this.symbols.Peek(nextCodeSymbolIndex).SymbolType != SymbolType.Multiplication))
{
return flag;
}
Symbol symbol = this.symbols.Peek(startIndex);
while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
{
int num2;
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
startIndex = num2 = startIndex + 1;
symbol = this.symbols.Peek(num2);
}
typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.Dereference, symbol.Location, this.symbols.Generated));
startIndex++;
flag = true;
}
}
示例12: GetTypeTokenBaseName
private void GetTypeTokenBaseName(ref MasterList<CsToken> typeTokens, ref int startIndex, out GenericType generic, bool unsafeCode)
{
generic = null;
Symbol symbol = this.symbols.Peek(startIndex);
int count = -1;
Label_0045:
while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
{
int num3;
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
startIndex = num3 = startIndex + 1;
symbol = this.symbols.Peek(num3);
}
if ((symbol.SymbolType != SymbolType.Other) && (symbol.SymbolType != SymbolType.This))
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
typeTokens.Add(new CsToken(symbol.Text, CsTokenType.Other, symbol.Location, this.symbols.Generated));
startIndex++;
count = this.GetNextCodeSymbolIndex(startIndex);
if (count != -1)
{
if (this.symbols.Peek(count).SymbolType == SymbolType.LessThan)
{
int num2;
MasterList<CsToken> items = this.GetGenericArgumentList(unsafeCode, null, startIndex, out num2);
if (items != null)
{
typeTokens.AddRange(items);
CodeLocation location = CodeLocation.Join<CsToken>(typeTokens.First, typeTokens.Last);
generic = new GenericType(typeTokens, location, this.symbols.Generated);
typeTokens = new MasterList<CsToken>();
typeTokens.Add(generic);
startIndex = num2 + 1;
count = this.GetNextCodeSymbolIndex(startIndex);
if (count == -1)
{
return;
}
}
}
symbol = this.symbols.Peek(count);
if ((symbol.SymbolType == SymbolType.Dot) || (symbol.SymbolType == SymbolType.QualifiedAlias))
{
int num5;
symbol = this.symbols.Peek(startIndex);
while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
{
int num4;
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
startIndex = num4 = startIndex + 1;
symbol = this.symbols.Peek(num4);
}
if (symbol.SymbolType == SymbolType.Dot)
{
typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.MemberAccess, symbol.Location, this.symbols.Generated));
}
else
{
typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.QualifiedAlias, symbol.Location, this.symbols.Generated));
}
startIndex = num5 = startIndex + 1;
symbol = this.symbols.Peek(num5);
goto Label_0045;
}
}
}
示例13: GetTypeTokenArrayBrackets
private void GetTypeTokenArrayBrackets(MasterList<CsToken> typeTokens, ref int startIndex)
{
Symbol symbol;
int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
if ((nextCodeSymbolIndex == -1) || (this.symbols.Peek(nextCodeSymbolIndex).SymbolType != SymbolType.OpenSquareBracket))
{
return;
}
for (int i = startIndex; i <= (nextCodeSymbolIndex - 1); i++)
{
Symbol symbol2 = this.symbols.Peek(startIndex);
typeTokens.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
startIndex++;
}
Microsoft.StyleCop.Node<CsToken> node = null;
Label_0067:
symbol = this.symbols.Peek(startIndex);
if (((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || (((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment)) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
{
typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
startIndex++;
goto Label_0067;
}
if (symbol.SymbolType == SymbolType.Number)
{
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Number));
startIndex++;
goto Label_0067;
}
if (symbol.SymbolType == SymbolType.Other)
{
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Other));
startIndex++;
goto Label_0067;
}
if (symbol.SymbolType == SymbolType.Comma)
{
typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Comma));
startIndex++;
goto Label_0067;
}
if (symbol.SymbolType == SymbolType.OpenSquareBracket)
{
if (node != null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
Bracket item = new Bracket(symbol.Text, CsTokenType.OpenSquareBracket, symbol.Location, this.symbols.Generated);
node = typeTokens.InsertLast(item);
startIndex++;
goto Label_0067;
}
if (symbol.SymbolType == SymbolType.CloseSquareBracket)
{
if (node == null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
Bracket bracket2 = new Bracket(symbol.Text, CsTokenType.CloseSquareBracket, symbol.Location, this.symbols.Generated);
Microsoft.StyleCop.Node<CsToken> node2 = typeTokens.InsertLast(bracket2);
startIndex++;
((Bracket) node.Value).MatchingBracketNode = node2;
bracket2.MatchingBracketNode = node;
node = null;
int count = this.GetNextCodeSymbolIndex(startIndex);
if ((count != -1) && (this.symbols.Peek(count).SymbolType != SymbolType.OpenSquareBracket))
{
return;
}
goto Label_0067;
}
if (node != null)
{
throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
}
}
示例14: GetGenericArgumentList
private MasterList<CsToken> GetGenericArgumentList(bool unsafeCode, CsToken name, int startIndex, out int endIndex)
{
endIndex = -1;
MasterList<CsToken> list = null;
int count = startIndex;
while (true)
{
Symbol symbol = this.symbols.Peek(count);
if ((symbol == null) || (((symbol.SymbolType != SymbolType.WhiteSpace) && (symbol.SymbolType != SymbolType.EndOfLine)) && (((symbol.SymbolType != SymbolType.SingleLineComment) && (symbol.SymbolType != SymbolType.MultiLineComment)) && (symbol.SymbolType != SymbolType.PreprocessorDirective))))
{
break;
}
count++;
}
Symbol symbol2 = this.symbols.Peek(count);
if ((symbol2 == null) || (symbol2.SymbolType != SymbolType.LessThan))
{
return list;
}
list = new MasterList<CsToken>();
if (name != null)
{
list.Add(name);
}
Microsoft.StyleCop.Node<CsToken> node = null;
for (int i = startIndex; i <= count; i++)
{
symbol2 = this.symbols.Peek(i);
if (symbol2.SymbolType == SymbolType.LessThan)
{
if (node != null)
{
return null;
}
Bracket item = new Bracket(symbol2.Text, CsTokenType.OpenGenericBracket, symbol2.Location, this.symbols.Generated);
node = list.InsertLast(item);
}
else
{
list.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
}
}
Label_00F4:
symbol2 = this.symbols.Peek(++count);
if (symbol2 == null)
{
throw new SyntaxException(this.document.SourceCode, name.LineNumber);
}
if (symbol2.SymbolType == SymbolType.GreaterThan)
{
if (node == null)
{
return null;
}
Bracket bracket2 = new Bracket(symbol2.Text, CsTokenType.CloseGenericBracket, symbol2.Location, this.symbols.Generated);
Microsoft.StyleCop.Node<CsToken> node2 = list.InsertLast(bracket2);
((Bracket) node.Value).MatchingBracketNode = node2;
bracket2.MatchingBracketNode = node;
endIndex = count;
return list;
}
if (symbol2.SymbolType == SymbolType.Other)
{
int num3 = 0;
CsToken token = this.GetTypeTokenAux(unsafeCode, true, false, count, out num3);
if (token == null)
{
throw new SyntaxException(this.document.SourceCode, symbol2.LineNumber);
}
count = num3;
list.Add(token);
goto Label_00F4;
}
if (((symbol2.SymbolType == SymbolType.WhiteSpace) || (symbol2.SymbolType == SymbolType.EndOfLine)) || (((symbol2.SymbolType == SymbolType.SingleLineComment) || (symbol2.SymbolType == SymbolType.MultiLineComment)) || (symbol2.SymbolType == SymbolType.PreprocessorDirective)))
{
list.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
goto Label_00F4;
}
if (symbol2.SymbolType == SymbolType.Comma)
{
list.Add(this.ConvertSymbol(symbol2, CsTokenType.Comma));
goto Label_00F4;
}
return null;
}