示例#1
0
 public override bool VisitObjectProperty( int startPropertyIndex, string propertyName, int propertyIndex )
 {
     if( Path.Count == 0 )
     {
         _hasTopLevelProperties = true;
         if( propertyName == "version" )
         {
             if( _thisVersion != null ) return Matcher.SetError( "Duplicate version." );
             return GetVersionValue( startPropertyIndex, out _thisVersion );
         }
     }
     else if( _versions != null && Path[Path.Count-1].PropertyName == "dependencies" && _projectNameFinder( propertyName ) )
     {
         Matcher.MatchWhiteSpaces( 0 );
         if( Matcher.Head == '{' )
         {
             JSONVersionFinder f = new JSONVersionFinder( Matcher, null, null );
             if( f.ThisVersion == null ) return Matcher.SetError( "Property version expected." );
             CollectVersion( f.ThisVersion );
         }
         else
         {
             int start = Matcher.StartIndex;
             string version;
             if( !Matcher.TryMatchJSONQuotedString( out version ) ) return Matcher.SetError( "Version string expected." );
             VersionOccurrence v = new VersionOccurrence( version, start, Matcher.StartIndex - start, false );
             Debug.Assert( v.IsNakedVersionNumber );
             CollectVersion( v );
         }
         return true;
     }
     return base.VisitObjectProperty( startPropertyIndex, propertyName, propertyIndex );
 }
示例#2
0
        void ExtractVersions(string text)
        {
            StringMatcher     m           = new StringMatcher(text);
            var               allVersions = new List <VersionOccurrence>();
            JSONVersionFinder finder      = new JSONVersionFinder(m, _projectNameFinder, allVersions);

            _thisVersion  = finder.ThisVersion;
            _allVersions  = allVersions;
            _sameVersions = finder.SameVersions;
            _parseError   = m.ErrorMessage;
        }
示例#3
0
 public override bool VisitObjectProperty(int startPropertyIndex, string propertyName, int propertyIndex)
 {
     if (Path.Count == 0)
     {
         _hasTopLevelProperties = true;
         if (propertyName == "version")
         {
             if (_thisVersion != null)
             {
                 return(Matcher.SetError("Duplicate version."));
             }
             return(GetVersionValue(startPropertyIndex, out _thisVersion));
         }
     }
     else if (_versions != null && Path[Path.Count - 1].PropertyName == "dependencies" && _projectNameFinder(propertyName))
     {
         Matcher.MatchWhiteSpaces(0);
         if (Matcher.Head == '{')
         {
             JSONVersionFinder f = new JSONVersionFinder(Matcher, null, null);
             if (f.ThisVersion == null)
             {
                 return(Matcher.SetError("Property version expected."));
             }
             CollectVersion(f.ThisVersion);
         }
         else
         {
             int    start = Matcher.StartIndex;
             string version;
             if (!Matcher.TryMatchJSONQuotedString(out version))
             {
                 return(Matcher.SetError("Version string expected."));
             }
             VersionOccurrence v = new VersionOccurrence(version, start, Matcher.StartIndex - start, false);
             Debug.Assert(v.IsNakedVersionNumber);
             CollectVersion(v);
         }
         return(true);
     }
     return(base.VisitObjectProperty(startPropertyIndex, propertyName, propertyIndex));
 }
示例#4
0
 void ExtractVersions( string text )
 {
     StringMatcher m = new StringMatcher( text );
     var allVersions = new List<VersionOccurrence>();
     JSONVersionFinder finder = new JSONVersionFinder( m, _projectNameFinder, allVersions );
     _thisVersion = finder.ThisVersion;
     _allVersions = allVersions;
     _sameVersions = finder.SameVersions;
     _parseError = m.ErrorMessage;
 }