Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed unknown block or directive error #45

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

mofantor
Copy link
Contributor

  • Added WithSkipValidBlocks option to skip valid sub-directives in blocks
  • Skip valid blocks by default (e.g., types, map)

* Added WithSkipValidBlocks option to skip valid sub-directives in blocks
* Skip valid blocks by default (e.g., types, map)
@tufanbarisyildirim
Copy link
Owner

omg I love it! Thanks @mofantor

@@ -194,7 +204,7 @@ func (p *Parser) Parse() (*gonginx.Config, error) {
}

// ParseBlock parse a block statement
func (p *Parser) parseBlock(inBlock bool) (*gonginx.Block, error) {
func (p *Parser) parseBlock(inBlock bool, isSkipValidDirective bool) (*gonginx.Block, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mofantor I like the solution here, do you think you can pass the all options (for the future when we need to check more options recursively) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not, and if we need to check more options ,we should use options collection to pass and validate( for future)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tufanbarisyildirim I have just finished two tasks in the project and I am ready to submit PR. If you are interested, you can come to the project and have a look。

  • move any context wrapper into their own file (remove from parser)
  • link the parent directive to any directive for easier manipulation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I already saw them, would love to see they are merging here! I will allocate some more time to go over today.

map
`

var SkipValidBlocks map[string]struct{} = map[string]struct{}{}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write a small comment here to make the linter happy? @mofantor

package parser

import "strings"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// skipValidBlocks defines a list of valid blocks to be skipped during initialization.
// This string is split by newline characters, with each trimmed block name added to the SkipValidBlocks mapping.

map
`

var SkipValidBlocks map[string]struct{} = map[string]struct{}{}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// SkipValidBlocks is a mapping used to store names of valid blocks that should be skipped.
// An empty struct is used as the value type to occupy minimal space, serving only as a presence indicator

@tufanbarisyildirim tufanbarisyildirim merged commit 548f7d6 into tufanbarisyildirim:master Apr 19, 2024
1 check passed
@mofantor mofantor deleted the fix/#42#43#44 branch April 19, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants