diff --git a/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java b/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java index fd52b7c17ae4..653e223326cd 100644 --- a/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java +++ b/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java @@ -1,4 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.codeInsight.daemon.impl; import com.intellij.openapi.diagnostic.Logger; @@ -127,6 +130,7 @@ public final class CollectHighlightsUtil { PsiElement commonParent = PsiTreeUtil.findCommonParent(left, right); if (commonParent == null) { LOG.error("No common parent for "+left+" and "+right+"; root: "+root+"; startOffset: "+startOffset+"; endOffset: "+endOffset); + return null; } LOG.assertTrue(commonParent.getTextRange() != null, commonParent); diff --git a/platform/lang-api/src/com/intellij/openapi/editor/LanguageIndentStrategy.java b/platform/lang-api/src/com/intellij/openapi/editor/LanguageIndentStrategy.java index 0188bbb43d44..87fe96736698 100644 --- a/platform/lang-api/src/com/intellij/openapi/editor/LanguageIndentStrategy.java +++ b/platform/lang-api/src/com/intellij/openapi/editor/LanguageIndentStrategy.java @@ -1,4 +1,7 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.openapi.editor; import com.intellij.lang.Language; @@ -10,10 +13,11 @@ import org.jetbrains.annotations.Nullable; public class LanguageIndentStrategy extends LanguageExtension { public static final String EP_NAME = "com.intellij.lang.indentStrategy"; - public static final LanguageIndentStrategy INSTANCE = new LanguageIndentStrategy(); private static final DefaultIndentStrategy DEFAULT_INDENT_STRATEGY = new DefaultIndentStrategy(); + public static final LanguageIndentStrategy INSTANCE = new LanguageIndentStrategy(); + public LanguageIndentStrategy() { super(EP_NAME, DEFAULT_INDENT_STRATEGY); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java index d0c7fafebd9a..8b61cf9f77bf 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java @@ -1,4 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.codeInspection.ui; import com.intellij.codeHighlighting.HighlightDisplayLevel; @@ -87,9 +90,9 @@ public final class InspectionTreeModel extends BaseTreeModel JBIterable traverseFrom(InspectionTreeNode node, boolean direction) { return JBIterable.generate(node, n -> getParent(n)).filter(n -> getParent(n) != null).flatMap(n1 -> { InspectionTreeNode p = getParent(n1); + assert p != null; int idx = getIndexOfChild(p, n1); if (idx < 0) return JBIterable.empty(); - assert p != null; InspectionTreeNode.Children children = p.myChildren; if (children == null) return JBIterable.empty(); InspectionTreeNode[] arr = children.myChildren; diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java index 03b04daff9ce..633d9674b710 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java +++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java @@ -1,4 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.openapi.module; import com.intellij.codeInsight.multiverse.CodeInsightContext; @@ -72,7 +75,8 @@ public class ModuleUtilCore { PsiFile file = element.getContainingFile(); if (file == null) return true; VirtualFile vFile = file.getVirtualFile(); - Module module = vFile == null ? null : projectFileIndex.getModuleForFile(vFile); + if (vFile == null) return true; + Module module = projectFileIndex.getModuleForFile(vFile); // element may be in library return module == null ? !projectFileIndex.isInLibraryClasses(vFile) : module.isDisposed(); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java index 0ec6080384e8..5563232fb093 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java @@ -1,4 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.openapi.projectRoots.impl; import com.intellij.openapi.Disposable; @@ -15,6 +18,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; import com.intellij.platform.workspace.jps.entities.SdkEntityBuilder; import com.intellij.platform.workspace.storage.InternalEnvironmentName; +import com.intellij.util.ArrayUtil; import com.intellij.util.concurrency.ThreadingAssertions; import com.intellij.workspaceModel.ide.impl.legacyBridge.sdk.SdkBridgeImpl; import org.jdom.Element; @@ -177,6 +181,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void commitChanges() { if (modificator == null) { LOG.error("Forbidden to call `commitChanges` outside of `SdkModificator`"); + return; } ThreadingAssertions.assertWriteAccess(); modificator.commitChanges(); @@ -220,6 +225,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public VirtualFile @NotNull [] getRoots(@NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to call `getRoots` outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return VirtualFile.EMPTY_ARRAY; } return modificator.getRoots(rootType); } @@ -228,6 +234,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public String @NotNull [] getUrls(@NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to call `getUrls` outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return ArrayUtil.EMPTY_STRING_ARRAY; } return modificator.getUrls(rootType); } @@ -236,6 +243,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void addRoot(@NotNull VirtualFile root, @NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.addRoot(root, rootType); } @@ -244,6 +252,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void addRoot(@NotNull String url, @NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.addRoot(url, rootType); } @@ -252,6 +261,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void removeRoot(@NotNull VirtualFile root, @NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.removeRoot(root, rootType); } @@ -260,6 +270,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void removeRoot(@NotNull String url, @NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.removeRoot(url, rootType); } @@ -268,6 +279,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void removeRoots(@NotNull OrderRootType rootType) { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.removeRoots(rootType); } @@ -276,6 +288,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements SdkBridge, Sdk public void removeAllRoots() { if (modificator == null) { LOG.error("Forbidden to mutate SDK outside of the `SdkModificator`. Please, use `com.intellij.openapi.projectRoots.Sdk.getSdkModificator`"); + return; } modificator.removeAllRoots(); } diff --git a/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java index 8771beadbcbe..0f886d12456e 100644 --- a/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java @@ -1,4 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.ide.util.treeView.smartTree; import com.intellij.ide.structureView.StructureViewModel; @@ -170,12 +173,14 @@ public abstract class CachingChildrenTreeNode extends AbstractTreeNode children = group.getChildren(); for (TreeElement node : children) { if (node == null) { LOG.error(group + " returned null child: " + children); + continue; } AbstractTreeNode abstractTreeNode = ungroupedObjects.get(node); CachingChildrenTreeNode child = createChildNode(node, abstractTreeNode instanceof TreeElementWrapper ? ((TreeElementWrapper)abstractTreeNode).getProvider() : null); diff --git a/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java index d262b1689a80..799d6703ece5 100644 --- a/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java @@ -1,4 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.ide.util.treeView.smartTree; @@ -38,6 +41,7 @@ public class GroupWrapper extends CachingChildrenTreeNode { for (TreeElement child : children) { if (child == null) { LOG.error(group + " returned null child: " + children); + continue; } TreeElementWrapper childNode = createChildNode(child, null); addSubElement(childNode); diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/UsageType.java b/platform/usageView/src/com/intellij/usages/impl/rules/UsageType.java index e925b0d59d1f..c9467250720f 100644 --- a/platform/usageView/src/com/intellij/usages/impl/rules/UsageType.java +++ b/platform/usageView/src/com/intellij/usages/impl/rules/UsageType.java @@ -1,4 +1,7 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package com.intellij.usages.impl.rules; import com.intellij.openapi.application.ApplicationManager; @@ -10,6 +13,8 @@ import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; public final class UsageType { + private static final Logger LOG = Logger.getInstance(UsageType.class); + public static final UsageType CLASS_INSTANCE_OF = new UsageType(UsageViewBundle.messagePointer("usage.type.instanceof")); public static final UsageType CLASS_IMPORT = new UsageType(UsageViewBundle.messagePointer("usage.type.import")); public static final UsageType CLASS_CAST_TO = new UsageType(UsageViewBundle.messagePointer("usage.type.cast.target")); @@ -45,8 +50,6 @@ public final class UsageType { public static final UsageType DELEGATE_TO_ANOTHER_INSTANCE = new UsageType(UsageViewBundle.messagePointer("usage.type.delegate.to.another.instance.method")); public static final UsageType DELEGATE_TO_ANOTHER_INSTANCE_PARAMETERS_CHANGED = new UsageType(UsageViewBundle.messagePointer("usage.type.delegate.to.another.instance.method.parameters.changed")); - private static final Logger LOG = Logger.getInstance(UsageType.class); - private final Supplier<@Nls(capitalization = Nls.Capitalization.Sentence) String> myNameComputable; /** diff --git a/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java b/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java index 775fdda0f505..b4ab8feb2302 100644 --- a/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java +++ b/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java @@ -1,5 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. - +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. /* * @author max */ @@ -29,6 +31,7 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.List; +import java.util.concurrent.atomic.AtomicLong; import static java.nio.file.StandardOpenOption.READ; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrUnusedIncDecInspection.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrUnusedIncDecInspection.java index c11239b36035..136816534b02 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrUnusedIncDecInspection.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrUnusedIncDecInspection.java @@ -1,4 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Nikita Iarychenko at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. package org.jetbrains.plugins.groovy.codeInspection.confusing; import com.intellij.codeInspection.LocalQuickFix; @@ -79,6 +82,7 @@ public final class GrUnusedIncDecInspection extends BaseInspection { if (cur == null) { LOG.error("no instruction found in flow." + "operand: " + operand.getText(), new Attachment("", owner.getText())); + return; } //get write access for inc or dec