/// <summary>
        /// Given the location information for a declared symbol,
        /// as well as the position of the declaration within which the symbol is declared,
        /// returns the zero-based line and character index indicating the position of the symbol in the file.
        /// Returns null if the given object is not compatible with the position information generated by this CompilationBuilder.
        /// </summary>
        public static Position SymbolPosition(QsLocation rootLocation, QsNullable <Position> symbolPosition, Range symbolRange)
        {
            // the position offset is set to null (only) for variables defined in the declaration
            var offset = symbolPosition.IsNull ? rootLocation.Offset : rootLocation.Offset + symbolPosition.Item;

            return(offset + symbolRange.Start);
        }
 public Location(string source, Position declOffset, QsLocation stmLoc, Range range)
 {
     this.SourceFile                = source;
     this.DeclarationOffset         = declOffset;
     this.RelativeStatementLocation = stmLoc;
     this.SymbolRange               = range;
 }
Esempio n. 3
0
 public Location(NonNullable <string> source, QsLocation rootLoc, QsLocation stmLoc, Tuple <QsPositionInfo, QsPositionInfo> range)
 {
     this.SourceFile      = source;
     this.RootNode        = rootLoc ?? throw new ArgumentNullException(nameof(rootLoc));
     this.StatementOffset = stmLoc ?? throw new ArgumentNullException(nameof(stmLoc));
     this.SymbolRange     = range ?? throw new ArgumentNullException(nameof(range));
 }
 public Location(NonNullable <string> source, Tuple <int, int> declOffset, QsLocation stmLoc, Tuple <QsPositionInfo, QsPositionInfo> range)
 {
     this.SourceFile                = source;
     this.DeclarationOffset         = declOffset ?? throw new ArgumentNullException(nameof(declOffset));
     this.RelativeStatementLocation = stmLoc ?? throw new ArgumentNullException(nameof(stmLoc));
     this.SymbolRange               = range ?? throw new ArgumentNullException(nameof(range));
 }
 internal TransformationState(Func <Identifier, bool> trackId,
                              QsLocation defaultOffset = null, IImmutableSet <NonNullable <string> > limitToSourceFiles = null)
 {
     this.TrackIdentifier     = trackId ?? throw new ArgumentNullException(nameof(trackId));
     this.RelevantSourseFiles = limitToSourceFiles;
     this.Locations           = ImmutableHashSet <Location> .Empty;
     this.DefaultOffset       = defaultOffset;
 }
Esempio n. 6
0
        /// <summary>
        /// Given the location information for a declared symbol,
        /// as well as the position of the declaration within which the symbol is declared,
        /// returns the zero-based line and character index indicating the position of the symbol in the file.
        /// Returns null if the given object is not compatible with the position information generated by this CompilationBuilder.
        /// </summary>
        public static Tuple <int, int> SymbolPosition(QsLocation rootLocation, QsNullable <Tuple <int, int> > symbolPosition, Tuple <QsPositionInfo, QsPositionInfo> symbolRange)
        {
            var offset = symbolPosition.IsNull // the position offset is set to null (only) for variables defined in the declaration
                ? DeclarationPosition(rootLocation)
                : StatementPosition(rootLocation.Offset, symbolPosition.Item);

            return(DeclarationPosition(GetAbsolutePosition(new Position(offset.Item1, offset.Item2), symbolRange.Item1)));
        }
Esempio n. 7
0
 /// <summary>
 /// Given the location of a callable, type or specialization declaration,
 /// returns the zero-based line and character index indicating the position of the declaration in the file.
 /// </summary>
 public static Tuple <int, int> DeclarationPosition(QsLocation location) => DeclarationPosition(AsPosition(location.Offset));
Esempio n. 8
0
 /// <summary>
 /// Given the position of the specialization declaration to whose implementation the statement belongs,
 /// and the position of the statement within the implementation,
 /// returns the zero-based line and character index indicating the position of the statement in the file.
 /// Returns null if either one of the given objects is not compatible with the position information generated by this CompilationBuilder.
 /// </summary>
 public static Tuple <int, int> StatementPosition(QsLocation rootLocation, QsLocation statementLocation) =>
 StatementPosition(rootLocation.Offset, statementLocation.Offset);
Esempio n. 9
0
 public IdentifierReferences(QsQualifiedName idName, QsLocation defaultOffset, IImmutableSet <NonNullable <string> > limitToSourceFiles = null) :
     base(new IdentifierLocation(idName, defaultOffset))
 {
     this.IdentifierName      = idName ?? throw new ArgumentNullException(nameof(idName));
     this.RelevantSourseFiles = limitToSourceFiles;
 }
Esempio n. 10
0
        // static methods for convenience

        public static IEnumerable <Location> Find(QsQualifiedName idName, QsNamespace ns, QsLocation defaultOffset,
                                                  out Tuple <NonNullable <string>, QsLocation> declarationLocation, IImmutableSet <NonNullable <string> > limitToSourceFiles = null)
        {
            var finder = new IdentifierReferences(idName, defaultOffset, limitToSourceFiles);

            finder.Transform(ns ?? throw new ArgumentNullException(nameof(ns)));
            declarationLocation = finder.DeclarationLocation;
            return(finder.Locations);
        }
Esempio n. 11
0
 public override QsLocation onLocation(QsLocation l)
 {
     this._Scope.SetRootLocation(l);
     return(base.onLocation(l));
 }
Esempio n. 12
0
 private static Tuple <int, int> StatementPosition(QsLocation rootLocation, Position statementPos) =>
 DeclarationPosition(AsPosition(rootLocation.Offset).Add(statementPos));
Esempio n. 13
0
 public override QsLocation onLocation(QsLocation l)
 {
     this._Scope.DeclarationOffset = l.Offset;
     return(l);
 }