mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+5
-1
@@ -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-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.
|
||||
package com.intellij.debugger.engine.evaluation;
|
||||
|
||||
import com.intellij.debugger.EvaluatingComputable;
|
||||
@@ -154,4 +154,8 @@ public final class EvaluationContextImpl implements EvaluationContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEvaluationPossible() {
|
||||
return getSuspendContext().getDebugProcess().isEvaluationPossible(getSuspendContext());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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-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.
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
@@ -46,6 +46,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -287,4 +288,23 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
}
|
||||
return StreamEx.empty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static byte[] readBytesArray(Value bytesArray) {
|
||||
if (bytesArray instanceof ArrayReference) {
|
||||
List<Value> values = ((ArrayReference)bytesArray).getValues();
|
||||
byte[] res = new byte[values.size()];
|
||||
int idx = 0;
|
||||
for (Value value : values) {
|
||||
if (value instanceof ByteValue) {
|
||||
res[idx++] = ((ByteValue)value).value();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -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-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.
|
||||
package com.intellij.debugger.impl.attach;
|
||||
|
||||
import com.intellij.debugger.engine.RemoteStateState;
|
||||
@@ -182,6 +182,7 @@ public class JavaAttachDebuggerProvider implements XLocalAttachDebuggerProvider
|
||||
if (param.startsWith("address")) {
|
||||
try {
|
||||
address = param.split("=")[1];
|
||||
address = StringUtil.trimStart(address, "*:"); // handle java 9 format: *:5005
|
||||
return new DebuggerLocalAttachInfo(socket, address, null, pid, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
+9
-5
@@ -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-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.
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
@@ -7,6 +7,7 @@ import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.PositionManagerImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -256,10 +257,13 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase<JavaLineB
|
||||
public XSourcePosition getSourcePosition(@NotNull XBreakpoint<JavaLineBreakpointProperties> breakpoint) {
|
||||
Integer ordinal = getLambdaOrdinal(breakpoint);
|
||||
if (ordinal != null && ordinal > -1) {
|
||||
SourcePosition linePosition = createLineSourcePosition((XLineBreakpointImpl)breakpoint);
|
||||
if (linePosition != null) {
|
||||
return DebuggerUtilsEx.toXSourcePosition(new PositionManagerImpl.JavaSourcePosition(linePosition, ordinal));
|
||||
}
|
||||
return ReadAction.compute(() -> {
|
||||
SourcePosition linePosition = createLineSourcePosition((XLineBreakpointImpl)breakpoint);
|
||||
if (linePosition != null) {
|
||||
return DebuggerUtilsEx.toXSourcePosition(new PositionManagerImpl.JavaSourcePosition(linePosition, ordinal));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+23
-18
@@ -1,23 +1,12 @@
|
||||
/*
|
||||
* 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-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.
|
||||
package com.intellij.debugger.ui.tree.render;
|
||||
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.evaluation.*;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsImpl;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.tree.ValueDescriptor;
|
||||
import com.sun.jdi.ArrayReference;
|
||||
import com.sun.jdi.Value;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
@@ -26,7 +15,23 @@ public class ByteArrayAsStringRenderer extends CompoundReferenceRenderer {
|
||||
public ByteArrayAsStringRenderer(final NodeRendererSettings rendererSettings) {
|
||||
super(rendererSettings, "String", null, null);
|
||||
setClassName("byte[]");
|
||||
LabelRenderer labelRenderer = new LabelRenderer();
|
||||
LabelRenderer labelRenderer = new LabelRenderer() {
|
||||
@Override
|
||||
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener)
|
||||
throws EvaluateException {
|
||||
if (evaluationContext instanceof EvaluationContextImpl && !((EvaluationContextImpl)evaluationContext).isEvaluationPossible()) {
|
||||
Value value = descriptor.getValue();
|
||||
if (value instanceof ArrayReference) {
|
||||
// TODO: read charset from the target vm
|
||||
byte[] bytes = DebuggerUtilsImpl.readBytesArray(value);
|
||||
if (bytes != null) {
|
||||
return new String(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.calcLabel(descriptor, evaluationContext, labelListener);
|
||||
}
|
||||
};
|
||||
labelRenderer.setLabelExpression(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "new String(this)"));
|
||||
setLabelRenderer(labelRenderer);
|
||||
}
|
||||
|
||||
+3
-20
@@ -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-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.
|
||||
package com.intellij.debugger.ui.tree.render;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
@@ -8,6 +8,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.impl.ClassLoadingUtils;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsImpl;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -61,7 +62,7 @@ class ImageObjectRenderer extends CompoundReferenceRenderer implements FullValue
|
||||
static ImageIcon getIcon(EvaluationContext evaluationContext, Value obj, String methodName) {
|
||||
try {
|
||||
Value bytes = getImageBytes(evaluationContext, obj, methodName);
|
||||
byte[] data = readBytes(bytes);
|
||||
byte[] data = DebuggerUtilsImpl.readBytesArray(bytes);
|
||||
if (data != null) {
|
||||
return new ImageIcon(data);
|
||||
}
|
||||
@@ -87,24 +88,6 @@ class ImageObjectRenderer extends CompoundReferenceRenderer implements FullValue
|
||||
return null;
|
||||
}
|
||||
|
||||
private static byte[] readBytes(Value bytes) {
|
||||
if (bytes instanceof ArrayReference) {
|
||||
List<Value> values = ((ArrayReference)bytes).getValues();
|
||||
byte[] res = new byte[values.size()];
|
||||
int idx = 0;
|
||||
for (Value value : values) {
|
||||
if (value instanceof ByteValue) {
|
||||
res[idx++] = ((ByteValue)value).value();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static abstract class IconPopupEvaluator extends CustomPopupFullValueEvaluator<Icon> {
|
||||
IconPopupEvaluator(@NotNull String linkText, @NotNull EvaluationContextImpl evaluationContext) {
|
||||
super(linkText, evaluationContext);
|
||||
|
||||
@@ -79,6 +79,7 @@ public class JavaRefactoringSettings implements PersistentStateComponent<JavaRef
|
||||
public boolean CONVERT_TO_INSTANCE_METHOD_PREVIEW_USAGES = true;
|
||||
|
||||
public Boolean INTRODUCE_LOCAL_CREATE_FINALS;
|
||||
public Boolean INTRODUCE_LOCAL_CREATE_VAR_TYPE = false;
|
||||
public Boolean INTRODUCE_PARAMETER_CREATE_FINALS;
|
||||
|
||||
public boolean INLINE_CLASS_SEARCH_IN_COMMENTS = true;
|
||||
|
||||
+41
@@ -770,6 +770,17 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
return wasSucceed[0];
|
||||
}
|
||||
|
||||
public static boolean canBeExtractedWithoutExplicitType(PsiExpression expr) {
|
||||
if (PsiUtil.isLanguageLevel10OrHigher(expr)) {
|
||||
PsiType type = expr.getType();
|
||||
return type != null &&
|
||||
!PsiType.NULL.equals(type) &&
|
||||
PsiTypesUtil.isDenotableType(type, expr) &&
|
||||
(expr instanceof PsiNewExpression || type.equals(((PsiExpression)expr.copy()).getType()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement getAnchor(PsiElement place) {
|
||||
PsiElement anchorStatement = RefactoringUtil.getParentStatement(place, false);
|
||||
@@ -935,6 +946,25 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
return initializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that diamond inside initializer is expanded, then replace variable type with var
|
||||
*/
|
||||
public static PsiElement expandDiamondsAndReplaceExplicitTypeWithVar(PsiTypeElement typeElement, PsiElement context) {
|
||||
PsiElement parent = typeElement.getParent();
|
||||
if (parent instanceof PsiVariable) {
|
||||
PsiExpression copyVariableInitializer = ((PsiVariable)parent).getInitializer();
|
||||
if (copyVariableInitializer instanceof PsiNewExpression) {
|
||||
final PsiDiamondType.DiamondInferenceResult diamondResolveResult =
|
||||
PsiDiamondTypeImpl.resolveInferredTypesNoCheck((PsiNewExpression)copyVariableInitializer, copyVariableInitializer);
|
||||
if (!diamondResolveResult.getInferredTypes().isEmpty()) {
|
||||
PsiDiamondTypeUtil.expandTopLevelDiamondsInside(copyVariableInitializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return typeElement.replace(JavaPsiFacade.getElementFactory(context.getProject()).createTypeElementFromText("var", context));
|
||||
}
|
||||
|
||||
public static PsiElement replace(final PsiExpression expr1, final PsiExpression ref, final Project project)
|
||||
throws IncorrectOperationException {
|
||||
final PsiExpression expr2;
|
||||
@@ -1021,6 +1051,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
final SuggestedNameInfo suggestedName = getSuggestedName(typeSelectorManager.getDefaultType(), expr, anchor);
|
||||
final String variableName = suggestedName.names.length > 0 ? suggestedName.names[0] : "";
|
||||
final boolean declareFinal = replaceAll && declareFinalIfAll || !anyAssignmentLHS && createFinals(anchor.getContainingFile());
|
||||
final boolean declareVarType = canBeExtractedWithoutExplicitType(expr) && createVarType();
|
||||
final boolean replaceWrite = anyAssignmentLHS && replaceChoice.isAll();
|
||||
return new IntroduceVariableSettings() {
|
||||
@Override
|
||||
@@ -1038,6 +1069,11 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
return declareFinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeclareVarType() {
|
||||
return declareVarType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceLValues() {
|
||||
return replaceWrite;
|
||||
@@ -1063,6 +1099,11 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
createFinals.booleanValue();
|
||||
}
|
||||
|
||||
public static boolean createVarType() {
|
||||
final Boolean createVarType = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE;
|
||||
return createVarType != null && createVarType.booleanValue();
|
||||
}
|
||||
|
||||
public static boolean checkAnchorBeforeThisOrSuper(final Project project,
|
||||
final Editor editor,
|
||||
final PsiElement tempAnchorElement,
|
||||
|
||||
+32
@@ -3,6 +3,7 @@ package com.intellij.refactoring.introduceVariable;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiNameHelper;
|
||||
@@ -37,6 +38,7 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
private StateRestoringCheckBox myCbReplaceWrite;
|
||||
private JCheckBox myCbFinal;
|
||||
private boolean myCbFinalState;
|
||||
private JCheckBox myCbVarType;
|
||||
private TypeSelector myTypeSelector;
|
||||
private NameSuggestionsManager myNameSuggestionsManager;
|
||||
private static final String REFACTORING_NAME = RefactoringBundle.message("introduce.variable.title");
|
||||
@@ -104,6 +106,11 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeclareVarType() {
|
||||
return myCbVarType.isVisible() && myCbVarType.isEnabled() && myCbVarType.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getSelectedType() {
|
||||
return myTypeSelector.getSelectedType();
|
||||
@@ -216,6 +223,24 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
};
|
||||
myCbFinal.addItemListener(myFinalListener);
|
||||
|
||||
myCbVarType = new NonFocusableCheckBox(RefactoringBundle.message("declare.var.type"));
|
||||
boolean toVarType = IntroduceVariableBase.canBeExtractedWithoutExplicitType(myExpression);
|
||||
if (toVarType) {
|
||||
myTypeSelector.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
myCbVarType.setEnabled(Comparing.equal(myTypeSelector.getSelectedType(), myExpression.getType()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
myCbVarType.setVisible(toVarType);
|
||||
myCbVarType.setSelected(IntroduceVariableBase.createVarType());
|
||||
|
||||
gbConstraints.gridy++;
|
||||
panel.add(myCbVarType, gbConstraints);
|
||||
|
||||
updateControls();
|
||||
|
||||
return panel;
|
||||
@@ -247,6 +272,10 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
myCbFinal.setEnabled(true);
|
||||
myCbFinal.setSelected(myCbFinalState);
|
||||
}
|
||||
|
||||
if (myCbVarType != null) {
|
||||
myCbVarType.setEnabled(Comparing.equal(myTypeSelector.getSelectedType(), myExpression.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,6 +286,9 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
if (myCbFinal.isEnabled()) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbFinal.isSelected();
|
||||
}
|
||||
if (myCbVarType.isVisible() && myCbVarType.isEnabled()) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE = myCbVarType.isSelected();
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -24,6 +24,10 @@ public interface IntroduceVariableSettings {
|
||||
boolean isReplaceAllOccurrences();
|
||||
|
||||
boolean isDeclareFinal();
|
||||
|
||||
default boolean isDeclareVarType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isReplaceLValues();
|
||||
|
||||
|
||||
+45
-6
@@ -42,6 +42,7 @@ import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.rename.ResolveSnapshotProvider;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
@@ -65,6 +66,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
private SmartPsiElementPointer<? extends PsiElement> myPointer;
|
||||
|
||||
private JCheckBox myCanBeFinalCb;
|
||||
private JCheckBox myCanBeVarTypeCb;
|
||||
private final IntroduceVariableSettings mySettings;
|
||||
private final SmartPsiElementPointer<PsiElement> myChosenAnchor;
|
||||
private final boolean myCantChangeFinalModifier;
|
||||
@@ -75,6 +77,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
private boolean myDeleteSelf = true;
|
||||
private final boolean mySkipTypeExpressionOnStart;
|
||||
private final PsiFile myFile;
|
||||
private final boolean myCanBeVarType;
|
||||
|
||||
public JavaVariableInplaceIntroducer(final Project project,
|
||||
IntroduceVariableSettings settings, PsiElement chosenAnchor, final Editor editor,
|
||||
@@ -100,6 +103,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
PsiElement parent = myExpr.getParent();
|
||||
myReplaceSelf = parent instanceof PsiExpressionStatement && !(parent.getParent() instanceof PsiSwitchLabeledRuleStatement);
|
||||
mySkipTypeExpressionOnStart = !(myExpr instanceof PsiFunctionalExpression && myReplaceSelf);
|
||||
myCanBeVarType = IntroduceVariableBase.canBeExtractedWithoutExplicitType(myExpr);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,6 +193,10 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
|
||||
}
|
||||
|
||||
if (myCanBeVarTypeCb != null) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE = myCanBeVarTypeCb.isSelected();
|
||||
}
|
||||
|
||||
final Document document = myEditor.getDocument();
|
||||
LOG.assertTrue(psiVariable.isValid());
|
||||
adjustLine(psiVariable, document);
|
||||
@@ -235,6 +243,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
@Override
|
||||
@Nullable
|
||||
protected JComponent getComponent() {
|
||||
if (myCantChangeFinalModifier && !(myCanBeVarType && getVariable() instanceof PsiLocalVariable)) return null;
|
||||
if (!myCantChangeFinalModifier) {
|
||||
myCanBeFinalCb = new NonFocusableCheckBox("Declare final");
|
||||
myCanBeFinalCb.setSelected(createFinals());
|
||||
@@ -252,19 +261,49 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (myCanBeVarType && getVariable() instanceof PsiLocalVariable) {
|
||||
myCanBeVarTypeCb = new NonFocusableCheckBox(RefactoringBundle.message("declare.var.type"));
|
||||
myCanBeVarTypeCb.setSelected(IntroduceVariableBase.createVarType());
|
||||
myCanBeVarTypeCb.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
WriteCommandAction.writeCommandAction(myProject).withName(getCommandName()).withGroupId(getCommandName()).run(() -> {
|
||||
final PsiVariable variable = getVariable();
|
||||
if (variable != null) {
|
||||
PsiTypeElement typeElement = variable.getTypeElement();
|
||||
LOG.assertTrue(typeElement != null);
|
||||
if (myCanBeVarTypeCb.isSelected()) {
|
||||
IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar(typeElement, variable);
|
||||
}
|
||||
else {
|
||||
typeElement = PsiTypesUtil.replaceWithExplicitType(typeElement);
|
||||
if (typeElement != null) { //simplify as it was before `var`
|
||||
IntroduceVariableBase.simplifyVariableInitializer(variable.getInitializer(), typeElement.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.setBorder(null);
|
||||
|
||||
GridBagConstraints gridBagConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
JBUI.insets(5), 0, 0);
|
||||
if (myCanBeFinalCb != null) {
|
||||
panel.add(myCanBeFinalCb, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
JBUI.insets(5), 0, 0));
|
||||
panel.add(myCanBeFinalCb, gridBagConstraints);
|
||||
}
|
||||
|
||||
panel.add(Box.createVerticalBox(), new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
|
||||
JBUI.emptyInsets(), 0, 0));
|
||||
if (myCanBeVarTypeCb != null) {
|
||||
panel.add(myCanBeVarTypeCb, gridBagConstraints);
|
||||
}
|
||||
|
||||
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
||||
panel.add(Box.createVerticalBox(), gridBagConstraints);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,11 @@ class VariableExtractor {
|
||||
highlight(var);
|
||||
|
||||
PsiUtil.setModifierProperty(var, PsiModifier.FINAL, mySettings.isDeclareFinal());
|
||||
if (mySettings.isDeclareVarType()) {
|
||||
PsiTypeElement typeElement = var.getTypeElement();
|
||||
LOG.assertTrue(typeElement != null);
|
||||
IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar(typeElement, var);
|
||||
}
|
||||
myFieldConflictsResolver.fix();
|
||||
return SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(var);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
class MyTest {
|
||||
{
|
||||
var temp = new ArrayList<String>();
|
||||
foo(temp);
|
||||
}
|
||||
|
||||
void foo(List<String> l) {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
class MyTest {
|
||||
{
|
||||
foo(<selection>new ArrayList<>()</selection>);
|
||||
}
|
||||
|
||||
void foo(List<String> l) {}
|
||||
}
|
||||
Vendored
+3
@@ -42,6 +42,9 @@ public class ClassFileUnderSourceRootTest extends IdeaTestCase {
|
||||
FileUtil.writeToFile(new File(dir, "p/A.java"), "package p;\npublic class A { }");
|
||||
FileUtil.copy(new File(PathManagerEx.getTestDataPath() + "/psi/cls/repo/pack/MyClass.class"), new File(dir, "pack/MyClass.class"));
|
||||
|
||||
root.refresh(false, true);
|
||||
assertSize(2, root.getChildren());
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
PsiTestUtil.addSourceRoot(myModule, root);
|
||||
ModuleRootModificationUtil.addModuleLibrary(myModule, root.getUrl());
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduceVariable.InputValidator;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
|
||||
@@ -263,6 +264,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
|
||||
doTest(new MockIntroduceVariableHandler("temp", true, false, false, CommonClassNames.JAVA_LANG_STRING));
|
||||
}
|
||||
|
||||
public void testVarTypeExtractedJava10() {
|
||||
doTestWithVarType(new MockIntroduceVariableHandler("temp", true, false, false, "java.util.ArrayList<java.lang.String>"));
|
||||
}
|
||||
|
||||
public void testDeclareTernary() {
|
||||
doTest(new MockIntroduceVariableHandler("temp", true, false, false, CommonClassNames.JAVA_LANG_STRING));
|
||||
}
|
||||
@@ -681,6 +686,17 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
|
||||
public void testChooseTypeExpressionWhenNotDenotable() { doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo")); }
|
||||
public void testChooseTypeExpressionWhenNotDenotable1() { doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo<?>")); }
|
||||
|
||||
private void doTestWithVarType(IntroduceVariableBase testMe) {
|
||||
Boolean asVarType = JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE;
|
||||
try {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE = true;
|
||||
doTest(testMe);
|
||||
}
|
||||
finally {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE = asVarType;
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest(IntroduceVariableBase testMe) {
|
||||
String baseName = "/refactoring/introduceVariable/" + getTestName(false);
|
||||
configureByFile(baseName + ".java");
|
||||
|
||||
+6
@@ -52,6 +52,7 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
|
||||
PsiType defaultType = typeSelectorManager.getDefaultType();
|
||||
PsiType type = myLookForType ? findType(typeSelectorManager.getTypesForAll(), defaultType) : defaultType;
|
||||
assertEquals(myExpectedTypeText, type.getInternalCanonicalText());
|
||||
boolean isDeclareVarType = canBeExtractedWithoutExplicitType(expr) && createVarType();
|
||||
IntroduceVariableSettings introduceVariableSettings = new IntroduceVariableSettings() {
|
||||
@Override
|
||||
public String getEnteredName() {
|
||||
@@ -82,6 +83,11 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
|
||||
public boolean isOK() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeclareVarType() {
|
||||
return isDeclareVarType;
|
||||
}
|
||||
};
|
||||
boolean validationResult = validator.isOK(introduceVariableSettings);
|
||||
assertValidationResult(validationResult);
|
||||
|
||||
@@ -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-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.
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -24,8 +24,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A service managing IDEA's 'dumb' mode: when indices are updated in background and the functionality is very much limited.
|
||||
* Only the explicitly allowed functionality is available. Usually it's allowed by implementing {@link DumbAware} interface.
|
||||
* A service managing the IDE's 'dumb' mode: when indexes are updated in the background, and the functionality is very much limited.
|
||||
* Only the explicitly allowed functionality is available. Usually, it's allowed by implementing {@link DumbAware} interface.
|
||||
*
|
||||
* @author peter
|
||||
*/
|
||||
@@ -43,8 +43,8 @@ public abstract class DumbService {
|
||||
public abstract ModificationTracker getModificationTracker();
|
||||
|
||||
/**
|
||||
* @return whether IntelliJ IDEA is in dumb mode, which means that right now indices are updated in background.
|
||||
* IDEA offers only limited functionality at such times, e.g. plain text file editing and version control operations.
|
||||
* @return whether the IDE is in dumb mode, which means that right now indexes are updated in the background.
|
||||
* The IDE offers only limited functionality at such times, e.g., plain text file editing and version control operations.
|
||||
*/
|
||||
public abstract boolean isDumb();
|
||||
|
||||
@@ -72,11 +72,12 @@ public abstract class DumbService {
|
||||
/**
|
||||
* Executes the runnable as soon as possible on AWT Event Dispatch when:
|
||||
* <ul>
|
||||
* <li>project is initialized</li>
|
||||
* <li>and there's no dumb mode in progress</li>
|
||||
* <li>project is initialized</li>
|
||||
* <li>and there's no dumb mode in progress</li>
|
||||
* </ul>
|
||||
* This may also happen immediately if these conditions are already met.<p/>
|
||||
* Note that it's not guaranteed that the dumb mode won't start again during this runnable execution, it should manage that situation explicitly.
|
||||
*
|
||||
* @param runnable runnable to run
|
||||
*/
|
||||
public abstract void runWhenSmart(@NotNull Runnable runnable);
|
||||
@@ -89,8 +90,9 @@ public abstract class DumbService {
|
||||
public abstract void waitForSmartMode();
|
||||
|
||||
/**
|
||||
* Pause the current thread until dumb mode ends, and then run the read action. Index is guaranteed to be available inside that read action,
|
||||
* Pause the current thread until dumb mode ends, and then run the read action. Indexes are guaranteed to be available inside that read action,
|
||||
* unless this method is already called with read access allowed.
|
||||
*
|
||||
* @throws ProcessCanceledException if the project is closed during dumb mode
|
||||
*/
|
||||
public <T> T runReadActionInSmartMode(@NotNull final Computable<T> r) {
|
||||
@@ -118,8 +120,9 @@ public abstract class DumbService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the current thread until dumb mode ends, and then run the read action. Index is guaranteed to be available inside that read action,
|
||||
* Pause the current thread until dumb mode ends, and then run the read action. Indexes are guaranteed to be available inside that read action,
|
||||
* unless this method is already called with read access allowed.
|
||||
*
|
||||
* @throws ProcessCanceledException if the project is closed during dumb mode
|
||||
*/
|
||||
public void runReadActionInSmartMode(@NotNull Runnable r) {
|
||||
@@ -148,9 +151,9 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* Pause the current thread until dumb mode ends, and then attempt to execute the runnable. If it fails due to another dumb mode having started,
|
||||
* try again until the runnable is able to complete successfully.
|
||||
* try again until the runnable can complete successfully.
|
||||
* It makes sense to use this method when you have a long-running activity consisting of many small read actions, and you don't want to
|
||||
* use a single long read action in order to keep the IDE responsive.
|
||||
* use a single long read action to keep the IDE responsive.
|
||||
*
|
||||
* @see #runReadActionInSmartMode(Runnable)
|
||||
*/
|
||||
@@ -168,14 +171,14 @@ public abstract class DumbService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the runnable later on EventDispatchThread AND when IDEA isn't in dumb mode.
|
||||
* The runnable won't be invoked if the project is disposed during dumb mode
|
||||
* Invoke the runnable later on EventDispatchThread AND when IDE isn't in dumb mode.
|
||||
* The runnable won't be invoked if the project is disposed during dumb mode.
|
||||
*/
|
||||
public abstract void smartInvokeLater(@NotNull Runnable runnable);
|
||||
|
||||
/**
|
||||
* Invoke the runnable later on EventDispatchThread with the given modality state AND when IDEA isn't in dumb mode.
|
||||
* The runnable won't be invoked if the project is disposed during dumb mode
|
||||
* Invoke the runnable later on EventDispatchThread with the given modality state AND when IDE isn't in dumb mode.
|
||||
* The runnable won't be invoked if the project is disposed during dumb mode.
|
||||
*/
|
||||
public abstract void smartInvokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState);
|
||||
|
||||
@@ -218,9 +221,9 @@ public abstract class DumbService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues a task to be executed in "dumb mode", where access to indices is forbidden. Tasks are executed sequentially
|
||||
* Queues a task to be executed in "dumb mode", where access to indexes is forbidden. Tasks are executed sequentially
|
||||
* in background unless {@link #completeJustSubmittedTasks()} is called in the same dispatch thread activity.<p/>
|
||||
*
|
||||
* <p>
|
||||
* Tasks can specify custom "equality" policy via their constructor. Calling this method has no effect if an "equal" task is already enqueued (but not yet running).
|
||||
*/
|
||||
public abstract void queueTask(@NotNull DumbModeTask task);
|
||||
@@ -233,17 +236,30 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* Runs the "just submitted" tasks under a modal dialog. "Just submitted" means that tasks were queued for execution
|
||||
* earlier within the same Swing event dispatch thread event processing, and there were no other tasks already running at that moment. Otherwise this method does nothing.<p/>
|
||||
*
|
||||
* earlier within the same Swing event dispatch thread event processing, and there were no other tasks already running at that moment. Otherwise, this method does nothing.<p/>
|
||||
* <p>
|
||||
* This functionality can be useful in refactorings (invoked in "smart mode"), when after VFS or root changes
|
||||
* (which could start "dumb mode") some reference resolve is required (which again requires "smart mode").<p/>
|
||||
*
|
||||
* <p>
|
||||
* Should be invoked on dispatch thread.
|
||||
*/
|
||||
public abstract void completeJustSubmittedTasks();
|
||||
|
||||
/**
|
||||
* Replaces given component temporarily with "Not available until indices are built" label during dumb mode.
|
||||
*
|
||||
* @param dumbUnawareContent Component to wrap.
|
||||
* @param parentDisposable Parent disposable.
|
||||
* @return Wrapped component.
|
||||
*/
|
||||
public abstract JComponent wrapGently(@NotNull JComponent dumbUnawareContent, @NotNull Disposable parentDisposable);
|
||||
|
||||
/**
|
||||
* Disables given component temporarily during dumb mode.
|
||||
*
|
||||
* @param component Component to disable.
|
||||
* @param disposable Parent disposable.
|
||||
*/
|
||||
public void makeDumbAware(@NotNull final JComponent component, @NotNull Disposable disposable) {
|
||||
component.setEnabled(!isDumb());
|
||||
getProject().getMessageBus().connect(disposable).subscribe(DUMB_MODE, new DumbModeListener() {
|
||||
@@ -259,6 +275,11 @@ public abstract class DumbService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a notification when given action is not available during dumb mode.
|
||||
*
|
||||
* @param message Notification message.
|
||||
*/
|
||||
public abstract void showDumbModeNotification(@NotNull String message);
|
||||
|
||||
public abstract Project getProject();
|
||||
@@ -273,23 +294,24 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* Enables or disables alternative resolve strategies for the current thread.<p/>
|
||||
*
|
||||
* Normally reference resolution uses index, and hence is not available in dumb mode. In some cases, alternative ways
|
||||
* <p>
|
||||
* Normally reference resolution uses indexes, and hence is not available in dumb mode. In some cases, alternative ways
|
||||
* of performing resolve are available, although much slower. It's impractical to always use these ways because it'll
|
||||
* lead to overloaded CPU (especially given there's also indexing in progress). But for some explicit user actions
|
||||
* (e.g. explicit Goto Declaration) turning these slower methods is beneficial.<p/>
|
||||
*
|
||||
* (e.g., explicit Goto Declaration) turning on these slower methods is beneficial.<p/>
|
||||
* <p>
|
||||
* NOTE: even with alternative resolution enabled, methods like resolve(), findClass() etc may still throw
|
||||
* {@link IndexNotReadyException}. So alternative resolve is not a panacea, it might help provide navigation in some cases
|
||||
* but not in all.<p/>
|
||||
*
|
||||
* A typical usage would involve try-finally, where the alternative resolution is first enabled, then an action is performed,
|
||||
* and then alternative resolution is turned off in the finally block.
|
||||
* <p>
|
||||
* A typical usage would involve {@code try-finally}, where the alternative resolution is first enabled, then an action is performed,
|
||||
* and then alternative resolution is turned off in the {@code finally} block.
|
||||
*/
|
||||
public abstract void setAlternativeResolveEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Invokes the given runnable with alternative resolve set to true.
|
||||
*
|
||||
* @see #setAlternativeResolveEnabled(boolean)
|
||||
*/
|
||||
public void withAlternativeResolveEnabled(@NotNull Runnable runnable) {
|
||||
@@ -304,6 +326,7 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* Invokes the given computable with alternative resolve set to true.
|
||||
*
|
||||
* @see #setAlternativeResolveEnabled(boolean)
|
||||
*/
|
||||
public <T, E extends Throwable> T computeWithAlternativeResolveEnabled(@NotNull ThrowableComputable<T, E> runnable) throws E {
|
||||
@@ -318,6 +341,7 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* Invokes the given runnable with alternative resolve set to true.
|
||||
*
|
||||
* @see #setAlternativeResolveEnabled(boolean)
|
||||
*/
|
||||
public <E extends Throwable> void runWithAlternativeResolveEnabled(@NotNull ThrowableRunnable<E> runnable) throws E {
|
||||
@@ -332,13 +356,13 @@ public abstract class DumbService {
|
||||
|
||||
/**
|
||||
* @return whether alternative resolution is enabled for the current thread.
|
||||
*
|
||||
* @see #setAlternativeResolveEnabled(boolean)
|
||||
*/
|
||||
public abstract boolean isAlternativeResolveEnabled();
|
||||
|
||||
/**
|
||||
* Obsolete, does nothing, just executes the passed runnable.
|
||||
*
|
||||
* @see #completeJustSubmittedTasks()
|
||||
*/
|
||||
@SuppressWarnings({"unused"})
|
||||
@@ -348,7 +372,8 @@ public abstract class DumbService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a heavy activity and suspends indexing (if any) for this time. The user still has the possibility to manually pause and resume the indexing. In that case, indexing won't be resumed automatically after the activity finishes.
|
||||
* Runs a heavy activity and suspends indexing (if any) for this time. The user still can manually pause and resume the indexing. In that case, indexing won't be resumed automatically after the activity finishes.
|
||||
*
|
||||
* @param activityName the text (a noun phrase) to display as a reason for the indexing being paused
|
||||
*/
|
||||
public abstract void suspendIndexingAndRun(@NotNull String activityName, @NotNull Runnable activity);
|
||||
@@ -359,15 +384,13 @@ public abstract class DumbService {
|
||||
public interface DumbModeListener {
|
||||
|
||||
/**
|
||||
* The event arrives on EDT
|
||||
* The event arrives on EDT.
|
||||
*/
|
||||
default void enteredDumbMode() {}
|
||||
|
||||
/**
|
||||
* The event arrives on EDT
|
||||
* The event arrives on EDT.
|
||||
*/
|
||||
default void exitDumbMode() {}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-31
@@ -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-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.
|
||||
|
||||
package com.intellij.codeInsight.template.impl;
|
||||
|
||||
@@ -23,12 +23,16 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.labels.DropDownLink;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.TreeTraversal;
|
||||
import com.intellij.util.ui.FormBuilder;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.PlatformColors;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
@@ -41,7 +45,10 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@@ -72,7 +79,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
public LiveTemplateSettingsEditor(TemplateImpl template,
|
||||
final String defaultShortcut,
|
||||
Map<TemplateOptionalProcessor, Boolean> options,
|
||||
TemplateContext context, final Runnable nodeChanged, boolean allowNoContext) {
|
||||
TemplateContext context, final Runnable nodeChanged) {
|
||||
super(new BorderLayout());
|
||||
myOptions = options;
|
||||
myContext = context;
|
||||
@@ -86,7 +93,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myTemplateEditor = TemplateEditorUtil.createEditor(false, myTemplate.getString(), context);
|
||||
myTemplate.setId(null);
|
||||
|
||||
createComponents(allowNoContext);
|
||||
createComponents();
|
||||
|
||||
myKeyField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
@@ -120,7 +127,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
TemplateEditorUtil.disposeTemplateEditor(myTemplateEditor);
|
||||
}
|
||||
|
||||
private void createComponents(boolean allowNoContexts) {
|
||||
private void createComponents() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
|
||||
GridBag gb = new GridBag().setDefaultInsets(4, 4, 4, 4).setDefaultWeightY(1).setDefaultFill(GridBagConstraints.BOTH);
|
||||
@@ -144,7 +151,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myTemplateOptionsPanel.add(createTemplateOptionsPanel());
|
||||
panel.add(myTemplateOptionsPanel, gb.nextLine().next().next().coverColumn(2).weighty(1));
|
||||
|
||||
panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().weighty(0).fillCellNone().anchor(GridBagConstraints.WEST));
|
||||
panel.add(createShortContextPanel(), gb.nextLine().next().weighty(0).fillCellNone().anchor(GridBagConstraints.WEST));
|
||||
|
||||
myTemplateEditor.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
@@ -201,8 +208,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
|
||||
private JPanel createTemplateOptionsPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(IdeBorderFactory.createTitledBorder(CodeInsightBundle.message("dialog.edit.template.options.title"),
|
||||
true));
|
||||
panel.setBorder(IdeBorderFactory.createTitledBorder(CodeInsightBundle.message("dialog.edit.template.options.title"), true));
|
||||
panel.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
@@ -277,15 +283,9 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
return result;
|
||||
}
|
||||
|
||||
private JPanel createShortContextPanel(final boolean allowNoContexts) {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
final JLabel ctxLabel = new JLabel();
|
||||
final JLabel change = new JLabel();
|
||||
change.setForeground(PlatformColors.BLUE);
|
||||
change.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
panel.add(ctxLabel, BorderLayout.CENTER);
|
||||
panel.add(change, BorderLayout.EAST);
|
||||
private JPanel createShortContextPanel() {
|
||||
JLabel ctxLabel = new JBLabel();
|
||||
LinkLabel<Object> change = new DropDownLink<>("Change", () -> {});
|
||||
|
||||
final Runnable updateLabel = () -> {
|
||||
myExpandByCombo.setEnabled(isExpandableFromEditor());
|
||||
@@ -319,10 +319,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
|
||||
final boolean noContexts = sb.length() == 0;
|
||||
if (noContexts) {
|
||||
if (!allowNoContexts) {
|
||||
ctxLabel.setForeground(JBColor.RED);
|
||||
}
|
||||
contexts = "No applicable contexts" + (allowNoContexts ? "" : " yet");
|
||||
contexts = "No applicable contexts";
|
||||
ctxLabel.setIcon(AllIcons.General.BalloonWarning);
|
||||
change.setText("Define");
|
||||
}
|
||||
@@ -336,11 +333,10 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myTemplateOptionsPanel.add(createTemplateOptionsPanel());
|
||||
};
|
||||
|
||||
new ClickListener() {
|
||||
change.setListener(new LinkListener<Object>() {
|
||||
@Override
|
||||
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
|
||||
if (disposeContextPopup()) return false;
|
||||
|
||||
public void linkSelected(LinkLabel aSource, Object aLinkData) {
|
||||
if (disposeContextPopup()) return;
|
||||
Pair<JPanel, CheckboxTree> pair = createPopupContextPanel(updateLabel, myContext);
|
||||
final JPanel content = pair.first;
|
||||
Dimension prefSize = content.getPreferredSize();
|
||||
@@ -350,20 +346,18 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myContextPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(content, pair.second)
|
||||
.setRequestFocus(true)
|
||||
.setResizable(true).createPopup();
|
||||
myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - 10)));
|
||||
myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - JBUI.scale(4))));
|
||||
myContextPopup.addListener(new JBPopupAdapter() {
|
||||
@Override
|
||||
public void onClosed(@NotNull LightweightWindowEvent event) {
|
||||
myLastSize = content.getSize();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}.installOn(change);
|
||||
}, null);
|
||||
|
||||
updateLabel.run();
|
||||
|
||||
return panel;
|
||||
return new FormBuilder().addLabeledComponent(ctxLabel, change).getPanel();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -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-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.
|
||||
package com.intellij.codeInsight.template.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
@@ -286,7 +286,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
|
||||
((DefaultTreeModel)myTree.getModel()).nodeChanged(node);
|
||||
TemplateSettings.getInstance().setLastSelectedTemplate(template.getGroupName(), template.getKey());
|
||||
}
|
||||
}, TemplateSettings.getInstance().getTemplate(template.getKey(), template.getGroupName()) != null);
|
||||
});
|
||||
for (Component component : myDetailsPanel.getComponents()) {
|
||||
if (component instanceof LiveTemplateSettingsEditor) {
|
||||
myDetailsPanel.remove(component);
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// 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.
|
||||
package com.intellij.ide.actions.searcheverywhere.statistics;
|
||||
|
||||
import com.intellij.ide.actions.searcheverywhere.FileSearchEverywhereContributor;
|
||||
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereContributor;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
|
||||
@@ -16,7 +15,7 @@ public class SearchEverywhereUsageTriggerCollector {
|
||||
|
||||
// this string will be used as ID for contributors from private
|
||||
// plugins that mustn't be sent in statistics
|
||||
private static final String NOT_REPORTABLE_CONTRIBUTOR_ID = "nonPublicContributor";
|
||||
private static final String NOT_REPORTABLE_CONTRIBUTOR_ID = "third.party";
|
||||
|
||||
public static final String DIALOG_OPEN = "dialogOpen";
|
||||
public static final String TAB_SWITCHED = "tabSwitched";
|
||||
@@ -39,6 +38,6 @@ public class SearchEverywhereUsageTriggerCollector {
|
||||
public static String getReportableContributorID(@NotNull SearchEverywhereContributor<?> contributor) {
|
||||
Class<? extends SearchEverywhereContributor> clazz = contributor.getClass();
|
||||
PluginInfo pluginInfo = PluginInfoDetectorKt.getPluginInfo(clazz);
|
||||
return pluginInfo.isSafeToReport() ? contributor.getSearchProviderId() : NOT_REPORTABLE_CONTRIBUTOR_ID;
|
||||
return pluginInfo.isDevelopedByJetBrains() ? contributor.getSearchProviderId() : NOT_REPORTABLE_CONTRIBUTOR_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
package com.intellij.ide.util.scopeChooser;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
@@ -28,7 +29,8 @@ public class ScopeConfigurable extends NamedConfigurable<NamedScope> {
|
||||
private ScopeEditorPanel myPanel;
|
||||
private String myPackageSet;
|
||||
private final JCheckBox mySharedCheckbox;
|
||||
private boolean myShareScope = false;
|
||||
private final JLabel mySharedContextHelp;
|
||||
private boolean myShareScope;
|
||||
private final Project myProject;
|
||||
private Icon myIcon;
|
||||
|
||||
@@ -38,6 +40,9 @@ public class ScopeConfigurable extends NamedConfigurable<NamedScope> {
|
||||
myShareScope = shareScope;
|
||||
myProject = project;
|
||||
mySharedCheckbox = new JCheckBox(IdeBundle.message("share.scope.checkbox.title"), shareScope);
|
||||
mySharedContextHelp = new JLabel(AllIcons.General.ContextHelp);
|
||||
mySharedContextHelp.setToolTipText(IdeBundle.message("share.scope.context.help"));
|
||||
mySharedContextHelp.setBorder(JBUI.Borders.empty(0, 5));
|
||||
myPanel = new ScopeEditorPanel(project, getHolder());
|
||||
myIcon = getHolder(myShareScope).getIcon();
|
||||
mySharedCheckbox.addActionListener(e -> {
|
||||
@@ -89,13 +94,20 @@ public class ScopeConfigurable extends NamedConfigurable<NamedScope> {
|
||||
return "project.scopes";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createTopRightComponent() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(BorderLayout.WEST, mySharedCheckbox);
|
||||
panel.add(BorderLayout.EAST, mySharedContextHelp);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
final JPanel wholePanel = new JPanel(new BorderLayout());
|
||||
wholePanel.add(myPanel.getPanel(), BorderLayout.CENTER);
|
||||
wholePanel.add(mySharedCheckbox, BorderLayout.SOUTH);
|
||||
wholePanel.setBorder(JBUI.Borders.empty(0, 10, 10, 10));
|
||||
return wholePanel;
|
||||
JPanel panel = myPanel.getPanel();
|
||||
panel.setBorder(JBUI.Borders.empty(0, 10, 10, 10));
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-2
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
|
||||
import com.intellij.openapi.editor.richcopy.settings.RichCopySettings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -70,8 +71,10 @@ class EditorSettingsStatisticsCollector extends ApplicationUsagesCollector {
|
||||
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsAbove(), "noBreadcrumbsBelow");
|
||||
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsShown(), "breadcrumbs");
|
||||
addBoolIfDiffers(set, es, esDefault, s -> s.isShowIntentionBulb(), "intentionBulb");
|
||||
for (String language : es.getOptions().getLanguageBreadcrumbsMap().keySet()) {
|
||||
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsShownFor(language), "breadcrumbsFor" + language);
|
||||
if (Registry.is("editor.breadcrumbs.language.statistics.enabled")) {
|
||||
for (String language : es.getOptions().getLanguageBreadcrumbsMap().keySet()) {
|
||||
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsShownFor(language), "breadcrumbsFor" + language);
|
||||
}
|
||||
}
|
||||
|
||||
RichCopySettings rcs = RichCopySettings.getInstance();
|
||||
|
||||
@@ -1,18 +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-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.
|
||||
package com.intellij.openapi.vfs.impl.jar;
|
||||
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
@@ -119,7 +105,7 @@ public class JarHandler extends ZipHandler {
|
||||
return originalFile;
|
||||
}
|
||||
|
||||
if (FSRecords.weHaveContentHashes) {
|
||||
if (FSRecords.WE_HAVE_CONTENT_HASHES) {
|
||||
return getMirrorWithContentHash(originalFile, originalAttributes);
|
||||
}
|
||||
|
||||
|
||||
+77
-67
@@ -44,26 +44,30 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
public class FSRecords {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.vfs.persistent.FSRecords");
|
||||
|
||||
public static final boolean weHaveContentHashes = SystemProperties.getBooleanProperty("idea.share.contents", true);
|
||||
public static final boolean WE_HAVE_CONTENT_HASHES = SystemProperties.getBooleanProperty("idea.share.contents", true);
|
||||
static final String VFS_FILES_EXTENSION = System.getProperty("idea.vfs.files.extension", ".dat");
|
||||
|
||||
private static final boolean lazyVfsDataCleaning = SystemProperties.getBooleanProperty("idea.lazy.vfs.data.cleaning", true);
|
||||
private static final boolean backgroundVfsFlush = SystemProperties.getBooleanProperty("idea.background.vfs.flush", true);
|
||||
private static final boolean inlineAttributes = SystemProperties.getBooleanProperty("idea.inline.vfs.attributes", true);
|
||||
private static final boolean bulkAttrReadSupport = SystemProperties.getBooleanProperty("idea.bulk.attr.read", false);
|
||||
private static final boolean useCompressionUtil = SystemProperties.getBooleanProperty("idea.use.lightweight.compression.for.vfs", false);
|
||||
private static final boolean useSmallAttrTable = SystemProperties.getBooleanProperty("idea.use.small.attr.table.for.vfs", true);
|
||||
static final String VFS_FILES_EXTENSION = System.getProperty("idea.vfs.files.extension", ".dat");
|
||||
private static final boolean ourStoreRootsSeparately = SystemProperties.getBooleanProperty("idea.store.roots.separately", false);
|
||||
|
||||
//TODO[anyone] when bumping the version, please delete `ourSymlinkTargetAttr_old` and use it's value for `ourSymlinkTargetAttr`
|
||||
private static final int VERSION = 22 + (weHaveContentHashes ? 0x10:0) + (IOUtil.ourByteBuffersUseNativeByteOrder ? 0x37:0) +
|
||||
31 + (bulkAttrReadSupport ? 0x27:0) + (inlineAttributes ? 0x31 : 0) +
|
||||
private static final int VERSION = 53 +
|
||||
(WE_HAVE_CONTENT_HASHES ? 0x10 : 0) +
|
||||
(IOUtil.BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER ? 0x37 : 0) +
|
||||
(bulkAttrReadSupport ? 0x27 : 0) +
|
||||
(inlineAttributes ? 0x31 : 0) +
|
||||
(ourStoreRootsSeparately ? 0x63 : 0) +
|
||||
(useCompressionUtil ? 0x7f : 0) + (useSmallAttrTable ? 0x31 : 0) +
|
||||
(PersistentHashMapValueStorage.COMPRESSION_ENABLED ? 21:0);
|
||||
(useCompressionUtil ? 0x7f : 0) +
|
||||
(useSmallAttrTable ? 0x31 : 0) +
|
||||
(PersistentHashMapValueStorage.COMPRESSION_ENABLED ? 0x15 : 0);
|
||||
|
||||
private static final int PARENT_OFFSET = 0;
|
||||
private static final int PARENT_SIZE = 4;
|
||||
@@ -121,17 +125,17 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static void writeAttributesToRecord(int id, int parentId, @NotNull FileAttributes attributes, @NotNull String name) {
|
||||
writeAndHandleErrors(()->{
|
||||
writeAndHandleErrors(() -> {
|
||||
setName(id, name);
|
||||
|
||||
setTimestamp(id, attributes.lastModified);
|
||||
setLength(id, attributes.isDirectory() ? -1L : attributes.length);
|
||||
|
||||
setFlags(id, (attributes.isDirectory() ? PersistentFS.IS_DIRECTORY_FLAG : 0) |
|
||||
(attributes.isWritable() ? 0 : PersistentFS.IS_READ_ONLY) |
|
||||
(attributes.isSymLink() ? PersistentFS.IS_SYMLINK : 0) |
|
||||
(attributes.isSpecial() ? PersistentFS.IS_SPECIAL : 0) |
|
||||
(attributes.isHidden() ? PersistentFS.IS_HIDDEN : 0), true);
|
||||
(attributes.isWritable() ? 0 : PersistentFS.IS_READ_ONLY) |
|
||||
(attributes.isSymLink() ? PersistentFS.IS_SYMLINK : 0) |
|
||||
(attributes.isSpecial() ? PersistentFS.IS_SPECIAL : 0) |
|
||||
(attributes.isHidden() ? PersistentFS.IS_HIDDEN : 0), true);
|
||||
setParent(id, parentId);
|
||||
});
|
||||
}
|
||||
@@ -166,9 +170,8 @@ public class FSRecords {
|
||||
|
||||
private static final AttrPageAwareCapacityAllocationPolicy REASONABLY_SMALL = new AttrPageAwareCapacityAllocationPolicy();
|
||||
|
||||
|
||||
public static void connect() {
|
||||
writeAndHandleErrors(()->{
|
||||
writeAndHandleErrors(() -> {
|
||||
if (!ourInitialized) {
|
||||
init();
|
||||
setupFlushing();
|
||||
@@ -190,15 +193,14 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static int getFreeRecord() {
|
||||
if (myFreeRecords.isEmpty()) return 0;
|
||||
return myFreeRecords.remove(myFreeRecords.size() - 1);
|
||||
return myFreeRecords.isEmpty() ? 0 : myFreeRecords.remove(myFreeRecords.size() - 1);
|
||||
}
|
||||
|
||||
private static void createBrokenMarkerFile(@Nullable Throwable reason) {
|
||||
final File brokenMarker = getCorruptionMarkerFile();
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try (PrintStream stream = new PrintStream(out)) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") PrintStream stream = new PrintStream(out)) {
|
||||
new Exception().printStackTrace(stream);
|
||||
if (reason != null) {
|
||||
stream.print("\nReason:\n");
|
||||
@@ -207,12 +209,10 @@ public class FSRecords {
|
||||
}
|
||||
LOG.info("Creating VFS corruption marker; Trace=\n" + out);
|
||||
|
||||
try (FileWriter writer = new FileWriter(brokenMarker)) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") FileWriter writer = new FileWriter(brokenMarker)) {
|
||||
writer.write("These files are corrupted and must be rebuilt from the scratch on next startup");
|
||||
}
|
||||
catch (IOException e) {
|
||||
// No luck.
|
||||
}
|
||||
catch (IOException ignored) { } // No luck.
|
||||
}
|
||||
|
||||
private static File getCorruptionMarkerFile() {
|
||||
@@ -221,7 +221,9 @@ public class FSRecords {
|
||||
|
||||
private static void init() {
|
||||
final File basePath = basePath().getAbsoluteFile();
|
||||
basePath.mkdirs();
|
||||
if (!(basePath.isDirectory() || basePath.mkdirs())) {
|
||||
throw new RuntimeException("Cannot create storage directory: " + basePath);
|
||||
}
|
||||
|
||||
final File namesFile = new File(basePath, "names" + VFS_FILES_EXTENSION);
|
||||
final File attributesFile = new File(basePath, "attrib" + VFS_FILES_EXTENSION);
|
||||
@@ -251,19 +253,22 @@ public class FSRecords {
|
||||
return inlineAttributes && useSmallAttrTable ? new CompactRecordsTable(recordsFile, pool, false) : super.createRecordsTable(pool, recordsFile);
|
||||
}
|
||||
};
|
||||
myContents = new RefCountingStorage(contentsFile.getPath(), CapacityAllocationPolicy.FIVE_PERCENT_FOR_GROWTH,
|
||||
useCompressionUtil) {
|
||||
|
||||
myContents = new RefCountingStorage(contentsFile.getPath(), CapacityAllocationPolicy.FIVE_PERCENT_FOR_GROWTH, useCompressionUtil) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected ExecutorService createExecutor() {
|
||||
return SequentialTaskExecutor.createSequentialApplicationPoolExecutor("FSRecords Pool");
|
||||
}
|
||||
}; // sources usually zipped with 4x ratio
|
||||
myContentHashesEnumerator = weHaveContentHashes ? new ContentHashesUtil.HashEnumerator(contentsHashesFile, storageLockContext): null;
|
||||
};
|
||||
|
||||
// sources usually zipped with 4x ratio
|
||||
myContentHashesEnumerator = WE_HAVE_CONTENT_HASHES ? new ContentHashesUtil.HashEnumerator(contentsHashesFile, storageLockContext) : null;
|
||||
|
||||
boolean aligned = PagedFileStorage.BUFFER_SIZE % RECORD_SIZE == 0;
|
||||
assert aligned; // for performance
|
||||
if (!aligned) LOG.error("Buffer size " + PagedFileStorage.BUFFER_SIZE + " is not aligned for record size " + RECORD_SIZE);
|
||||
myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, storageLockContext,
|
||||
PagedFileStorage.BUFFER_SIZE, aligned, IOUtil.ourByteBuffersUseNativeByteOrder);
|
||||
PagedFileStorage.BUFFER_SIZE, aligned, IOUtil.BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER);
|
||||
|
||||
boolean initial = myRecords.length() == 0;
|
||||
|
||||
@@ -273,8 +278,9 @@ public class FSRecords {
|
||||
setCurrentVersion();
|
||||
}
|
||||
|
||||
if (getVersion() != VERSION) {
|
||||
throw new IOException("FS repository version mismatch");
|
||||
int version = getVersion();
|
||||
if (version != VERSION) {
|
||||
throw new IOException("FS repository version mismatch: actual=" + version + " expected=" + VERSION);
|
||||
}
|
||||
|
||||
if (myRecords.getInt(HEADER_CONNECTION_STATUS_OFFSET) != SAFELY_CLOSED_MAGIC) {
|
||||
@@ -431,7 +437,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static void cleanRecord(int id) {
|
||||
myRecords.put(id * RECORD_SIZE, ZEROES, 0, RECORD_SIZE);
|
||||
myRecords.put(((long)id) * RECORD_SIZE, ZEROES, 0, RECORD_SIZE);
|
||||
}
|
||||
|
||||
private static PersistentStringEnumerator getNames() {
|
||||
@@ -554,7 +560,7 @@ public class FSRecords {
|
||||
|
||||
// todo: Address / capacity store in records table, size store with payload
|
||||
public static int createRecord() {
|
||||
return writeAndHandleErrors(()->{
|
||||
return writeAndHandleErrors(() -> {
|
||||
DbConnection.markDirty();
|
||||
|
||||
final int free = DbConnection.getFreeRecord();
|
||||
@@ -578,7 +584,7 @@ public class FSRecords {
|
||||
return (int)getRecords().length();
|
||||
}
|
||||
public static int getMaxId() {
|
||||
return readAndHandleErrors(()->length()/RECORD_SIZE);
|
||||
return readAndHandleErrors(() -> length() / RECORD_SIZE);
|
||||
}
|
||||
|
||||
static void deleteRecordRecursively(int id) {
|
||||
@@ -629,7 +635,7 @@ public class FSRecords {
|
||||
private static void deleteContentAndAttributes(int id) throws IOException {
|
||||
int content_page = getContentRecordId(id);
|
||||
if (content_page != 0) {
|
||||
if (weHaveContentHashes) {
|
||||
if (WE_HAVE_CONTENT_HASHES) {
|
||||
getContentStorage().releaseRecord(content_page, false);
|
||||
}
|
||||
else {
|
||||
@@ -674,8 +680,8 @@ public class FSRecords {
|
||||
if (ourStoreRootsSeparately) {
|
||||
TIntArrayList result = new TIntArrayList();
|
||||
|
||||
try (LineNumberReader stream = new LineNumberReader(
|
||||
new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") LineNumberReader stream =
|
||||
new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
String str;
|
||||
while ((str = stream.readLine()) != null) {
|
||||
int index = str.indexOf(' ');
|
||||
@@ -683,8 +689,7 @@ public class FSRecords {
|
||||
result.add(id);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ignored) {
|
||||
}
|
||||
catch (FileNotFoundException ignored) { }
|
||||
|
||||
return result.toNativeArray();
|
||||
}
|
||||
@@ -728,7 +733,8 @@ public class FSRecords {
|
||||
static int findRootRecord(@NotNull String rootUrl) {
|
||||
return writeAndHandleErrors(() -> {
|
||||
if (ourStoreRootsSeparately) {
|
||||
try (LineNumberReader stream = new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") LineNumberReader stream =
|
||||
new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
String str;
|
||||
while((str = stream.readLine()) != null) {
|
||||
int index = str.indexOf(' ');
|
||||
@@ -741,7 +747,8 @@ public class FSRecords {
|
||||
catch (FileNotFoundException ignored) {}
|
||||
|
||||
DbConnection.markDirty();
|
||||
try (Writer stream = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DbConnection.myRootsFile, true)))) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") Writer stream =
|
||||
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DbConnection.myRootsFile, true)))) {
|
||||
int id = createRecord();
|
||||
stream.write(id + " " + rootUrl + "\n");
|
||||
return id;
|
||||
@@ -796,7 +803,8 @@ public class FSRecords {
|
||||
DbConnection.markDirty();
|
||||
if (ourStoreRootsSeparately) {
|
||||
List<String> rootsThatLeft = new ArrayList<>();
|
||||
try (LineNumberReader stream = new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") LineNumberReader stream =
|
||||
new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(DbConnection.myRootsFile))))) {
|
||||
String str;
|
||||
while((str = stream.readLine()) != null) {
|
||||
int index = str.indexOf(' ');
|
||||
@@ -808,8 +816,9 @@ public class FSRecords {
|
||||
}
|
||||
catch (FileNotFoundException ignored) {}
|
||||
|
||||
try (Writer stream = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DbConnection.myRootsFile)))) {
|
||||
for(String line:rootsThatLeft) {
|
||||
try (@SuppressWarnings("ImplicitDefaultCharsetUsage") Writer stream =
|
||||
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DbConnection.myRootsFile)))) {
|
||||
for (String line:rootsThatLeft) {
|
||||
stream.write(line);
|
||||
stream.write("\n");
|
||||
}
|
||||
@@ -874,8 +883,8 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
public static class NameId {
|
||||
@NotNull
|
||||
public static final NameId[] EMPTY_ARRAY = new NameId[0];
|
||||
|
||||
public final int id;
|
||||
public final CharSequence name;
|
||||
public final int nameId;
|
||||
@@ -894,7 +903,7 @@ public class FSRecords {
|
||||
|
||||
@NotNull
|
||||
public static NameId[] listAll(int parentId) {
|
||||
return readAndHandleErrors(()->{
|
||||
return readAndHandleErrors(() -> {
|
||||
try (final DataInputStream input = readAttribute(parentId, ourChildrenAttr)) {
|
||||
if (input == null) return NameId.EMPTY_ARRAY;
|
||||
|
||||
@@ -913,7 +922,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static boolean wereChildrenAccessed(int id) {
|
||||
return readAndHandleErrors(()-> findAttributePage(id, ourChildrenAttr, false) != 0);
|
||||
return readAndHandleErrors(() -> findAttributePage(id, ourChildrenAttr, false) != 0);
|
||||
}
|
||||
|
||||
private static <T> T readAndHandleErrors(@NotNull ThrowableComputable<T, ?> action) {
|
||||
@@ -1014,6 +1023,7 @@ public class FSRecords {
|
||||
|
||||
private static void incLocalModCount() {
|
||||
DbConnection.markDirty();
|
||||
//noinspection NonAtomicOperationOnVolatileField
|
||||
ourLocalModificationCount++;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1040,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
public static int getParent(int id) {
|
||||
return readAndHandleErrors(()->{
|
||||
return readAndHandleErrors(() -> {
|
||||
final int parentId = getRecordInt(id, PARENT_OFFSET);
|
||||
if (parentId == id) {
|
||||
LOG.error("Cyclic parent child relations in the database. id = " + id);
|
||||
@@ -1113,7 +1123,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static int getNameId(int id) {
|
||||
return readAndHandleErrors(()-> doGetNameId(id));
|
||||
return readAndHandleErrors(() -> doGetNameId(id));
|
||||
}
|
||||
|
||||
private static int doGetNameId(int id) {
|
||||
@@ -1121,7 +1131,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
public static int getNameId(String name) {
|
||||
return readAndHandleErrors(()->getNames().enumerate(name));
|
||||
return readAndHandleErrors(() -> getNames().enumerate(name));
|
||||
}
|
||||
|
||||
public static String getName(int id) {
|
||||
@@ -1130,7 +1140,7 @@ public class FSRecords {
|
||||
|
||||
@NotNull
|
||||
static CharSequence getNameSequence(int id) {
|
||||
return readAndHandleErrors(()->doGetNameSequence(id));
|
||||
return readAndHandleErrors(() -> doGetNameSequence(id));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1140,7 +1150,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
public static String getNameByNameId(int nameId) {
|
||||
return readAndHandleErrors(()-> doGetNameByNameId(nameId));
|
||||
return readAndHandleErrors(() -> doGetNameByNameId(nameId));
|
||||
}
|
||||
|
||||
private static String doGetNameByNameId(int nameId) throws IOException {
|
||||
@@ -1173,7 +1183,7 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static long getLength(int id) {
|
||||
return readAndHandleErrors(()->getRecords().getLong(getOffset(id, LENGTH_OFFSET)));
|
||||
return readAndHandleErrors(() -> getRecords().getLong(getOffset(id, LENGTH_OFFSET)));
|
||||
}
|
||||
|
||||
static void setLength(int id, long len) {
|
||||
@@ -1281,7 +1291,7 @@ public class FSRecords {
|
||||
|
||||
@Nullable
|
||||
public static DataInputStream readAttributeWithLock(int fileId, FileAttribute att) {
|
||||
return readAndHandleErrors(()->{
|
||||
return readAndHandleErrors(() -> {
|
||||
try (DataInputStream stream = readAttribute(fileId, att)) {
|
||||
if (stream != null && att.isVersioned()) {
|
||||
try {
|
||||
@@ -1427,7 +1437,6 @@ public class FSRecords {
|
||||
|
||||
private static void checkFileIsValid(int fileId) throws IOException {
|
||||
assert fileId > 0 : fileId;
|
||||
// TODO: This assertion is a bit timey, will remove when bug is caught.
|
||||
if (!lazyVfsDataCleaning) {
|
||||
assert !BitUtil.isSet(doGetFlags(fileId), FREE_RECORD_FLAG) : "Accessing attribute of a deleted page: " + fileId + ":" + doGetNameSequence(fileId);
|
||||
}
|
||||
@@ -1442,11 +1451,11 @@ public class FSRecords {
|
||||
}
|
||||
|
||||
static void releaseContent(int contentId) {
|
||||
writeAndHandleErrors(() -> getContentStorage().releaseRecord(contentId, !weHaveContentHashes));
|
||||
writeAndHandleErrors(() -> getContentStorage().releaseRecord(contentId, !WE_HAVE_CONTENT_HASHES));
|
||||
}
|
||||
|
||||
static int getContentId(int fileId) {
|
||||
return readAndHandleErrors(()->getContentRecordId(fileId));
|
||||
return readAndHandleErrors(() -> getContentRecordId(fileId));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1464,7 +1473,7 @@ public class FSRecords {
|
||||
static int storeUnlinkedContent(byte[] bytes) {
|
||||
return writeAndHandleErrors(() -> {
|
||||
int recordId;
|
||||
if (weHaveContentHashes) {
|
||||
if (WE_HAVE_CONTENT_HASHES) {
|
||||
recordId = findOrCreateContentRecord(bytes, 0, bytes.length);
|
||||
if (recordId > 0) return recordId;
|
||||
recordId = -recordId;
|
||||
@@ -1518,7 +1527,7 @@ public class FSRecords {
|
||||
|
||||
int page;
|
||||
final boolean fixedSize;
|
||||
if (weHaveContentHashes) {
|
||||
if (WE_HAVE_CONTENT_HASHES) {
|
||||
page = findOrCreateContentRecord(bytes.getBytes(), bytes.getOffset(), bytes.getLength());
|
||||
|
||||
if (page < 0 || getContentId(myFileId) != page) {
|
||||
@@ -1558,7 +1567,7 @@ public class FSRecords {
|
||||
}
|
||||
}
|
||||
|
||||
private static final boolean DUMP_STATISTICS = weHaveContentHashes; // TODO: remove once not needed
|
||||
private static final boolean DUMP_STATISTICS = WE_HAVE_CONTENT_HASHES; // TODO: remove once not needed
|
||||
private static long totalContents;
|
||||
private static long totalReuses;
|
||||
private static long time;
|
||||
@@ -1566,7 +1575,7 @@ public class FSRecords {
|
||||
private static int reuses;
|
||||
|
||||
private static int findOrCreateContentRecord(byte[] bytes, int offset, int length) throws IOException {
|
||||
assert weHaveContentHashes;
|
||||
assert WE_HAVE_CONTENT_HASHES;
|
||||
|
||||
long started = DUMP_STATISTICS ? System.nanoTime():0;
|
||||
myDigest.reset();
|
||||
@@ -1751,7 +1760,7 @@ public class FSRecords {
|
||||
long t = System.currentTimeMillis();
|
||||
|
||||
int recordCount=
|
||||
readAndHandleErrors(()->{
|
||||
readAndHandleErrors(() -> {
|
||||
final int fileLength = length();
|
||||
assert fileLength % RECORD_SIZE == 0;
|
||||
return fileLength / RECORD_SIZE;
|
||||
@@ -1763,7 +1772,7 @@ public class FSRecords {
|
||||
int flags = getFlags(id);
|
||||
LOG.assertTrue((flags & ~ALL_VALID_FLAGS) == 0, "Invalid flags: 0x" + Integer.toHexString(flags) + ", id: " + id);
|
||||
int currentId = id;
|
||||
boolean isFreeRecord = readAndHandleErrors(()->DbConnection.myFreeRecords.contains(currentId));
|
||||
boolean isFreeRecord = readAndHandleErrors(() -> DbConnection.myFreeRecords.contains(currentId));
|
||||
if (BitUtil.isSet(flags, FREE_RECORD_FLAG)) {
|
||||
LOG.assertTrue(isFreeRecord, "Record, marked free, not in free list: " + id);
|
||||
}
|
||||
@@ -1790,7 +1799,7 @@ public class FSRecords {
|
||||
CharSequence name = getNameSequence(id);
|
||||
LOG.assertTrue(parentId == 0 || name.length()!=0, "File with empty name found under " + getNameSequence(parentId) + ", id=" + id);
|
||||
|
||||
writeAndHandleErrors(()->{
|
||||
writeAndHandleErrors(() -> {
|
||||
checkContentsStorageSanity(id);
|
||||
checkAttributesStorageSanity(id, usedAttributeRecordIds, validAttributeIds);
|
||||
});
|
||||
@@ -1821,8 +1830,7 @@ public class FSRecords {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAttributesSanity(final int attributeRecordId, final IntArrayList usedAttributeRecordIds,
|
||||
final IntArrayList validAttributeIds) throws IOException {
|
||||
private static void checkAttributesSanity(int attributeRecordId, IntArrayList usedAttributeRecordIds, IntArrayList validAttributeIds) throws IOException {
|
||||
assert !usedAttributeRecordIds.contains(attributeRecordId);
|
||||
usedAttributeRecordIds.add(attributeRecordId);
|
||||
|
||||
@@ -1844,7 +1852,9 @@ public class FSRecords {
|
||||
dataInputStream.skipBytes(attDataRecordIdOrSize);
|
||||
continue;
|
||||
}
|
||||
else attDataRecordIdOrSize -= MAX_SMALL_ATTR_SIZE;
|
||||
else {
|
||||
attDataRecordIdOrSize -= MAX_SMALL_ATTR_SIZE;
|
||||
}
|
||||
}
|
||||
assert !usedAttributeRecordIds.contains(attDataRecordIdOrSize);
|
||||
usedAttributeRecordIds.add(attDataRecordIdOrSize);
|
||||
@@ -1858,4 +1868,4 @@ public class FSRecords {
|
||||
public static void handleError(Throwable e) throws RuntimeException, Error {
|
||||
DbConnection.handleError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1147,8 @@ project.import.open.existing.openExisting=Open Existing Project
|
||||
project.import.open.existing.reimport=Delete Existing Project and Import
|
||||
|
||||
code.folding.settings=Code Folding Settings
|
||||
share.scope.checkbox.title=Share scope
|
||||
share.scope.checkbox.title=Share through VCS
|
||||
share.scope.context.help=Shared configurations are stored in .idea directory and\nare available to other team members through VCS.
|
||||
bean.property=Bean Property
|
||||
plugin.manager.uninstalled.tooltip=Plugin was uninstalled; changes will be applied on restart
|
||||
plugin.manager.installed.tooltip=Plugin will be activated after restart
|
||||
|
||||
@@ -126,6 +126,7 @@ extractSuperInterface.javadoc=JavaDoc
|
||||
no.interface.name.specified=No interface name specified
|
||||
replace.all.occurences=Replace &all occurrences ({0} occurrences)
|
||||
declare.final=Declare &final
|
||||
declare.var.type=Declare &var type
|
||||
introduce.parameter.title=Extract Parameter
|
||||
parameter.of.type=Parameter of &type:
|
||||
use.variable.initializer.to.initialize.parameter=Use variable &initializer to initialize parameter
|
||||
|
||||
+17
-23
@@ -194,20 +194,20 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
VirtualFile projectStructure = createTestProjectStructure();
|
||||
String testName = getTestName(false);
|
||||
|
||||
// wrt persistence subDir becomes partially loaded and subsubDir becomes fully loaded
|
||||
// wrt persistence subDir becomes partially loaded and subSubDir becomes fully loaded
|
||||
File nestedDirOutsideTheProject = new File(projectStructure.getPath() + "../../../"+testName + "/subDir", "subSubDir").getCanonicalFile();
|
||||
Disposable disposable = null;
|
||||
|
||||
try {
|
||||
boolean atleastSecondRun = nestedDirOutsideTheProject.getParentFile().getParentFile().exists();
|
||||
boolean atLeastSecondRun = nestedDirOutsideTheProject.getParentFile().getParentFile().exists();
|
||||
StringBuilder eventLog = new StringBuilder();
|
||||
|
||||
if (atleastSecondRun) {
|
||||
if (atLeastSecondRun) {
|
||||
disposable = Disposer.newDisposable();
|
||||
getProject().getMessageBus().connect(disposable).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
for(VFileEvent event:events) {
|
||||
for (VFileEvent event : events) {
|
||||
if (event instanceof VFileDeleteEvent) process(((VFileDeleteEvent)event).getFile());
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
String path = file.getPath();
|
||||
eventLog.append(path.substring(path.indexOf(testName) + testName.length() + 1)).append("\n");
|
||||
Iterable<VirtualFile> files = ((NewVirtualFile)file).iterInDbChildren();
|
||||
for(VirtualFile nested:files) process(nested);
|
||||
for (VirtualFile nested : files) process(nested);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -224,17 +224,17 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
VirtualFile nestedDirOutsideTheProjectFile = VfsUtil.createDirectories(nestedDirOutsideTheProject.getPath());
|
||||
WriteAction.run(() -> nestedDirOutsideTheProjectFile.createChildData(null, "Foo.txt"));
|
||||
|
||||
// subsubDir becomes fully loaded wrt persistence
|
||||
// subSubDir becomes fully loaded wrt persistence
|
||||
nestedDirOutsideTheProjectFile.getChildren();
|
||||
|
||||
if (atleastSecondRun) {
|
||||
if (atLeastSecondRun) {
|
||||
assertEquals("subDir\n" +
|
||||
"subDir/subSubDir\n" +
|
||||
"subDir/subSubDir/Foo.txt\n",
|
||||
eventLog.toString()
|
||||
);
|
||||
eventLog.toString());
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
if (disposable != null) Disposer.dispose(disposable);
|
||||
// remove <testName>/subDir via java.io to have vfs events on next test launch
|
||||
FileUtil.delete(nestedDirOutsideTheProject.getParentFile());
|
||||
@@ -342,7 +342,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
|
||||
private void log(String msg, @NotNull List<? extends VFileEvent> events) {
|
||||
List<String> names = ContainerUtil.map(events, e -> e.getClass().getSimpleName() + "->" + PathUtil.getFileName(e.getPath()));
|
||||
log.append(msg).append(names).append("\n");
|
||||
log.append(msg).append(names).append('\n');
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -396,8 +396,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
"After:[VFileDeleteEvent->test.txt]\n",
|
||||
|
||||
new VFileContentChangeEvent(this, vFile.getParent(), 0, 0, false),
|
||||
new VFileDeleteEvent(this, vFile, false)
|
||||
);
|
||||
new VFileDeleteEvent(this, vFile, false));
|
||||
}
|
||||
|
||||
public void testProcessNestedDeletions() throws IOException {
|
||||
@@ -417,8 +416,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
|
||||
new VFileDeleteEvent(this, testTxt, false),
|
||||
new VFileDeleteEvent(this, testTxt.getParent(), false),
|
||||
new VFileDeleteEvent(this, test2Txt, false)
|
||||
);
|
||||
new VFileDeleteEvent(this, test2Txt, false));
|
||||
}
|
||||
|
||||
public void testProcessCompositeMoveEvents() throws IOException {
|
||||
@@ -438,8 +436,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
"After:[VFileDeleteEvent->d]\n",
|
||||
|
||||
new VFileMoveEvent(this, testTxt, newParent),
|
||||
new VFileDeleteEvent(this, newParent, false)
|
||||
);
|
||||
new VFileDeleteEvent(this, newParent, false));
|
||||
}
|
||||
|
||||
public void testProcessCompositeCopyEvents() throws IOException {
|
||||
@@ -459,8 +456,7 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
"After:[VFileDeleteEvent->test.txt]\n",
|
||||
|
||||
new VFileCopyEvent(this, testTxt, newParent,"new.txt"),
|
||||
new VFileDeleteEvent(this, testTxt, false)
|
||||
);
|
||||
new VFileDeleteEvent(this, testTxt, false));
|
||||
}
|
||||
|
||||
public void testProcessCompositeRenameEvents() throws IOException {
|
||||
@@ -480,8 +476,6 @@ public class PersistentFsTest extends PlatformTestCase {
|
||||
"After:[VFilePropertyChangeEvent->test2.txt]\n",
|
||||
|
||||
new VFileDeleteEvent(this, test2Txt, false),
|
||||
new VFilePropertyChangeEvent(this, testTxt, VirtualFile.PROP_NAME, file.getName(), file2.getName(), false)
|
||||
);
|
||||
new VFilePropertyChangeEvent(this, testTxt, VirtualFile.PROP_NAME, file.getName(), file2.getName(), false));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -220,9 +220,9 @@ class GuiTestRule : TestRule {
|
||||
//find first page with such actions like "Create New Project" without timeout
|
||||
private fun isWelcomeFrameFirstStep(timeout: org.fest.swing.timing.Timeout = Timeouts.seconds01): Boolean {
|
||||
val createNewProjectAction = GuiTestUtilKt.ignoreComponentLookupException {
|
||||
WelcomeFrameFixture.find(robot(), timeout).apply { robot().finder().find(this@apply.target() as Container) { it is ActionLink && it.text.contains("New Project") } }
|
||||
WelcomeFrameFixture.find(robot(), timeout).let { robot().finder().find(it.target() as Container) { it is ActionLink && it.text.contains("New Project") } }
|
||||
}
|
||||
return createNewProjectAction?.target()?.isShowing ?: false
|
||||
return createNewProjectAction?.isShowing ?: false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -509,6 +509,9 @@ vcs.code.analysis.before.checkin.show.only.new.threshold=-1
|
||||
vcs.code.analysis.before.checkin.show.only.new.threshold.description=Show only newly introduced warnings and errors in results \
|
||||
of before checkin analysis if the number of changed files is less or equals than threshold
|
||||
|
||||
vcs.process.externally.added.files=false
|
||||
vcs.process.externally.added.files.description=Process externally added files. Add such files to VCS automatically or prompt user.
|
||||
|
||||
psi.incremental.reparse.depth.limit=1000
|
||||
psi.deferIconLoading=true
|
||||
|
||||
@@ -1407,6 +1410,9 @@ editor.breadcrumbs.gap.right.description=An additional space after every breadcr
|
||||
editor.breadcrumbs.java.icon=false
|
||||
editor.breadcrumbs.java.icon.description=Shows icon for Java breadcrumbs
|
||||
|
||||
editor.breadcrumbs.language.statistics.enabled=false
|
||||
editor.breadcrumbs.language.statistics.enabled.description=Enables language-specific statistics for breadcrumbs (FUS)
|
||||
|
||||
testDiscovery.enabled=false
|
||||
testDiscovery.enabled.description=Enable instrumentation during tests to be able to start 'tests which pass this code' later
|
||||
|
||||
|
||||
@@ -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-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.
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.util.ThreadLocalCachedValue;
|
||||
@@ -20,23 +6,22 @@ import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class IOUtil {
|
||||
public static final boolean ourByteBuffersUseNativeByteOrder = SystemProperties.getBooleanProperty("idea.bytebuffers.use.native.byte.order", true);
|
||||
@SuppressWarnings("SpellCheckingInspection") public static final boolean BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER =
|
||||
SystemProperties.getBooleanProperty("idea.bytebuffers.use.native.byte.order", true);
|
||||
|
||||
private static final int STRING_HEADER_SIZE = 1;
|
||||
private static final int STRING_LENGTH_THRESHOLD = 255;
|
||||
|
||||
@NonNls private static final String LONGER_THAN_64K_MARKER = "LONGER_THAN_64K";
|
||||
private static final String LONGER_THAN_64K_MARKER = "LONGER_THAN_64K";
|
||||
|
||||
private IOUtil() {}
|
||||
|
||||
@@ -45,9 +30,9 @@ public class IOUtil {
|
||||
if (length == -1) return null;
|
||||
if (length == 0) return "";
|
||||
|
||||
byte[] bytes = new byte[length*2];
|
||||
byte[] bytes = new byte[length * 2];
|
||||
stream.readFully(bytes);
|
||||
return new String(bytes, 0, length*2, CharsetToolkit.UTF_16BE_CHARSET);
|
||||
return new String(bytes, 0, length * 2, CharsetToolkit.UTF_16BE_CHARSET);
|
||||
}
|
||||
|
||||
public static void writeString(@Nullable String s, @NotNull DataOutput stream) throws IOException {
|
||||
@@ -55,6 +40,7 @@ public class IOUtil {
|
||||
stream.writeInt(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
stream.writeInt(s.length());
|
||||
if (s.isEmpty()) {
|
||||
return;
|
||||
@@ -91,7 +77,7 @@ public class IOUtil {
|
||||
}
|
||||
};
|
||||
|
||||
public static void writeUTF(@NotNull DataOutput storage, @NotNull final String value) throws IOException {
|
||||
public static void writeUTF(@NotNull DataOutput storage, @NotNull String value) throws IOException {
|
||||
writeUTFFast(ourReadWriteBuffersCache.getValue(), storage, value);
|
||||
}
|
||||
|
||||
@@ -104,7 +90,7 @@ public class IOUtil {
|
||||
return new byte[STRING_LENGTH_THRESHOLD + STRING_HEADER_SIZE];
|
||||
}
|
||||
|
||||
public static void writeUTFFast(@NotNull byte[] buffer, @NotNull DataOutput storage, @NotNull final String value) throws IOException {
|
||||
public static void writeUTFFast(@NotNull byte[] buffer, @NotNull DataOutput storage, @NotNull String value) throws IOException {
|
||||
int len = value.length();
|
||||
if (len < STRING_LENGTH_THRESHOLD) {
|
||||
buffer[0] = (byte)len;
|
||||
@@ -133,7 +119,6 @@ public class IOUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
private static final ThreadLocalCachedValue<char[]> spareBufferLocal = new ThreadLocalCachedValue<char[]>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -157,15 +142,16 @@ public class IOUtil {
|
||||
storage.readFully(buffer, 0, len);
|
||||
|
||||
char[] chars = spareBufferLocal.getValue();
|
||||
for(int i = 0; i < len; ++i) chars[i] = (char)(buffer[i] &0xFF);
|
||||
for (int i = 0; i < len; ++i) chars[i] = (char)(buffer[i] & 0xFF);
|
||||
return new String(chars, 0, len);
|
||||
}
|
||||
|
||||
public static boolean isAscii(@NotNull String str) {
|
||||
return isAscii((CharSequence)str);
|
||||
}
|
||||
|
||||
public static boolean isAscii(@NotNull CharSequence str) {
|
||||
for (int i = 0, length = str.length(); i < length; ++ i) {
|
||||
for (int i = 0, length = str.length(); i < length; ++i) {
|
||||
if (str.charAt(i) >= 128) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -183,7 +169,7 @@ public class IOUtil {
|
||||
public boolean accept(final File pathname) {
|
||||
return pathname.getName().startsWith(baseName);
|
||||
}
|
||||
}): null;
|
||||
}) : null;
|
||||
|
||||
boolean ok = true;
|
||||
if (files != null) {
|
||||
@@ -205,7 +191,8 @@ public class IOUtil {
|
||||
Object o = outField.get(stream);
|
||||
if (o instanceof OutputStream) {
|
||||
stream = (OutputStream)o;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +208,8 @@ public class IOUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T openCleanOrResetBroken(@NotNull ThrowableComputable<T, IOException> factoryComputable, @NotNull final File file) throws IOException {
|
||||
public static <T> T openCleanOrResetBroken(@NotNull ThrowableComputable<T, ? extends IOException> factoryComputable,
|
||||
@NotNull final File file) throws IOException {
|
||||
return openCleanOrResetBroken(factoryComputable, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -230,33 +218,32 @@ public class IOUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> T openCleanOrResetBroken(@NotNull ThrowableComputable<T, IOException> factoryComputable, @NotNull Runnable cleanupCallback) throws IOException {
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
try {
|
||||
return factoryComputable.compute();
|
||||
} catch (IOException ex) {
|
||||
if (i == 1) throw ex;
|
||||
cleanupCallback.run();
|
||||
}
|
||||
public static <T> T openCleanOrResetBroken(@NotNull ThrowableComputable<T, ? extends IOException> factoryComputable,
|
||||
@NotNull Runnable cleanupCallback) throws IOException {
|
||||
try {
|
||||
return factoryComputable.compute();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
cleanupCallback.run();
|
||||
}
|
||||
|
||||
return null;
|
||||
return factoryComputable.compute();
|
||||
}
|
||||
|
||||
public static void writeStringList(@NotNull DataOutput out, @NotNull Collection<String> list) throws IOException {
|
||||
DataInputOutputUtil.writeINT(out, list.size());
|
||||
for (final String s : list) {
|
||||
for (String s : list) {
|
||||
writeUTF(out, s);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> readStringList(@NotNull DataInput in) throws IOException {
|
||||
final int size = DataInputOutputUtil.readINT(in);
|
||||
final ArrayList<String> strings = new ArrayList<String>(size);
|
||||
int size = DataInputOutputUtil.readINT(in);
|
||||
List<String> strings = new ArrayList<String>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
strings.add(readUTF(in));
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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-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.
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -29,7 +15,7 @@ import java.util.Arrays;
|
||||
|
||||
public class IntToIntBtree {
|
||||
public static int version() {
|
||||
return 4 + (IOUtil.ourByteBuffersUseNativeByteOrder ? 0xFF : 0);
|
||||
return 4 + (IOUtil.BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER ? 0xFF : 0);
|
||||
}
|
||||
|
||||
private static final int HAS_ZERO_KEY_MASK = 0xFF000000;
|
||||
@@ -71,7 +57,7 @@ public class IntToIntBtree {
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
|
||||
storage = new ResizeableMappedFile(file, pageSize, storageLockContext, 1024 * 1024, true, IOUtil.ourByteBuffersUseNativeByteOrder);
|
||||
storage = new ResizeableMappedFile(file, pageSize, storageLockContext, 1024 * 1024, true, IOUtil.BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER);
|
||||
storage.setRoundFactor(pageSize);
|
||||
root = new BtreeRootNode(this);
|
||||
|
||||
@@ -1150,14 +1136,14 @@ public class IntToIntBtree {
|
||||
|
||||
public boolean processMappings(@NotNull KeyValueProcessor processor) throws IOException {
|
||||
doFlush();
|
||||
|
||||
|
||||
if (hasZeroKey) {
|
||||
if (!processor.process(0, zeroKeyValue)) return false;
|
||||
}
|
||||
|
||||
if(root.address == UNDEFINED_ADDRESS) return true;
|
||||
root.syncWithStore();
|
||||
|
||||
|
||||
return processLeafPages(root.getNodeView(), processor);
|
||||
}
|
||||
|
||||
|
||||
@@ -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-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.
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -91,7 +77,7 @@ public class PersistentBTreeEnumerator<Data> extends PersistentEnumeratorBase<Da
|
||||
lockContext,
|
||||
VALUE_PAGE_SIZE,
|
||||
true,
|
||||
IOUtil.ourByteBuffersUseNativeByteOrder
|
||||
IOUtil.BYTE_BUFFERS_USE_NATIVE_BYTE_ORDER
|
||||
),
|
||||
dataDescriptor,
|
||||
initialSize,
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
@@ -96,7 +97,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
}
|
||||
|
||||
private static boolean isExternalEvent(@NotNull VirtualFileEvent event) {
|
||||
return event.isFromRefresh();
|
||||
return event.isFromRefresh() && Registry.is("vcs.process.externally.added.files");
|
||||
}
|
||||
|
||||
private boolean isUnderMyVcs(@NotNull VirtualFile file) {
|
||||
|
||||
+4
-20
@@ -1,12 +1,12 @@
|
||||
// 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-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.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.PsiDiamondTypeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RedundantExplicitVariableTypeInspection extends AbstractBaseJavaLoc
|
||||
PsiTypeElement element2Highlight) {
|
||||
PsiTypeElement typeElementCopy = copyVariable.getTypeElement();
|
||||
if (typeElementCopy != null) {
|
||||
replaceExplicitTypeWithVar(typeElementCopy, variable);
|
||||
IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar(typeElementCopy, variable);
|
||||
if (variable.getType().equals(copyVariable.getType())) {
|
||||
holder.registerProblem(element2Highlight,
|
||||
"Explicit type of local variable can be omitted",
|
||||
@@ -58,22 +58,6 @@ public class RedundantExplicitVariableTypeInspection extends AbstractBaseJavaLoc
|
||||
};
|
||||
}
|
||||
|
||||
private static PsiElement replaceExplicitTypeWithVar(PsiTypeElement typeElement, PsiElement context) {
|
||||
PsiElement parent = typeElement.getParent();
|
||||
if (parent instanceof PsiVariable) {
|
||||
PsiExpression copyVariableInitializer = ((PsiVariable)parent).getInitializer();
|
||||
if (copyVariableInitializer instanceof PsiNewExpression) {
|
||||
final PsiDiamondType.DiamondInferenceResult diamondResolveResult =
|
||||
PsiDiamondTypeImpl.resolveInferredTypesNoCheck((PsiNewExpression)copyVariableInitializer, copyVariableInitializer);
|
||||
if (!diamondResolveResult.getInferredTypes().isEmpty()) {
|
||||
PsiDiamondTypeUtil.expandTopLevelDiamondsInside(copyVariableInitializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return typeElement.replace(JavaPsiFacade.getElementFactory(context.getProject()).createTypeElementFromText("var", context));
|
||||
}
|
||||
|
||||
private static class ReplaceWithVarFix implements LocalQuickFix {
|
||||
@Nls
|
||||
@NotNull
|
||||
@@ -87,7 +71,7 @@ public class RedundantExplicitVariableTypeInspection extends AbstractBaseJavaLoc
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
if (element instanceof PsiTypeElement) {
|
||||
CodeStyleManager.getInstance(project)
|
||||
.reformat(replaceExplicitTypeWithVar((PsiTypeElement)element, element));
|
||||
.reformat(IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar((PsiTypeElement)element, element));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import com.intellij.openapi.actionSystem.LangDataKeys
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleType
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
@@ -27,6 +26,7 @@ import org.jetbrains.idea.devkit.DevKitBundle
|
||||
import org.jetbrains.idea.devkit.inspections.quickfix.PluginDescriptorChooser
|
||||
import org.jetbrains.idea.devkit.module.PluginModuleType
|
||||
import org.jetbrains.idea.devkit.util.DescriptorUtil
|
||||
import org.jetbrains.idea.devkit.util.PsiUtil
|
||||
import java.util.*
|
||||
import javax.swing.JComponent
|
||||
|
||||
@@ -56,7 +56,7 @@ class NewThemeAction: AnAction() {
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val module = e.getData(LangDataKeys.MODULE)
|
||||
e.presentation.isEnabled = module != null && ModuleType.get(module) is PluginModuleType //todo[kb] PsiUtil.isPluginModule stopped working
|
||||
e.presentation.isEnabled = module != null && (PsiUtil.isPluginModule(module) || PluginModuleType.get(module) is PluginModuleType)
|
||||
}
|
||||
|
||||
private fun createThemeJson(themeName: String, isDark: Boolean, project: Project, dir: PsiDirectory): PsiFile {
|
||||
|
||||
@@ -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-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.
|
||||
package org.jetbrains.idea.devkit.actions.service;
|
||||
|
||||
import com.intellij.ide.IdeView;
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.application.WriteActionAware;
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -33,6 +34,7 @@ import org.jetbrains.idea.devkit.actions.DevkitActionsUtil;
|
||||
import org.jetbrains.idea.devkit.dom.Extensions;
|
||||
import org.jetbrains.idea.devkit.dom.IdeaPlugin;
|
||||
import org.jetbrains.idea.devkit.util.DescriptorUtil;
|
||||
import org.jetbrains.idea.devkit.util.PsiUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
@@ -42,9 +44,10 @@ import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* An base class for actions generating service classes (implementation and optionally interface) and registering new service in plugin.xml.
|
||||
* An base class for actions generating service classes (implementation and optionally interface) and registering new service in {@code plugin.xml}.
|
||||
*/
|
||||
abstract class NewServiceActionBase extends CreateInDirectoryActionBase implements WriteActionAware {
|
||||
|
||||
NewServiceActionBase(String text, String description) {
|
||||
super(text, description, null);
|
||||
}
|
||||
@@ -54,6 +57,12 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Module module = e.getData(LangDataKeys.MODULE);
|
||||
e.getPresentation().setEnabled(module != null && PsiUtil.isPluginModule(module));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(@NotNull AnActionEvent e) {
|
||||
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
|
||||
@@ -88,7 +97,9 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
protected abstract String getTagName();
|
||||
|
||||
protected abstract String getOnlyImplementationTemplateName();
|
||||
|
||||
protected abstract String getInterfaceTemplateName();
|
||||
|
||||
protected abstract String getImplementationTemplateName();
|
||||
|
||||
protected abstract String getDialogTitle();
|
||||
@@ -122,7 +133,8 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
if (isSeparateMode()) {
|
||||
myServiceImplementationTextField.setEnabled(true);
|
||||
myServiceNameLabel.setText(DevKitBundle.message("new.service.dialog.interface"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myServiceImplementationTextField.setEnabled(false);
|
||||
myServiceNameLabel.setText(DevKitBundle.message("new.service.dialog.class"));
|
||||
}
|
||||
@@ -194,7 +206,8 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
myAdjusting = true;
|
||||
myServiceImplementationTextField.setText("");
|
||||
myAdjusting = false;
|
||||
} else if (myNeedAdjust) {
|
||||
}
|
||||
else if (myNeedAdjust) {
|
||||
myAdjusting = true;
|
||||
myServiceImplementationTextField.setText("impl." + myServiceNameTextField.getText() + "Impl");
|
||||
myAdjusting = false;
|
||||
@@ -286,7 +299,8 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
String interfacePackage;
|
||||
if (implementationDirRelativePackage.isEmpty()) {
|
||||
interfacePackage = ""; // interface and implementation are placed in the same package; there shouldn't be an import statement
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//noinspection ConstantConditions
|
||||
interfacePackage = StringUtil.getPackageName(createdInterface.getQualifiedName());
|
||||
}
|
||||
@@ -320,9 +334,9 @@ abstract class NewServiceActionBase extends CreateInDirectoryActionBase implemen
|
||||
private boolean doCreateService(Callable<Boolean> action) {
|
||||
try {
|
||||
return WriteCommandAction.writeCommandAction(getProject())
|
||||
.withName(DevKitBundle.message("new.service.class.action.name"))
|
||||
.withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION)
|
||||
.compute(() -> action.call());
|
||||
.withName(DevKitBundle.message("new.service.class.action.name"))
|
||||
.withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION)
|
||||
.compute(() -> action.call());
|
||||
}
|
||||
catch (Exception e) {
|
||||
handleException(e);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
package git4idea.notification
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vcs.VcsBundle
|
||||
import com.intellij.openapi.vcs.VcsConfiguration
|
||||
import com.intellij.openapi.vcs.VcsShowConfirmationOption
|
||||
@@ -15,6 +16,7 @@ class GitExternalFileNotifierTest : GitSingleRepoTest() {
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
Registry.get("vcs.process.externally.added.files").setValue(true, testRootDisposable)
|
||||
setStandardConfirmation(project, vcs.name, VcsConfiguration.StandardConfirmation.ADD, VcsShowConfirmationOption.Value.SHOW_CONFIRMATION)
|
||||
projectRoot.children //ensure that all subsequent VFS events will be fired after new files added to projectRoot
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ import org.jetbrains.plugins.github.api.data.GithubPullRequestMergeMethod;
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
public class GithubPullRequestMergeRebaseRequest {
|
||||
@NotNull private final String sha;
|
||||
@NotNull private final GithubPullRequestMergeMethod method;
|
||||
@NotNull private final GithubPullRequestMergeMethod mergeMethod;
|
||||
|
||||
public GithubPullRequestMergeRebaseRequest(@NotNull String sha) {
|
||||
this.sha = sha;
|
||||
this.method = GithubPullRequestMergeMethod.rebase;
|
||||
this.mergeMethod = GithubPullRequestMergeMethod.rebase;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,19 +9,19 @@ public class GithubPullRequestMergeRequest {
|
||||
@NotNull private final String commitTitle;
|
||||
@NotNull private final String commitMessage;
|
||||
@NotNull private final String sha;
|
||||
@NotNull private final GithubPullRequestMergeMethod method;
|
||||
@NotNull private final GithubPullRequestMergeMethod mergeMethod;
|
||||
|
||||
public GithubPullRequestMergeRequest(@NotNull String commitTitle,
|
||||
@NotNull String commitMessage,
|
||||
@NotNull String sha,
|
||||
@NotNull GithubPullRequestMergeMethod method) {
|
||||
if (method != GithubPullRequestMergeMethod.merge && method != GithubPullRequestMergeMethod.squash) {
|
||||
@NotNull GithubPullRequestMergeMethod mergeMethod) {
|
||||
if (mergeMethod != GithubPullRequestMergeMethod.merge && mergeMethod != GithubPullRequestMergeMethod.squash) {
|
||||
throw new IllegalArgumentException("Invalid merge method");
|
||||
}
|
||||
|
||||
this.commitTitle = commitTitle;
|
||||
this.commitMessage = commitMessage;
|
||||
this.sha = sha;
|
||||
this.method = method;
|
||||
this.mergeMethod = mergeMethod;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user