Skip to content

Interactions #114

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

Merged
merged 6 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'idea'
id 'java'
id "org.jetbrains.intellij" version "0.3.12"
id 'net.researchgate.release' version '2.6.0'
id "org.jetbrains.intellij" version "0.4.8"
id 'net.researchgate.release' version '2.8.0'
}

apply plugin: 'idea'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

public interface GraphEntity {
public interface GraphEntity extends NoIdGraphEntity {

String getId();

Expand All @@ -12,7 +12,4 @@ public interface GraphEntity {

String getTypesName();

boolean isTypesSingle();

String getRepresentation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

import java.util.List;

public interface GraphPath {
public interface GraphPath extends NoIdGraphEntity {

/**
* Return nodes and relationships.
*/
List<Object> getComponents();

default boolean isTypesSingle() {
return true;
}

default String getRepresentation() {
return "Path";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.neueda.jetbrains.plugin.graphdb.database.api.data;

public interface NoIdGraphEntity {

boolean isTypesSingle();

String getRepresentation();

}
1 change: 1 addition & 0 deletions database/neo4j/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dependencies {
compile project(':database:api')
compile "org.neo4j.driver:neo4j-java-driver:$versionNeo4jJavaBoltDriver"
compile("com.fasterxml.jackson.core:jackson-annotations:$versionJacksonMapper")
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
version=2.5.6

# Intellij SDK
intellijSdkVersion=2018.3
intellijSdkVersion=2019.1.1

# Versions
versionJunit=4.12
versionAssertj=3.8.0
versionMockito=2.10.0
versionNeo4jJavaBoltDriver=1.6.3
versionAssertj=3.12.2
versionMockito=2.27.0
versionNeo4jJavaBoltDriver=1.6.4
versionPrefuse=1.0.0
versionGoogleAnalytics=1.1.2
versionJacksonMapper=2.8.6
versionJacksonMapper=2.9.8

# Performance
org.gradle.jvmargs=-Xmx512m
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@
icon="/actions/refresh.png"
description="Clean canvas">
</action>
<action id="GraphDatabaseConsoleToolWindowActions.CopyQueryOutput"
class="com.neueda.jetbrains.plugin.graphdb.jetbrains.actions.ui.console.CopyQueryOutputAction"
text="Copy query result to clipboard"
icon="/actions/copy.png"
description="Copy query result to clipboard">
</action>
</group>

<group id="GraphDatabaseFileActions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ default boolean isAssignableTo(CypherType t) {
return true;
}

if (this instanceof CypherList && t instanceof CypherList) {
return true;
}

return false;
return this instanceof CypherList && t instanceof CypherList;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public final class ProceduresCompletionProvider extends BaseCompletionProvider {
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
withCypherMetadataProvider(parameters, (metadataProvider -> {
metadataProvider.getProcedures().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement);
}));
withCypherMetadataProvider(parameters, (metadataProvider -> metadataProvider.getProcedures().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public final class PropertyKeyCompletionProvider extends BaseCompletionProvider
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
withCypherMetadataProvider(parameters, (metadataProvider -> {
metadataProvider.getPropertyKeys().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement);
}));
withCypherMetadataProvider(parameters, (metadataProvider -> metadataProvider.getPropertyKeys().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public final class RelationshipTypeCompletionProvider extends BaseCompletionProv
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
withCypherMetadataProvider(parameters, (metadataProvider -> {
metadataProvider.getRelationshipTypes().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement);
}));
withCypherMetadataProvider(parameters, (metadataProvider -> metadataProvider.getRelationshipTypes().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ public class UserFunctionsCompletionProvider extends BaseCompletionProvider {

@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
withCypherMetadataProvider(parameters, (metadataProvider -> {
metadataProvider.getUserFunctions().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement);
}));
withCypherMetadataProvider(parameters, (metadataProvider -> metadataProvider.getUserFunctions().stream()
.map(CypherElement::getLookupElement)
.forEach(result::addElement)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ public String generateDoc(PsiElement element, @Nullable PsiElement originalEleme
}

Optional<String> userFunctionDocumentation = userFunctionDocumentation(element);
if (userFunctionDocumentation.isPresent()) {
return userFunctionDocumentation.get();
}
return userFunctionDocumentation.orElse(null);

return null;
}

private Optional<String> builtInFunctionDocumentation(PsiElement element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CypherParameterInfoHandler
@Override
@SuppressWarnings("unchecked")
public PsiElement[] getActualParameters(@NotNull CypherInvocation o) {
return ArrayUtil.toObjectArray((List) o.arguments(), PsiElement.class);
return ArrayUtil.toObjectArray(o.arguments(), PsiElement.class);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ default List<InvokableInformation> resolve() {
if (this instanceof CypherProcedureInvocation) {
svc.findProcedure(getFullName())
.map(CypherProcedureElement::getInvokableInformation)
.ifPresent(info -> matchedInvocations.add(info));
.ifPresent(matchedInvocations::add);
return matchedInvocations;
}

Expand All @@ -74,7 +74,7 @@ default List<InvokableInformation> resolve() {
if (matchedInvocations.isEmpty()) {
svc.findUserFunction(getFullName())
.map(CypherUserFunctionElement::getInvokableInformation)
.ifPresent(info -> matchedInvocations.add(info));
.ifPresent(matchedInvocations::add);
}
return matchedInvocations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* TODO: Description
Expand Down Expand Up @@ -56,7 +53,7 @@ protected <T extends CypherNamedElement> Collection<T> uniqueVariants(List<T> da
Map<String, T> variants = new HashMap<>();

data.stream()
.filter(element -> element != null)
.filter(Objects::nonNull)
.forEach(element -> {
String name = element.getName();
if (name != null && name.length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar)
}

private void register(PsiReferenceRegistrar registrar,
@NotNull ElementPattern pattern,
@NotNull ElementPattern<PsiElement> pattern,
CypherReferenceContributionPriority contributionPriority,
ReferenceFactory referenceFactory) {
registrar.registerReferenceProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.neueda.jetbrains.plugin.graphdb.language.cypher.inspections.CypherFunctionCallInspection;
import com.neueda.jetbrains.plugin.graphdb.test.integration.neo4j.tests.cypher.util.BaseInspectionTest;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -125,7 +126,7 @@ private void generateTypeCompatibilityTests(String query, String expected, List<

public void testStringTypeCheck() {
String query = "MATCH p=(n)-[r]-() RETURN ltrim(%s)";
generateTypeCompatibilityTests(query, "STRING", asList("STRING"));
generateTypeCompatibilityTests(query, "STRING", Collections.singletonList("STRING"));
}

public void testNullableStringTypeCheck() {
Expand All @@ -145,7 +146,7 @@ public void testNullableNumberTypeCheck() {

public void testIntegerTypeCheck() {
String query = "MATCH p=(n)-[r]-() RETURN substring(\"a\", %s)";
generateTypeCompatibilityTests(query, "INTEGER", asList("INTEGER"));
generateTypeCompatibilityTests(query, "INTEGER", Collections.singletonList("INTEGER"));
}

public void testNullableIntegerTypeCheck() {
Expand All @@ -155,7 +156,7 @@ public void testNullableIntegerTypeCheck() {

public void testBooleanTypeCheck() {
String query = "MATCH p=(n)-[r]-() CALL test.bool(%s) RETURN p";
generateTypeCompatibilityTests(query, "BOOLEAN", asList("BOOLEAN"));
generateTypeCompatibilityTests(query, "BOOLEAN", Collections.singletonList("BOOLEAN"));
}

public void testNullableBooleanTypeCheck() {
Expand All @@ -175,17 +176,17 @@ public void testNullableFloatTypeCheck() {

public void testPathTypeCheck() {
String query = "MATCH p=(n)-[r]-() RETURN ufrpath(%s)";
generateTypeCompatibilityTests(query, "PATH", asList("PATH"));
generateTypeCompatibilityTests(query, "PATH", Collections.singletonList("PATH"));
}

public void testNodeTypeCheck() {
String query = "MATCH p=(n)-[r]-() RETURN ufrnode(%s)";
generateTypeCompatibilityTests(query, "NODE", asList("NODE"));
generateTypeCompatibilityTests(query, "NODE", Collections.singletonList("NODE"));
}

public void testRelationshipTypeCheck() {
String query = "MATCH p=(n)-[r]-() RETURN ufrrel(%s)";
generateTypeCompatibilityTests(query, "RELATIONSHIP", asList("RELATIONSHIP"));
generateTypeCompatibilityTests(query, "RELATIONSHIP", Collections.singletonList("RELATIONSHIP"));
}

public void testSizeArray() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TestSimpleGraph {
public static void main(String[] argv) {
PrefuseVisualization v = new PrefuseVisualization(new IdeaLookAndFeelService());

Map<String, String> config = new HashMap<String, String>();
Map<String, String> config = new HashMap<>();
config.put(Neo4jBoltConfiguration.HOST, "localhost");
// config.put(Neo4jBoltConfiguration.PASSWORD)
// config.put(Neo4jBoltConfiguration.PORT)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.neueda.jetbrains.plugin.graphdb.jetbrains.actions.ui.console;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.MessageBus;
import com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.console.event.CopyQueryOutputEvent;
import org.jetbrains.annotations.NotNull;

public class CopyQueryOutputAction extends AnAction {

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = getEventProject(e);

if (project == null) {
return;
}

MessageBus messageBus = project.getMessageBus();
messageBus.syncPublisher(CopyQueryOutputEvent.COPY_QUERY_OUTPUT_TOPIC).copyQueryOutputToClipboard();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public DiffService(Project project) {
}

public void updateNode(DataSourceApi api, GraphEntity oldNode, GraphEntity newNode) {
StringBuilder sb = new StringBuilder("MATCH (n) WHERE ID(n) = $id ")
.append(diffLabels(oldNode.getTypes(), newNode.getTypes()))
.append(" SET n = $props")
.append(" RETURN n");

service.executeQuery(api, new ExecuteQueryPayload(sb.toString(),
String query = "MATCH (n) WHERE ID(n) = $id " +
diffLabels(oldNode.getTypes(), newNode.getTypes()) +
" SET n = $props" +
" RETURN n";
service.executeQuery(api, new ExecuteQueryPayload(query,
ImmutableMap.of(
"id", Long.parseLong(oldNode.getId()),
"props", newNode.getPropertyContainer().getProperties()),
Expand All @@ -35,11 +35,11 @@ public void updateNode(DataSourceApi api, GraphEntity oldNode, GraphEntity newNo

public void updateRelationShip(DataSourceApi api, GraphEntity relationship,
GraphEntity updatedRel) {
StringBuilder sb = new StringBuilder("MATCH ()-[n]->() WHERE ID(n) = $id ")
.append(" SET n = $props")
.append(" RETURN n");

service.executeQuery(api, new ExecuteQueryPayload(sb.toString(),
String query = "MATCH ()-[n]->() WHERE ID(n) = $id " +
" SET n = $props" +
" RETURN n";
service.executeQuery(api, new ExecuteQueryPayload(query,
ImmutableMap.of(
"id", Long.parseLong(relationship.getId()),
"props", updatedRel.getPropertyContainer().getProperties()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.neueda.jetbrains.plugin.graphdb.jetbrains.ui.console.event;

import com.intellij.util.messages.Topic;

public interface CopyQueryOutputEvent {

Topic<CopyQueryOutputEvent> COPY_QUERY_OUTPUT_TOPIC = Topic.create("GraphDatabaseConsole.CopyQueryOutputTopic", CopyQueryOutputEvent.class);

void copyQueryOutputToClipboard();
}
Loading