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 Handle Nested Language Support #6066

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Naveenaidu
Copy link
Member

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Checklist

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    individually.
    It is not sufficient to have "fixup commits" on your PR,
    our bot will still report the issues for the previous commit.) You will
    likely receive a lot of bot comments and build failures if coala does not
    pass on every single commit!

After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.

Please consider helping us by reviewing other peoples pull requests as well:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@Naveenaidu
Copy link
Member Author

Naveenaidu commented Aug 22, 2019

A preview of the working https://asciinema.org/a/263844

We have a test coverage of 100% 🎉
But Travis fails in coala --non-interactive since it's not able to find the modules such as coalib.nested that has been added in this PR

@Naveenaidu Naveenaidu force-pushed the add-handle-nested-languages-support branch from b51694a to 9cebbf6 Compare August 22, 2019 17:57
@virresh
Copy link
Member

virresh commented Aug 25, 2019

But Travis fails in coala --non-interactive since it's not able to find the modules such as coalib.nested that has been added in this PR

You forgot to make __init__.py inside nestedlib, due to which find packages cannot find it when building wheels for it. Even though python3 doesn't mandate you to make a init for declaring a folder as a package
https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages

@Naveenaidu Naveenaidu force-pushed the add-handle-nested-languages-support branch 12 times, most recently from 0e7b9a9 to c4e4d5a Compare August 26, 2019 04:01
@Naveenaidu
Copy link
Member Author

Naveenaidu commented Aug 26, 2019

But Travis fails in coala --non-interactive since it's not able to find the modules such as coalib.nested that has been added in this PR

You forgot to make __init__.py inside nestedlib, due to which find packages cannot find it when building wheels for it. Even though python3 doesn't mandate you to make a init for declaring a folder as a package
https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages

Doneee! Made the required changes. We now have 100% coverage on Travis 🎊

I'll work on rearranging the commits so that we have 100% on ever commit level.

@Naveenaidu Naveenaidu force-pushed the add-handle-nested-languages-support branch from c4e4d5a to da2b449 Compare August 26, 2019 06:22
This PR adds the NlSectionPosition class.
NlSectionPosition class is a derived class of TextRange.
It gives finer control to set the position. These include
the line number and column number.

This is a derived class of TextPosition Object.
This PR adds the class NlSection.

In Nested Language mode, we divide the original file
into various sections. These sections are called as
`pure language sections` and `mixed language` sections.

NlSection helps us to define these sections and also
maitain the information of the start and the end position
of these sections in the original file. This information
helps us while linting.

This has an similar implementation to that of the SourceRange
of coala which is used to store the information about the
affected code.

This PR also has the tests for NlSection.
Regex module is used in PyJinjaParser to
extract the NlSections. Hence adding this
in the test-requirement.txt
Regex module is used by PyJinjaParser.
This PR adds the Parser class.

Parsers are used to seperate a nested language file into
various nested language sections. Parser eats up the files
and spits out a list of NlSection objects that is used to
identify which part of the file has which language.

This is a Base Class for all the parsers that would henceforth
parse nested language files.
This PR adds an Parser that can parse through a nested
language file which is made up of the combination of
python and jinja2 and gives out a list of NlSection
Objects.
This PR, adds the arguments that will be needed to
run coala in Nested language mode.

The new arguments added are:
1. `--handle-nested`: Used to specify the nl mode
2. '--language1: Tells about the languages present in nl file
Add PEP8TestBear and Jinja2TestBear for running the
tests on NestedLanguage files
@Naveenaidu Naveenaidu force-pushed the add-handle-nested-languages-support branch 2 times, most recently from c5cacc0 to 5cfb344 Compare August 26, 2019 07:08
NlInfoExtractor is used to extract the information from
the arguments provide when running coala in nested language
mode. It extracts information such:

1. Name of languages
2. Mapping of language with it's temporary files,
3. Mapping of bear with the languages
4. Mapping of orig_files and the temporary languages

NlInfoExtractor also converts the arg_list provided into args
that coala can use.
This PR adds the NlFileHandler.

NlFileHandler is reponsible to create the file dicts
of the segreagted pure language. It is also used to
preprocess the nl_file_dicts to add the position markers
to the nl_file_dicts to mark the position of sections
in the file.
This PR adds the NlCliParsing.

NlCliParsing is used to parse the cli arguments and use
the information to create cli_sections just like coala
does when it receives arguments from CLI
This PR adds NlCore

NlCore is the main core of the entire Nested language
Architecture. This is the class with with the coala
interacts with, to access an functions of Nested language.

This is responsible for creating coala_nl_sections and
writing the selected patches by the user to the original
file.

The coverage was failing for `test_apply_patches_to_nl_file` because
shutil was not being to find the file. This PR mocks the
`write_patches_to_orig_nl_file` function of NlCore.
This PR adds the support for nested language mode.
The patches selected by the user in nested language
mode is now passed onto NlCore to replace the old
content of the original nested language file with
the patched version.

coalaTest - Add tests for Nl Mode
This PR adds the support for nested languages mode in
ConsoleInteraction.py. The function have been updated
to pass the nl_file_dict where the patches chosen by
the user will be applied.

We have also disabled printing the affected files in
Nested Language Mode, since we do not physically have
these files in the system.
This PR adds the support for nested language mode. It
allows creation of new nl_sections when the Nested language
mode is run.

During the execution of instantiate_processes, we get the
file_dict of the temporary files from the nested lang parsers
instead of fetching it from the physical file.
This PR adds the support for the nested Language mode
in Configuration Gathering. Parse the cli arguments passed
to coala in Nested language mode and create coala sections.
The ResultAction and the various actions for result
is updated to support Nested Language mode. The API
calls have been updates with an extra argument called
as `nl_file_dict`. It is to this dicitionary that the
result actions will be applying the changes that the
user decides to apply
@Naveenaidu Naveenaidu force-pushed the add-handle-nested-languages-support branch from 5cfb344 to 38c4552 Compare August 26, 2019 07:12
@abhishalya
Copy link
Member

@Naveenaidu Its probably too difficult to review this PR. But if the CI passes and your mentors approve this PR, I'm happy to merge. I just think that the GSoC contributions should be considered and counted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants