File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3- * Changes which are in master , but not yet in a release* :
3+ * Changes which are in this source code , but not yet in a release* :
44
55* Adds equality to ` PrefixInfo ` class
66* Fixes parse error if external reference file path contains a space (` ='C:\My Dir\[file.xlsx]Sheet'!A1 ` )
7+ * Adds an option to ` ExcelFormulaParser.SkipToRelevant ` to not skip reference nodes which do not contain a prefix
78
89
910## 1.2.1
Original file line number Diff line number Diff line change @@ -376,14 +376,15 @@ public static IEnumerable<ParseTreeNode> GetReferenceNodes(this ParseTreeNode in
376376 /// <summary>
377377 /// Go to the first "relevant" child node, i.e. skips wrapper nodes
378378 /// </summary>
379+ /// <param name="skipReferencesWithoutPrefix">If true, skip all reference nodes without a prefix instead of only parentheses</param>
379380 /// <remarks>
380381 /// Skips:
381382 /// * FormulaWithEq and ArrayFormula nodes
382383 /// * Formula nodes
383384 /// * Parentheses
384385 /// * Reference nodes which are just wrappers
385386 /// </remarks>
386- public static ParseTreeNode SkipToRelevant ( this ParseTreeNode input )
387+ public static ParseTreeNode SkipToRelevant ( this ParseTreeNode input , bool skipReferencesWithoutPrefix = true )
387388 {
388389 while ( true )
389390 {
@@ -395,8 +396,6 @@ public static ParseTreeNode SkipToRelevant(this ParseTreeNode input)
395396 break ;
396397 case GrammarNames . Argument :
397398 case GrammarNames . Formula :
398- case GrammarNames . Reference :
399- // This also catches parentheses
400399 if ( input . ChildNodes . Count == 1 )
401400 {
402401 input = input . ChildNodes [ 0 ] ;
@@ -406,6 +405,18 @@ public static ParseTreeNode SkipToRelevant(this ParseTreeNode input)
406405 return input ;
407406 }
408407 break ;
408+ case GrammarNames . Reference :
409+ // Skip references which are parentheses
410+ // Skip references without a prefix (=> they only have one child node) if the option is set
411+ if ( ( skipReferencesWithoutPrefix && input . ChildNodes . Count == 1 ) || input . IsParentheses ( ) )
412+ {
413+ input = input . ChildNodes [ 0 ] ;
414+ }
415+ else
416+ {
417+ return input ;
418+ }
419+ break ;
409420 default :
410421 return input ;
411422 }
You can’t perform that action at this time.
0 commit comments