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

Changes for 2017.3 #2912

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

version = 0.13
ideaVersion = 2016.3
ideaVersion = 2017.3
javaVersion = 1.8
javaTargetVersion = 1.8
delveVersion = 0.11.318
Expand Down
2 changes: 1 addition & 1 deletion src/com/goide/GoModuleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getDescription() {

@Nullable
@Override
public Icon getBigIcon() {
public Icon getIcon() {
return GoIcons.MODULE_ICON;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import java.util.Collection;

public class GoProjectModelConverterProvider extends ConverterProvider {
public static final String PROJECT_JDK_NAME_ATTR = "project-jdk-name"; // ProjectRootManagerImpl.PROJECT_JDK_NAME_ATTR
public static final String PROJECT_JDK_TYPE_ATTR = "project-jdk-type"; // ProjectRootManagerImpl.PROJECT_JDK_TYPE_ATTR
private static final String PROJECT_ROOT_MANAGER = "ProjectRootManager";

protected GoProjectModelConverterProvider() {
Expand Down Expand Up @@ -82,11 +84,10 @@ public ConversionProcessor<ModuleSettings> createModuleFileConverter() {
public ConversionProcessor<RunManagerSettings> createRunConfigurationsConverter() {
return new RunConfigurationsConverter();
}

@Override
public boolean isConversionNeeded() {
Element component = getProjectRootManager(context);
return component != null && isGoSdkType(component.getAttributeValue(ProjectRootManagerImpl.PROJECT_JDK_TYPE_ATTR));
return component != null && isGoSdkType(component.getAttributeValue(PROJECT_JDK_TYPE_ATTR));
}

@Override
Expand Down Expand Up @@ -148,7 +149,7 @@ private static class ProjectFileConverter extends ConversionProcessor<ProjectSet
@Override
public boolean isConversionNeeded(@NotNull ProjectSettings settings) {
Element projectRootManager = getProjectRootManager(settings.getRootElement());
return projectRootManager != null && isGoSdkType(projectRootManager.getAttributeValue(ProjectRootManagerImpl.PROJECT_JDK_TYPE_ATTR));
return projectRootManager != null && isGoSdkType(projectRootManager.getAttributeValue(PROJECT_JDK_TYPE_ATTR));
}

@Override
Expand Down Expand Up @@ -207,7 +208,7 @@ private static Element getProjectRootManager(@Nullable Element rootElement) {
}

private static void updateSdkType(@NotNull File file, @NotNull Element projectRootManager) throws CannotConvertException {
projectRootManager.setAttribute(ProjectRootManagerImpl.PROJECT_JDK_TYPE_ATTR, GoConstants.SDK_TYPE_ID);
projectRootManager.setAttribute(PROJECT_JDK_TYPE_ATTR, GoConstants.SDK_TYPE_ID);
saveFile(file, projectRootManager, "Cannot save sdk type changing");
}

Expand Down
31 changes: 19 additions & 12 deletions src/com/goide/usages/GoFileStructureGroupRuleProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,31 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.usages.PsiElementUsageGroupBase;
import com.intellij.usages.Usage;
import com.intellij.usages.UsageGroup;
import com.intellij.usages.UsageTarget;
import com.intellij.usages.impl.FileStructureGroupRuleProvider;
import com.intellij.usages.rules.PsiElementUsage;
import com.intellij.usages.rules.SingleParentUsageGroupingRule;
import com.intellij.usages.rules.UsageGroupingRule;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class GoFileStructureGroupRuleProvider implements FileStructureGroupRuleProvider {
public static final UsageGroupingRule USAGE_GROUPING_RULE = usage -> {
PsiElement psiElement = usage instanceof PsiElementUsage ? ((PsiElementUsage)usage).getElement() : null;
GoNamedElement topmostElement = PsiTreeUtil.getParentOfType(psiElement, GoTypeSpec.class, GoFunctionOrMethodDeclaration.class);
if (topmostElement != null) {
return new PsiElementUsageGroupBase<>(topmostElement);
}
return null;
};

@Nullable
@Override
public UsageGroupingRule getUsageGroupingRule(Project project) {
return USAGE_GROUPING_RULE;
return new GoClassGroupingRule();
}
private static class GoClassGroupingRule extends SingleParentUsageGroupingRule {
@Nullable
@Override
protected UsageGroup getParentGroupFor(@NotNull Usage usage, @NotNull UsageTarget[] targets) {
if (!(usage instanceof PsiElementUsage)) return null;
final PsiElement psiElement = ((PsiElementUsage)usage).getElement();
GoNamedElement topmostElement = PsiTreeUtil.getParentOfType(psiElement, GoTypeSpec.class, GoFunctionOrMethodDeclaration.class);
if (topmostElement != null) {
return new PsiElementUsageGroupBase<>(topmostElement);
}
return null;
}
}
}