private static FileSystemPath GetBasePathBeforeMapping(IQualifiableReference pathReference)
        {
            IQualifier qualifier = pathReference.GetQualifier();

            if (qualifier == null)
            {
                IProjectFile file = pathReference.GetTreeNode().GetSourceFile().ToProjectFile();
                Assertion.AssertNotNull(file, "file == null");
                return(file.Location.Directory);
            }

            var reference = qualifier as IReference;

            if (reference != null)
            {
                ResolveResultWithInfo resolveResultWithInfo = (reference).Resolve();
                var pathDeclaredElement = resolveResultWithInfo.DeclaredElement as IPathDeclaredElement;
                if (pathDeclaredElement == null)
                {
                    return(FileSystemPath.Empty);
                }

                return(pathDeclaredElement.Path);
            }

            var pathQualifier = qualifier as IPathQualifier;

            if (pathQualifier != null)
            {
                return(pathQualifier.Path);
            }

            return(FileSystemPath.Empty);
        }
예제 #2
0
        /// <summary>
        /// Debugs the client info.
        /// </summary>
        /// <returns>The client info.</returns>
        /// <param name="taskNetwork">Task network.</param>
        public static string ClientStateInfo(TaskNetworkComponent taskNetwork)
        {
            string clientInfo = "";

            foreach (UtilityAIClient client in taskNetwork.clients)
            {
                clientInfo = client.ai + " | State: " + client.state + "\n";
                foreach (KeyValuePair <IQualifier, float> item in client.selectorResults)
                {
                    IQualifier qualifier = item.Key;
                    float      score     = item.Value;

                    var action     = qualifier.action;
                    var actionName = action.GetType().Name;
                    if (action is ActionWithOptions <Vector3> )
                    {
                        var _action = action as ActionWithOptions <Vector3>;
                        action = _action;
                        //actionName = _action.name;
                    }

                    if (client.currentAction == action)
                    {
                        clientInfo += string.Format(" <b>Qualifier:</b> {0} | <b>Score:</b>: <color=lime>{1}</color>\n <b>Action:</b>:  <color=lime>{2}</color>\n", qualifier.GetType().Name, score, actionName);
                    }
                    else
                    {
                        clientInfo += string.Format(" <b>Qualifier:</b> {0} | <b>Score:</b>: {1}\n <b>Action:</b>:  {2}\n", qualifier.GetType().Name, score, actionName);
                    }
                }
            }


            return(clientInfo);
        }
예제 #3
0
        /// <summary>
        /// Selects the action for execution, given the specified context.
        /// This selector choses the highest scoring <see cref="IQualifier"/>.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="qualifiers">The qualifiers from which to find the action.</param>
        /// <param name="defaultQualifier">The default qualifier.</param>
        /// <returns>
        /// The qualifier whose action should be chosen.
        /// </returns>
        public override IQualifier Select(IAIContext context, IList <IQualifier> qualifiers, IDefaultQualifier defaultQualifier)
        {
            var count = qualifiers.Count;

            float      max        = defaultQualifier.score;
            IQualifier highRoller = null;

            for (int i = 0; i < count; i++)
            {
                var qualifier = qualifiers[i];
                if (qualifier.isDisabled)
                {
                    continue;
                }

                var score = qualifier.Score(context);
                if (score > max)
                {
                    max        = score;
                    highRoller = qualifier;
                }
            }

            if (highRoller == null)
            {
                return(defaultQualifier);
            }

            return(highRoller);
        }
예제 #4
0
        internal void ReplaceQualifier(QualifierView qv, IQualifier replacement, bool recordUndo = true)
        {
            var qualifiers = qv.parent.selector.qualifiers;
            var idx        = qualifiers.IndexOf(qv.qualifier);

            if (idx < 0)
            {
                return;
            }

            if (recordUndo)
            {
                _undoRedo.Do(new ReplaceQualifierOperation(this, qv.qualifier, replacement, qv));

                //We don't want to clone during undo/redo as the cloning is recorded
                TryClone(qv.qualifier, replacement);
            }

            replacement.action = qv.qualifier.action;
            qualifiers[idx]    = replacement;
            qv.qualifier       = replacement;

            //Need to refresh editor
            this.inspectorState.Refresh();

            this.isDirty = true;
        }
예제 #5
0
        public override IQualifier Select(IAIContext context, IList <IQualifier> qualifiers, IDefaultQualifier defaultQualifier)
        {
            int        count     = qualifiers.Count;
            float      single    = defaultQualifier.score;
            IQualifier qualifier = null;

            for (int i = 0; i < count; i++)
            {
                IQualifier item = qualifiers[i];
                if (!item.isDisabled)
                {
                    float single1 = item.Score(context);
                    if (single1 > single)
                    {
                        single    = single1;
                        qualifier = item;
                    }
                }
            }
            if (qualifier == null)
            {
                return(defaultQualifier);
            }
            return(qualifier);
        }
예제 #6
0
        public override IQualifier Select(IAIContext context, IList <IQualifier> qualifiers, IDefaultQualifier defaultQualifier)
        {
            IQualifier qualifier = defaultQualifier;

            for (int i = 0; i < qualifiers.Count; i++)
            {
                IQualifier item = qualifiers[i];
                if (!item.isDisabled)
                {
                    float single = item.Score(context);
                    if (this._decomposition == DecompositionType.One && single > 0f)
                    {
                        return(item);
                    }
                    if (this._decomposition == DecompositionType.All && single <= 0f)
                    {
                        return(base.defaultQualifier);
                    }
                    qualifier = item;
                    IConnectorAction connectorAction = item.action as IConnectorAction;
                    if (connectorAction != null)
                    {
                        connectorAction.Select(context);
                    }
                }
            }
            if (this._decomposition == DecompositionType.All)
            {
                return(qualifier);
            }
            return(defaultQualifier);
        }
 internal ReplaceQualifierOperation(AIUI ui, IQualifier oldValue, IQualifier newValue, QualifierView target)
     : base(ui)
 {
     _target   = target;
     _oldValue = oldValue;
     _newValue = newValue;
 }
        internal QualifierVisualizer(IQualifier q, SelectorVisualizer parent)
        {
            this._qualifier = q;
            this._parent    = parent;
            SelectorAction      selectorAction     = q.action as SelectorAction;
            AILinkAction        aILinkAction       = q.action as AILinkAction;
            CompositeAction     compositeAction    = q.action as CompositeAction;
            IRequireTermination requireTermination = q.action as IRequireTermination;

            if (selectorAction != null)
            {
                this._action = new SelectorActionVisualizer(selectorAction, this);
                return;
            }
            if (aILinkAction != null)
            {
                this._action = new AILinkActionVisualizer(aILinkAction, this);
                return;
            }
            if (compositeAction != null)
            {
                this._action = new CompositeActionVisualizer(compositeAction, this);
                return;
            }
            if (requireTermination != null)
            {
                this._action = new ActionRequiresTerminationVisualizer(q.action, this);
                return;
            }
            if (q.action != null)
            {
                this._action = new ActionVisualizer(q.action, this);
            }
        }
예제 #9
0
        internal QualifierVisualizer(IQualifier q, SelectorVisualizer parent)
        {
            _qualifier = q;
            _parent    = parent;

            var selectorAction = q.action as SelectorAction;
            var linkAction     = q.action as AILinkAction;
            var compAction     = q.action as CompositeAction;
            var irt            = q.action as IRequireTermination;

            if (selectorAction != null)
            {
                _action = new SelectorActionVisualizer(selectorAction, this);
            }
            else if (linkAction != null)
            {
                _action = new AILinkActionVisualizer(linkAction, this);
            }
            else if (compAction != null)
            {
                _action = new CompositeActionVisualizer(compAction, this);
            }
            else if (irt != null)
            {
                _action = new ActionRequiresTerminationVisualizer(q.action, this);
            }
            else if (q.action != null)
            {
                _action = new ActionVisualizer(q.action, this);
            }
        }
예제 #10
0
        private ReferenceCollection CreateTypeNameReferences(ICSharpLiteralExpression literal,
                                                             ExpectedObjectTypeReferenceKind kind)
        {
            var literalValue = (string)literal.ConstantValue.Value;

            if (literalValue == null)
            {
                return(ReferenceCollection.Empty);
            }

            var symbolCache = literal.GetPsiServices().Symbols;

            IQualifier qualifier    = null;
            var        references   = new LocalList <IReference>();
            var        startIndex   = 0;
            var        nextDotIndex = literalValue.IndexOf('.');

            while (true)
            {
                var endIndex = nextDotIndex != -1 ? nextDotIndex : literalValue.Length;

                // startIndex + 1 to skip leading quote in tree node, which doesn't exist in literalValue
                var rangeWithin = TextRange.FromLength(startIndex + 1, endIndex - startIndex);

                // Behaviour and resolution is almost identical for each part.
                // For a single component, it is either a Unity object with an inferred namespace, a type in the global
                // namespace, or the namespace for an as yet uncompleted qualified type name
                // For a trailing component, it is a qualified reference, and could be a type, or a continuation of the
                // namespace qualification
                // For a middle component, it could be a namespace, or the user typing a new type, with the trailing
                // text being the old component
                // When there is no qualifier, resolve should match:
                // * inferred type, with expected type check
                // * type in global namespace, with expected type check
                // * namespace, with expected type check (so namespace won't be the last thing)
                // When there is a qualifier, resolve should match
                // * namespaces
                // * qualified type with expected type check
                // For the final component, resolve should match namespaces, but with the expected type check
                // At all times, completion should show both namespaces and qualified types
                // Leading and trailing space are treated as part of a name, and will cause resolve to fail
                // TODO: Handle trailing dot
                var isFinalPart = nextDotIndex == -1;
                var reference   = new UnityObjectTypeOrNamespaceReference(literal, qualifier, literal.Literal, rangeWithin,
                                                                          kind, symbolCache, isFinalPart);

                references.Add(reference);
                if (nextDotIndex == -1)
                {
                    break;
                }

                startIndex   = nextDotIndex + 1;
                nextDotIndex = literalValue.IndexOf('.', startIndex);
                qualifier    = reference;
            }

            return(new ReferenceCollection(references.ReadOnlyList()));
        }
예제 #11
0
        public IXmlAttributeValue ParseReferenceIdentifier(IXmlAttributeValue xmlAttributeValue, IQualifier qualifier)
        {
            ReferenceModuleAttributeValue attributeValue = new ReferenceModuleAttributeValue();

            return ParseAttributeValueAspect(xmlAttributeValue, attributeValue, delegate(string text) {
                                                                                                          return ParseMemberIdentifier
                                                                                                              (text,
                                                                                                               qualifier); });
        }
예제 #12
0
        public IAction Select(IAIContext context)
        {
            IQualifier qualifier = this.Select(context, this._qualifiers, this._defaultQualifier);

            if (qualifier == null)
            {
                return(null);
            }
            return(qualifier.action);
        }
 public UnityObjectTypeOrNamespaceReference(ICSharpLiteralExpression owner, [CanBeNull] IQualifier qualifier,
                                            ITokenNode token, TextRange rangeWithin,
                                            ExpectedObjectTypeReferenceKind kind, ISymbolCache symbolCache,
                                            bool isFinalPart)
     : base(owner, qualifier, token, rangeWithin.ToTreeTextRange())
 {
     mySymbolCache              = symbolCache;
     myIsFinalPart              = isFinalPart;
     myForwardedTypesFilter     = new ForwardedTypesFilter(symbolCache);
     myExpectedObjectTypeFilter = new ExpectedObjectTypeFilter(kind, mustBeClass: isFinalPart);
 }
예제 #14
0
        public int CompareTo(IQualifier other)
        {
            //  Current instance is greater than object being compared too.
            if (other == null)
            {
                return(1);
            }

            return(this._score.CompareTo(other._score));
            //return this.Score(context).CompareTo(other.Score(context));
        }
예제 #15
0
        /// <summary>
        /// Selects the action for execution.
        /// </summary>
        /// <returns>The select.</returns>
        /// <param name="context">Context.</param>
        public IAction Select(IAIContext context)
        {
            List <IQualifier> qualifiers       = rootSelector.qualifiers;
            IDefaultQualifier defaultQualifier = rootSelector.defaultQualifier;
            IQualifier        winner           = rootSelector.Select(context, qualifiers, defaultQualifier);

            CompositeQualifier cq = winner as CompositeQualifier;
            // TODO:  What if there are no scoreres?
            //float score = cq.Score(context, cq.scorers);
            IAction action = winner.action;

            return(action);
        }
        public override IQualifier Select(IAIContext context, IList <IQualifier> qualifiers, IDefaultQualifier defaultQualifier)
        {
            int   count  = qualifiers.Count;
            float single = defaultQualifier.score;

            for (int i = 0; i < count; i++)
            {
                IQualifier item = qualifiers[i];
                if (!item.isDisabled && item.Score(context) > single)
                {
                    return(item);
                }
            }
            return(defaultQualifier);
        }
예제 #17
0
        public ReferenceName ParseMemberIdentifier(string text, IQualifier qualifier)
        {
            lexer = new CSharpLexer(new StringBuffer(text));
            Start();
            TreeElement firstIdentifier = ParseIdentifier();
            ReferenceName referenceName = CreateMemeberIdentifier(firstIdentifier, qualifier);
            if(lexer.TokenType != null)
            {
                UnexpectedToken ex = new UnexpectedToken("Unexpected token");
                ex.ParsingResult = referenceName;
                throw ex;
            }

            return referenceName;
        }
예제 #18
0
        internal void Reconnect(IQualifier q)
        {
            this.qualifier = q;

            if (this.actionView != null)
            {
                //If an action view is present bug the action is null, this means inconsistency between config end editor config
                //While this should not occur, we still handle it just in case.
                if (q.action == null)
                {
                    this.actionView = null;
                }
                else
                {
                    this.actionView.action = q.action;
                }
            }
        }
        internal IQualifierVisualizer FindQualifierVisualizer(IQualifier target)
        {
            int count = this._selectorVisualizers.Count;

            for (int i = 0; i < count; i++)
            {
                SelectorVisualizer item = this._selectorVisualizers[i];
                int num = item.qualifiers.Count;
                for (int j = 0; j < num; j++)
                {
                    IQualifierVisualizer qualifierVisualizer = (IQualifierVisualizer)item.qualifiers[j];
                    if (qualifierVisualizer.qualifier == target)
                    {
                        return(qualifierVisualizer);
                    }
                }
            }
            return(null);
        }
        internal IQualifierVisualizer FindQualifierVisualizer(IQualifier target)
        {
            var selectorCount = _selectorVisualizers.Count;

            for (int i = 0; i < selectorCount; i++)
            {
                var s             = _selectorVisualizers[i];
                var qualiferCount = s.qualifiers.Count;
                for (int j = 0; j < qualiferCount; j++)
                {
                    var q = (IQualifierVisualizer)s.qualifiers[j];
                    if (ReferenceEquals(q.qualifier, target))
                    {
                        return(q);
                    }
                }
            }

            return(null);
        }
예제 #21
0
        internal SelectorVisualizer(Selector s, UtilityAIVisualizer parent)
        {
            this._selector = s;
            this._parent   = parent;
            List <IQualifier> qualifiers = this._selector.qualifiers;
            int count = qualifiers.Count;

            for (int i = 0; i < count; i++)
            {
                IQualifier item = qualifiers[i];
                if (!(item is ICompositeScorer))
                {
                    base.qualifiers.Add(new QualifierVisualizer(item, this));
                }
                else
                {
                    base.qualifiers.Add(new CompositeQualifierVisualizer((ICompositeScorer)item, this));
                }
            }
            base.defaultQualifier = new DefaultQualifierVisualizer(this._selector.defaultQualifier, this);
        }
예제 #22
0
        public NancyRazorLayoutReference(IExpression owner, IQualifier qualifier, TToken token,
                                         TreeTextRange rangeWithin, ProjectFileType expectedFileType, bool noCircular, bool allowEmptyName)
            : base(owner, qualifier, token, rangeWithin, expectedFileType, noCircular, allowEmptyName)
        {
            Assertion.Assert(owner.ConstantValue.IsString(), "expression is not string constant");

            ResolveFilter = element =>
            {
                var pathDeclaredElement = element as IPathDeclaredElement;
                if (pathDeclaredElement == null || pathDeclaredElement.GetProjectItem() == null)
                {
                    return(false);
                }

                if (pathDeclaredElement.Path.ExistsDirectory)
                {
                    return(false);
                }
                return(true);
            };
        }
        internal static bool IsConnectedTo(this Selector source, Selector target)
        {
            SelectorAction selectorAction;
            bool           flag;

            using (IEnumerator <IQualifier> enumerator = BasicExtensions.AllQualifiers(source).GetEnumerator())
            {
                do
                {
Label1:
                    if (enumerator.MoveNext())
                    {
                        IQualifier current = enumerator.Current;
                        selectorAction = current.action as SelectorAction;
                        if (selectorAction != null)
                        {
                            break;
                        }
                        CompositeAction compositeAction = current.action as CompositeAction;
                        if (compositeAction != null)
                        {
                            selectorAction = compositeAction.connectorAction as SelectorAction;
                        }
                        else
                        {
                            goto Label1;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }while (selectorAction == null);
                flag = (selectorAction.selector != target ? selectorAction.selector.IsConnectedTo(target) : true);
            }
            return(flag);
        }
예제 #24
0
 private ReferenceName CreateMemeberIdentifier(TreeElement firstIdentifier, IQualifier qualifier)
 {
     return new FilteredReferenceName(firstIdentifier, qualifier, new FiltersArray(new ISymbolFilter[] { PropertyOrFiledFilter.INSTANCE, PublicOrProtectedFilter.INSTANCE }));
 }
 private static IPathReference GetFolderPathReference(IJavaScriptLiteralExpression literal, IQualifier qualifier,
     IJavaScriptLiteralExpression token, TreeTextRange range)
 {
     return new AngularJsFolderLateBoundReference<IJavaScriptLiteralExpression, IJavaScriptLiteralExpression>(literal, qualifier, token, range);
 }
예제 #26
0
 public ReferenceName(TreeElement identifier, IQualifier qualifier)
     : this(identifier)
 {
     this.qualifier = qualifier;
 }
예제 #27
0
 public AngularJsFileLateBoundReference(TOwner owner, IQualifier qualifier, TToken token, TreeTextRange rangeWithin)
     : base(owner, qualifier, token, rangeWithin)
 {
 }
예제 #28
0
 public FilteredReferenceName(IQualifier qualifier, IFiltersProvider filtersProvider)
     : base(qualifier)
 {
     if (filtersProvider == null) throw new ArgumentNullException("filtersProvider");
     this.filtersProvider = filtersProvider;
 }
예제 #29
0
        public ReferenceType ParseTypeReference(string text, IQualifier qualifier)
        {
            // it's stub
            try
            {
                ReferenceName referenceName = ParseReferenceName(text, qualifier);
                ReferenceType referenceType = new ReferenceType();
                referenceType.AddChild(referenceName);
                return referenceType;
            }
            catch (UnexpectedToken ex)
            {
                ReferenceName referenceName = ex.ParsingResult as ReferenceName;
                if(referenceName != null)
                {
                    ReferenceType referenceType = new ReferenceType();
                    referenceType.AddChild(referenceName);
                    UnexpectedToken newEx = new UnexpectedToken("Unexpected token");
                    newEx.ParsingResult = referenceType;
                    throw newEx;
                }

                throw;
            }
        }
 private static IPathReference GetFolderPathReference(IJavaScriptLiteralExpression literal, IQualifier qualifier,
                                                      IJavaScriptLiteralExpression token, TreeTextRange range)
 {
     return(new AngularJsFolderLateBoundReference <IJavaScriptLiteralExpression, IJavaScriptLiteralExpression>(literal, qualifier, token, range));
 }
        public override IQualifier Select(IAIContext context, IList <IQualifier> qualifiers, IDefaultQualifier defaultQualifier)
        {
            int num;

            if (!this._UpdateTaskQualifiers())
            {
                return(defaultQualifier);
            }
            for (int i = 0; i < this._tasks.Count; i++)
            {
                this._tasks[i].Reset();
            }
            IQualifier  qualifier  = defaultQualifier;
            IHTNContext worldState = context as IHTNContext;
            bool        flag       = false;

            this._plan.Clear();
            if (worldState != null)
            {
                int decompositionScore = worldState.DecompositionScore;
                this.DecompositionScore = 0;
                worldState.PlanResult   = PlanResultType.NoPlan;
                for (int j = 0; j < (int)worldState.WorldStateChanges.Length; j++)
                {
                    if (worldState.WorldStateChanges[j].Count > 0)
                    {
                        worldState.WorldStateChanges[j].Clear();
                    }
                }
                int num1 = 0;
                worldState.StartDomainDecomposition();
                for (int k = 0; k < this._tasks.Count; k++)
                {
                    TaskQualifier item = this._tasks[k];
                    if (!item.isDisabled)
                    {
                        int num2 = num1;
                        if (num1 >= decompositionScore)
                        {
                            worldState.PlanResult = PlanResultType.KeepCurrentPlan;
                            break;
                        }
                        else if (item.Decompose(this, null, worldState, ref this._plan, ref num2, decompositionScore, out num) <= 0f)
                        {
                            num = 0;
                            item.GetFullDecompositionCost(ref num);
                            num1 += num;
                            num1++;
                        }
                        else
                        {
                            num1 += num;
                            if (worldState.PlanState != PlanStateType.Running || num1 < decompositionScore)
                            {
                                flag = true;
                                worldState.DecompositionScore = num1;
                                for (int l = 0; l < qualifiers.Count; l++)
                                {
                                    IQualifier item1 = qualifiers[l];
                                    if (item1.Score(context) > 0f)
                                    {
                                        IConnectorAction connectorAction = item1.action as IConnectorAction;
                                        if (connectorAction != null)
                                        {
                                            connectorAction.Select(context);
                                        }
                                        else
                                        {
                                        }
                                        qualifier = item1;
                                    }
                                }
                                break;
                            }
                            else
                            {
                                worldState.PlanResult = PlanResultType.KeepCurrentPlan;
                                break;
                            }
                        }
                    }
                }
            }
            if (flag)
            {
                if (worldState != null)
                {
                    worldState.HtnPlan.Clear();
                    for (int m = this._plan.Count - 1; m >= 0; m--)
                    {
                        this._plan[m].State = PrimitiveTaskStateType.NotStarted;
                        worldState.HtnPlan.Push(this._plan[m]);
                    }
                    if (Application.isEditor)
                    {
                        worldState.DebugPlan.Clear();
                        for (int n = 0; n < this._plan.Count; n++)
                        {
                            PrimitiveTaskSelector primitiveTaskSelector = this._plan[n];
                            worldState.DebugPlan.Add(primitiveTaskSelector);
                        }
                    }
                    if (worldState.PlanState != PlanStateType.Running)
                    {
                        worldState.PlanResult = PlanResultType.FoundNewPlan;
                    }
                    else
                    {
                        worldState.PlanResult = PlanResultType.ReplacedPlan;
                    }
                    worldState.PlanState = PlanStateType.Running;
                    foreach (KeyValuePair <Guid, Stack <IEffect> > appliedExpectedEffect in worldState.AppliedExpectedEffects)
                    {
                        Stack <IEffect> value = appliedExpectedEffect.Value;
                        value.Clear();
                        Pool.Free <Stack <IEffect> >(ref value);
                    }
                    worldState.AppliedExpectedEffects.Clear();
                    foreach (KeyValuePair <Guid, Stack <IEffect> > appliedEffect in worldState.AppliedEffects)
                    {
                        Stack <IEffect> effects = appliedEffect.Value;
                        effects.Clear();
                        Pool.Free <Stack <IEffect> >(ref effects);
                    }
                    worldState.AppliedEffects.Clear();
                    for (int o = 0; o < (int)worldState.WorldStateChanges.Length; o++)
                    {
                        Stack <WorldStateInfo> worldStateChanges = worldState.WorldStateChanges[o];
                        while (worldStateChanges.Count > 0 && worldStateChanges.Peek().Temporary)
                        {
                            worldStateChanges.Pop();
                        }
                        if (worldStateChanges.Count > 0)
                        {
                            WorldStateInfo worldStateInfo = worldStateChanges.Peek();
                            worldState.PreviousWorldState[o] = worldState.WorldState[o];
                            worldState.WorldState[o]         = worldStateInfo.Value;
                        }
                    }
                }
            }
            else if (worldState != null)
            {
                if (worldState.PlanState != PlanStateType.Running)
                {
                    worldState.PlanResult = PlanResultType.NoPlan;
                }
                else
                {
                    worldState.PlanResult = PlanResultType.KeepCurrentPlan;
                }
            }
            return(qualifier);
        }
예제 #32
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LinkedScorer" /> class.
 /// </summary>
 /// <param name="qualifier">The qualifier.</param>
 public LinkedScorer(IQualifier <T> qualifier)
 {
     this.qualifier = qualifier;
 }
예제 #33
0
        private TreeElement ParseReferencedName(TreeElement id, IQualifier qualifier)
        {
            TreeElement result = id;
            TokenNodeType tokenType = lexer.TokenType;
            XmlToken xmlToken = id as XmlToken;
            if (xmlToken != null && xmlToken.type == L4NTokenNodeType.IDENTIFIER)
            {
                result = new ReferenceName(id, qualifier);
                // TODO parse argument list
            }

            while (tokenType == CSharpTokenType.DOT)
            {
            //                if (LexerUtil.LookaheadToken(lexer, 1) != CSharpTokenType.IDENTIFIER)
            //                {
            //                    UnexpectedToken ex = new UnexpectedToken("Expected identifier");
            //                    ex.ParsingResult = result;
            //                    throw ex;
            //                }
                result = ParseReferenceNameInternal(result);
                tokenType = lexer.TokenType;
            }
            return result;
        }
예제 #34
0
 protected ReferenceName ParseTypeNameOrAttributeValue(string text, IQualifier qualifier)
 {
     lexer = new CSharpLexer(new StringBuffer(text));
     Start();
     TreeElement firstIdentifier = ParseIdentifier();
     TreeElement result = ParseReferencedName(firstIdentifier, qualifier);
     return (ReferenceName)result;
 }
예제 #35
0
 /// <summary>
 ///     Adds a qualifier.
 /// </summary>
 /// <param name="qualifier">The qualifier.</param>
 public void AddQualifier(IQualifier <T> qualifier)
 {
     this.QualifiersList.Add(qualifier);
 }
예제 #36
0
 public ReferenceName(IQualifier qualifier)
     : this()
 {
     this.qualifier = qualifier;
 }
 public PsiFileReference(TOwner owner, IQualifier qualifier, TToken token, TreeTextRange rangeWithin)
     : base(owner, qualifier, token, rangeWithin)
 {
 }
예제 #38
0
        public IXmlAttributeValue ParseReferenceType(IXmlAttributeValue xmlAttributeValue, IQualifier qualifier)
        {
            ReferenceTypeAttributeValue attributeValue = new ReferenceTypeAttributeValue();

            return ParseAttributeValueAspect(xmlAttributeValue, attributeValue, text => ParseTypeReference(text, qualifier));
        }
예제 #39
0
 public ReferenceName ParseReferenceName(string text, IQualifier qualifier)
 {
     return ParseTypeNameOrAttributeValue(text, qualifier);
 }
        public static ISymbolTable GetReferenceSymbolTable(IPathReference pathReference, bool useReferenceName, bool includeHttpHandlers = true)
        {
            var propertiesSearcher =
                pathReference.GetTreeNode().GetSolution().GetComponent <MSBuildPropertiesCache>();

            string productHomeDir = propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(),
                                                                                "ProductHomeDir");
            var basePath = new FileSystemPath(productHomeDir);

            if (basePath.IsEmpty)
            {
                return(EmptySymbolTable.INSTANCE);
            }

            FolderQualifierInfo folderQualifierInfo = null;
            IPsiServices        psiServices         = pathReference.GetTreeNode().GetPsiServices();
            var baseProjectFolder = psiServices.Solution.FindProjectItemsByLocation(basePath).FirstOrDefault() as IProjectFolder;

            if (baseProjectFolder != null)
            {
                folderQualifierInfo = new FolderQualifierInfo(baseProjectFolder);
            }

            FileSystemPath websiteRoot = GetRootPath(pathReference);
            IQualifier     qualifier   = pathReference.GetQualifier();

            if (useReferenceName)
            {
                PathDeclaredElement target = null;
                string name = pathReference.GetName();
                switch (name)
                {
                case PathDeclaredElement.CURRENT_DIR_NAME:
                    target = new PathDeclaredElement(PathDeclaredElement.CURRENT_DIR_NAME, psiServices, basePath);
                    break;

                case PathDeclaredElement.LEVEL_UP_NAME:
                    target = new PathDeclaredElement(PathDeclaredElement.LEVEL_UP_NAME, psiServices, basePath.Directory);
                    break;

                case PathDeclaredElement.ROOT_NAME:
                    if (qualifier != null)
                    {
                        goto default;
                    }
                    target = new PathDeclaredElement(PathDeclaredElement.ROOT_NAME, psiServices, websiteRoot);
                    break;

                default:
                    try
                    {
                        string parserGenOutputBase =
                            propertiesSearcher.GetProjectPropertyByName(pathReference.GetTreeNode().GetProject(), "ParserGenOutputBase");
                        FileSystemPath path = basePath.Combine(parserGenOutputBase + "\\" + name);
                        target = new PathDeclaredElement(name, psiServices, path);
                    }
                    catch (InvalidPathException)
                    {
                    }
                    catch (ArgumentException)
                    {
                    }
                    break;
                }
                var table = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null);
                if (target != null)
                {
                    table.AddSymbol(target, EmptySubstitution.INSTANCE, 1);
                }
                return(table);
            }

            FileSystemPath rootPath              = (qualifier == null) ? websiteRoot : FileSystemPath.Empty;
            ISymbolTable   symbolTableByPath     = PathReferenceUtil.GetSymbolTableByPath(basePath, psiServices, basePath.Directory, rootPath, true);
            FileSystemPath basePathBeforeMapping = GetBasePathBeforeMapping(pathReference);

            if (!basePathBeforeMapping.IsNullOrEmpty())
            {
                IWebProjectPathMapping pathMapping = WebPathMappingManager.GetPathMapping(pathReference);
                List <FileSystemPath>  mappedPaths = pathMapping.GetAllPathPartsIn(basePathBeforeMapping).ToList();
                if (mappedPaths.Any())
                {
                    var mappedPathsTable = new SymbolTable(psiServices, folderQualifierInfo != null ? new SymbolTableDependencySet(folderQualifierInfo) : null);
                    foreach (FileSystemPath mappedPath in mappedPaths)
                    {
                        var declaredElement = new PathDeclaredElement(psiServices, mappedPath);
                        mappedPathsTable.AddSymbol(declaredElement, EmptySubstitution.INSTANCE, 1);
                    }
                    symbolTableByPath = symbolTableByPath.Merge(mappedPathsTable);
                }
            }

            if (!includeHttpHandlers)
            {
                return(symbolTableByPath);
            }

            var httpHandlersTable = new SymbolTable(psiServices);

            return(httpHandlersTable.Merge(symbolTableByPath));
        }