Skip to content

Commit

Permalink
fix empty tip for methods with no parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rusbob committed Oct 5, 2017
1 parent 295dcc0 commit 0e5e98a
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -55,7 +55,7 @@ Temporary Items
## Plugin-specific files:

# IntelliJ
/out/
**/out/

# mpeltonen/sbt-idea plugin
.idea_modules/
Expand Down Expand Up @@ -97,4 +97,4 @@ idea-flex.skeleton
/book-dev
/_book
/.ideaDataSources
/dataSources
/dataSources
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ Graph Database support plugin allows you to work with databases without leaving
- Bugs, questions, suggestions - [Issue tracker](https://github.com/neueda/jetbrains-plugin-graph-database-support/issues)
- [Documentation](https://neueda.gitbooks.io/jetbrains-plugin-graph-database-support/content)

Plugin is developed and supported by [Neueda R&D](http://neueda.lv/).
Plugin is developed and supported by [Neueda R&D](http://labs.neueda.com/).

![plugin screenshot](docs/screenshots/plugin.png)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'idea'
id 'java'
id "org.jetbrains.intellij" version "0.1.10"
id 'net.researchgate.release' version '2.4.0'
id 'net.researchgate.release' version '2.6.0'
}

apply plugin: 'idea'
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Expand Up @@ -6,7 +6,7 @@ Graph Database support plugin allows you to work with databases without leaving
- Bugs, questions, suggestions - [Issue tracker](https://github.com/neueda/jetbrains-plugin-graph-database-support/issues)
- [Documentation](https://neueda.gitbooks.io/jetbrains-plugin-graph-database-support/content)

Plugin is developed and supported by [Neueda R&D](http://neueda.lv/).
Plugin is developed and supported by [Neueda R&D](http://labs.neueda.com/).

![plugin screenshot](screenshots/plugin.png)

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
@@ -1,12 +1,12 @@
version=2.5.1-SNAPSHOT

# Intellij SDK
intellijSdkVersion=2016.3
intellijSdkVersion=2017.2.2

# Versions
versionJunit=4.12
versionAssertj=3.4.1
versionMockito=1.10.19
versionAssertj=3.8.0
versionMockito=2.10.0
versionNeo4jJavaBoltDriver=1.1.0
versionPrefuse=1.0.0
versionGoogleAnalytics=1.1.2
Expand Down
@@ -1,10 +1,16 @@
package com.neueda.jetbrains.plugin.graphdb.language.cypher.editor;

import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.lang.parameterInfo.*;
import com.intellij.lang.parameterInfo.CreateParameterInfoContext;
import com.intellij.lang.parameterInfo.ParameterInfoContext;
import com.intellij.lang.parameterInfo.ParameterInfoHandlerWithTabActionSupport;
import com.intellij.lang.parameterInfo.ParameterInfoUIContext;
import com.intellij.lang.parameterInfo.ParameterInfoUtils;
import com.intellij.lang.parameterInfo.UpdateParameterInfoContext;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.JBColor;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.neueda.jetbrains.plugin.graphdb.language.cypher.completion.metadata.elements.InvokableInformation;
Expand Down Expand Up @@ -133,10 +139,15 @@ public String getPresentation(CypherInvocation ci, @NotNull ParameterInfoUIConte

int current = context.getCurrentParameterIndex();


if (signature == null || Objects.equals(signature, "()")) {
context.setUIComponentEnabled(false);
return null;
int start = 0;
int end = 0;
if (signature == null) {
String message = "unknown parameters";
return context.setupUIComponentPresentation(message, start, end, false, false, false, JBColor.RED);
}
if (Objects.equals(signature, "()")) {
String message = "no parameters";
return context.setupUIComponentPresentation(message, start, end, false, false, false, JBColor.RED);
}

String stripped = signature.substring(1, signature.length() - 1) + ",";
Expand Down
Expand Up @@ -7,28 +7,28 @@
public class CypherProcedureElementTest {

@Test
public void testEmptySignatureAndVoidReturnType() throws Exception {
public void testEmptySignatureAndVoidReturnType() {
CypherProcedureElement element = element("namespace.name", "namespace.name() :: VOID");
assertThat(element.getInvokableInformation().getSignature()).isEqualTo("()");
assertThat(element.getInvokableInformation().getReturnTypeString()).isEqualTo("VOID");
}

@Test
public void testNonEmptySignatureAndVoidReturnType() throws Exception {
public void testNonEmptySignatureAndVoidReturnType() {
CypherProcedureElement element = element("namespace.name", "namespace.name(node :: NODE?) :: VOID");
assertThat(element.getInvokableInformation().getSignature()).isEqualTo("(node :: NODE?)");
assertThat(element.getInvokableInformation().getReturnTypeString()).isEqualTo("VOID");
}

@Test
public void testEmptySignatureAndValueReturnType() throws Exception {
public void testEmptySignatureAndValueReturnType() {
CypherProcedureElement element = element("namespace.name", "namespace.name() :: (value :: STRING?)");
assertThat(element.getInvokableInformation().getSignature()).isEqualTo("()");
assertThat(element.getInvokableInformation().getReturnTypeString()).isEqualTo("value :: STRING?");
}

@Test
public void testNonSignatureAndValueReturnType() throws Exception {
public void testNonSignatureAndValueReturnType() {
CypherProcedureElement element = element("namespace.name", "namespace.name(node :: NODE?) :: (value :: STRING?)");
assertThat(element.getInvokableInformation().getSignature()).isEqualTo("(node :: NODE?)");
assertThat(element.getInvokableInformation().getReturnTypeString()).isEqualTo("value :: STRING?");
Expand All @@ -37,4 +37,4 @@ public void testNonSignatureAndValueReturnType() throws Exception {
private CypherProcedureElement element(String name, String signature) {
return new CypherProcedureElement(name, signature, null);
}
}
}
Expand Up @@ -5,7 +5,7 @@
public class CypherDocumentationTest {

@Test
public void testBuiltInFunctionsLoadsCorrectly() throws Exception {
public void testBuiltInFunctionsLoadsCorrectly() {
CypherDocumentation.BUILT_IN_FUNCTIONS.lookup("toString");
}
}
Expand Up @@ -79,12 +79,12 @@ public void testUserDefinedFunction() {

public void testNoParams() {
doTest("RETURN e(<caret>)",
null);
"<html>no parameters</html>");
}

public void testUnknownFunction() {
doTest("return unknown(<caret>)",
null);
"<html>unknown parameters</html>");
}

public void testSecondArgument() {
Expand Down
Expand Up @@ -119,7 +119,7 @@ private void generateTypeCompatibilityTests(String query, String expected, List<
"<error descr=\"expected " + expected + ", got " + p.first + "\">" + p.second + "</error>"));

}
deletFile();
deleteFile();
});
}

Expand Down
Expand Up @@ -29,10 +29,8 @@ protected void addDataSourceFileAndCheck(String fileContent) {
addFileAndCheck(fileName, fileContent);
}

protected void deletFile() {
ApplicationManager.getApplication().runWriteAction(() -> {
myFixture.getFile().delete();
});
protected void deleteFile() {
ApplicationManager.getApplication().runWriteAction(() -> myFixture.getFile().delete());
}

protected void addUnavailableDataSourceFileAndCheck(String fileContent) {
Expand Down
@@ -1,16 +1,18 @@
package com.neueda.jetbrains.plugin.graphdb.test.integration.neo4j.tests.database.common;

import static org.assertj.core.api.Assertions.*;

import java.util.*;
import java.util.stream.Collectors;

import com.neueda.jetbrains.plugin.graphdb.jetbrains.component.datasource.metadata.DataSourceMetadata;
import com.neueda.jetbrains.plugin.graphdb.jetbrains.component.datasource.metadata.Neo4jBoltCypherDataSourceMetadata;
import com.neueda.jetbrains.plugin.graphdb.jetbrains.component.datasource.state.DataSourceApi;
import com.neueda.jetbrains.plugin.graphdb.test.integration.neo4j.data.StoredProcedure;
import com.neueda.jetbrains.plugin.graphdb.test.integration.neo4j.util.base.BaseIntegrationTest;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.neueda.jetbrains.plugin.graphdb.jetbrains.component.datasource.metadata.Neo4jBoltCypherDataSourceMetadata.STORED_PROCEDURES;
import static org.assertj.core.api.Assertions.assertThat;

@SuppressWarnings("unchecked")
public abstract class AbstractDataSourceMetadataTest extends BaseIntegrationTest {

Expand All @@ -22,14 +24,14 @@ public void setUp() throws Exception {

public abstract DataSourceApi getDataSource();

public void testMetadataExists() throws Exception {
public void testMetadataExists() {
Optional<DataSourceMetadata> metadata = component().dataSourcesMetadata().getMetadata(getDataSource());
assertThat(metadata).isPresent();
}

public void testMetadataHaveRequiredProcedures() {
DataSourceMetadata metadata = getMetadata();
List<Map<String, String>> storedProcedures = metadata.getMetadata(Neo4jBoltCypherDataSourceMetadata.STORED_PROCEDURES);
List<Map<String, String>> storedProcedures = metadata.getMetadata(STORED_PROCEDURES);

List<Map<String, String>> requiredProcedures = requiredProcedures().stream()
.map(StoredProcedure::asMap)
Expand Down

0 comments on commit 0e5e98a

Please sign in to comment.