mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer fastutil IntArrayList
GitOrigin-RevId: f57a2f34a522a21fac3dbe5e10ccdbe3ef9c702a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ab1d807794
commit
ba65cd10c8
File diff suppressed because it is too large
Load Diff
@@ -17,5 +17,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
<orderEntry type="library" name="Jaxen" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.xml.psi" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -33,6 +33,7 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.externalSystem" />
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -56,7 +56,6 @@ import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
import com.intellij.util.io.PathKt;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
@@ -73,6 +72,7 @@ import io.netty.handler.codec.protobuf.ProtobufEncoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.ide.BuiltInServerManager;
|
||||
@@ -1799,7 +1799,7 @@ public final class BuildManager implements Disposable {
|
||||
final String element = tokenizer.nextToken();
|
||||
list.add(FileNameCache.storeName(element));
|
||||
}
|
||||
myPath = list.toArray();
|
||||
myPath = list.toIntArray();
|
||||
}
|
||||
|
||||
public abstract String getValue();
|
||||
@@ -1824,7 +1824,7 @@ public final class BuildManager implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static class WinInternedPath extends InternedPath {
|
||||
private static final class WinInternedPath extends InternedPath {
|
||||
private WinInternedPath(String path) {
|
||||
super(path);
|
||||
}
|
||||
@@ -1848,7 +1848,7 @@ public final class BuildManager implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static class XInternedPath extends InternedPath {
|
||||
private static final class XInternedPath extends InternedPath {
|
||||
private XInternedPath(String path) {
|
||||
super(path);
|
||||
}
|
||||
|
||||
@@ -26,5 +26,6 @@
|
||||
<orderEntry type="module" module-name="intellij.jvm.analysis.impl" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+11
-23
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.refactoring.util.duplicates;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
@@ -32,7 +18,7 @@ import com.intellij.refactoring.extractMethod.InputVariables;
|
||||
import com.intellij.refactoring.util.RefactoringChangeUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -41,7 +27,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public class DuplicatesFinder {
|
||||
public final class DuplicatesFinder {
|
||||
private static final Logger LOG = Logger.getInstance(DuplicatesFinder.class);
|
||||
public static final Key<Parameter> PARAMETER = Key.create("PARAMETER");
|
||||
private final PsiElement @NotNull [] myPattern;
|
||||
@@ -80,13 +66,15 @@ public class DuplicatesFinder {
|
||||
int i = 0;
|
||||
do {
|
||||
startOffset = controlFlow.getStartOffset(pattern[i++]);
|
||||
} while(startOffset < 0 && i < pattern.length);
|
||||
}
|
||||
while(startOffset < 0 && i < pattern.length);
|
||||
|
||||
int endOffset;
|
||||
int j = pattern.length - 1;
|
||||
do {
|
||||
endOffset = controlFlow.getEndOffset(pattern[j--]);
|
||||
} while(endOffset < 0 && j >= 0);
|
||||
}
|
||||
while (endOffset < 0 && j >= 0);
|
||||
|
||||
IntArrayList exitPoints = new IntArrayList();
|
||||
final Collection<PsiStatement> exitStatements = ControlFlowUtil
|
||||
@@ -248,7 +236,7 @@ public class DuplicatesFinder {
|
||||
return match;
|
||||
}
|
||||
|
||||
protected boolean isSelf(@NotNull PsiElement candidate) {
|
||||
private boolean isSelf(@NotNull PsiElement candidate) {
|
||||
for (PsiElement pattern : myPattern) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (PsiTreeUtil.isAncestor(pattern, candidate, false)) {
|
||||
@@ -277,7 +265,7 @@ public class DuplicatesFinder {
|
||||
|
||||
final IntArrayList exitPoints = new IntArrayList();
|
||||
ControlFlowUtil.findExitPointsAndStatements(controlFlow, startOffset, endOffset, exitPoints, ControlFlowUtil.DEFAULT_EXIT_STATEMENTS_CLASSES);
|
||||
final PsiVariable[] outVariables = ControlFlowUtil.getOutputVariables(controlFlow, startOffset, endOffset, exitPoints.toArray());
|
||||
final PsiVariable[] outVariables = ControlFlowUtil.getOutputVariables(controlFlow, startOffset, endOffset, exitPoints.toIntArray());
|
||||
|
||||
if (outVariables.length > 0) {
|
||||
if (outVariables.length == 1) {
|
||||
@@ -731,7 +719,7 @@ public class DuplicatesFinder {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean matchLeaf(@NotNull PsiElement pattern, @NotNull PsiElement candidate, @NotNull Match match) {
|
||||
private static boolean matchLeaf(@NotNull PsiElement pattern, @NotNull PsiElement candidate, @NotNull Match match) {
|
||||
if (pattern.getParent() instanceof PsiVariable && ((PsiVariable)pattern.getParent()).getNameIdentifier() == pattern) {
|
||||
return match.putDeclarationCorrespondence(pattern.getParent(), candidate.getParent());
|
||||
}
|
||||
@@ -930,7 +918,7 @@ public class DuplicatesFinder {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static PsiElement @NotNull [] getFilteredChildren(@NotNull PsiElement element) {
|
||||
private static PsiElement @NotNull [] getFilteredChildren(@NotNull PsiElement element) {
|
||||
PsiElement[] children = element.getChildren();
|
||||
return getDeeplyFilteredElements(children);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics" />
|
||||
<orderEntry type="module" module-name="intellij.platform.inspect" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
+3
-3
@@ -1,18 +1,18 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.codeInsight.highlighting;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HighlightBreakOutsHandler extends HighlightUsagesHandlerBase<PsiElement> {
|
||||
public final class HighlightBreakOutsHandler extends HighlightUsagesHandlerBase<PsiElement> {
|
||||
private final PsiElement myTarget;
|
||||
|
||||
public HighlightBreakOutsHandler(Editor editor, PsiFile file, PsiElement target) {
|
||||
|
||||
+4
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.codeInsight.highlighting;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -23,7 +9,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,7 +18,7 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class HighlightExitPointsHandler extends HighlightUsagesHandlerBase<PsiElement> {
|
||||
public final class HighlightExitPointsHandler extends HighlightUsagesHandlerBase<PsiElement> {
|
||||
private final PsiElement myTarget;
|
||||
|
||||
public HighlightExitPointsHandler(final Editor editor, final PsiFile file, final PsiElement target) {
|
||||
@@ -142,9 +128,8 @@ public class HighlightExitPointsHandler extends HighlightUsagesHandlerBase<PsiEl
|
||||
HighlightUsagesHandler.getShortcutText());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getFeatureId() {
|
||||
public @NotNull String getFeatureId() {
|
||||
return ProductivityFeatureNames.CODEASSISTS_HIGHLIGHT_RETURN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.codeInspection.streamMigration;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -12,8 +12,8 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.siyeh.ig.psiutils.*;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -29,7 +29,7 @@ import static com.intellij.util.ObjectUtils.tryCast;
|
||||
* as a part of forEach operation of resulting stream possibly with
|
||||
* some intermediate operations extracted.
|
||||
*/
|
||||
class TerminalBlock {
|
||||
final class TerminalBlock {
|
||||
private static final Logger LOG = Logger.getInstance(TerminalBlock.class);
|
||||
|
||||
private final @NotNull PsiVariable myVariable;
|
||||
@@ -423,7 +423,7 @@ class TerminalBlock {
|
||||
* @return the terminal block with all possible terminal operations extracted (may return this if no operations could be extracted)
|
||||
*/
|
||||
@NotNull
|
||||
TerminalBlock extractOperations() {
|
||||
private TerminalBlock extractOperations() {
|
||||
return StreamEx.iterate(this, Objects::nonNull, TerminalBlock::extractOperation).reduce((a, b) -> b).orElse(this);
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ class TerminalBlock {
|
||||
/**
|
||||
* @return stream of physical expressions used in intermediate operations in arbitrary order
|
||||
*/
|
||||
StreamEx<PsiExpression> intermediateExpressions() {
|
||||
private StreamEx<PsiExpression> intermediateExpressions() {
|
||||
return StreamEx.of(myOperations, 1, myOperations.length).flatMap(Operation::expressions);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.refactoring.extractMethod;
|
||||
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
@@ -26,12 +12,12 @@ import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ControlFlowWrapper {
|
||||
public final class ControlFlowWrapper {
|
||||
private static final Logger LOG = Logger.getInstance(ControlFlowWrapper.class);
|
||||
|
||||
private final ControlFlow myControlFlow;
|
||||
@@ -101,7 +87,7 @@ public class ControlFlowWrapper {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("exit points:");
|
||||
for (int i = 0; i < myExitPoints.size(); i++) {
|
||||
LOG.debug(" " + myExitPoints.get(i));
|
||||
LOG.debug(" " + myExitPoints.getInt(i));
|
||||
}
|
||||
LOG.debug("exit statements:");
|
||||
for (PsiStatement exitStatement : myExitStatements) {
|
||||
@@ -159,7 +145,7 @@ public class ControlFlowWrapper {
|
||||
}
|
||||
|
||||
PsiVariable @NotNull [] getOutputVariables(boolean collectVariablesAtExitPoints) {
|
||||
PsiVariable[] myOutputVariables = ControlFlowUtil.getOutputVariables(myControlFlow, myFlowStart, myFlowEnd, myExitPoints.toArray());
|
||||
PsiVariable[] myOutputVariables = ControlFlowUtil.getOutputVariables(myControlFlow, myFlowStart, myFlowEnd, myExitPoints.toIntArray());
|
||||
if (collectVariablesAtExitPoints) {
|
||||
//variables declared in selected block used in return statements are to be considered output variables when extracting guard methods
|
||||
final Set<PsiVariable> outputVariables = ContainerUtil.set(myOutputVariables);
|
||||
|
||||
+2
-14
@@ -1,33 +1,21 @@
|
||||
// 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.
|
||||
package com.intellij.refactoring.extractMethod.newImpl
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil
|
||||
import com.intellij.codeInsight.ExceptionUtil
|
||||
import com.intellij.codeInsight.Nullability
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil
|
||||
import com.intellij.codeInspection.dataFlow.*
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValue
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager
|
||||
import com.intellij.psi.codeStyle.VariableKind
|
||||
import com.intellij.psi.controlFlow.*
|
||||
import com.intellij.psi.controlFlow.ControlFlow
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil.DEFAULT_EXIT_STATEMENTS_CLASSES
|
||||
import com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import com.intellij.refactoring.extractMethod.newImpl.structures.DataOutput
|
||||
import com.intellij.refactoring.extractMethod.newImpl.structures.ExtractOptions
|
||||
import com.intellij.refactoring.util.classMembers.ClassMemberReferencesVisitor
|
||||
import com.intellij.util.containers.IntArrayList
|
||||
import com.siyeh.ig.psiutils.VariableAccessUtils
|
||||
import java.util.LinkedHashSet
|
||||
import kotlin.Comparator
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||
|
||||
data class ExitDescription(val statements: List<PsiStatement>, val numberOfExits: Int, val hasSpecialExits: Boolean)
|
||||
data class ExternalReference(val variable: PsiVariable, val references: List<PsiReferenceExpression>)
|
||||
@@ -94,7 +82,7 @@ class CodeFragmentAnalyzer(val elements: List<PsiElement>) {
|
||||
fun findOutputVariables(): List<PsiVariable> {
|
||||
val exitPoints = IntArrayList()
|
||||
ControlFlowUtil.findExitPointsAndStatements(flow, flowRange.first, flowRange.last, exitPoints, *DEFAULT_EXIT_STATEMENTS_CLASSES)
|
||||
return ControlFlowUtil.getOutputVariables(flow, flowRange.first, flowRange.last, exitPoints.toArray()).distinct()
|
||||
return ControlFlowUtil.getOutputVariables(flow, flowRange.first, flowRange.last, exitPoints.toIntArray()).distinct()
|
||||
}
|
||||
|
||||
fun findUndeclaredVariables(): List<PsiVariable> {
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
<orderEntry type="module" module-name="intellij.java.indexing" exported="" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -16,7 +16,6 @@ import com.intellij.psi.impl.source.tree.LightTreeUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
import com.intellij.util.io.EnumeratorStringDescriptor;
|
||||
@@ -25,6 +24,7 @@ import com.intellij.util.text.StringSearcher;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.*;
|
||||
|
||||
import static com.intellij.psi.impl.source.tree.JavaElementType.*;
|
||||
|
||||
public class JavaNullMethodArgumentIndex extends ScalarIndexExtension<JavaNullMethodArgumentIndex.MethodCallData> {
|
||||
public final class JavaNullMethodArgumentIndex extends ScalarIndexExtension<JavaNullMethodArgumentIndex.MethodCallData> {
|
||||
private static final Logger LOG = Logger.getInstance(JavaNullMethodArgumentIndex.class);
|
||||
|
||||
public static final ID<MethodCallData, Void> INDEX_ID = ID.create("java.null.method.argument");
|
||||
@@ -74,7 +74,7 @@ public class JavaNullMethodArgumentIndex extends ScalarIndexExtension<JavaNullMe
|
||||
final String name = getMethodName(lighterAst, element, element.getTokenType());
|
||||
if (name != null) {
|
||||
for (int i = 0; i < indices.size(); i++) {
|
||||
result.put(new MethodCallData(name, indices.get(i)), null);
|
||||
result.put(new MethodCallData(name, indices.getInt(i)), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.psi.controlFlow;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
@@ -9,17 +9,17 @@ import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.containers.IntStack;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ControlFlowUtil {
|
||||
public final class ControlFlowUtil {
|
||||
private static final Logger LOG = Logger.getInstance(ControlFlowUtil.class);
|
||||
|
||||
private static class SSAInstructionState implements Cloneable {
|
||||
@@ -557,7 +557,7 @@ public class ControlFlowUtil {
|
||||
for (PsiVariable variable : visibleReadOffsets.keySet()) {
|
||||
final Function<Integer, BitSet> calculator = getReachableInstructionsCalculator();
|
||||
final BitSet collectedOffsets = new BitSet(flowEnd);
|
||||
for (final int writeOffset : writeOffsets.get(variable).toArray()) {
|
||||
for (int writeOffset : writeOffsets.get(variable).toIntArray()) {
|
||||
LOG.assertTrue(writeOffset >= flowStart, "writeOffset");
|
||||
final BitSet reachableOffsets = calculator.fun(writeOffset);
|
||||
collectedOffsets.or(reachableOffsets);
|
||||
@@ -612,9 +612,9 @@ public class ControlFlowUtil {
|
||||
|
||||
private boolean isAnyReadOffsetReachableFrom(@Nullable IntArrayList readOffsets, @NotNull IntArrayList fromOffsets) {
|
||||
if (readOffsets != null && !readOffsets.isEmpty()) {
|
||||
final int[] readOffsetsArray = readOffsets.toArray();
|
||||
final int[] readOffsetsArray = readOffsets.toIntArray();
|
||||
for (int j = 0; j < fromOffsets.size(); j++) {
|
||||
int fromOffset = fromOffsets.get(j);
|
||||
int fromOffset = fromOffsets.getInt(j);
|
||||
if (areInstructionsReachable(flow, readOffsetsArray, fromOffset)) {
|
||||
LOG.debug("reachableFromOffset:", fromOffset);
|
||||
return true;
|
||||
@@ -923,11 +923,11 @@ public class ControlFlowUtil {
|
||||
}
|
||||
|
||||
public static boolean returnPresentBetween(@NotNull ControlFlow flow, final int startOffset, final int endOffset) {
|
||||
class MyVisitor extends InstructionClientVisitor<Boolean> {
|
||||
final class MyVisitor extends InstructionClientVisitor<Boolean> {
|
||||
// false if control flow at this offset terminates either by return called or exception thrown
|
||||
private final boolean[] isNormalCompletion = new boolean[flow.getSize() + 1];
|
||||
|
||||
MyVisitor() {
|
||||
private MyVisitor() {
|
||||
int i;
|
||||
final int length = flow.getSize();
|
||||
for (i = 0; i < startOffset; i++) {
|
||||
@@ -1236,7 +1236,7 @@ public class ControlFlowUtil {
|
||||
*/
|
||||
public static boolean isDominator(ControlFlow flow, int maybeDominator, int target) {
|
||||
class MyVisitor extends InstructionClientVisitor<Boolean> {
|
||||
final BitSet myReachedWithoutDominator = new BitSet();
|
||||
private final BitSet myReachedWithoutDominator = new BitSet();
|
||||
|
||||
@Override
|
||||
public void visitInstruction(Instruction instruction, int offset, int nextOffset) {
|
||||
@@ -2372,7 +2372,7 @@ public class ControlFlowUtil {
|
||||
locationOffsetList.add(offset);
|
||||
}
|
||||
}
|
||||
int[] locationOffsets = locationOffsetList.toArray();
|
||||
int[] locationOffsets = locationOffsetList.toIntArray();
|
||||
|
||||
for (int offset = startOffset; offset < endOffset; offset++) {
|
||||
Instruction instruction = instructions.get(offset);
|
||||
|
||||
@@ -8,18 +8,17 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.containers.Queue;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class DefUseUtil {
|
||||
public final class DefUseUtil {
|
||||
private static final Logger LOG = Logger.getInstance(DefUseUtil.class);
|
||||
|
||||
private DefUseUtil() { }
|
||||
@@ -269,7 +268,7 @@ public class DefUseUtil {
|
||||
|
||||
@Override
|
||||
protected int getNext(int index, int no) {
|
||||
return myBackwardTraces[index].get(no);
|
||||
return myBackwardTraces[index].getInt(no);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -411,11 +410,11 @@ public class DefUseUtil {
|
||||
// hack: ControlFlow doesn't contains parameters initialization
|
||||
int startIndex = elem;
|
||||
|
||||
TIntArrayList workQueue = new TIntArrayList();
|
||||
IntArrayList workQueue = new IntArrayList();
|
||||
workQueue.add(startIndex);
|
||||
|
||||
while (!workQueue.isEmpty()) {
|
||||
int index = workQueue.remove(workQueue.size() - 1);
|
||||
int index = workQueue.removeInt(workQueue.size() - 1);
|
||||
if (visited[index]) {
|
||||
continue;
|
||||
}
|
||||
@@ -526,7 +525,7 @@ public class DefUseUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static class InstructionStateWalker {
|
||||
private static final class InstructionStateWalker {
|
||||
private final Map<InstructionKey, InstructionState> myStates;
|
||||
private final WalkThroughStack myWalkThroughStack;
|
||||
private final List<? extends Instruction> myInstructions;
|
||||
|
||||
@@ -71,5 +71,6 @@
|
||||
<orderEntry type="library" scope="TEST" name="kotlinx-coroutines-jdk8" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics" scope="TEST" />
|
||||
<orderEntry type="library" scope="TEST" name="jaxb-api" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.java.codeInsight.psi;
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
@@ -12,7 +12,7 @@ import com.intellij.psi.PsiJavaFile;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.java.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -39,8 +39,8 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
@@ -242,7 +242,7 @@ public class FindUsagesTest extends JavaPsiTestCase {
|
||||
|
||||
}
|
||||
|
||||
private static class SearchResult implements Comparable<SearchResult> {
|
||||
private static final class SearchResult implements Comparable<SearchResult> {
|
||||
String fileName;
|
||||
int startOffset;
|
||||
int endOffset;
|
||||
@@ -293,7 +293,7 @@ public class FindUsagesTest extends JavaPsiTestCase {
|
||||
for (int i = 0; i < filesList.size(); i++) {
|
||||
PsiFile psiFile = filesList.get(i);
|
||||
actual.add(
|
||||
new SearchResult(psiFile.getName(), i < starts.length ? startsList.get(i) : -1, i < ends.length ? endsList.get(i) : -1));
|
||||
new SearchResult(psiFile.getName(), i < starts.length ? startsList.getInt(i) : -1, i < ends.length ? endsList.getInt(i) : -1));
|
||||
}
|
||||
|
||||
Collections.sort(expected);
|
||||
@@ -350,7 +350,7 @@ public class FindUsagesTest extends JavaPsiTestCase {
|
||||
while(!resolveStarted.get()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
|
||||
WriteAction.run(() -> {
|
||||
toSleepMs.set(0);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.java.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -15,7 +15,7 @@ import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.JavaPsiTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -77,11 +77,11 @@ public class PlainTextUsagesTest extends JavaPsiTestCase {
|
||||
}
|
||||
|
||||
for (int i = 0; i < starts.length; i++) {
|
||||
assertEquals("starts[" + i + "]", starts[i], startsList.get(i));
|
||||
assertEquals("starts[" + i + "]", starts[i], startsList.getInt(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < ends.length; i++) {
|
||||
assertEquals("ends[" + i + "]", ends[i], endsList.get(i));
|
||||
assertEquals("ends[" + i + "]", ends[i], endsList.getInt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
<orderEntry type="library" name="JDOM" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -23,10 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.text.ImmutableCharSequence;
|
||||
import gnu.trove.TIntIntHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -42,7 +42,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
public final class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
private static final Logger LOG = Logger.getInstance(DocumentImpl.class);
|
||||
private static final int STRIP_TRAILING_SPACES_BULK_MODE_LINES_LIMIT = 1000;
|
||||
|
||||
@@ -1197,7 +1197,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
if (myDoingBulkUpdate) throw new UnexpectedBulkUpdateStateException(myBulkUpdateEnteringTrace);
|
||||
}
|
||||
|
||||
private static class UnexpectedBulkUpdateStateException extends RuntimeException implements ExceptionWithAttachments {
|
||||
private static final class UnexpectedBulkUpdateStateException extends RuntimeException implements ExceptionWithAttachments {
|
||||
private final Attachment[] myAttachments;
|
||||
|
||||
private UnexpectedBulkUpdateStateException(Throwable enteringTrace) {
|
||||
|
||||
@@ -1,29 +1,15 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.editor.ex.LineIterator;
|
||||
import com.intellij.openapi.util.text.LineTokenizer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.BitUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.text.MergingCharSequence;
|
||||
import gnu.trove.TByteArrayList;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,7 +20,7 @@ import java.util.Arrays;
|
||||
* <p/>
|
||||
* Immutable.
|
||||
*/
|
||||
public class LineSet{
|
||||
public final class LineSet {
|
||||
private static final int MODIFIED_MASK = 0x4;
|
||||
private static final int SEPARATOR_MASK = 0x3;
|
||||
|
||||
@@ -224,13 +210,13 @@ public class LineSet{
|
||||
return this;
|
||||
}
|
||||
if (indices.size() == 1) {
|
||||
int index = indices.get(0);
|
||||
int index = indices.getInt(0);
|
||||
if (isLastEmptyLine(index) || isModified(index)) return this;
|
||||
}
|
||||
|
||||
byte[] flags = myFlags.clone();
|
||||
for (int i=0; i<indices.size();i++) {
|
||||
int index = indices.get(i);
|
||||
int index = indices.getInt(i);
|
||||
flags[index] |= MODIFIED_MASK;
|
||||
}
|
||||
return new LineSet(myStarts, flags, myLength);
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel" />
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+6
-7
@@ -1,5 +1,4 @@
|
||||
// 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.
|
||||
|
||||
package com.intellij.openapi.editor.ex.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
@@ -23,9 +22,9 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.MergingCharSequence;
|
||||
import gnu.trove.TIntIntHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
getSegments().removeAll();
|
||||
}
|
||||
|
||||
public synchronized void unregisterLayer(@NotNull IElementType tokenType) {
|
||||
protected synchronized void unregisterLayer(@NotNull IElementType tokenType) {
|
||||
final LayerDescriptor layer = myTokensToLayer.remove(tokenType);
|
||||
if (layer != null) {
|
||||
getSegments().myLayerBuffers.remove(layer);
|
||||
@@ -93,7 +92,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
int start = insertOffset;
|
||||
for (int i = 0; i < tokenTypes.size(); i++) {
|
||||
IElementType type = tokenTypes.get(i);
|
||||
final int len = lengths.get(i);
|
||||
final int len = lengths.getInt(i);
|
||||
start += mySeparator.length();
|
||||
final int globalIndex = index2Global.get(i);
|
||||
MappedRange[] ranges = getSegments().myRanges;
|
||||
@@ -186,7 +185,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
return super.createIterator(startOffset);
|
||||
}
|
||||
|
||||
private class MappingSegments extends SegmentArrayWithData {
|
||||
private final class MappingSegments extends SegmentArrayWithData {
|
||||
private MappedRange[] myRanges = new MappedRange[INITIAL_SIZE];
|
||||
private final Map<LayerDescriptor, Mapper> myLayerBuffers = new HashMap<>();
|
||||
|
||||
@@ -334,7 +333,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
}
|
||||
}
|
||||
|
||||
private class Mapper implements HighlighterClient {
|
||||
private final class Mapper implements HighlighterClient {
|
||||
private final DocumentImpl doc;
|
||||
private final EditorHighlighter highlighter;
|
||||
private final String mySeparator;
|
||||
@@ -489,7 +488,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
|
||||
return getSegments().myRanges[segmentIndex] != null;
|
||||
}
|
||||
|
||||
private class LayeredHighlighterIteratorImpl implements LayeredHighlighterIterator {
|
||||
private final class LayeredHighlighterIteratorImpl implements LayeredHighlighterIterator {
|
||||
private final HighlighterIterator myBaseIterator;
|
||||
private HighlighterIterator myLayerIterator;
|
||||
private int myLayerStartOffset;
|
||||
|
||||
+2
-2
@@ -1,7 +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.
|
||||
package com.intellij.refactoring.suggested
|
||||
|
||||
import com.intellij.util.containers.IntArrayList
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||
|
||||
/**
|
||||
* Finds an increasing subsequence of element in the list with the maximum sum of [weightFunction] for all elements.
|
||||
@@ -38,5 +38,5 @@ internal fun <T : Comparable<T>> findMaximumWeightIncreasingSubsequence(list: Li
|
||||
result.add(index)
|
||||
index = subsequenceLastButOneItems[index]
|
||||
}
|
||||
return result.toArray().reversedArray()
|
||||
return result.toIntArray().reversedArray()
|
||||
}
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
|
||||
public class LineWrapper {
|
||||
|
||||
public static IntArrayList calcBreakOffsets(char[] text, int startOffset, int endOffset, boolean lineStart, double x, double clipX,
|
||||
WidthProvider widthProvider) {
|
||||
public final class LineWrapper {
|
||||
public static IntArrayList calcBreakOffsets(char[] text, int startOffset, int endOffset, boolean lineStart, double x, double clipX,
|
||||
WidthProvider widthProvider) {
|
||||
IntArrayList breakOffsets = new IntArrayList();
|
||||
int nextOffset = startOffset;
|
||||
while (true) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.ui.paint.LinePainter2D;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -42,7 +42,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class TextPainter extends BasePainter {
|
||||
final class TextPainter extends BasePainter {
|
||||
private final DocumentEx myDocument;
|
||||
private RangeMarker myRangeToPrint;
|
||||
private int myOffset;
|
||||
@@ -631,7 +631,7 @@ class TextPainter extends BasePainter {
|
||||
IntArrayList breakOffsets = LineWrapper.calcBreakOffsets(text, myOffset, end, lineStart, position.getX(), clip.getWidth(),
|
||||
(t, start, count, x) -> getTextSegmentWidth(t, start, count, x, g));
|
||||
for (int i = 0; i < breakOffsets.size(); i++) {
|
||||
int breakOffset = breakOffsets.get(i);
|
||||
int breakOffset = breakOffsets.getInt(i);
|
||||
drawTabbedString(g, text, breakOffset - myOffset, position, backColor, underscoredColor);
|
||||
position.setLocation(0, position.getY() + getLineHeight(g));
|
||||
if (position.getY() > clip.getY() + clip.getHeight() - getLineHeight(g)) {
|
||||
@@ -736,7 +736,7 @@ class TextPainter extends BasePainter {
|
||||
return v.getLogicalBounds().getWidth();
|
||||
}
|
||||
|
||||
public double nextTabStop(Graphics2D g, double x) {
|
||||
private double nextTabStop(Graphics2D g, double x) {
|
||||
double tabSize = myCodeStyleSettings.getTabSize(myFileType);
|
||||
if (tabSize <= 0) {
|
||||
tabSize = 1;
|
||||
@@ -755,7 +755,7 @@ class TextPainter extends BasePainter {
|
||||
}
|
||||
|
||||
// Wraps HighlighterIterator, joining adjacent regions with identical attributes
|
||||
private static class HighlightingAttributesIterator {
|
||||
private static final class HighlightingAttributesIterator {
|
||||
@NotNull private final HighlighterIterator myDelegate;
|
||||
private int myEnd;
|
||||
private TextAttributes myAttributes;
|
||||
|
||||
+18
-33
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// 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.
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
@@ -47,8 +32,8 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -56,7 +41,7 @@ import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHandler {
|
||||
public final class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHandler {
|
||||
private Editor myEditor;
|
||||
private Caret myCaret;
|
||||
private PsiFile myFile;
|
||||
@@ -171,7 +156,7 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
myEditor.getScrollingModel().disableAnimation();
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
myEditor.getScrollingModel().enableAnimation();
|
||||
|
||||
|
||||
LogicalPosition hintPosition = myCaret.getLogicalPosition();
|
||||
if (myWarningLocation != null) {
|
||||
LogicalPosition targetPosition = myEditor.offsetToLogicalPosition(myWarningLocation.getStartOffset());
|
||||
@@ -459,15 +444,15 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
CodeDocumentationAwareCommenter commenter = (CodeDocumentationAwareCommenter)myCommenter;
|
||||
HighlighterIterator it = ((EditorEx)myEditor).getHighlighter().createIterator(offset - 1);
|
||||
IElementType tokenType = it.getTokenType();
|
||||
return (tokenType != null && (it.getEnd() > offset && (tokenType == commenter.getLineCommentTokenType() ||
|
||||
return (tokenType != null && (it.getEnd() > offset && (tokenType == commenter.getLineCommentTokenType() ||
|
||||
tokenType == commenter.getBlockCommentTokenType() ||
|
||||
tokenType == commenter.getDocumentationCommentTokenType()) ||
|
||||
includingAfterLineComment && it.getEnd() == offset && tokenType == commenter.getLineCommentTokenType() &&
|
||||
tokenType == commenter.getDocumentationCommentTokenType()) ||
|
||||
includingAfterLineComment && it.getEnd() == offset && tokenType == commenter.getLineCommentTokenType() &&
|
||||
!(commenter instanceof CommenterWithLineSuffix)));
|
||||
}
|
||||
|
||||
private boolean canDetectBlockComments() {
|
||||
return myEditor instanceof EditorEx && myCommenter instanceof CodeDocumentationAwareCommenter &&
|
||||
return myEditor instanceof EditorEx && myCommenter instanceof CodeDocumentationAwareCommenter &&
|
||||
((CodeDocumentationAwareCommenter)myCommenter).getBlockCommentTokenType() != null;
|
||||
}
|
||||
|
||||
@@ -561,13 +546,13 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
}
|
||||
if (warnAboutNestedComments) {
|
||||
myWarning = CodeInsightBundle.message("block.comment.nested.comment", nestedCommentPrefixes.size());
|
||||
myWarningLocation = myDocument.createRangeMarker(nestedCommentPrefixes.get(0),
|
||||
nestedCommentPrefixes.get(0) + normalizedPrefix.length());
|
||||
myWarningLocation = myDocument.createRangeMarker(nestedCommentPrefixes.getInt(0),
|
||||
nestedCommentPrefixes.getInt(0) + normalizedPrefix.length());
|
||||
}
|
||||
int shift = 0;
|
||||
if (!(commentedSuffix == null &&
|
||||
!nestedCommentSuffixes.isEmpty() &&
|
||||
nestedCommentSuffixes.get(nestedCommentSuffixes.size() - 1) + commentSuffix.length() == endOffset)) {
|
||||
nestedCommentSuffixes.getInt(nestedCommentSuffixes.size() - 1) + commentSuffix.length() == endOffset)) {
|
||||
myDocument.insertString(endOffset, commentSuffix);
|
||||
shift += commentSuffix.length();
|
||||
}
|
||||
@@ -577,8 +562,8 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
int j = nestedCommentSuffixes.size() - 1;
|
||||
final TextRange selection = new TextRange(startOffset, endOffset);
|
||||
while (i >= 0 && j >= 0) {
|
||||
final int prefixIndex = nestedCommentPrefixes.get(i);
|
||||
final int suffixIndex = nestedCommentSuffixes.get(j);
|
||||
final int prefixIndex = nestedCommentPrefixes.getInt(i);
|
||||
final int suffixIndex = nestedCommentSuffixes.getInt(j);
|
||||
if (prefixIndex > suffixIndex) {
|
||||
shift += doBoundCommentingAndGetShift(prefixIndex, commentedPrefix, normalizedPrefix.length(), commentSuffix, false, selection);
|
||||
--i;
|
||||
@@ -592,16 +577,16 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
}
|
||||
}
|
||||
while (i >= 0) {
|
||||
final int prefixIndex = nestedCommentPrefixes.get(i);
|
||||
final int prefixIndex = nestedCommentPrefixes.getInt(i);
|
||||
shift += doBoundCommentingAndGetShift(prefixIndex, commentedPrefix, normalizedPrefix.length(), commentSuffix, false, selection);
|
||||
--i;
|
||||
}
|
||||
while (j >= 0) {
|
||||
final int suffixIndex = nestedCommentSuffixes.get(j);
|
||||
final int suffixIndex = nestedCommentSuffixes.getInt(j);
|
||||
shift += doBoundCommentingAndGetShift(suffixIndex, commentedSuffix, normalizedSuffix.length(), commentPrefix, true, selection);
|
||||
--j;
|
||||
}
|
||||
if (!(commentedPrefix == null && !nestedCommentPrefixes.isEmpty() && nestedCommentPrefixes.get(0) == startOffset)) {
|
||||
if (!(commentedPrefix == null && !nestedCommentPrefixes.isEmpty() && nestedCommentPrefixes.getInt(0) == startOffset)) {
|
||||
myDocument.insertString(startOffset, commentPrefix);
|
||||
shift += commentPrefix.length();
|
||||
}
|
||||
@@ -684,8 +669,8 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
|
||||
int prefixIndex = prefixes.size() - 1;
|
||||
for (int i = toReplaceWithComments.size() - 1; i >= 0; i--) {
|
||||
int position = toReplaceWithComments.get(i);
|
||||
if (prefixIndex >= 0 && position == prefixes.get(prefixIndex)) {
|
||||
int position = toReplaceWithComments.getInt(i);
|
||||
if (prefixIndex >= 0 && position == prefixes.getInt(prefixIndex)) {
|
||||
prefixIndex--;
|
||||
document.replaceString(offset + position, offset + position + commentedPrefix.length(), commentPrefix);
|
||||
}
|
||||
|
||||
+12
-15
@@ -1,5 +1,4 @@
|
||||
// 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.
|
||||
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
@@ -32,16 +31,15 @@ import com.intellij.psi.impl.source.tree.injected.InjectedCaret;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHandler {
|
||||
|
||||
public final class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHandler {
|
||||
private static final Key<Boolean> INJECTION_FORBIDS_LINE_COMMENTS = Key.create("INJECTION_FORBIDS_LINE_COMMENTS");
|
||||
|
||||
/**
|
||||
@@ -304,8 +302,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
final SyntaxTable mySyntaxTable = ((CustomSyntaxTableFileType)file.getFileType()).getSyntaxTable();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getLineCommentPrefix() {
|
||||
public @NotNull String getLineCommentPrefix() {
|
||||
return mySyntaxTable.getLineComment();
|
||||
}
|
||||
|
||||
@@ -403,7 +400,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
private static Language getLineEndLanguage(@NotNull PsiFile file, @NotNull Editor editor, int line) {
|
||||
Document document = editor.getDocument();
|
||||
int lineEndOffset = document.getLineEndOffset(line) - 1;
|
||||
lineEndOffset = Math.max(0, CharArrayUtil.shiftBackward(document.getCharsSequence(), lineEndOffset < 0 ? 0 : lineEndOffset, " \t"));
|
||||
lineEndOffset = Math.max(0, CharArrayUtil.shiftBackward(document.getCharsSequence(), Math.max(lineEndOffset, 0), " \t"));
|
||||
return PsiUtilCore.getLanguageAtOffset(file, lineEndOffset);
|
||||
}
|
||||
|
||||
@@ -436,7 +433,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
return CharArrayUtil.regionMatches(chars, offset, prefix) ? offset : -1;
|
||||
}
|
||||
|
||||
public void doDefaultCommenting(final Block block) {
|
||||
private void doDefaultCommenting(final Block block) {
|
||||
final Document document = block.editor.getDocument();
|
||||
DocumentUtil.executeInBulk(
|
||||
document, block.endLine - block.startLine >= Registry.intValue("comment.by.line.bulk.lines.trigger"), () -> {
|
||||
@@ -508,7 +505,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
}
|
||||
|
||||
if (commenter instanceof SelfManagingCommenter) {
|
||||
final SelfManagingCommenter selfManagingCommenter = (SelfManagingCommenter)commenter;
|
||||
SelfManagingCommenter selfManagingCommenter = (SelfManagingCommenter)commenter;
|
||||
selfManagingCommenter.uncommentLine(line, startOffset, document, block.commenterStateMap.get(selfManagingCommenter));
|
||||
return;
|
||||
}
|
||||
@@ -593,7 +590,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
assert prefixes.size() == suffixes.size();
|
||||
|
||||
for (int i = prefixes.size() - 1; i >= 0; i--) {
|
||||
uncommentRange(document, startOffset + prefixes.get(i), Math.min(startOffset + suffixes.get(i) + suffix.length(), endOffset), commenter);
|
||||
uncommentRange(document, startOffset + prefixes.getInt(i), Math.min(startOffset + suffixes.getInt(i) + suffix.length(), endOffset), commenter);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -698,14 +695,14 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
position = nearestSuffix + suffix.length();
|
||||
}
|
||||
}
|
||||
if (!(commentedSuffix == null && !suffixes.isEmpty() && offset + suffixes.get(suffixes.size() - 1) + suffix.length() >= endOffset)) {
|
||||
if (!(commentedSuffix == null && !suffixes.isEmpty() && offset + suffixes.getInt(suffixes.size() - 1) + suffix.length() >= endOffset)) {
|
||||
document.insertString(endOffset, suffix);
|
||||
}
|
||||
int nearestPrefix = prefixes.size() - 1;
|
||||
int nearestSuffix = suffixes.size() - 1;
|
||||
while (nearestPrefix >= 0 || nearestSuffix >= 0) {
|
||||
if (nearestSuffix == -1 || nearestPrefix != -1 && prefixes.get(nearestPrefix) > suffixes.get(nearestSuffix)) {
|
||||
final int position = prefixes.get(nearestPrefix);
|
||||
if (nearestSuffix == -1 || nearestPrefix != -1 && prefixes.getInt(nearestPrefix) > suffixes.getInt(nearestSuffix)) {
|
||||
final int position = prefixes.getInt(nearestPrefix);
|
||||
nearestPrefix--;
|
||||
if (commentedPrefix != null) {
|
||||
document.replaceString(offset + position, offset + position + prefix.length(), commentedPrefix);
|
||||
@@ -715,7 +712,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
}
|
||||
}
|
||||
else {
|
||||
final int position = suffixes.get(nearestSuffix);
|
||||
final int position = suffixes.getInt(nearestSuffix);
|
||||
nearestSuffix--;
|
||||
if (commentedSuffix != null) {
|
||||
document.replaceString(offset + position, offset + position + suffix.length(), commentedSuffix);
|
||||
@@ -725,7 +722,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(commentedPrefix == null && !prefixes.isEmpty() && prefixes.get(0) == 0)) {
|
||||
if (!(commentedPrefix == null && !prefixes.isEmpty() && prefixes.getInt(0) == 0)) {
|
||||
document.insertString(offset, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.refactoring.rename.inplace.InplaceRefactoring;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TemplateState implements Disposable {
|
||||
public final class TemplateState implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(TemplateState.class);
|
||||
private Project myProject;
|
||||
private Editor myEditor;
|
||||
@@ -753,7 +753,7 @@ public class TemplateState implements Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private static class TemplateDocumentChange {
|
||||
private static final class TemplateDocumentChange {
|
||||
public final String newValue;
|
||||
public final int startOffset;
|
||||
public final int endOffset;
|
||||
@@ -1182,7 +1182,7 @@ public class TemplateState implements Disposable {
|
||||
private void restoreEmptyVariables(IntArrayList indices) {
|
||||
List<TextRange> rangesToRemove = new ArrayList<>();
|
||||
for (int i = 0; i < indices.size(); i++) {
|
||||
int index = indices.get(i);
|
||||
int index = indices.getInt(i);
|
||||
rangesToRemove.add(TextRange.create(mySegments.getSegmentStart(index), mySegments.getSegmentEnd(index)));
|
||||
}
|
||||
rangesToRemove.sort((o1, o2) -> {
|
||||
@@ -1436,7 +1436,7 @@ public class TemplateState implements Disposable {
|
||||
return myEditor;
|
||||
}
|
||||
|
||||
private static class MyBasicUndoableAction extends BasicUndoableAction implements Disposable {
|
||||
private static final class MyBasicUndoableAction extends BasicUndoableAction implements Disposable {
|
||||
@Nullable
|
||||
private TemplateState myTemplateState;
|
||||
|
||||
|
||||
+4
-18
@@ -1,24 +1,10 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.intellij.codeEditor.printing;
|
||||
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class LineWrapperTest {
|
||||
private final LineWrapper.WidthProvider myWidthProvider = new LineWrapper.WidthProvider() {
|
||||
@@ -69,6 +55,6 @@ public class LineWrapperTest {
|
||||
|
||||
private void doTest(String text, boolean atLineStart, double clipWidth, int... expectedBreaks) {
|
||||
IntArrayList actualBreaks = LineWrapper.calcBreakOffsets(text.toCharArray(), 0, text.length(), atLineStart, 0, clipWidth, myWidthProvider);
|
||||
assertArrayEquals(expectedBreaks, actualBreaks.toArray());
|
||||
assertArrayEquals(expectedBreaks, actualBreaks.toIntArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.objectSerializer.annotations" />
|
||||
<orderEntry type="library" name="lz4-java" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.serialization.xml
|
||||
|
||||
import com.intellij.openapi.components.BaseState
|
||||
@@ -6,9 +6,9 @@ import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.serialization.BaseBeanBinding
|
||||
import com.intellij.serialization.PropertyAccessor
|
||||
import com.intellij.util.ObjectUtils
|
||||
import com.intellij.util.containers.IntArrayList
|
||||
import com.intellij.util.xmlb.BeanBinding
|
||||
import com.intellij.util.xmlb.SerializationFilter
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||
import org.jdom.Element
|
||||
|
||||
internal class KotlinAwareBeanBinding(beanClass: Class<*>) : BeanBinding(beanClass) {
|
||||
@@ -64,8 +64,8 @@ internal class KotlinAwareBeanBinding(beanClass: Class<*>) : BeanBinding(beanCla
|
||||
|
||||
if (bindingIndices != null) {
|
||||
bindingIndices.sort()
|
||||
for (i in 0 until bindingIndices.size()) {
|
||||
element = serializePropertyInto(myBindings[bindingIndices.getQuick(i)], o, element, filter, false)
|
||||
for (i in 0 until bindingIndices.size) {
|
||||
element = serializePropertyInto(myBindings[bindingIndices.getInt(i)], o, element, filter, false)
|
||||
}
|
||||
}
|
||||
return element
|
||||
|
||||
+4
-5
@@ -1,12 +1,12 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -16,8 +16,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileOffsetsManager {
|
||||
|
||||
public final class FileOffsetsManager {
|
||||
@NotNull
|
||||
public static FileOffsetsManager getInstance() {
|
||||
return ServiceManager.getService(FileOffsetsManager.class);
|
||||
@@ -176,6 +175,6 @@ public class FileOffsetsManager {
|
||||
prev = c;
|
||||
}
|
||||
|
||||
return new LineOffsets(modificationStamp, originalLineOffsets.toArray(), convertedLineOffsets.toArray());
|
||||
return new LineOffsets(modificationStamp, originalLineOffsets.toIntArray(), convertedLineOffsets.toIntArray());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -25,7 +25,6 @@ import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import com.intellij.util.containers.ConcurrentIntObjectMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.containers.ObjectIntHashMap;
|
||||
import com.intellij.util.hash.ContentHashEnumerator;
|
||||
import com.intellij.util.io.DataOutputStream;
|
||||
@@ -33,6 +32,7 @@ import com.intellij.util.io.*;
|
||||
import com.intellij.util.io.storage.*;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -49,7 +49,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class FSRecords {
|
||||
public final class FSRecords {
|
||||
private static final Logger LOG = Logger.getInstance(FSRecords.class);
|
||||
|
||||
public static final boolean WE_HAVE_CONTENT_HASHES = SystemProperties.getBooleanProperty("idea.share.contents", true);
|
||||
@@ -171,7 +171,7 @@ public class FSRecords {
|
||||
return msg;
|
||||
}
|
||||
|
||||
private static class DbConnection {
|
||||
private static final class DbConnection {
|
||||
private static boolean ourInitialized;
|
||||
|
||||
private static PersistentStringEnumerator myNames;
|
||||
@@ -1645,7 +1645,7 @@ public class FSRecords {
|
||||
return stream;
|
||||
}
|
||||
|
||||
private static class ContentOutputStream extends DataOutputStream {
|
||||
private static final class ContentOutputStream extends DataOutputStream {
|
||||
final int myFileId;
|
||||
final boolean myFixedSize;
|
||||
|
||||
@@ -1753,7 +1753,7 @@ public class FSRecords {
|
||||
}
|
||||
}
|
||||
|
||||
private static class AttributeOutputStream extends DataOutputStream {
|
||||
private static final class AttributeOutputStream extends DataOutputStream {
|
||||
@NotNull
|
||||
private final FileAttribute myAttribute;
|
||||
private final int myFileId;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<orderEntry type="library" name="OroMatcher" level="project" />
|
||||
<orderEntry type="library" name="lz4-java" level="project" />
|
||||
<orderEntry type="library" name="commons-compress" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
|
||||
package com.intellij.util.containers;
|
||||
|
||||
@@ -22,9 +8,8 @@ import java.util.Iterator;
|
||||
/**
|
||||
* @author lvo
|
||||
*/
|
||||
public class IntObjectCache<T> extends ObjectCacheBase implements Iterable<T> {
|
||||
|
||||
public static final int DEFAULT_SIZE = 8192;
|
||||
public final class IntObjectCache<T> extends ObjectCacheBase implements Iterable<T> {
|
||||
private static final int DEFAULT_SIZE = 8192;
|
||||
public static final int MIN_SIZE = 4;
|
||||
|
||||
private int myTop;
|
||||
@@ -108,7 +93,7 @@ public class IntObjectCache<T> extends ObjectCacheBase implements Iterable<T> {
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
final IntArrayList keys = new IntArrayList(count());
|
||||
final it.unimi.dsi.fastutil.ints.IntArrayList keys = new it.unimi.dsi.fastutil.ints.IntArrayList(count());
|
||||
int current = myTop;
|
||||
while (current > 0) {
|
||||
if (myCache[current].value != null) {
|
||||
@@ -117,7 +102,7 @@ public class IntObjectCache<T> extends ObjectCacheBase implements Iterable<T> {
|
||||
current = myCache[current].next;
|
||||
}
|
||||
for (int i = 0; i < keys.size(); ++ i) {
|
||||
remove(keys.get(i));
|
||||
remove(keys.getInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +139,7 @@ public class IntObjectCache<T> extends ObjectCacheBase implements Iterable<T> {
|
||||
myCache[index].value = x;
|
||||
addEntry2HashTable(index);
|
||||
add2Top(index);
|
||||
|
||||
|
||||
if (deletedValue != null) {
|
||||
fireListenersAboutDeletion(deletedKey, deletedValue);
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
<orderEntry type="library" name="Kryo" level="project" />
|
||||
<orderEntry type="library" name="Objenesis" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ex" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -3,8 +3,8 @@ package com.intellij.workspace.api
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.containers.IntArrayList
|
||||
import gnu.trove.THashMap
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||
import kotlin.collections.set
|
||||
|
||||
interface VirtualFileUrlManager {
|
||||
@@ -20,7 +20,7 @@ class VirtualFileUrlManagerImpl: VirtualFileUrlManager {
|
||||
private val idGenerator= IntIdGenerator()
|
||||
private val EMPTY_URL = VirtualFileUrl(0, this)
|
||||
private val fileNameStore = VirtualFileNameStore()
|
||||
private val id2NodeMapping = THashMap<Int, FilePathNode>()
|
||||
private val id2NodeMapping = Int2ObjectOpenHashMap<FilePathNode>()
|
||||
private val rootNode = FilePathNode(0, 0)
|
||||
|
||||
@Synchronized
|
||||
@@ -34,7 +34,7 @@ class VirtualFileUrlManagerImpl: VirtualFileUrlManager {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getParentVirtualUrlById(id: Int): VirtualFileUrl? = id2NodeMapping[id]?.parent?.let { VirtualFileUrl(it.nodeId, this) }
|
||||
override fun getParentVirtualUrlById(id: Int): VirtualFileUrl? = id2NodeMapping.get(id)?.parent?.let { VirtualFileUrl(it.nodeId, this) }
|
||||
|
||||
@Synchronized
|
||||
override fun getUrlById(id: Int): String {
|
||||
@@ -47,14 +47,14 @@ class VirtualFileUrlManagerImpl: VirtualFileUrlManager {
|
||||
node = node.parent
|
||||
}
|
||||
|
||||
if (contentIds.size() == 1) {
|
||||
return fileNameStore.getNameForId(contentIds[0])?.let {
|
||||
if (contentIds.size == 1) {
|
||||
return fileNameStore.getNameForId(contentIds.getInt(0))?.let {
|
||||
return@let if (it.isEmpty()) "/" else it
|
||||
} ?: ""
|
||||
}
|
||||
val builder = StringBuilder()
|
||||
for (index in contentIds.size() - 1 downTo 0) {
|
||||
builder.append(fileNameStore.getNameForId(contentIds[index]))
|
||||
for (index in contentIds.size - 1 downTo 0) {
|
||||
builder.append(fileNameStore.getNameForId(contentIds.getInt(index)))
|
||||
if (index != 0) builder.append("/")
|
||||
}
|
||||
return builder.toString()
|
||||
@@ -208,28 +208,28 @@ class VirtualFileUrlManagerImpl: VirtualFileUrlManager {
|
||||
private inner class FilePathNode(val nodeId: Int, val contentId: Int, val parent: FilePathNode? = null) {
|
||||
private var children: MutableList<FilePathNode>? = null
|
||||
|
||||
internal fun findChild(nameId: Int): FilePathNode? {
|
||||
fun findChild(nameId: Int): FilePathNode? {
|
||||
// If search of child node will be slow, replace SmartList to THashSet
|
||||
// For now SmartList reduce 500Kb memory on IDEA project
|
||||
return children?.find { it.contentId == nameId }
|
||||
}
|
||||
|
||||
internal fun addChild(newNode: FilePathNode) {
|
||||
fun addChild(newNode: FilePathNode) {
|
||||
createChildrenList()
|
||||
children!!.add(newNode)
|
||||
}
|
||||
|
||||
internal fun removeChild(node: FilePathNode) {
|
||||
fun removeChild(node: FilePathNode) {
|
||||
children?.remove(node)
|
||||
}
|
||||
|
||||
internal fun isEmpty() = children == null || children!!.isEmpty()
|
||||
fun isEmpty() = children == null || children!!.isEmpty()
|
||||
|
||||
private fun createChildrenList() {
|
||||
if (children == null) children = SmartList()
|
||||
}
|
||||
|
||||
internal fun print(): String {
|
||||
fun print(): String {
|
||||
val buffer = StringBuilder()
|
||||
print(buffer, "", "")
|
||||
return buffer.toString()
|
||||
|
||||
+4
-19
@@ -1,30 +1,16 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// 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.
|
||||
package com.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiSuperMethodUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.RenameFix;
|
||||
import com.siyeh.ig.psiutils.MethodUtils;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -33,8 +19,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class LambdaUnfriendlyMethodOverloadInspection extends BaseInspection {
|
||||
|
||||
public final class LambdaUnfriendlyMethodOverloadInspection extends BaseInspection {
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
@@ -109,7 +94,7 @@ public class LambdaUnfriendlyMethodOverloadInspection extends BaseInspection {
|
||||
final int max = functionalIndices.size();
|
||||
boolean equalTypes = true;
|
||||
for (int i = 0; i < max; i++) {
|
||||
final int index = functionalIndices.get(i);
|
||||
final int index = functionalIndices.getInt(i);
|
||||
final PsiType otherFunctionalType = otherParameters[index].getType();
|
||||
if (!LambdaUtil.isFunctionalType(otherFunctionalType)) {
|
||||
continue outer;
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.analysis.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="library" name="NanoXML" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+6
-17
@@ -17,29 +17,18 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.Graph;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
import com.intellij.util.graph.InboundSemiGraph;
|
||||
import com.intellij.util.graph.*;
|
||||
import gnu.trove.THashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class ResourceBundlePropertiesUpdateManager {
|
||||
public final class ResourceBundlePropertiesUpdateManager {
|
||||
private final static Logger LOG = Logger.getInstance(ResourceBundlePropertiesUpdateManager.class);
|
||||
|
||||
private final ResourceBundle myResourceBundle;
|
||||
@@ -249,7 +238,7 @@ public class ResourceBundlePropertiesUpdateManager {
|
||||
if (myKeyIndices.containsKey(key)) {
|
||||
final IntArrayList indices = myKeyIndices.get(key);
|
||||
for (int i = 0; i < indices.size(); i++) {
|
||||
final int searchIdx = indices.getQuick(i) + 1;
|
||||
final int searchIdx = indices.getInt(i) + 1;
|
||||
if (searchIdx < myKeys.size()) {
|
||||
final String nextProperty = myKeys.get(searchIdx);
|
||||
if (nextProperty != null) {
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
|
||||
<orderEntry type="module" module-name="intellij.spellchecker" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" exported="" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 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.
|
||||
// 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.
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.actions.CommonEditActionsProvider;
|
||||
@@ -11,7 +11,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.SideBorder;
|
||||
import com.intellij.ui.components.JBLayeredPane;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -253,7 +253,7 @@ public class CaptionPanel extends JBLayeredPane implements DataProvider, DeleteP
|
||||
int selectionSize = oldSelection.size();
|
||||
|
||||
for (int i = 0; i < selectionSize; i++) {
|
||||
int index = oldSelection.get(i);
|
||||
int index = oldSelection.getInt(i);
|
||||
if (0 <= index && index < componentSize) {
|
||||
newSelection.add(myRootChildren.get(index));
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// 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.
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.*;
|
||||
@@ -43,10 +43,10 @@ import com.intellij.ui.components.JBLayeredPane;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.FixedHashMap;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -576,7 +576,7 @@ public abstract class DesignerEditorPanel extends JPanel
|
||||
for (int i = 0; i < myExpandedState.length; i++) {
|
||||
IntArrayList path = new IntArrayList();
|
||||
componentToPath((RadComponent)myExpandedComponents.get(i), path);
|
||||
myExpandedState[i] = path.toArray();
|
||||
myExpandedState[i] = path.toIntArray();
|
||||
}
|
||||
|
||||
mySelectionState = getSelectionState();
|
||||
@@ -608,7 +608,7 @@ public abstract class DesignerEditorPanel extends JPanel
|
||||
for (int i = 0; i < selectionState.length; i++) {
|
||||
IntArrayList path = new IntArrayList();
|
||||
componentToPath(selection.get(i), path);
|
||||
selectionState[i] = path.toArray();
|
||||
selectionState[i] = path.toIntArray();
|
||||
}
|
||||
|
||||
return selectionState;
|
||||
|
||||
Reference in New Issue
Block a user