示例#1
0
        public NodeDescriptor(HtmlNode node, NodeKind kind)
        {
            if (node == null)
                throw new ArgumentNullException(nameof(node));

            Node = node;
            Kind = kind;
        }
示例#2
0
 /// <summary>
 ///  create a new node
 /// </summary>
 public TreeNode(NodeKind kind, int LineNum,TokenType Type,  int currentLevelNum, string Scope)
     : this()
 {
     this.NodeKind = kind;
     this.LineNum = LineNum;
     this.Type = Type;
     this.LevelNum = currentLevelNum;
     this.Scope = Scope;
 }
示例#3
0
 /// <summary>
 /// 产生普通节点
 /// </summary>
 /// <param name="kind"></param>
 /// <param name="type"></param>
 /// <param name="tID"></param>
 /// <param name="Linenum"></param>
 /// <param name="scope"></param>
 public TreeNode(NodeKind kind, TokenType type, string name, int Linenum, string scope)
     : this()
 {
     this.NodeKind = kind;
     this.Type = type;
     this.Name = name;
     this.LineNum = Linenum;
     this.Scope = scope;
 }
示例#4
0
        public Node(NodeKind kind, Cursor cursor)
        {
            /** \note The node ids are 1-based to make it easier to detect errors. */
            _id = _nodes.Count + 1;
            _nodes[_id] = this;

            _kind = kind;
            // Make a deep copy of the position so as to protect it from unwanted side-effects.
            _cursor = new Cursor(cursor);
        }
示例#5
0
        public Routine(
            NodeKind kind,
            Cursor cursor,
            SymbolDefinition name,
            Profile profile,
            Block block
        )
            : base(kind, cursor, name)
        {
            _profile = profile;
            _profile.Above = this;

            _block = block;
            _block.Above = this;
        }
        public string Get(
            string sourceText,
            NodeKind nodeKind = NodeKind.CompilationUnit,
            bool openCurlyOnNewLine = false,
            bool closeCurlyOnNewLine = false,
            bool preserveOriginalWhitespace = false,
            bool keepRedundantApiCalls = false,
            bool avoidUsingStatic = false)
        {
            string responseText = "Quoter is currently down for maintenance. Please check back later.";
            if (string.IsNullOrEmpty(sourceText))
            {
                responseText = "Please specify the source text.";
            }
            else if (sourceText.Length > 2000)
            {
                responseText = "Only strings shorter than 2000 characters are supported; your input string is " + sourceText.Length + " characters long.";
            }
            else
            {
                try
                {
                    var quoter = new Quoter
                    {
                        OpenParenthesisOnNewLine = openCurlyOnNewLine,
                        ClosingParenthesisOnNewLine = closeCurlyOnNewLine,
                        UseDefaultFormatting = !preserveOriginalWhitespace,
                        RemoveRedundantModifyingCalls = !keepRedundantApiCalls,
                        ShortenCodeWithUsingStatic = !avoidUsingStatic
                    };

                    responseText = quoter.Quote(sourceText, nodeKind);
                }
                catch (Exception ex)
                {
                    responseText = ex.ToString();
                }
            }

            Response.Headers.Add("Cache-Control", new[] { "no-cache" });
            Response.Headers.Add("Pragma", new[] { "no-cache" });
            Response.Headers.Add("Expires", new[] { "-1" });
            Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            Response.Headers.Add("Access-Control-Allow-Headers", new[] { "Content-Type" });

            return responseText;
        }
        public HttpResponseMessage Get(
            string sourceText,
            NodeKind nodeKind = NodeKind.CompilationUnit,
            bool openCurlyOnNewLine = false,
            bool closeCurlyOnNewLine = false,
            bool preserveOriginalWhitespace = false,
            bool keepRedundantApiCalls = false,
            bool avoidUsingStatic = false)
        {
            string responseText = "Quoter is currently down for maintenance. Please check back later.";
            if (string.IsNullOrEmpty(sourceText))
            {
                responseText = "Please specify the source text.";
            }
            else if (sourceText.Length > 2000)
            {
                responseText = "Only strings shorter than 2000 characters are supported; your input string is " + sourceText.Length + " characters long.";
            }
            else
            {
                try
                {
                    var quoter = new Quoter
                    {
                        OpenParenthesisOnNewLine = openCurlyOnNewLine,
                        ClosingParenthesisOnNewLine = closeCurlyOnNewLine,
                        UseDefaultFormatting = !preserveOriginalWhitespace,
                        RemoveRedundantModifyingCalls = !keepRedundantApiCalls,
                        ShortenCodeWithUsingStatic = !avoidUsingStatic
                    };

                    responseText = quoter.Quote(sourceText, nodeKind);
                }
                catch (Exception ex)
                {
                    responseText = ex.ToString();
                }
            }

            responseText = HttpUtility.HtmlEncode(responseText);

            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(responseText, Encoding.UTF8, "text/html");
            return response;
        }
示例#8
0
 private static bool VerifyCanGetAttributes(NodeKind kind)
 {
     return(kind == NodeKind.Column ||
            kind == NodeKind.LocalColumn ||
            kind == NodeKind.PrimaryKey);
 }
示例#9
0
 public Node(NodeKind kind)
 {
     this.kind = kind;
 }
        private void AddNodeFromGUI(NodeKind kind, float x, float y)
        {
            string nodeName = AssetBundleGraphSettings.DEFAULT_NODE_NAME[kind] + nodes.Where(node => node.Kind == kind).ToList().Count;
            NodeGUI newNode = new NodeGUI(new NodeData(nodeName, kind, x, y));

            Undo.RecordObject(this, "Add " + AssetBundleGraphSettings.DEFAULT_NODE_NAME[kind] + " Node");

            AddNodeGUI(newNode);
        }
示例#11
0
 public CssDeclaration(string name, CssValue value, NodeKind kind)
     : base(kind)
 {
     Info = CssProperty.Get(name);
     Value = value;
 }
示例#12
0
 public Identity(SyntaxReference reference, Compilation compilation, NodeKind kind, Frame frame = null, string manualIdentifier = null) : this(reference.GetSymbol(compilation), kind, frame, manualIdentifier)
 {
 }
示例#13
0
        /*
         *  Create NodeData from JSON
         */
        public NodeData(Dictionary<string, object> jsonData)
        {
            m_name = jsonData[NODE_NAME] as string;
            m_id = jsonData[NODE_ID]as string;
            m_kind = AssetBundleGraphSettings.NodeKindFromString(jsonData[NODE_KIND] as string);

            var pos = jsonData[NODE_POS] as Dictionary<string, object>;
            m_x = (float)Convert.ToDouble(pos[NODE_POS_X]);
            m_y = (float)Convert.ToDouble(pos[NODE_POS_Y]);

            var inputs  = jsonData[NODE_INPUTPOINTS] as List<object>;
            var outputs = jsonData[NODE_OUTPUTPOINTS] as List<object>;
            m_inputPoints  = new List<ConnectionPointData>();
            m_outputPoints = new List<ConnectionPointData>();

            foreach(var obj in inputs) {
                var pDic = obj as Dictionary<string, object>;
                m_inputPoints.Add(new ConnectionPointData(pDic, this, true));
            }

            foreach(var obj in outputs) {
                var pDic = obj as Dictionary<string, object>;
                m_outputPoints.Add(new ConnectionPointData(pDic, this, false));
            }

            switch (m_kind) {
            case NodeKind.IMPORTSETTING_GUI:
                // nothing to do
                break;
            case NodeKind.PREFABBUILDER_GUI:
            case NodeKind.MODIFIER_GUI:
                {
                    if(jsonData.ContainsKey(NODE_SCRIPT_CLASSNAME)) {
                        m_scriptClassName = jsonData[NODE_SCRIPT_CLASSNAME] as string;
                    }
                    if(jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA)) {
                        m_scriptInstanceData = new SerializableMultiTargetString(jsonData[NODE_SCRIPT_INSTANCE_DATA] as Dictionary<string, object>);
                    }
                }
                break;
            case NodeKind.LOADER_GUI:
                {
                    m_loaderLoadPath = new SerializableMultiTargetString(jsonData[NODE_LOADER_LOAD_PATH] as Dictionary<string, object>);
                }
                break;
            case NodeKind.FILTER_GUI:
                {
                    var filters = jsonData[NODE_FILTER] as List<object>;

                    m_filter = new List<FilterEntry>();

                    for(int i=0; i<filters.Count; ++i) {
                        var f = filters[i] as Dictionary<string, object>;

                        var keyword = f[NODE_FILTER_KEYWORD] as string;
                        var keytype = f[NODE_FILTER_KEYTYPE] as string;
                        var pointId = f[NODE_FILTER_POINTID] as string;

                        var point = m_outputPoints.Find(p => p.Id == pointId);
                        UnityEngine.Assertions.Assert.IsNotNull(point, "Output point not found for " + keyword);
                        m_filter.Add(new FilterEntry(keyword, keytype, point));
                    }
                }
                break;
            case NodeKind.GROUPING_GUI:
                {
                    m_groupingKeyword = new SerializableMultiTargetString(jsonData[NODE_GROUPING_KEYWORD] as Dictionary<string, object>);
                }
                break;
            case NodeKind.BUNDLECONFIG_GUI:
                {
                    m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(jsonData[NODE_BUNDLECONFIG_BUNDLENAME_TEMPLATE] as Dictionary<string, object>);
                    m_variants = new List<Variant>();
                    if(jsonData.ContainsKey(NODE_BUNDLECONFIG_VARIANTS)){
                        var variants = jsonData[NODE_BUNDLECONFIG_VARIANTS] as List<object>;

                        for(int i=0; i<variants.Count; ++i) {
                            var v = variants[i] as Dictionary<string, object>;

                            var name    = v[NODE_BUNDLECONFIG_VARIANTS_NAME] as string;
                            var pointId = v[NODE_BUNDLECONFIG_VARIANTS_POINTID] as string;

                            var point = m_inputPoints.Find(p => p.Id == pointId);
                            UnityEngine.Assertions.Assert.IsNotNull(point, "Input point not found for " + name);
                            m_variants.Add(new Variant(name, point));
                        }
                    }
                }
                break;
            case NodeKind.BUNDLEBUILDER_GUI:
                {
                    m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt(jsonData[NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS] as Dictionary<string, object>);
                }
                break;
            case NodeKind.EXPORTER_GUI:
                {
                    m_exporterExportPath = new SerializableMultiTargetString(jsonData[NODE_EXPORTER_EXPORT_PATH] as Dictionary<string, object>);
                }
                break;
            default:
                throw new ArgumentOutOfRangeException ();
            }
        }
示例#14
0
 public AssignmentNode(NodeKind kind, SyntaxTreeNode syntaxTreeNode, string contentPart) : base(kind, syntaxTreeNode, contentPart)
 {
 }
 private IEnumerable<int> LeftBoundaryNodesOfANode(int i, NodeKind nodeKind) {
     return FillLeftTopAndBottomVerts(NodeLayer(i), layerArrays.X[i], nodeKind);
 }
示例#16
0
 public static bool Has(this NodeKind @this, NodeKind nodeKind)
 {
     return (@this & nodeKind) == nodeKind;
 }
示例#17
0
 public void KindIsCorrect(string text, NodeKind kind)
 {
     Assert.Equal(kind, CssUnitInfo.Get(text).Kind);
 }
示例#18
0
 public Marker(NodeKind nodeKind, ISymbol symbol, string name, bool navigationSuggested)
     : this(nodeKind, symbol.ContainingType.GetFullyQualifiedMetadataName(), name, navigationSuggested, false)
 {
 }
示例#19
0
 public Node(NodeKind kind, T nodeInfo = default(T))
 {
     NodeKind = kind;
     NodeInfo = nodeInfo;
 }
示例#20
0
        private static string ConvertValue(object value, out NodeKind kind)
        {
            if (value == null)
            {
                kind = NodeKind.Null;
                return("");
            }

            string val;

#if DATETIME_AS_TIMESTAMPS
            // convert dates to unix timestamps
            if (value.GetType() == typeof(DateTime))
            {
                val  = ToTimestamp(((DateTime)value)).ToString();
                kind = NodeKind.Numeric;
            }
            else
#endif
            if (value is int)
            {
                val  = ((int)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is uint)
            {
                val  = ((uint)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is long)
            {
                val  = ((long)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is ulong)
            {
                val  = ((ulong)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is byte)
            {
                val  = ((byte)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is sbyte)
            {
                val  = ((sbyte)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is short)
            {
                val  = ((short)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is ushort)
            {
                val  = ((ushort)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is float)
            {
                val  = ((float)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is double)
            {
                val  = ((double)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is decimal)
            {
                val  = ((decimal)value).ToString(CultureInfo.InvariantCulture);
                kind = NodeKind.Numeric;
            }
            else
            if (value is bool)
            {
                val  = ((bool)value) ? "true" : "false";
                kind = NodeKind.Boolean;
            }
            else
            {
                val  = value.ToString();
                kind = NodeKind.String;
            }

            return(val);
        }
 public Node(AstNode astNode, NodeKind kind)
 {
     AstNode             = astNode;
     Kind                = kind;
     ContainingStatement = astNode.GetParent <Statement>();
 }
示例#22
0
 public Node(string n, NodeKind k, AttributeList a)
 {
     Name = n;
     Kind = k;
     Attributes = a;
 }
        IEnumerable<int> FillRightTopAndBottomVerts(int[] layer, int vPosition, NodeKind nodeKind) {
            double t = 0, b = 0;
            if (nodeKind == NodeKind.Bottom) {
                b = Single.MaxValue;//we don't have bottom boundaries here since they will be cut off
            } else if (nodeKind == NodeKind.Top) {
                t = Single.MaxValue;//we don't have top boundaries here since they will be cut off
            }

            int v = layer[vPosition];

            for (int i = vPosition + 1; i < layer.Length; i++) {
                int u = layer[i];
                Anchor anchor = this.anchors[u];
                if (anchor.TopAnchor > t) {
                    if (!NodeUCanBeCrossedByNodeV(u, v)) {
                        t = anchor.TopAnchor;
                        if (anchor.BottomAnchor > b)
                            b = anchor.BottomAnchor;
                        yield return u;
                    }
                } else if (anchor.BottomAnchor > b) {
                    if (!NodeUCanBeCrossedByNodeV(u, v)) {
                        b = anchor.BottomAnchor;
                        if (anchor.TopAnchor > t)
                            t = anchor.TopAnchor;
                        yield return u;
                    }
                }
            }

        }
示例#24
0
        private void ParseOutput()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(_outputBuffer.ToString());
            XmlNode entryNode = xmlDoc.SelectSingleNode("/info/entry");
            if (entryNode == null) return;
            string foundValue;

            foundValue = getAttributeValue(entryNode, "revision");
            if (!String.IsNullOrEmpty(foundValue))
            {
                Revision = Int32.Parse(foundValue);
            }

            foundValue = getAttributeValue(entryNode, "kind");
            if (!String.IsNullOrEmpty(foundValue))
            {
                if (foundValue == Subversion.NodeKind.dir.ToString())
                {
                    m_eNodeKind = Subversion.NodeKind.dir;
                }
                else if (foundValue == Subversion.NodeKind.file.ToString())
                {
                    m_eNodeKind = Subversion.NodeKind.file;
                }
                else
                {
                    Log.LogError("Unknown node kind: " + foundValue);
                }
            }
            string nodeText;

            nodeText = getNodeText(entryNode, "url");
            if (!String.IsNullOrEmpty(nodeText))
            {
                RepositoryPath = nodeText;
            }

            nodeText = getNodeText(entryNode, "repository/root");
            if (!String.IsNullOrEmpty(nodeText))
            {
                m_strRepositoryRoot = nodeText;
            }

            nodeText = getNodeText(entryNode, "repository/uuid");
            if (!String.IsNullOrEmpty(nodeText))
            {
                m_Guid = new Guid(nodeText);
            }

            XmlNode childNode;
            childNode = entryNode.SelectSingleNode("commit");
            if (childNode != null)
            {
                foundValue = getAttributeValue(childNode, "revision");
                if (!String.IsNullOrEmpty(foundValue))
                {
                    m_nLastChangedRev = Int32.Parse(foundValue);
                }

                nodeText = getNodeText(childNode, "author");
                if (!String.IsNullOrEmpty(nodeText))
                {
                    m_strLastChangedAuthor = nodeText;
                }

                nodeText = getNodeText(childNode, "date");
                if (!String.IsNullOrEmpty(nodeText))
                {
                    m_LastChangedDate = DateTime.Parse(nodeText);
                }
            }

            nodeText = getNodeText(entryNode, "wc-info/schedule");
            if (!String.IsNullOrEmpty(nodeText))
            {
                if (nodeText == Subversion.Schedule.normal.ToString())
                {
                    m_eSchedule = Subversion.Schedule.normal;
                }
                else
                {
                    Log.LogError("Unknown schedule: " + nodeText);
                }
            }
        }
示例#25
0
 public StatementFactory Kind(NodeKind kind)
 {
     this.kind = kind;
     return(this);
 }
示例#26
0
 /// <summary>
 /// Reset all instance variables to their default (unset) state.
 /// </summary>
 private void ResetMemberVariables()
 {
     RepositoryPath = string.Empty;
     m_strRepositoryRoot = string.Empty;
     m_Guid = Guid.Empty;
     m_eNodeKind = Subversion.NodeKind.unknown;
     m_strLastChangedAuthor = string.Empty;
     m_nLastChangedRev = 0;
     m_LastChangedDate = DateTime.Now;
     m_eSchedule = Subversion.Schedule.unknown;
 }
示例#27
0
 public Reference(NodeKind kind, Cursor cursor, string symbol)
     : base(kind, cursor)
 {
     _symbol = symbol;
 }
        private SyntaxKind GetBinaryExpressionKind(NodeKind nodeKind)
        {
            switch (nodeKind)
            {
            case NodeKind.PlusToken:
                return(SyntaxKind.AddExpression);

            case NodeKind.MinusToken:
                return(SyntaxKind.SubtractExpression);

            case NodeKind.AsteriskToken:
                return(SyntaxKind.MultiplyExpression);

            case NodeKind.SlashToken:
                return(SyntaxKind.DivideExpression);

            case NodeKind.PercentToken:
                return(SyntaxKind.ModuloExpression);

            case NodeKind.LessThanLessThanToken:
                return(SyntaxKind.LeftShiftExpression);

            case NodeKind.GreaterThanGreaterThanToken:
            case NodeKind.GreaterThanGreaterThanGreaterThanToken:
                return(SyntaxKind.RightShiftExpression);

            case NodeKind.BarBarToken:
                return(SyntaxKind.LogicalOrExpression);

            case NodeKind.AmpersandAmpersandToken:
                return(SyntaxKind.LogicalAndExpression);

            case NodeKind.BarToken:
                return(SyntaxKind.BitwiseOrExpression);

            case NodeKind.AmpersandToken:
                return(SyntaxKind.BitwiseAndExpression);

            case NodeKind.CaretToken:
                return(SyntaxKind.ExclusiveOrExpression);

            case NodeKind.EqualsEqualsToken:
            case NodeKind.EqualsEqualsEqualsToken:
                return(SyntaxKind.EqualsExpression);

            case NodeKind.ExclamationEqualsToken:
            case NodeKind.ExclamationEqualsEqualsToken:
                return(SyntaxKind.NotEqualsExpression);

            case NodeKind.LessThanToken:
                return(SyntaxKind.LessThanExpression);

            case NodeKind.LessThanEqualsToken:
                return(SyntaxKind.LessThanOrEqualExpression);

            case NodeKind.GreaterThanToken:
                return(SyntaxKind.GreaterThanExpression);

            case NodeKind.GreaterThanEqualsToken:
                return(SyntaxKind.GreaterThanOrEqualExpression);

            case NodeKind.InstanceOfKeyword:
            case NodeKind.IsKeyword:
                return(SyntaxKind.IsExpression);

            case NodeKind.AsKeyword:
                return(SyntaxKind.AsExpression);

            //case NodeKind.QuestionQuestionToken:
            //    return SyntaxKind.CoalesceExpression;

            default:
                return(SyntaxKind.None);
            }

            //InKeyword in
            //LessThanSlashToken </
            //EqualsGreaterThanToken =>
            //AsteriskAsteriskToken **
            //PlusPlusToken ++
            //MinusMinusToken --
            //GreaterThanGreaterThanGreaterThanToken >>>
            //ExclamationToken ^
            //TildeToken ~
            //QuestionToken ?
            //ColonToken :
            //AtToken @
        }
示例#29
0
 /// <summary>
 /// Given the input C# code <paramref name="sourceText"/> returns the C# source code of
 /// Roslyn API calls that recreate the syntax tree for the input code.
 /// </summary>
 /// <param name="sourceText">A C# souce text</param>
 /// <param name="nodeKind">What kind of C# syntax node should the input be parsed as</param>
 /// <returns>A C# expression that describes calls to the Roslyn syntax API necessary to recreate
 /// the syntax tree for the source text.</returns>
 public string Quote(string sourceText, NodeKind nodeKind)
 {
     return Quote(Parse(sourceText, nodeKind));
 }
示例#30
0
 private BoundBinaryOperator(NodeKind nodeKind, BoundBinaryOperatorKind kind, Type operandType, Type resultType)
     : this(nodeKind, kind, operandType, operandType, resultType)
 {
 }
			public Node (AstNode astNode, NodeKind kind)
			{
				AstNode = astNode;
				Kind = kind;
				ContainingStatement = astNode.GetParent<Statement> ();
			}
示例#32
0
 private BoundBinaryOperator(NodeKind nodeKind, BoundBinaryOperatorKind kind, Type type)
     : this(nodeKind, kind, type, type, type)
 {
 }
示例#33
0
文件: CssUnit.cs 项目: carbon/Css
 public CssUnit(string name, NodeKind kind)
 {
     Name = name;
     Kind = kind;
 }
示例#34
0
 public TypeNode(NodeKind kind) : base(kind)
 {
 }
示例#35
0
 internal CssUnitInfo(string name, NodeKind kind, CssUnitFlags flags = CssUnitFlags.None)
 {
     Name  = name;
     Kind  = kind;
     Flags = flags;
 }
示例#36
0
文件: CssRule.cs 项目: carbon/Css
 public CssRule(RuleType type, NodeKind kind)
     : base(kind)
 {
     Type = type;
 }
示例#37
0
 public Op(TokenKind tokenKind, NodeKind nodeKind)
 {
     this.tokenKind = tokenKind;
     this.nodeKind  = nodeKind;
 }
示例#38
0
 public static INavigatableMarker CreateNavigatableMarker(NodeKind nodeKind, ISymbol containingType, string symbolName, bool navigationSuggested = true)
 {
     return(SymbolNodeBase.CreateMarker(nodeKind, containingType, symbolName, navigationSuggested));
 }
示例#39
0
 public ErrorNodeSuggestionHandlerBase(NodeKind kind)
     : base(kind)
 {
 }
示例#40
0
 /// <summary>
 /// Constructs an <see cref="NpgsqlTsQuery"/>.
 /// </summary>
 /// <param name="kind"></param>
 protected NpgsqlTsQuery(NodeKind kind) => Kind = kind;
        IEnumerable<int> FillLeftTopAndBottomVerts(int[] layer, int vPosition, NodeKind nodeKind) {
            double t = 0, b = 0;
            if (nodeKind == NodeKind.Top)
                t = Single.MaxValue; //there are no top vertices - they are cut down by the top boundaryCurve curve       
            else if (nodeKind == NodeKind.Bottom)
                b = Single.MaxValue; //there are no bottom vertices - they are cut down by the top boundaryCurve curve

            int v = layer[vPosition];

            for (int i = vPosition - 1; i >= 0; i--) {
                int u = layer[i];
                Anchor anchor = this.anchors[u];
                if (anchor.TopAnchor > t + ApproximateComparer.DistanceEpsilon) {
                    if (!NodeUCanBeCrossedByNodeV(u, v)) {
                        t = anchor.TopAnchor;
                        b = Math.Max(b, anchor.BottomAnchor);
                        yield return u;
                    }
                } else if (anchor.BottomAnchor > b + ApproximateComparer.DistanceEpsilon) {
                    if (!NodeUCanBeCrossedByNodeV(u, v)) {
                        t = Math.Max(t, anchor.TopAnchor);
                        b = anchor.BottomAnchor;
                        yield return u;
                    }
                }
            }
        }
示例#42
0
 private IEnumerable <int> LeftBoundaryNodesOfANode(int i, NodeKind nodeKind)
 {
     return(FillLeftTopAndBottomVerts(NodeLayer(i), layerArrays.X[i], nodeKind));
 }
示例#43
0
 public ExpressionParseResultBuilderFactory StatementKind(NodeKind kind)
 {
     this.statementKind = kind;
     return(this);
 }
示例#44
0
 /// <summary>
 /// Given the input C# code <paramref name="sourceText"/> returns the C# source code of
 /// Roslyn API calls that recreate the syntax tree for the input code.
 /// </summary>
 /// <param name="sourceText">A C# souce text</param>
 /// <param name="nodeKind">What kind of C# syntax node should the input be parsed as</param>
 /// <returns>A C# expression that describes calls to the Roslyn syntax API necessary to recreate
 /// the syntax tree for the source text.</returns>
 public string Quote(string sourceText, NodeKind nodeKind)
 {
     return(Quote(Parse(sourceText, nodeKind)));
 }
示例#45
0
        public IActionResult Get(
            string sourceText,
            NodeKind nodeKind               = NodeKind.CompilationUnit,
            bool openCurlyOnNewLine         = false,
            bool closeCurlyOnNewLine        = false,
            bool preserveOriginalWhitespace = false,
            bool keepRedundantApiCalls      = false,
            bool avoidUsingStatic           = false,
            bool generateLINQPad            = false)
        {
            string prefix = null;

            string responseText = "Quoter is currently down for maintenance. Please check back later.";

            if (string.IsNullOrEmpty(sourceText))
            {
                responseText = "Please specify the source text.";
            }
            else if (sourceText.Length > 2000)
            {
                responseText = "Only strings shorter than 2000 characters are supported; your input string is " + sourceText.Length + " characters long.";
            }
            else
            {
                try
                {
                    var quoter = new Quoter
                    {
                        OpenParenthesisOnNewLine      = openCurlyOnNewLine,
                        ClosingParenthesisOnNewLine   = closeCurlyOnNewLine,
                        UseDefaultFormatting          = !preserveOriginalWhitespace,
                        RemoveRedundantModifyingCalls = !keepRedundantApiCalls,
                        ShortenCodeWithUsingStatic    = !avoidUsingStatic
                    };

                    responseText = quoter.QuoteText(sourceText, nodeKind);
                }
                catch (Exception ex)
                {
                    responseText = ex.ToString();

                    prefix = "Congratulations! You've found a bug in Quoter! Please open an issue at <a href=\"https://github.com/KirillOsenkov/RoslynQuoter/issues/new\" target=\"_blank\">https://github.com/KirillOsenkov/RoslynQuoter/issues/new</a> and paste the code you've typed above and this stack:";
                }
            }

            if (generateLINQPad)
            {
                var linqpadFile = $@"<Query Kind=""Expression"">
  <NuGetReference>Microsoft.CodeAnalysis.Compilers</NuGetReference>
  <NuGetReference>Microsoft.CodeAnalysis.CSharp</NuGetReference>
  <Namespace>static Microsoft.CodeAnalysis.CSharp.SyntaxFactory</Namespace>
  <Namespace>Microsoft.CodeAnalysis.CSharp.Syntax</Namespace>
  <Namespace>Microsoft.CodeAnalysis.CSharp</Namespace>
  <Namespace>Microsoft.CodeAnalysis</Namespace>
</Query>

{responseText}
";

                var responseBytes = Encoding.UTF8.GetBytes(linqpadFile);

                return(File(responseBytes, "application/octet-stream", "Quoter.linq"));
            }

            responseText = HttpUtility.HtmlEncode(responseText);

            if (prefix != null)
            {
                responseText = "<div class=\"error\"><p>" + prefix + "</p><p>" + responseText + "</p><p><br/>P.S. Sorry!</p></div>";
            }

            return(Ok(responseText));
        }
示例#46
0
 public Node(NodeKind kind, long index)
     : this(kind, PayloadKind.Index)
 {
     indexPayload = index;
 }
示例#47
0
 public Node FindAbove(NodeKind kind)
 {
     Node first = this;
     while (first != null)
     {
         if (first.Kind == kind)
             return first;
         first = first.Above;
     }
     throw new System.Exception("Search for " + kind.ToString() + " node failed");
 }
示例#48
0
 public Definition(NodeKind kind, Cursor cursor, SymbolDefinition name)
     : base(kind, cursor)
 {
     _name = name;
     _name.Above = this;
 }
示例#49
0
文件: CssValue.cs 项目: carbon/Css
 public CssValue(NodeKind kind)
     : base(kind)
 {
 }
        /*
         *  Create NodeData from JSON
         */
        public NodeData(Dictionary <string, object> jsonData)
        {
            m_name = jsonData[NODE_NAME] as string;
            m_id   = jsonData[NODE_ID] as string;
            m_kind = AssetBundleGraphSettings.NodeKindFromString(jsonData[NODE_KIND] as string);

            var pos = jsonData[NODE_POS] as Dictionary <string, object>;

            m_x = (float)Convert.ToDouble(pos[NODE_POS_X]);
            m_y = (float)Convert.ToDouble(pos[NODE_POS_Y]);

            var inputs  = jsonData[NODE_INPUTPOINTS] as List <object>;
            var outputs = jsonData[NODE_OUTPUTPOINTS] as List <object>;

            m_inputPoints  = new List <ConnectionPointData>();
            m_outputPoints = new List <ConnectionPointData>();

            foreach (var obj in inputs)
            {
                var pDic = obj as Dictionary <string, object>;
                m_inputPoints.Add(new ConnectionPointData(pDic, this, true));
            }

            foreach (var obj in outputs)
            {
                var pDic = obj as Dictionary <string, object>;
                m_outputPoints.Add(new ConnectionPointData(pDic, this, false));
            }

            switch (m_kind)
            {
            case NodeKind.IMPORTSETTING_GUI:
                // nothing to do
                break;

            case NodeKind.PREFABBUILDER_GUI:
            case NodeKind.MODIFIER_GUI:
            {
                if (jsonData.ContainsKey(NODE_SCRIPT_CLASSNAME))
                {
                    m_scriptClassName = jsonData[NODE_SCRIPT_CLASSNAME] as string;
                }
                if (jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA))
                {
                    m_scriptInstanceData = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_SCRIPT_INSTANCE_DATA));
                }
            }
            break;

            case NodeKind.LOADER_GUI:
            {
                m_loaderLoadPath = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_LOADER_LOAD_PATH));
            }
            break;

            case NodeKind.FILTER_GUI:
            {
                var filters = jsonData[NODE_FILTER] as List <object>;

                m_filter = new List <FilterEntry>();

                for (int i = 0; i < filters.Count; ++i)
                {
                    var f = filters[i] as Dictionary <string, object>;

                    var keyword = f[NODE_FILTER_KEYWORD] as string;
                    var keytype = f[NODE_FILTER_KEYTYPE] as string;
                    var pointId = f[NODE_FILTER_POINTID] as string;

                    var point = m_outputPoints.Find(p => p.Id == pointId);
                    UnityEngine.Assertions.Assert.IsNotNull(point, "Output point not found for " + keyword);
                    m_filter.Add(new FilterEntry(keyword, keytype, point));
                }
            }
            break;

            case NodeKind.GROUPING_GUI:
            {
                m_groupingKeyword = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_GROUPING_KEYWORD));
            }
            break;

            case NodeKind.BUNDLECONFIG_GUI:
            {
                m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_BUNDLECONFIG_BUNDLENAME_TEMPLATE));
                if (jsonData.ContainsKey(NODE_BUNDLECONFIG_USE_GROUPASVARIANTS))
                {
                    m_bundleConfigUseGroupAsVariants = Convert.ToBoolean(jsonData[NODE_BUNDLECONFIG_USE_GROUPASVARIANTS]);
                }
                m_variants = new List <Variant>();
                if (jsonData.ContainsKey(NODE_BUNDLECONFIG_VARIANTS))
                {
                    var variants = jsonData[NODE_BUNDLECONFIG_VARIANTS] as List <object>;

                    for (int i = 0; i < variants.Count; ++i)
                    {
                        var v = variants[i] as Dictionary <string, object>;

                        var name    = v[NODE_BUNDLECONFIG_VARIANTS_NAME] as string;
                        var pointId = v[NODE_BUNDLECONFIG_VARIANTS_POINTID] as string;

                        var point = m_inputPoints.Find(p => p.Id == pointId);
                        UnityEngine.Assertions.Assert.IsNotNull(point, "Input point not found for " + name);
                        m_variants.Add(new Variant(name, point));
                    }
                }
            }
            break;

            case NodeKind.BUNDLEBUILDER_GUI:
            {
                m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS));
            }
            break;

            case NodeKind.EXPORTER_GUI:
            {
                m_exporterExportPath   = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_PATH));
                m_exporterExportOption = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_OPTION));
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#51
0
        /*
         * Constructor used to create new node from GUI
         */
        public NodeData(string name, NodeKind kind, float x, float y)
        {
            m_id = Guid.NewGuid().ToString();
            m_name = name;
            m_x = x;
            m_y = y;
            m_kind = kind;

            m_inputPoints  = new List<ConnectionPointData>();
            m_outputPoints = new List<ConnectionPointData>();

            // adding defalut input point.
            // Loader does not take input
            if(kind != NodeKind.LOADER_GUI) {
                m_inputPoints.Add(new ConnectionPointData(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL, this, true));
            }

            // adding default output point.
            // Filter and Exporter does not have output.
            if(kind != NodeKind.FILTER_GUI && kind != NodeKind.EXPORTER_GUI) {
                m_outputPoints.Add(new ConnectionPointData(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL, this, false));
            }

            switch(m_kind) {
            case NodeKind.PREFABBUILDER_GUI:
            case NodeKind.MODIFIER_GUI:
                m_scriptClassName 	= String.Empty;
                m_scriptInstanceData = new SerializableMultiTargetString();
                break;

            case NodeKind.IMPORTSETTING_GUI:
                break;

            case NodeKind.FILTER_GUI:
                m_filter = new List<FilterEntry>();
                break;

            case NodeKind.LOADER_GUI:
                m_loaderLoadPath = new SerializableMultiTargetString();
                break;

            case NodeKind.GROUPING_GUI:
                m_groupingKeyword = new SerializableMultiTargetString(AssetBundleGraphSettings.GROUPING_KEYWORD_DEFAULT);
                break;

            case NodeKind.BUNDLECONFIG_GUI:
                m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(AssetBundleGraphSettings.BUNDLECONFIG_BUNDLENAME_TEMPLATE_DEFAULT);
                m_variants = new List<Variant>();
                break;

            case NodeKind.BUNDLEBUILDER_GUI:
                m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt();
                break;

            case NodeKind.EXPORTER_GUI:
                m_exporterExportPath = new SerializableMultiTargetString();
                break;

            default:
                throw new AssetBundleGraphException("[FATAL]Unhandled nodekind. unimplmented:"+ m_kind);
            }
        }
示例#52
0
文件: CssNode.cs 项目: carbon/Css
        public CssNode(NodeKind kind, CssNode parent = null)
        {
            Kind = kind;

            this.parent = parent;
        }
示例#53
0
 /// <summary>
 /// Given the input C# code <paramref name="sourceText"/> returns
 /// the syntax tree for the input code.
 /// </summary>
 /// <param name="sourceText">A C# souce text</param>
 /// <param name="nodeKind">What kind of C# syntax node should the input be parsed as</param>
 private static SyntaxNode Parse(string sourceText, NodeKind nodeKind)
 {
     switch (nodeKind)
     {
         case NodeKind.CompilationUnit:
             return SyntaxFactory.ParseCompilationUnit(sourceText);
         case NodeKind.Statement:
             return SyntaxFactory.ParseStatement(sourceText);
         case NodeKind.Expression:
             return SyntaxFactory.ParseExpression(sourceText);
         default:
             throw new InvalidOperationException();
     }
 }
示例#54
0
 public FeatureTreeNodeInfo(int hvo, NodeKind kind)
 {
     iHvo  = hvo;
     eKind = kind;
 }
        IEnumerable<int> LeftFromTheNode(int[] layer, int vPosition, NodeKind nodeKind, double leftMostX, double rightMostX) {
            double t = 0, b = 0;
            if (nodeKind == NodeKind.Bottom)
                b = Single.MaxValue;//we don't have bottom boundaries here since they will be cut off
            else if (nodeKind == NodeKind.Top)
                t = Single.MaxValue;//we don't have top boundaries here since they will be cut off

            int v = layer[vPosition];

            for (int i = vPosition - 1; i > -1; i--) {
                int u = layer[i];
                if (NodeUCanBeCrossedByNodeV(u, v))
                    continue;
                Anchor anchor = anchors[u];
                if (anchor.Right <= leftMostX)
                    break;
                if (anchor.Left < rightMostX) {
                    if (anchor.TopAnchor > t + ApproximateComparer.DistanceEpsilon) {
                        t = anchor.TopAnchor;
                        yield return u;
                    } else if (anchor.BottomAnchor > b + ApproximateComparer.DistanceEpsilon) {
                        b = anchor.BottomAnchor;
                        yield return u;
                    }
                }
            }
        }
 public EntityHierarchyNodeId(NodeKind kind, int id, int version)
 => (Kind, Id, Version) = (kind, id, version);
		public FeatureTreeNodeInfo(int hvo, NodeKind kind)
		{
			iHvo = hvo;
			eKind = kind;
		}
示例#58
0
 private void Test(string sourceText, NodeKind nodeKind = NodeKind.CompilationUnit)
 {
     Test(sourceText, useDefaultFormatting: true, removeRedundantCalls: true, shortenCodeWithUsingStatic: false, nodeKind);
     Test(sourceText, useDefaultFormatting: false, removeRedundantCalls: true, shortenCodeWithUsingStatic: true, nodeKind);
 }
        /*
         * Constructor used to create new node from GUI
         */
        public NodeData(string name, NodeKind kind, float x, float y)
        {
            m_id   = Guid.NewGuid().ToString();
            m_name = name;
            m_x    = x;
            m_y    = y;
            m_kind = kind;

            m_inputPoints  = new List <ConnectionPointData>();
            m_outputPoints = new List <ConnectionPointData>();


            // adding defalut input point.
            // Loader does not take input
            if (kind != NodeKind.LOADER_GUI)
            {
                m_inputPoints.Add(new ConnectionPointData(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL, this, true));
            }

            // adding default output point.
            // Filter and Exporter does not have output.
            if (kind != NodeKind.FILTER_GUI && kind != NodeKind.EXPORTER_GUI)
            {
                m_outputPoints.Add(new ConnectionPointData(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL, this, false));
            }

            switch (m_kind)
            {
            case NodeKind.PREFABBUILDER_GUI:
            case NodeKind.MODIFIER_GUI:
                m_scriptClassName    = String.Empty;
                m_scriptInstanceData = new SerializableMultiTargetString();
                break;

            case NodeKind.IMPORTSETTING_GUI:
                break;

            case NodeKind.FILTER_GUI:
                m_filter = new List <FilterEntry>();
                break;

            case NodeKind.LOADER_GUI:
                m_loaderLoadPath = new SerializableMultiTargetString();
                break;

            case NodeKind.GROUPING_GUI:
                m_groupingKeyword = new SerializableMultiTargetString(AssetBundleGraphSettings.GROUPING_KEYWORD_DEFAULT);
                break;

            case NodeKind.BUNDLECONFIG_GUI:
                m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(AssetBundleGraphSettings.BUNDLECONFIG_BUNDLENAME_TEMPLATE_DEFAULT);
                m_bundleConfigUseGroupAsVariants = false;
                m_variants = new List <Variant>();
                break;

            case NodeKind.BUNDLEBUILDER_GUI:
                m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt();
                break;

            case NodeKind.EXPORTER_GUI:
                m_exporterExportPath   = new SerializableMultiTargetString();
                m_exporterExportOption = new SerializableMultiTargetInt();
                break;

            default:
                throw new AssetBundleGraphException("[FATAL]Unhandled nodekind. unimplmented:" + m_kind);
            }
        }
示例#60
0
 public NodeKindSuggestionHandler(NodeKind kind)
 {
     _kind = kind;
 }