Permalink
Browse files

Migrate to java 8

  • Loading branch information...
1 parent 76ad491 commit b68855e32081c7eecb4230a1a768c07952daac2c @zolotov zolotov committed Jul 23, 2016
Showing with 1,385 additions and 2,303 deletions.
  1. +3 −6 google-app-engine/src/com/intellij/appengine/AppEngineExtension.java
  2. +2 −2 plan9/src/com/plan9/intel/ide/highlighting/AsmIntelSyntaxHighlighter.java
  3. +1 −1 resources/META-INF/google-app-engine-core-yaml.xml
  4. +1 −1 resources/META-INF/plugin.xml
  5. +12 −24 src/com/goide/GoDocumentationProvider.java
  6. +2 −1 src/com/goide/GoIcons.java
  7. +1 −1 src/com/goide/GoModuleType.java
  8. +32 −38 src/com/goide/UpdateComponent.java
  9. +6 −9 src/com/goide/actions/tool/GoExternalToolsAction.java
  10. +7 −11 src/com/goide/actions/tool/GoFmtCheckinFactory.java
  11. +4 −9 src/com/goide/actions/tool/GoFmtProjectAction.java
  12. +9 −13 src/com/goide/appengine/YamlFilesModificationTracker.java
  13. +3 −10 src/com/goide/appengine/run/GoAppEngineRunConfigurationEditor.java
  14. +3 −11 src/com/goide/codeInsight/imports/GoExcludePathLookupActionProvider.java
  15. +9 −17 src/com/goide/codeInsight/imports/GoGetPackageFix.java
  16. +4 −4 src/com/goide/codeInsight/imports/GoImportOptimizer.java
  17. +40 −75 src/com/goide/codeInsight/imports/GoImportPackageQuickFix.java
  18. +4 −7 src/com/goide/completion/BracesInsertHandler.java
  19. +1 −1 src/com/goide/completion/GoAutoImportCompletionContributor.java
  20. +4 −4 src/com/goide/completion/GoAutoImportInsertHandler.java
  21. +12 −18 src/com/goide/completion/GoCompletionUtil.java
  22. +15 −21 src/com/goide/completion/GoKeywordCompletionProvider.java
  23. +9 −8 src/com/goide/completion/GoReferenceCompletionProvider.java
  24. +7 −20 src/com/goide/completion/GoStructLiteralCompletion.java
  25. +34 −45 src/com/goide/completion/GoTestFunctionCompletionProvider.java
  26. +11 −15 src/com/goide/configuration/GoBuildTagsUI.java
  27. +46 −64 src/com/goide/configuration/GoLibrariesConfigurable.java
  28. +2 −10 src/com/goide/configuration/GoLibrariesConfigurableProvider.java
  29. +5 −3 src/com/goide/configuration/GoModuleEditorsProvider.java
  30. +38 −47 src/com/goide/configuration/GoSdkConfigurable.java
  31. +1 −1 src/com/goide/configuration/GoVendoringUI.java
  32. +3 −4 src/com/goide/configuration/ListenableHideableDecorator.java
  33. +22 −42 src/com/goide/dlv/DlvDebugProcess.java
  34. +1 −1 src/com/goide/dlv/DlvRemoteVmConnection.java
  35. +29 −50 src/com/goide/dlv/DlvStackFrame.java
  36. +33 −61 src/com/goide/dlv/DlvXValue.java
  37. +13 −17 src/com/goide/editor/GoFoldingBuilder.java
  38. +3 −3 src/com/goide/editor/GoParameterInfoHandler.java
  39. +8 −11 src/com/goide/editor/GoTypedHandler.java
  40. +2 −2 src/com/goide/editor/surround/GoStatementsSurrounder.java
  41. +2 −2 src/com/goide/editor/surround/GoWithForSurrounder.java
  42. +4 −6 src/com/goide/go/GoGotoContributorBase.java
  43. +1 −1 src/com/goide/highlighting/exitpoint/GoBreakStatementExitPointHandler.java
  44. +1 −3 src/com/goide/inspections/GoAnonymousFieldDefinitionTypeInspection.java
  45. +2 −2 src/com/goide/inspections/GoAssignmentNilWithoutExplicitTypeInspection.java
  46. +5 −3 src/com/goide/inspections/GoAssignmentToReceiverInspection.java
  47. +1 −1 src/com/goide/inspections/GoBoolExpressionsInspection.java
  48. +1 −1 src/com/goide/inspections/GoCommentStartInspection.java
  49. +1 −1 src/com/goide/inspections/GoDeferInLoopInspection.java
  50. +1 −1 src/com/goide/inspections/GoDirectAssignToStructFieldInMapInspection.java
  51. +4 −4 src/com/goide/inspections/GoDuplicateArgumentInspection.java
  52. +4 −4 src/com/goide/inspections/GoDuplicateFieldsOrMethodsInspection.java
  53. +28 −35 src/com/goide/inspections/GoDuplicateFunctionOrMethodInspection.java
  54. +2 −3 src/com/goide/inspections/GoDuplicateReturnArgumentInspection.java
  55. +1 −1 src/com/goide/inspections/GoEmbeddedInterfacePointerInspection.java
  56. +1 −1 src/com/goide/inspections/GoEmptyDeclarationInspection.java
  57. +37 −43 src/com/goide/inspections/GoExportedOwnDeclarationInspection.java
  58. +9 −22 src/com/goide/inspections/GoFileIgnoredByBuildToolNotificationProvider.java
  59. +2 −2 src/com/goide/inspections/GoFunctionCallInspection.java
  60. +1 −1 src/com/goide/inspections/GoFunctionVariadicParameterInspection.java
  61. +1 −1 src/com/goide/inspections/GoInfiniteForInspection.java
  62. +1 −1 src/com/goide/inspections/GoInspectionBase.java
  63. +9 −12 src/com/goide/inspections/GoInvalidPackageImportInspection.java
  64. +1 −1 src/com/goide/inspections/GoInvalidStringOrCharInspection.java
  65. +1 −1 src/com/goide/inspections/GoMissingReturnInspection.java
  66. +1 −1 src/com/goide/inspections/GoMixedNamedUnnamedParametersInspection.java
  67. +1 −1 src/com/goide/inspections/GoNoNewVariablesInspection.java
  68. +6 −3 src/com/goide/inspections/GoPlaceholderChecker.java
  69. +1 −1 src/com/goide/inspections/GoPlaceholderCountInspection.java
  70. +1 −1 src/com/goide/inspections/GoRangeIterationOnIllegalTypeInspection.java
  71. +1 −1 src/com/goide/inspections/GoReceiverNamesInspection.java
  72. +2 −2 src/com/goide/inspections/GoRedeclareImportAsFunctionInspection.java
  73. +2 −2 src/com/goide/inspections/GoRedundantBlankArgInRangeInspection.java
  74. +1 −1 src/com/goide/inspections/GoRedundantSecondIndexInSlicesInspection.java
  75. +1 −1 src/com/goide/inspections/GoRedundantTypeDeclInCompositeLit.java
  76. +1 −1 src/com/goide/inspections/GoReservedWordUsedAsNameInspection.java
  77. +1 −1 src/com/goide/inspections/GoStructInitializationInspection.java
  78. +2 −2 src/com/goide/inspections/GoStructTagInspection.java
  79. +1 −1 src/com/goide/inspections/GoUnderscoreUsedAsValueInspection.java
  80. +1 −9 src/com/goide/inspections/GoUnusedImportInspection.java
  81. +1 −1 src/com/goide/inspections/GoUsedAsValueInCondition.java
  82. +1 −1 src/com/goide/inspections/GoVarDeclarationInspection.java
  83. +15 −21 src/com/goide/inspections/WrongModuleTypeNotificationProvider.java
  84. +2 −2 src/com/goide/inspections/unresolved/GoAssignmentToConstantInspection.java
  85. +1 −1 src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java
  86. +1 −1 src/com/goide/inspections/unresolved/GoUnusedConstInspection.java
  87. +1 −1 src/com/goide/inspections/unresolved/GoUnusedFunctionInspection.java
  88. +1 −1 src/com/goide/inspections/unresolved/GoUnusedParameterInspection.java
  89. +20 −24 src/com/goide/inspections/unresolved/GoUnusedVariableInspection.java
  90. +2 −2 src/com/goide/marker/GoRecursiveCallMarkerProvider.java
  91. +7 −11 src/com/goide/parser/GoParserUtil.java
  92. +2 −8 src/com/goide/project/GoLibrariesService.java
  93. +42 −70 src/com/goide/project/GoModuleLibrariesInitializer.java
  94. +1 −1 src/com/goide/project/GoModuleSettings.java
  95. +8 −9 src/com/goide/project/GoProjectStructureDetector.java
  96. +1 −1 src/com/goide/project/migration/GoBuildTagsSettingsConverterProvider.java
  97. +2 −2 src/com/goide/project/migration/GoProjectModelConverterProvider.java
  98. +130 −179 src/com/goide/psi/GoFile.java
  99. +2 −7 src/com/goide/psi/impl/GoCachedReference.java
  100. +1 −1 src/com/goide/psi/impl/GoFieldNameReference.java
  101. +2 −1 src/com/goide/psi/impl/GoLightType.java
  102. +5 −9 src/com/goide/psi/impl/GoNamedElementImpl.java
  103. +22 −65 src/com/goide/psi/impl/GoPsiImplUtil.java
  104. +17 −36 src/com/goide/psi/impl/GoReference.java
  105. +2 −2 src/com/goide/psi/impl/GoReferenceBase.java
  106. +2 −2 src/com/goide/psi/impl/GoScopeProcessorBase.java
  107. +6 −20 src/com/goide/psi/impl/GoTypeReference.java
  108. +1 −7 src/com/goide/psi/impl/GoTypeUtil.java
  109. +1 −1 src/com/goide/psi/impl/GoVarReference.java
  110. +2 −2 src/com/goide/psi/impl/imports/GoImportReference.java
  111. +2 −9 src/com/goide/psi/impl/imports/GoImportReferenceSet.java
  112. +3 −8 src/com/goide/quickfix/GoDeleteImportQuickFix.java
  113. +4 −7 src/com/goide/quickfix/GoDeleteQuickFix.java
  114. +28 −43 src/com/goide/quickfix/GoMultiplePackagesQuickFix.java
  115. +16 −19 src/com/goide/quickfix/GoRenameQuickFix.java
  116. +5 −8 src/com/goide/quickfix/GoReplaceWithReturnStatementQuickFix.java
  117. +2 −1 src/com/goide/quickfix/GoSimplifyBoolExprQuickFix.java
  118. +36 −55 src/com/goide/refactor/GoIntroduceVariableBase.java
  119. +2 −7 src/com/goide/refactor/GoIntroduceVariableDialog.java
  120. +3 −3 src/com/goide/refactor/GoRefactoringUtil.java
  121. +8 −19 src/com/goide/runconfig/GoBuildingRunner.java
  122. +4 −15 src/com/goide/runconfig/GoConsoleFilter.java
  123. +17 −6 src/com/goide/runconfig/GoRunLineMarkerProvider.java
  124. +5 −8 src/com/goide/runconfig/GoRunUtil.java
  125. +1 −1 src/com/goide/runconfig/GoRunningState.java
  126. +1 −1 src/com/goide/runconfig/application/GoApplicationRunningState.java
  127. +7 −13 src/com/goide/runconfig/before/GoBeforeRunTaskProvider.java
  128. +4 −4 src/com/goide/runconfig/file/GoRunFileConfiguration.java
  129. +1 −1 src/com/goide/runconfig/testing/GoTestConsoleProperties.java
  130. +3 −3 src/com/goide/runconfig/testing/GoTestFinder.java
  131. +3 −15 src/com/goide/runconfig/testing/GoTestLocator.java
  132. +3 −3 src/com/goide/runconfig/testing/GoTestRunConfigurationProducerBase.java
  133. +1 −6 src/com/goide/runconfig/testing/GoTestRunLineMarkerProvider.java
  134. +3 −16 src/com/goide/runconfig/testing/GoTestRunningState.java
  135. +12 −25 src/com/goide/runconfig/testing/coverage/GoCoverageAnnotator.java
  136. +5 −8 src/com/goide/runconfig/testing/coverage/GoCoverageEngine.java
  137. +1 −1 src/com/goide/runconfig/testing/coverage/GoCoverageProjectData.java
  138. +27 −35 src/com/goide/runconfig/testing/coverage/GoCoverageRunner.java
  139. +1 −7 src/com/goide/runconfig/testing/frameworks/gocheck/GocheckFramework.java
  140. +3 −17 src/com/goide/runconfig/testing/ui/GoTestRunConfigurationEditorForm.java
  141. +4 −18 src/com/goide/runconfig/ui/GoApplicationConfigurationEditorForm.java
  142. +12 −23 src/com/goide/sdk/GoIdeaSdkService.java
  143. +11 −26 src/com/goide/sdk/GoPackageUtil.java
  144. +3 −6 src/com/goide/sdk/GoSdkService.java
  145. +33 −59 src/com/goide/sdk/GoSdkUtil.java
  146. +20 −29 src/com/goide/sdk/GoSmallIDEsSdkService.java
  147. +3 −9 src/com/goide/stubs/GoConstSpecStub.java
  148. +1 −1 src/com/goide/stubs/GoElementTypeFactory.java
  149. +16 −33 src/com/goide/stubs/index/GoIdFilter.java
  150. +2 −8 src/com/goide/stubs/types/GoConstDefinitionStubElementType.java
  151. +4 −16 src/com/goide/stubs/types/GoConstSpecStubElementType.java
  152. +2 −7 src/com/goide/stubs/types/GoFunctionDeclarationStubElementType.java
  153. +1 −7 src/com/goide/stubs/types/GoImportSpecStubElementType.java
  154. +2 −8 src/com/goide/stubs/types/GoMethodDeclarationStubElementType.java
  155. +3 −9 src/com/goide/stubs/types/GoTypeSpecStubElementType.java
  156. +2 −8 src/com/goide/stubs/types/GoVarDefinitionStubElementType.java
  157. +2 −8 src/com/goide/stubs/types/GoVarSpecStubElementType.java
  158. +3 −14 src/com/goide/template/GoFieldNameMacro.java
  159. +1 −1 src/com/goide/tree/GoStructureViewFactory.java
  160. +7 −14 src/com/goide/usages/GoFileStructureGroupRuleProvider.java
  161. +9 −17 src/com/goide/util/GoExecutor.java
  162. +2 −2 src/com/goide/util/GoHistoryProcessListener.java
  163. +13 −17 src/com/goide/util/GoTargetSystem.java
  164. +5 −22 src/com/goide/util/GoUtil.java
  165. +4 −7 tests/com/goide/GoCodeInsightFixtureTestCase.java
  166. +1 −7 tests/com/goide/GoFindUsageTest.java
  167. +24 −25 tests/com/goide/GoParametrizedTestBase.java
  168. +40 −57 tests/com/goide/GoPerformanceTest.java
  169. +11 −18 tests/com/goide/GoSdkServiceTest.java
  170. +1 −6 tests/com/goide/actions/GoCreateFileActionTest.java
  171. +2 −6 tests/com/goide/codeInsight/imports/GoImportOptimizerTest.java
  172. +5 −6 tests/com/goide/codeInsight/unwrap/GoUnwrapTestCase.java
  173. +3 −8 tests/com/goide/completion/GoCompletionTestBase.java
  174. +1 −8 tests/com/goide/editor/GoExitPointsHighlightingTest.java
  175. +1 −1 tests/com/goide/editor/GoStatementMoverTest.java
  176. +2 −5 tests/com/goide/formatter/GoFormatterTest.java
  177. +5 −14 tests/com/goide/inspections/GoInvalidPackageImportInspectionTest.java
  178. +2 −5 tests/com/goide/psi/GoImportListTest.java
  179. +9 −22 tests/com/goide/psi/legacy/GoLegacyResolveTestBase.java
  180. +2 −2 tests/com/goide/runconfig/GoConsoleFilterTest.java
  181. +1 −4 tests/com/goide/runconfig/testing/GoEventsConverterTestCase.java
  182. +3 −2 tests/com/goide/type/GoExpectedTypesTest.java
  183. +9 −16 tests/com/goide/util/GoStringLiteralEscaperTest.java
@@ -30,12 +30,9 @@
public static void enableTestingMode(@NotNull Disposable disposable) {
ourTestingMode = true;
- Disposer.register(disposable, new Disposable() {
- @Override
- public void dispose() {
- //noinspection AssignmentToStaticFieldFromInstanceMethod
- ourTestingMode = false;
- }
+ Disposer.register(disposable, () -> {
+ //noinspection AssignmentToStaticFieldFromInstanceMethod
+ ourTestingMode = false;
});
}
@@ -20,16 +20,16 @@
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
-import java.util.HashMap;
import java.util.Map;
import static com.plan9.intel.ide.highlighting.AsmIntelSyntaxHighlightingColors.*;
public class AsmIntelSyntaxHighlighter extends SyntaxHighlighterBase {
- private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = new HashMap<IElementType, TextAttributesKey>();
+ private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = ContainerUtil.newHashMap();
static {
fillMap(ATTRIBUTES, LINE_COMMENT, AsmIntelLexerTokens.LINE_COMMENT);
@@ -14,7 +14,7 @@
~ limitations under the License.
-->
-<!-- todo[IDEA 17] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 15 -->
+<!-- todo[IDEA 17] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 17 -->
<idea-plugin version="2">
<extensions defaultExtensionNs="com.intellij">
<completion.contributor language="yaml" implementationClass="yaml.AppEngineYamlCompletionContributor"/>
@@ -407,7 +407,7 @@
<!-- GAE -->
<!-- START plugin.xml of future GAE module -->
- <!-- todo[IDEA 17] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 16 -->
+ <!-- todo[IDEA 17] It's supposed that GAE-core module will be moved to IDEA source and bundled in IDEA 17 -->
<!--<id>com.intellij.appengine</id>-->
<depends optional="true" config-file="google-app-engine-core-yaml.xml">org.jetbrains.plugins.yaml</depends>
<extensionPoints>
@@ -44,6 +44,7 @@
import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Function;
+import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.indexing.IdFilter;
import com.intellij.xml.util.XmlStringUtil;
@@ -209,13 +210,8 @@ else if (type != null) {
@NotNull
private static String getParametersAsString(@NotNull GoParameters parameters) {
- final String contextImportPath = getImportPathForElement(parameters);
- return StringUtil.join(GoParameterInfoHandler.getParameterPresentations(parameters, new Function<PsiElement, String>() {
- @Override
- public String fun(PsiElement element) {
- return getTypePresentation(element, new GoDocumentationPresentationFunction(contextImportPath));
- }
- }), ", ");
+ String contextImportPath = getImportPathForElement(parameters);
+ return StringUtil.join(GoParameterInfoHandler.getParameterPresentations(parameters, element -> getTypePresentation(element, new GoDocumentationPresentationFunction(contextImportPath))), ", ");
}
@Nullable
@@ -264,12 +260,7 @@ public static String getTypePresentation(@Nullable PsiElement element, @NotNull
: "*" + getTypePresentation(inner, presentationFunction);
}
if (type instanceof GoTypeList) {
- return "(" + StringUtil.join(((GoTypeList)type).getTypeList(), new Function<GoType, String>() {
- @Override
- public String fun(GoType element) {
- return getTypePresentation(element, presentationFunction);
- }
- }, ", ") + ")";
+ return "(" + StringUtil.join(((GoTypeList)type).getTypeList(), element1 -> getTypePresentation(element1, presentationFunction), ", ") + ")";
}
if (type instanceof GoFunctionType) {
return getSignatureOwnerTypePresentation((GoFunctionType)type, presentationFunction);
@@ -286,17 +277,14 @@ public String fun(GoType element) {
}
if (type instanceof GoStructType) {
StringBuilder result = new StringBuilder("struct {");
- result.append(StringUtil.join(((GoStructType)type).getFieldDeclarationList(), new Function<GoFieldDeclaration, String>() {
- @Override
- public String fun(GoFieldDeclaration declaration) {
- GoAnonymousFieldDefinition anon = declaration.getAnonymousFieldDefinition();
- String result = anon != null
- ? getTypePresentation(anon.getGoTypeInner(null), presentationFunction)
- : StringUtil.join(declaration.getFieldDefinitionList(), GoPsiImplUtil.GET_TEXT_FUNCTION, ", ") +
- " " + getTypePresentation(declaration.getType(), presentationFunction);
- GoTag tag = declaration.getTag();
- return result + (tag != null ? tag.getText() : "");
- }
+ result.append(StringUtil.join(((GoStructType)type).getFieldDeclarationList(), declaration -> {
+ GoAnonymousFieldDefinition anon = declaration.getAnonymousFieldDefinition();
+ String result1 = anon != null
+ ? getTypePresentation(anon.getGoTypeInner(null), presentationFunction)
+ : StringUtil.join(declaration.getFieldDefinitionList(), (NotNullFunction<PsiElement, String>)PsiElement::getText, ", ") +
+ " " + getTypePresentation(declaration.getType(), presentationFunction);
+ GoTag tag = declaration.getTag();
+ return result1 + (tag != null ? tag.getText() : "");
}, "; "));
return result.append("}").toString();
}
@@ -24,6 +24,7 @@
import javax.swing.*;
+@SuppressWarnings("ConstantConditions")
public interface GoIcons {
Icon ICON = IconLoader.findIcon("/icons/go.png");
Icon TYPE = IconLoader.findIcon("/icons/type.png");
@@ -46,7 +47,7 @@
private Helper() {}
@NotNull
- public static LayeredIcon createIconWithShift(@NotNull final Icon base, Icon mark) {
+ public static LayeredIcon createIconWithShift(@NotNull Icon base, Icon mark) {
LayeredIcon icon = new LayeredIcon(2) {
@Override
public int getIconHeight() {
@@ -71,7 +71,7 @@ public Icon getNodeIcon(boolean isOpened) {
@NotNull
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
- @NotNull final GoModuleBuilder moduleBuilder,
+ @NotNull GoModuleBuilder moduleBuilder,
@NotNull ModulesProvider modulesProvider) {
return new ModuleWizardStep[]{new ProjectJdkForModuleStep(wizardContext, GoSdkType.getInstance()) {
@Override
@@ -69,45 +69,39 @@ private static void checkForUpdates() {
PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
long lastUpdate = propertiesComponent.getOrInitLong(KEY, 0);
if (lastUpdate == 0 || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1)) {
- ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
- @Override
- public void run() {
- try {
- String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
- IdeaPluginDescriptor plugin = getPlugin();
- String pluginVersion = plugin.getVersion();
- String pluginId = plugin.getPluginId().getIdString();
- String os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
- String uid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
- final String url =
- "https://plugins.jetbrains.com/plugins/list" +
- "?pluginId=" + pluginId +
- "&build=" + buildNumber +
- "&pluginVersion=" + pluginVersion +
- "&os=" + os +
- "&uuid=" + uid;
- PropertiesComponent.getInstance().setValue(KEY, String.valueOf(System.currentTimeMillis()));
- HttpRequests.request(url).connect(
- new HttpRequests.RequestProcessor<Object>() {
- @Override
- public Object process(@NotNull HttpRequests.Request request) throws IOException {
- try {
- JDOMUtil.load(request.getReader());
- LOG.info((request.isSuccessful() ? "Successful" : "Unsuccessful") + " update: " + url);
- }
- catch (JDOMException e) {
- LOG.warn(e);
- }
- return null;
- }
+ ApplicationManager.getApplication().executeOnPooledThread(() -> {
+ try {
+ String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
+ IdeaPluginDescriptor plugin = getPlugin();
+ String pluginVersion = plugin.getVersion();
+ String pluginId = plugin.getPluginId().getIdString();
+ String os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
+ String uid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
+ String url =
+ "https://plugins.jetbrains.com/plugins/list" +
+ "?pluginId=" + pluginId +
+ "&build=" + buildNumber +
+ "&pluginVersion=" + pluginVersion +
+ "&os=" + os +
+ "&uuid=" + uid;
+ PropertiesComponent.getInstance().setValue(KEY, String.valueOf(System.currentTimeMillis()));
+ HttpRequests.request(url).connect(
+ request -> {
+ try {
+ JDOMUtil.load(request.getReader());
+ LOG.info((request.isSuccessful() ? "Successful" : "Unsuccessful") + " update: " + url);
}
- );
- }
- catch (UnknownHostException ignored) {
- }
- catch (IOException e) {
- LOG.warn(e);
- }
+ catch (JDOMException e) {
+ LOG.warn(e);
+ }
+ return null;
+ }
+ );
+ }
+ catch (UnknownHostException ignored) {
+ }
+ catch (IOException e) {
+ LOG.warn(e);
}
});
}
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2015 Sergey Ignatov, Alexander Zolotov, Florin Patan
+ * Copyright 2013-2016 Sergey Ignatov, Alexander Zolotov, Florin Patan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,12 +99,12 @@ private boolean doSomething(@NotNull VirtualFile virtualFile,
return doSomething(virtualFile, module, project, title, withProgress, Consumer.EMPTY_CONSUMER);
}
- protected boolean doSomething(@NotNull final VirtualFile virtualFile,
+ protected boolean doSomething(@NotNull VirtualFile virtualFile,
@Nullable Module module,
@NotNull Project project,
@NotNull String title,
boolean withProgress,
- @NotNull final Consumer<Boolean> consumer) {
+ @NotNull Consumer<Boolean> consumer) {
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
@@ -113,12 +113,9 @@ protected boolean doSomething(@NotNull final VirtualFile virtualFile,
FileDocumentManager.getInstance().saveAllDocuments();
}
- createExecutor(project, module, title, virtualFile).executeWithProgress(withProgress, new Consumer<Boolean>() {
- @Override
- public void consume(Boolean result) {
- consumer.consume(result);
- VfsUtil.markDirtyAndRefresh(true, true, true, virtualFile);
- }
+ createExecutor(project, module, title, virtualFile).executeWithProgress(withProgress, result -> {
+ consumer.consume(result);
+ VfsUtil.markDirtyAndRefresh(true, true, true, virtualFile);
});
return true;
}
@@ -33,15 +33,14 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
-import com.intellij.util.Consumer;
import com.intellij.util.PairConsumer;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -50,11 +49,11 @@
@Override
@NotNull
- public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
+ public CheckinHandler createHandler(@NotNull CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
return new CheckinHandler() {
@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
- final JCheckBox checkBox = new JCheckBox("Go fmt");
+ JCheckBox checkBox = new JCheckBox("Go fmt");
return new RefreshableOnComponent() {
@Override
@NotNull
@@ -83,16 +82,13 @@ public void restoreState() {
@Override
public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
if (enabled(panel)) {
- final Ref<Boolean> success = new Ref<Boolean>(true);
+ Ref<Boolean> success = Ref.create(true);
FileDocumentManager.getInstance().saveAllDocuments();
for (PsiFile file : getPsiFiles()) {
VirtualFile virtualFile = file.getVirtualFile();
new GoFmtFileAction().doSomething(virtualFile, ModuleUtilCore.findModuleForPsiElement(file), file.getProject(), "Go fmt", true,
- new Consumer<Boolean>() {
- @Override
- public void consume(Boolean result) {
- if (!result) success.set(false);
- }
+ result -> {
+ if (!result) success.set(false);
});
}
if (!success.get()) {
@@ -121,7 +117,7 @@ private ReturnResult showErrorMessage(@Nullable CommitExecutor executor) {
@NotNull
private List<PsiFile> getPsiFiles() {
Collection<VirtualFile> files = panel.getVirtualFiles();
- List<PsiFile> psiFiles = new ArrayList<PsiFile>();
+ List<PsiFile> psiFiles = ContainerUtil.newArrayList();
PsiManager manager = PsiManager.getInstance(panel.getProject());
for (VirtualFile file : files) {
PsiFile psiFile = manager.findFile(file);
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2015 Sergey Ignatov, Alexander Zolotov, Florin Patan
+ * Copyright 2013-2016 Sergey Ignatov, Alexander Zolotov, Florin Patan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -51,13 +50,9 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
}
- private static void fmt(@NotNull Project project, @Nullable Module module, @NotNull String presentation, @NotNull final VirtualFile dir) {
+ private static void fmt(@NotNull Project project, @Nullable Module module, @NotNull String presentation, @NotNull VirtualFile dir) {
GoExecutor.in(project, module).withPresentableName(presentation).withWorkDirectory(dir.getPath())
- .withParameters("fmt", "./...").showOutputOnError().executeWithProgress(false, new Consumer<Boolean>() {
- @Override
- public void consume(Boolean result) {
- VfsUtil.markDirtyAndRefresh(true, true, true, dir);
- }
- });
+ .withParameters("fmt", "./...").showOutputOnError().executeWithProgress(false,
+ result -> VfsUtil.markDirtyAndRefresh(true, true, true, dir));
}
}
@@ -71,20 +71,16 @@ public static YamlFilesModificationTracker getInstance(@NotNull Project project)
}
@NotNull
- public static Collection<VirtualFile> getYamlFiles(@NotNull final Project project, @Nullable final Module module) {
+ public static Collection<VirtualFile> getYamlFiles(@NotNull Project project, @Nullable Module module) {
UserDataHolder dataHolder = ObjectUtils.notNull(module, project);
- return CachedValuesManager.getManager(project).getCachedValue(dataHolder, new CachedValueProvider<Collection<VirtualFile>>() {
- @Nullable
- @Override
- public Result<Collection<VirtualFile>> compute() {
- Collection<VirtualFile> yamlFiles = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
- @Override
- public Collection<VirtualFile> compute() {
- return FilenameIndex.getAllFilesByExt(project, "yaml", GoUtil.moduleScopeWithoutLibraries(project, module));
- }
- });
- return Result.create(yamlFiles, getInstance(project));
- }
+ return CachedValuesManager.getManager(project).getCachedValue(dataHolder, () -> {
+ Collection<VirtualFile> yamlFiles = ApplicationManager.getApplication().runReadAction(new Computable<Collection<VirtualFile>>() {
+ @Override
+ public Collection<VirtualFile> compute() {
+ return FilenameIndex.getAllFilesByExt(project, "yaml", GoUtil.moduleScopeWithoutLibraries(project, module));
+ }
+ });
+ return CachedValueProvider.Result.create(yamlFiles, getInstance(project));
});
}
}
Oops, something went wrong.

0 comments on commit b68855e

Please sign in to comment.