Skip to content
New issue

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

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

Already on GitHub? # to your account

Query params per file #107

Merged
merged 16 commits into from
Jan 22, 2019
Merged

Conversation

ex3m1024
Copy link
Contributor

Implements #91 on a basic level.
Some functionality may be added before next release, but this provides the bare minimum - two editors in Parameters tab, the second one for parameters specific to the Cypher file open right now. And a button (left column, 3rd button in Graph Database Console) to toggle between using global and file-specific parameters. File-specific params are saved in .json next to global params, a .json for each Cypher file that was opened in the editor.
Tests were modified to ensure that correct params are used when needed.

Future ideas:

  • Maximize Global parameters editor when a non-Cypher file is opened (and File-specific params editor is hidden). Requires to remember last set JBSplitter proportions to restore when needed
  • Ensure old .json files with params are deleted (how to determine that they are unneeded if, for example, the project was closed and may be reopened later? Maybe a "clean cache" button or leave as is?)
  • Hide toggle button on the left after a non-Cypher file was opened (the global/file-specific mode setting may be left as is to restore the correct setting after a Cypher file gets opened)


public class CypherParametersProviderTest extends BaseIntegrationTest {

private class TestParametersProvider implements ParametersProvider {

private String parametersJson;
private String globalParametersJson, fileSpecificParametersJson;
Copy link
Contributor

Choose a reason for hiding this comment

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

Make 2 separate fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b481123

@@ -43,13 +40,18 @@ public void registerParametersProvider(final ParametersProvider parametersProvid
}

public Map<String, Object> getParameters(PsiElement element) throws Exception {
if (!isValidParametersMap(parametersProvider.getParametersJson())) {
return Collections.emptyMap();
if (element == null) return Collections.emptyMap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use curly braces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b481123

@@ -24,11 +34,41 @@ public static VirtualFile getDataSourceFile(Project project, DataSourceApi dataS
public static VirtualFile getScratchFile(Project project, String fileName) throws IOException {
return ScratchFileService.getInstance().findFile(
ParameterRootType.getInstance(),
project.getName() + fileName,
project.getName() + "_" + fileName,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not backward compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored in b481123

ScratchFileService.Option.create_if_missing
);
}

public static String getParams(VirtualFile file) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is crazy.

Refactor to linear if statements.

Example:

if (stmnt) {
  return 
}

if (stmnt) {
  return
}

mainwork
return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b481123

@ex3m1024 ex3m1024 merged commit fda97e7 into neueda:master Jan 22, 2019
@ex3m1024 ex3m1024 deleted the query-params-per-file branch January 23, 2019 09:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants