Skip to content

Commit

Permalink
1105 fixes after a CR
Browse files Browse the repository at this point in the history
  • Loading branch information
SilinMykola committed Jul 1, 2022
1 parent 26b4206 commit 0021f42
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
import com.magento.idea.magento2plugin.magento.files.GraphQLSchema;
import com.magento.idea.magento2plugin.magento.files.SchemaGraphQLsFile;
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
Expand All @@ -25,7 +25,7 @@ public class NewGraphQLSchemaAction extends AbstractContextAction {
* New schema.graphqls file action constructor.
*/
public NewGraphQLSchemaAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, GraphQLSchema.getInstance());
super(ACTION_NAME, ACTION_DESCRIPTION, SchemaGraphQLsFile.getInstance());
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
import com.magento.idea.magento2plugin.magento.files.GraphQLSchema;
import com.magento.idea.magento2plugin.magento.files.ModuleFileInterface;
import com.magento.idea.magento2plugin.magento.files.SchemaGraphQLsFile;
import com.magento.idea.magento2plugin.magento.packages.Areas;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.util.magento.FileBasedIndexUtil;
Expand Down Expand Up @@ -44,7 +44,7 @@ public PsiFile execute(final String actionName, final String moduleName) {
new FileFromTemplateGenerator(project);
parentDirectory = directoryGenerator
.findOrCreateSubdirectory(parentDirectory, Package.moduleBaseAreaDir);
final GraphQLSchema graphQlSchemaFile = GraphQLSchema.getInstance();
final SchemaGraphQLsFile graphQlSchemaFile = SchemaGraphQLsFile.getInstance();
PsiFile graphQlSchema = FileBasedIndexUtil.findModuleConfigFile(
graphQlSchemaFile.getFileName(),
Areas.getAreaByString(Areas.base.name()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
package com.magento.idea.magento2plugin.magento.files;

import com.intellij.lang.Language;
import com.jetbrains.php.lang.PhpLanguage;
import com.intellij.lang.jsgraphql.GraphQLLanguage;

public class GraphQLSchema implements ModuleFileInterface {
public class SchemaGraphQLsFile implements ModuleFileInterface {

public static final String FILE_NAME = "schema.graphqls";

public static final String TEMPLATE = "Magento GraphQL Schema";
private static final GraphQLSchema INSTANCE = new GraphQLSchema();
private static final SchemaGraphQLsFile INSTANCE = new SchemaGraphQLsFile();

public static GraphQLSchema getInstance() {
public static SchemaGraphQLsFile getInstance() {
return INSTANCE;
}

Expand All @@ -31,6 +31,6 @@ public String getTemplate() {

@Override
public Language getLanguage() {
return PhpLanguage.INSTANCE;
return GraphQLLanguage.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.inspections.graphqls;

import com.magento.idea.magento2plugin.magento.files.GraphQLSchema;
import com.magento.idea.magento2plugin.magento.files.SchemaGraphQLsFile;

public class SchemaResolverInspectionTest extends InspectionGraphqlsFixtureTestCase {

Expand All @@ -22,24 +23,36 @@ protected boolean isWriteActionRequired() {
return false;
}

/**
* Inspection with valid schema resolver.
*/
public void testWithValidSchemaResolverInterface() throws Exception {
myFixture.configureByFile(getFixturePath(GraphQLSchema.FILE_NAME));
myFixture.configureByFile(getFixturePath(SchemaGraphQLsFile.FILE_NAME));
assertHasNoHighlighting(errorMessage);
}

/**
* Inspection with invalid schema resolver.
*/
public void testWithInvalidSchemaResolverInterface() throws Exception {
myFixture.configureByFile(getFixturePath(GraphQLSchema.FILE_NAME));
myFixture.configureByFile(getFixturePath(SchemaGraphQLsFile.FILE_NAME));
assertHasHighlighting(errorMessage);
}

/**
* Inspection with valid batch resolver.
*/
public void testWithValidBatchResolverInterface() throws Exception {
myFixture.configureByFile(getFixturePath(GraphQLSchema.FILE_NAME));
myFixture.configureByFile(getFixturePath(SchemaGraphQLsFile.FILE_NAME));

assertHasNoHighlighting(errorMessage);
}

/**
* Inspection with valid batch service contract resolver.
*/
public void testWithValidBatchServiceContractResolverInterface() throws Exception {
myFixture.configureByFile(getFixturePath(GraphQLSchema.FILE_NAME));
myFixture.configureByFile(getFixturePath(SchemaGraphQLsFile.FILE_NAME));

assertHasNoHighlighting(errorMessage);
}
Expand Down

0 comments on commit 0021f42

Please sign in to comment.