本文整理汇总了C#中JsAstNode类的典型用法代码示例。如果您正苦于以下问题:C# JsAstNode类的具体用法?C# JsAstNode怎么用?C# JsAstNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsAstNode类属于命名空间,在下文中一共展示了JsAstNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEquivalentTo
public override bool IsEquivalentTo(JsAstNode otherNode)
{
var otherRegExp = otherNode as JsRegExpLiteral;
return otherRegExp != null
&& string.CompareOrdinal(Pattern, otherRegExp.Pattern) == 0
&& string.CompareOrdinal(PatternSwitches, otherRegExp.PatternSwitches) == 0;
}
示例2: IsSafe
public bool IsSafe(JsAstNode node)
{
// assume it is unless preven otherwise
m_isSafe = true;
node.IfNotNull(n => n.Accept(this));
return m_isSafe;
}
示例3: Apply
public static void Apply(JsAstNode node)
{
if (node != null)
{
node.Accept(s_instance);
}
}
示例4: Append
public void Append(JsAstNode statement)
{
if (statement != null)
{
Context.UpdateWith(statement.Context);
Statements.Append(statement);
}
}
示例5: ReplaceChild
public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
{
if (Operand == oldNode)
{
Operand = newNode;
return true;
}
return false;
}
示例6: ReplaceChild
public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
{
if (Value == oldNode)
{
Value = newNode;
return true;
}
return false;
}
示例7: ReplaceChild
public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
{
if (Condition == oldNode)
{
Condition = newNode;
return true;
}
return false;
}
示例8: IsEquivalentTo
public override bool IsEquivalentTo(JsAstNode otherNode)
{
var otherThis = otherNode as JsThisLiteral;
// this really assume we are comparing this operators from the same object scope.
// if you compare a this-literal from one function to a this-literal from another,
// it will pop positive -- but it won't actually be equivalent!
return otherThis != null;
}
示例9: Apply
public static bool Apply(TextWriter writer, JsAstNode node)
{
if (node != null)
{
var visitor = new JsonOutputVisitor(writer);
node.Accept(visitor);
return visitor.IsValid;
}
return false;
}
示例10: Apply
public static void Apply(TextWriter writer, JsAstNode node, JsSettings settings)
{
if (node != null)
{
var outputVisitor = new JsOutputVisitor(writer, settings);
node.Accept(outputVisitor);
// if there is a symbol map that we are tracking, tell it that we have ended an output run
// and pass it offsets to the last line and column positions.
settings.IfNotNull(s => s.SymbolsMap.IfNotNull(m => m.EndOutputRun(outputVisitor.m_lineCount, outputVisitor.m_lineLength)));
}
}
示例11: Match
public bool Match(JsAstNode node, string identifiers)
{
// set the match to false
m_isMatch = false;
// identifiers cannot be null or blank and must match: IDENT(.IDENT)*
// since for JS there has to be at least a global object, the dot must be AFTER the first character.
if (node != null && !string.IsNullOrEmpty(identifiers))
{
// get all the parts
var parts = identifiers.Split('.');
// each part must be a valid JavaScript identifier. Assume everything is valid
// unless at least one is invalid -- then forget it
var isValid = true;
foreach (var part in parts)
{
if (!JsScanner.IsValidIdentifier(part))
{
isValid = false;
break;
}
}
// must be valid to continue
if (isValid)
{
// save the parts and start the index on the last one, since we'll be walking backwards
m_parts = parts;
m_index = parts.Length - 1;
node.Accept(this);
}
}
return m_isMatch;
}
示例12: ReplaceChild
/// <summary>
/// Replace the existing direct child node of the block with a new node.
/// </summary>
/// <param name="oldNode">existing statement node to replace.</param>
/// <param name="newNode">node with which to replace the existing node.</param>
/// <returns>true if the replacement was a succeess; false otherwise</returns>
public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
{
for (int ndx = m_list.Count - 1; ndx >= 0; --ndx)
{
if (m_list[ndx] == oldNode)
{
m_list[ndx].IfNotNull(n => n.Parent = (n.Parent == this) ? null : n.Parent);
if (newNode == null)
{
// just remove it
m_list.RemoveAt(ndx);
}
else
{
JsBlock newBlock = newNode as JsBlock;
if (newBlock != null)
{
// the new "statement" is a block. That means we need to insert all
// the statements from the new block at the location of the old item.
m_list.RemoveAt(ndx);
InsertRange(ndx, newBlock.m_list);
}
else
{
// not a block -- slap it in there
m_list[ndx] = newNode;
newNode.Parent = this;
}
}
return true;
}
}
return false;
}
示例13: ReplaceChild
public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
{
if (TryBlock == oldNode)
{
TryBlock = ForceToBlock(newNode);
return true;
}
if (CatchParameter == oldNode)
{
CatchParameter = newNode as JsParameterDeclaration;
return true;
}
if (CatchBlock == oldNode)
{
CatchBlock = ForceToBlock(newNode);
return true;
}
if (FinallyBlock == oldNode)
{
FinallyBlock = ForceToBlock(newNode);
return true;
}
return false;
}
示例14: Insert
/// <summary>
/// Insert a new node into the given position index within the block
/// </summary>
/// <param name="position">zero-based index into which the new node will be inserted</param>
/// <param name="item">new node to insert into the block</param>
public void Insert(int position, JsAstNode item)
{
if (item != null)
{
var block = item as JsBlock;
if (block != null)
{
InsertRange(position, block.Children);
}
else
{
item.Parent = this;
m_list.Insert(position, item);
}
}
}
示例15: InsertAfter
/// <summary>
/// Insert the given statement node after an existing node in the block.
/// </summary>
/// <param name="after">exisitng child node of the block</param>
/// <param name="item">node to insert after the existing node</param>
public void InsertAfter(JsAstNode after, JsAstNode item)
{
if (item != null)
{
int index = m_list.IndexOf(after);
if (index >= 0)
{
var block = item as JsBlock;
if (block != null)
{
// don't insert a block into a block -- insert the new block's
// children instead (don't want nested blocks)
InsertRange(index + 1, block.Children);
}
else
{
item.Parent = this;
m_list.Insert(index + 1, item);
}
}
}
}