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

Add .frm and .cls extensions to VB6 #6155

Merged
merged 28 commits into from
Nov 14, 2022
Merged

Conversation

DecimalTurn
Copy link
Contributor

@DecimalTurn DecimalTurn commented Nov 4, 2022

Following up on discussions in issue #5824, I'm proposing to add .frm and .cls as extensions for VB6 with heuristics to distinguish it from VBA.

Description

The heuristics added to distinguish VBA from VB6 were suggested by @XusinboyBekchanov :

  • frm
    VBA:
    image
    VB6:
    image

  • cls
    VB6 :
    image
    VBA : If the pattern above doesn't match, we default to VBA.

The key of these are based on the way the VB6 and VBA IDEs encode information at the top of the file when exporting the forms or class module as text files. From what I know, there isn't really a good reason for developers to alter this information as this could cause issues when trying to import back the text file into their IDE. Hence, those differences should be sufficiently reliable to distinguish between VBA and VB6.

PS : Due to the way I pulled changes from master, this pull request appears to contain more commits that it really does. Commits before 2d3547 can be ignored.

Checklist:

VB6

VBA

@DecimalTurn DecimalTurn requested a review from a team as a code owner November 4, 2022 05:04
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

Why are you removing the samples/VBA/cApplication.cls sample? We don't remove samples if we can avoid it.

samples/Visual Basic 6.0/frmMain.frm is massive. Please replace it with a smaller sample.

I also recommend adding two distinct samples for each of these extensions to help the classifier in the event things slip through the heuristics.

lib/linguist/languages.yml Show resolved Hide resolved
lib/linguist/languages.yml Show resolved Hide resolved
@DecimalTurn
Copy link
Contributor Author

DecimalTurn commented Nov 4, 2022

Why are you removing the samples/VBA/cApplication.cls sample? We don't remove samples if we can avoid it.

Because this sample is a VB6 sample (based on the heuristics this PR introduced). My understanding is that in the PR #4725, where this sample was added, the intention was to put VBA and VB6 under the same language "VBA/VB6", but when it changed to just VBA, the sample for VB6 was left there by mistake.

And the reason why I didn't add it to the VB6 samples is because I couldn't find its origin on GitHub and I wanted to add a sample from a popular project such as hijackthis.

samples/Visual Basic 6.0/frmMain.frm is massive. Please replace it with a smaller sample.

Sure. Will do.

I also recommend adding two distinct samples for each of these extensions to help the classifier in the event things slip through the heuristics.

Sounds good. Should I add back cApplication.cls as a VB6 sample or should I add another one instead to avoid confusion?

@DecimalTurn
Copy link
Contributor Author

Regarding the .bas extension, I've intentionally kept it out of this PR since I'm still not sure about the heuristic for it when it's time to distinguish between VBA and VB6.

@lildude
Copy link
Member

lildude commented Nov 5, 2022

Because this sample is a VB6 sample (based on the heuristics this PR introduced). My understanding is that in the PR #4725, where this sample was added, the intention was to put VBA and VB6 under the same language "VBA/VB6", but when it changed to just VBA, the sample for VB6 was left there by mistake.

Cool. In that case, please move it rather than remove it. We've already approved its inclusion so there's no need to find the source etc.

You can still add another if it'll help the classifier which is falling on this extension.

@DecimalTurn
Copy link
Contributor Author

DecimalTurn commented Nov 9, 2022

The Classifier test didn't succeed with 100%, but it's already better:

.cls (5/6)
VBA/GridCoord.cls BAD ❌(Visual Basic 6.0)
VBA/WorkbookReporter.cls ✅
VBA/dictionary.cls ✅
Visual Basic 6.0/cApplication.cls ✅
Visual Basic 6.0/clsDataPack.cls ✅
Visual Basic 6.0/clsMenuImage.cls ✅

.frm (4/4)
VBA/frmConvert.frm ✅
VBA/stdSaveHandler.frm ✅
Visual Basic 6.0/Adjustments_BlackAndWhite.frm ✅
Visual Basic 6.0/frmProcMan.frm ✅

Considering that the heuristics should be pretty reliable, can this suffice?

@lildude
Copy link
Member

lildude commented Nov 9, 2022

The Classifier test didn't succeed with 100%, but it's already

It needs to. Try removing the sample or adding another sample.

@DecimalTurn
Copy link
Contributor Author

DecimalTurn commented Nov 9, 2022

Alright, I've switched the problematic sample with another one from the same project. Now, all the tests are passing and I updated the PR description at the top with the correct samples.
Looks like we are good to go unless there is something I missed.

@lildude lildude requested a review from Alhadis November 12, 2022 14:11
lib/linguist/heuristics.yml Outdated Show resolved Hide resolved
DecimalTurn and others added 3 commits November 12, 2022 13:14
Apply regex simplification suggested by @Alhadis

Co-authored-by: John Gardner <gardnerjohng@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants