Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2016-01-04 11:05:38 +01:00
84 changed files with 2512 additions and 1334 deletions
+1 -1
View File
@@ -9,6 +9,6 @@
<plugin id="com.intellij.properties" />
<plugin id="com.intellij.uiDesigner" />
<plugin id="org.intellij.groovy" />
<plugin id="org.jetbrains.kotlin" min-version="1.0.0-beta-3595" max-version="1.1" />
<plugin id="org.jetbrains.kotlin" min-version="1.0.0-beta-4584" max-version="1.1" />
</component>
</project>
-1
View File
@@ -238,7 +238,6 @@
<module fileurl="file://$PROJECT_DIR$/plugins/tasks/tasks-java/tasks-java.iml" filepath="$PROJECT_DIR$/plugins/tasks/tasks-java/tasks-java.iml" group="plugins/tasks" />
<module fileurl="file://$PROJECT_DIR$/plugins/tasks/tasks-tests/tasks-tests.iml" filepath="$PROJECT_DIR$/plugins/tasks/tasks-tests/tasks-tests.iml" group="plugins/tasks" />
<module fileurl="file://$PROJECT_DIR$/plugins/terminal/terminal.iml" filepath="$PROJECT_DIR$/plugins/terminal/terminal.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/testFramework/test-framework-java8.iml" filepath="$PROJECT_DIR$/platform/testFramework/test-framework-java8.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/testFramework/testFramework.iml" filepath="$PROJECT_DIR$/platform/testFramework/testFramework.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/java/testFramework/testFramework-java.iml" filepath="$PROJECT_DIR$/java/testFramework/testFramework-java.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/platform/testRunner/testRunner.iml" filepath="$PROJECT_DIR$/platform/testRunner/testRunner.iml" group="platform" />
+1 -1
View File
@@ -18,7 +18,7 @@ import com.intellij.util.text.VersionComparatorUtil
import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_Beta3_Idea142branch150versionNoTests"
String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_Beta4_Idea142branch150versionNoTests"
target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') {
def communityHome = guessHome(this)
@@ -31,7 +31,7 @@ class JCiPUtil {
private static final String GUARDED_BY = "net.jcip.annotations.GuardedBy";
static boolean isJCiPAnnotation(String ref) {
return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals("ref");
return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals(ref) || "NotThreadSafe".equals(ref);
}
private JCiPUtil() {
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.actions.OptimizeImportsProcessor;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.hint.QuestionAction;
import com.intellij.ide.util.DefaultPsiElementCellRenderer;
@@ -267,17 +266,6 @@ public class AddImportAction implements QuestionAction {
myEditor.getCaretModel().moveToLogicalPosition(new LogicalPosition(pos2.line, newCol));
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!myProject.isDisposed() && myProject.isOpen()) {
DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
if (daemonCodeAnalyzer != null) {
daemonCodeAnalyzer.updateVisibleHighlighters(myEditor);
}
}
}
});
}
protected void bindReference(PsiReference ref, PsiClass targetClass) {
@@ -19,42 +19,32 @@ import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.JavaProjectCodeInsightSettings;
import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction;
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction;
import com.intellij.ide.util.MethodCellRenderer;
import com.intellij.codeInspection.HintAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.*;
import com.intellij.psi.util.proximity.PsiProximityComparator;
import com.intellij.ui.popup.list.ListPopupImpl;
import com.intellij.ui.popup.list.PopupListElementRenderer;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ObjectUtils;
import com.intellij.util.Processor;
import com.intellij.util.containers.LinkedMultiMap;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
public class StaticImportMethodFix implements IntentionAction {
public class StaticImportMethodFix implements IntentionAction, HintAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.StaticImportMethodFix");
private final SmartPsiElementPointer<PsiMethodCallExpression> myMethodCall;
private List<PsiMethod> candidates;
@@ -68,9 +58,7 @@ public class StaticImportMethodFix implements IntentionAction {
public String getText() {
String text = QuickFixBundle.message("static.import.method.text");
if (candidates != null && candidates.size() == 1) {
text += " '" + PsiFormatUtil.formatMethod(candidates.get(0), PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME, 0)+"'";
text += " '" + getMethodPresentableText() + "'";
}
else {
text += "...";
@@ -78,6 +66,13 @@ public class StaticImportMethodFix implements IntentionAction {
return text;
}
@NotNull
private String getMethodPresentableText() {
return PsiFormatUtil.formatMethod(candidates.get(0), PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
PsiFormatUtilBase.SHOW_FQ_NAME, 0);
}
@Override
@NotNull
public String getFamilyName() {
@@ -91,6 +86,7 @@ public class StaticImportMethodFix implements IntentionAction {
&& myMethodCall.getElement() != null
&& myMethodCall.getElement().isValid()
&& myMethodCall.getElement().getMethodExpression().getQualifierExpression() == null
&& myMethodCall.getElement().resolveMethod() == null
&& file.getManager().isInProject(file)
&& !(candidates == null ? candidates = getMethodsToImport() : candidates).isEmpty()
;
@@ -263,146 +259,61 @@ public class StaticImportMethodFix implements IntentionAction {
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) {
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
if (candidates.size() == 1) {
final PsiMethod toImport = candidates.get(0);
doImport(toImport);
}
else {
chooseAndImport(editor, project);
}
}
private void doImport(final PsiMethod toImport) {
CommandProcessor.getInstance().executeCommand(toImport.getProject(), new Runnable(){
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
PsiMethodCallExpression element = myMethodCall.getElement();
if (element != null) {
AddSingleMemberStaticImportAction.bindAllClassRefs(element.getContainingFile(), toImport, toImport.getName(), toImport.getContainingClass());
}
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
});
final List<PsiMethod> methodsToImport = getMethodsToImport();
if (methodsToImport.isEmpty()) return;
createQuestionAction(methodsToImport, project, editor).execute();
}
}, getText(), this);
});
}
private void chooseAndImport(Editor editor, final Project project) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
doImport(candidates.get(0));
return;
@NotNull
private StaticImportMethodQuestionAction createQuestionAction(List<PsiMethod> methodsToImport, @NotNull Project project, Editor editor) {
return new StaticImportMethodQuestionAction(project, editor, methodsToImport, myMethodCall);
}
private ImportClassFixBase.Result doFix(Editor editor) {
if (candidates.isEmpty()) {
return ImportClassFixBase.Result.POPUP_NOT_SHOWN;
}
final BaseListPopupStep<PsiMethod> step =
new BaseListPopupStep<PsiMethod>(QuickFixBundle.message("class.to.import.chooser.title"), candidates) {
final StaticImportMethodQuestionAction action = createQuestionAction(candidates, myMethodCall.getProject(), editor);
if (candidates.size() == 1) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public PopupStep onChosen(PsiMethod selectedValue, boolean finalChoice) {
if (selectedValue == null) {
return FINAL_CHOICE;
}
if (finalChoice) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
LOG.assertTrue(selectedValue.isValid());
doImport(selectedValue);
return FINAL_CHOICE;
}
String qname = PsiUtil.getMemberQualifiedName(selectedValue);
if (qname == null) return FINAL_CHOICE;
List<String> excludableStrings = AddImportAction.getAllExcludableStrings(qname);
return new BaseListPopupStep<String>(null, excludableStrings) {
@NotNull
@Override
public String getTextFor(String value) {
return "Exclude '" + value + "' from auto-import";
}
@Override
public PopupStep onChosen(String selectedValue, boolean finalChoice) {
if (finalChoice) {
AddImportAction.excludeFromImport(project, selectedValue);
}
return super.onChosen(selectedValue, finalChoice);
}
};
public void run() {
action.execute();
}
});
return ImportClassFixBase.Result.CLASS_AUTO_IMPORTED;
}
@Override
public boolean hasSubstep(PsiMethod selectedValue) {
return true;
}
@NotNull
@Override
public String getTextFor(PsiMethod value) {
return ObjectUtils.assertNotNull(value.getName());
}
@Override
public Icon getIconFor(PsiMethod aValue) {
return aValue.getIcon(0);
}
};
final ListPopupImpl popup = new ListPopupImpl(step) {
final PopupListElementRenderer rightArrow = new PopupListElementRenderer(this);
@Override
protected ListCellRenderer getListElementRenderer() {
return new MethodCellRenderer(true, PsiFormatUtilBase.SHOW_NAME){
@Nullable
@Override
protected TextAttributes getNavigationItemAttributes(Object value) {
TextAttributes attrs = super.getNavigationItemAttributes(value);
if (value instanceof PsiMethod && !((PsiMethod)value).isDeprecated()) {
PsiClass psiClass = ((PsiMethod)value).getContainingClass();
if (psiClass != null && psiClass.isDeprecated()) {
return TextAttributes.merge(attrs, super.getNavigationItemAttributes(psiClass));
}
}
return attrs;
}
@Override
protected DefaultListCellRenderer getRightCellRenderer(final Object value) {
final DefaultListCellRenderer moduleRenderer = super.getRightCellRenderer(value);
return new DefaultListCellRenderer(){
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
if (moduleRenderer != null) {
Component moduleComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (!isSelected) {
moduleComponent.setBackground(getBackgroundColor(value));
}
panel.add(moduleComponent, BorderLayout.CENTER);
}
rightArrow.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Component rightArrowComponent = rightArrow.getNextStepLabel();
panel.add(rightArrowComponent, BorderLayout.EAST);
return panel;
}
};
}
};
}
};
popup.showInBestPositionFor(editor);
String hintText = ShowAutoImportPass.getMessage(candidates.size() > 1, getMethodPresentableText());
if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
final PsiMethodCallExpression element = myMethodCall.getElement();
final TextRange textRange = element.getTextRange();
HintManager.getInstance().showQuestionHint(editor, hintText,
textRange.getStartOffset(),
textRange.getEndOffset(), action);
}
return ImportClassFixBase.Result.POPUP_SHOWN;
}
@Override
public boolean startInWriteAction() {
return true;
return false;
}
@Override
public boolean showHint(@NotNull Editor editor) {
final PsiMethodCallExpression callExpression = myMethodCall.getElement();
if (callExpression == null || callExpression.getMethodExpression().getQualifierExpression() != null) {
return false;
}
ImportClassFixBase.Result result = doFix(editor);
return result == ImportClassFixBase.Result.POPUP_SHOWN || result == ImportClassFixBase.Result.CLASS_AUTO_IMPORTED;
}
}
@@ -0,0 +1,217 @@
/*
* 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.
*/
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction;
import com.intellij.codeInsight.hint.QuestionAction;
import com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction;
import com.intellij.ide.util.MethodCellRenderer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.psi.util.PsiUtil;
import com.intellij.ui.popup.list.ListPopupImpl;
import com.intellij.ui.popup.list.PopupListElementRenderer;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.List;
public class StaticImportMethodQuestionAction implements QuestionAction {
private static final Logger LOG = Logger.getInstance("#" + StaticImportMethodQuestionAction.class.getName());
private final Project myProject;
private final Editor myEditor;
private List<PsiMethod> myCandidates;
private final SmartPsiElementPointer<PsiMethodCallExpression> myMethodCall;
public StaticImportMethodQuestionAction(Project project,
Editor editor,
List<PsiMethod> candidates,
SmartPsiElementPointer<PsiMethodCallExpression> methodCall) {
myProject = project;
myEditor = editor;
myCandidates = candidates;
myMethodCall = methodCall;
}
@Override
public boolean execute() {
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final PsiMethodCallExpression element = myMethodCall.getElement();
if (element == null || !element.isValid()){
return false;
}
for (PsiMethod targetMethod : myCandidates) {
if (!targetMethod.isValid()) {
return false;
}
}
if (myCandidates.size() == 1){
doImport(myCandidates.get(0));
}
else{
chooseAndImport(myEditor, myProject);
}
return true;
}
private void doImport(final PsiMethod toImport) {
final Project project = toImport.getProject();
CommandProcessor.getInstance().executeCommand(project, new Runnable(){
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
PsiMethodCallExpression element = myMethodCall.getElement();
if (element != null) {
AddSingleMemberStaticImportAction.bindAllClassRefs(element.getContainingFile(), toImport, toImport.getName(), toImport.getContainingClass());
}
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
});
}
}, QuickFixBundle.message("add.import"), this);
}
private void chooseAndImport(final Editor editor, final Project project) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
doImport(myCandidates.get(0));
return;
}
final BaseListPopupStep<PsiMethod> step =
new BaseListPopupStep<PsiMethod>(QuickFixBundle.message("method.to.import.chooser.title"), myCandidates) {
@Override
public PopupStep onChosen(PsiMethod selectedValue, boolean finalChoice) {
if (selectedValue == null) {
return FINAL_CHOICE;
}
if (finalChoice) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
LOG.assertTrue(selectedValue.isValid());
doImport(selectedValue);
return FINAL_CHOICE;
}
String qname = PsiUtil.getMemberQualifiedName(selectedValue);
if (qname == null) return FINAL_CHOICE;
List<String> excludableStrings = AddImportAction.getAllExcludableStrings(qname);
return new BaseListPopupStep<String>(null, excludableStrings) {
@NotNull
@Override
public String getTextFor(String value) {
return "Exclude '" + value + "' from auto-import";
}
@Override
public PopupStep onChosen(String selectedValue, boolean finalChoice) {
if (finalChoice) {
AddImportAction.excludeFromImport(project, selectedValue);
}
return super.onChosen(selectedValue, finalChoice);
}
};
}
@Override
public boolean hasSubstep(PsiMethod selectedValue) {
return true;
}
@NotNull
@Override
public String getTextFor(PsiMethod value) {
return ObjectUtils.assertNotNull(value.getName());
}
@Override
public Icon getIconFor(PsiMethod aValue) {
return aValue.getIcon(0);
}
};
final ListPopupImpl popup = new ListPopupImpl(step) {
final PopupListElementRenderer rightArrow = new PopupListElementRenderer(this);
@Override
protected ListCellRenderer getListElementRenderer() {
return new MethodCellRenderer(true, PsiFormatUtilBase.SHOW_NAME){
@Nullable
@Override
protected TextAttributes getNavigationItemAttributes(Object value) {
TextAttributes attrs = super.getNavigationItemAttributes(value);
if (value instanceof PsiMethod && !((PsiMethod)value).isDeprecated()) {
PsiClass psiClass = ((PsiMethod)value).getContainingClass();
if (psiClass != null && psiClass.isDeprecated()) {
return TextAttributes.merge(attrs, super.getNavigationItemAttributes(psiClass));
}
}
return attrs;
}
@Override
protected DefaultListCellRenderer getRightCellRenderer(final Object value) {
final DefaultListCellRenderer moduleRenderer = super.getRightCellRenderer(value);
return new DefaultListCellRenderer(){
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
if (moduleRenderer != null) {
Component moduleComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (!isSelected) {
moduleComponent.setBackground(getBackgroundColor(value));
}
panel.add(moduleComponent, BorderLayout.CENTER);
}
rightArrow.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Component rightArrowComponent = rightArrow.getNextStepLabel();
panel.add(rightArrowComponent, BorderLayout.EAST);
return panel;
}
};
}
};
}
};
popup.showInBestPositionFor(editor);
}
}
@@ -22,6 +22,5 @@
<orderEntry type="module" module-name="vcs-api" />
<orderEntry type="library" scope="TEST" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="module" module-name="test-framework-java8" />
</component>
</module>
@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/client/node-rpc-client/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/client/node-rpc-client/out" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
+3 -1
View File
@@ -1 +1,3 @@
node_modules/
node_modules/
npm-debug.log
out/
@@ -1,42 +0,0 @@
var gulp = require('gulp')
var ts = require('gulp-typescript')
var concat = require('gulp-concat')
var uglify = require('gulp-uglify')
var newer = require('gulp-newer')
var sourcemaps = require('gulp-sourcemaps')
var path = require('path')
var outDir = 'out'
var outFile = 'ij-rpc-client.js'
var sources = "src/*.ts";
var tsProject = ts.createProject({
target: "ES5",
noImplicitAny: true,
removeComments: true,
sortOutput: true,
module: "commonjs"
});
gulp.task("compile", function () {
var tsResult = gulp.src(sources)
.pipe(sourcemaps.init())
//.pipe(newer(outDir + '/' + outFile))
.pipe(ts(tsProject));
tsResult.js.pipe(concat(outFile))
//.pipe(uglify({
// output: {
// beautify: true,
// indent_level: 2
// }
// }))
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: path.resolve('testData')}))
.pipe(gulp.dest(outDir))
});
gulp.task('watch', function () {
gulp.watch(sources, ['compile']);
});
gulp.task('default', ['compile']);
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -2,16 +2,21 @@
"name": "ij-rpc-client",
"version": "0.0.1",
"description": "IntelliJ Platform RPC client",
"scripts": {
"compile": "rimraf app/out && tsconfig -i 2 && tsc",
"test": "mocha --harmony_default_parameters --harmony_rest_parameters"
},
"repository": {
"type": "git",
"url": "https://github.com/JetBrains/intellij-community.git"
},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-concat": "^2.4.3",
"gulp-newer": "^0.5.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-typescript": "^2.4.2",
"gulp-uglify": "^1.1.0"
"rimraf": "^2.5.0",
"should": "^8.0.2",
"tsconfig-glob": "^0.3.3",
"typescript": "^1.8.0-dev.20151231"
},
"dependencies": {
"bluebird": "^3.1.1"
}
}
@@ -1,82 +1,98 @@
"use strict"
import net = require("net")
import rpc = require("./rpc")
import * as net from "net"
import { JsonRpc, Transport } from "./rpc"
export class RpcClient {
connect(port:Number = 63342) {
var socket = net.connect({port: port}, function () {
console.log('Connected to IJ RPC server localhost:' + port)
});
connect(port: number = 63342) {
const socket = net.connect({port: port}, () => {
console.log("Connected to IJ RPC server localhost: " + port)
})
var jsonRpc = new rpc.JsonRpc(new SocketTransport(socket))
var decoder:MessageDecoder = new MessageDecoder(jsonRpc.messageReceived)
socket.on('data', decoder.messageReceived)
const transport = new SocketTransport(socket)
const jsonRpc = new JsonRpc(transport)
const decoder = new MessageDecoder(jsonRpc.messageReceived)
socket.on("data", decoder.messageReceived)
}
}
const enum State {LENGTH, CONTENT}
class SocketTransport implements rpc.Transport {
export class SocketTransport implements Transport {
private headerBuffer = new Buffer(4)
constructor(private socket:net.Socket) {
opened: () => void
constructor(private socket: net.Socket = new net.Socket()) {
}
send(id:number, domain:string, command:string, params:any[] = null):void {
var encodedParams = JSON.stringify(params)
var header = (id == -1 ? '' : (id + ', ')) + '"' + domain + '", "' + command + '"';
this.headerBuffer.writeUInt32BE(Buffer.byteLength(encodedParams) + header.length, 0)
connect(port: number = 63342) {
this.socket.connect(port, null, ()=> {
const opened = this.opened
if (opened != null) {
opened()
}
})
this.socket.on("error", (e: Error) => {
console.error(e)
})
this.socket.write(new Buffer([67, 72, 105, -107, 126, -21, -81, -72, 64, 54, -87, -88, 0, -46, -48, 34, -7, -67]))
}
send(id: number, domain: string, command: string, params: any[] = null): void {
const encodedParams = JSON.stringify(params)
const header = (id == -1 ? '' : (id + ', ')) + '"' + domain + '", "' + command + '"';
this.headerBuffer.writeUInt32BE(header.length + Buffer.byteLength(encodedParams), 0)
this.socket.write(this.headerBuffer)
this.socket.write(encodedParams, 'utf-8')
this.socket.write(header)
this.socket.write(encodedParams)
}
sendResult(id:number, result:any):void {
sendResult(id: number, result: any): void {
this.sendResultOrError(id, result, false)
}
sendError(id:number, error:any):void {
sendError(id: number, error: any): void {
this.sendResultOrError(id, error, true)
}
private sendResultOrError(id:number, result:any, isError:boolean):void {
private sendResultOrError(id: number, result: any, isError: boolean): void {
var encodedResult = JSON.stringify(result)
var header = id + ', "' + (isError ? 'e': 'r') + '"';
var header = id + ', "' + (isError ? 'e' : 'r') + '"';
this.headerBuffer.writeUInt32BE(Buffer.byteLength(encodedResult) + header.length, 0)
this.socket.write(this.headerBuffer)
this.socket.write(encodedResult, 'utf-8')
this.socket.write(encodedResult)
}
}
class MessageDecoder {
private state:State = State.LENGTH
private contentLength:number = 0
private state: State = State.LENGTH
private contentLength: number = 0
private buffers:Array<Buffer> = []
private totalBufferLength:number = 0
private offset:number = 0
private buffers: Array<Buffer> = []
private totalBufferLength: number = 0
private offset: number = 0
constructor(private messageProcessor:(message:any)=>void) {
constructor(private messageProcessor: (message: any)=>void) {
}
private byteConsumed(count:number) {
private byteConsumed(count: number) {
this.offset += count
this.totalBufferLength -= count
}
messageReceived(buffer:Buffer) {
messageReceived(buffer: Buffer) {
this.totalBufferLength += buffer.length
while (true) {
//noinspection FallThroughInSwitchStatementJS
switch (this.state) {
case State.LENGTH: {
case State.LENGTH:
{
if (this.totalBufferLength < 4) {
this.buffers.push(buffer)
return
}
var totalBuffer:Buffer
var totalBuffer: Buffer
if (this.buffers.length === 0) {
totalBuffer = buffer
}
@@ -92,13 +108,14 @@ class MessageDecoder {
buffer = totalBuffer
}
case State.CONTENT: {
case State.CONTENT:
{
if (this.totalBufferLength < this.contentLength) {
this.buffers.push(buffer)
return
}
var totalBuffer:Buffer
var totalBuffer: Buffer
if (this.buffers.length === 0) {
totalBuffer = buffer
}
@@ -1,39 +1,39 @@
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/bluebird/bluebird.d.ts" />
"use strict"
import Promise = require("bluebird")
class PromiseCallback {
constructor(public resolve:(value?:any) => void, public reject:(error?:any) => void) {
constructor(public resolve: (value?: any) => void, public reject: (error?: any) => void) {
}
}
export interface Transport {
send(id:number, domain:string, command:string, params:any[]):void
opened?: () => void
sendResult(id:number, result:any):void
connect(port: number): void
sendError(id:number, error:any):void
send(id: number, domain: string, command: string, params: any[]): void
sendResult(id: number, result: any):void
sendError(id: number, error: any):void
}
export class JsonRpc {
private messageIdCounter = 0
private callbacks:Map<number, PromiseCallback> = new Map<number, PromiseCallback>()
private domains:Map<string, any> = new Map<string, any>()
private callbacks: Map<number, PromiseCallback> = new Map<number, PromiseCallback>()
private domains: Map<string, any> = new Map<string, any>()
constructor(private transport:Transport) {
constructor(private transport: Transport) {
}
public call<T>(domain:string, command:string, ...params: any[]):Promise<T> {
return new Promise((resolve:(value:T) => void, reject:(error?:any) => void) => {
public call<T>(domain: string, command: string, ...params: any[]): Promise<T> {
return new Promise((resolve: (value: T) => void, reject: (error?: any) => void) => {
var id = this.messageIdCounter++;
this.callbacks.set(id, new PromiseCallback(resolve, reject))
this.transport.send(id, domain, command, params)
})
}
messageReceived(message:Array<any>) {
messageReceived(message: Array<any>) {
if (message.length === 1 || (message.length === 2 && !(typeof message[1] === 'string'))) {
var promiseCallback = this.callbacks.get(message[0])
var singletonArray = safeGet(message, 1)
@@ -45,8 +45,8 @@ export class JsonRpc {
}
}
else {
var id:number
var offset:number
var id: number
var offset: number
if (typeof message[0] === 'string') {
id = -1
offset = 0
@@ -56,11 +56,11 @@ export class JsonRpc {
offset = 1
}
var onRejected = id === -1 ? null : (error:any) => this.transport.sendError(id, error)
var onRejected = id === -1 ? null : (error: any) => this.transport.sendError(id, error)
try {
var object = this.domains.get(message[offset])
var method = object[message[offset + 1]]
var result:any
var result: any
var args = safeGet(message, offset + 2)
if (args === null) {
result = method.call(object)
@@ -70,7 +70,7 @@ export class JsonRpc {
}
if (id !== -1) {
var onFulfilled = (result:any) => this.transport.sendResult(id, result)
var onFulfilled = (result: any) => this.transport.sendResult(id, result)
if (result instanceof Promise) {
(<Promise<any>>result).done(onFulfilled, onRejected)
}
@@ -89,6 +89,6 @@ export class JsonRpc {
}
}
function safeGet(a:any[], index:number):Array<any> {
function safeGet(a: any[], index: number): Array<any> {
return index < a.length ? a[index] : null
}
@@ -0,0 +1,30 @@
const should = require("should")
const rpcClient = require("../out/rpc-client")
const rpc = require("../out/rpc")
describe("RPC", function () {
it("connect", function (done) {
const transport = new rpcClient.SocketTransport()
transport.opened = function () {
done()
}
transport.connect()
})
it("connect", function (done) {
this.timeout(5000000)
const transport = new rpcClient.SocketTransport()
transport.opened = function () {
}
transport.connect(63343)
const rpcServer = new rpc.JsonRpc(transport)
rpcServer.call("Ide", "about")
.then(function (r) {
console.log(r)
done()
}, function (e) {
throw e
})
})
})
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"removeComments": true,
"outDir": "out",
"newLine": "LF",
"noResolve": true,
"noEmitOnError": true,
"inlineSources": true,
"sourceMap": true
},
"filesGlob": [
"src/*.ts",
"typings/**/*.d.ts"
],
"files": [
"typings/bluebird/bluebird.d.ts",
"typings/node/node.d.ts",
"src/rpc-client.ts",
"src/rpc.ts"
]
}
@@ -3,13 +3,12 @@
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "35fffaa44bff5392741b3022d805fe3563023a3d"
"commit": "dc9dabe74a5be62613b17a3605309783a12ff28a"
},
"bluebird/bluebird.d.ts": {
"commit": "cf7c97b2a68a385c98c75fb6edd81083c97c983c"
"commit": "dc9dabe74a5be62613b17a3605309783a12ff28a"
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1 +0,0 @@
/// <reference path="node/node.d.ts" />
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.OutputStream;
/**
* @api {get} /about The application info
@@ -41,6 +42,7 @@ import java.io.IOException;
* @apiGroup Platform
*
* @apiParam {Boolean} [registeredFileTypes=false] Whether to include the list of registered file types.
* @apiParam {Boolean} [more=false] Whether to include the full info.
*
* @apiSuccess {String} name The full application name.
* @apiSuccess {String} productName The product name.
@@ -58,7 +60,7 @@ import java.io.IOException;
* @apiUse SuccessExample
* @apiUse SuccessExampleWithRegisteredFileTypes
*/
class AboutHttpService extends RestService {
public class AboutHttpService extends RestService {
@NotNull
@Override
protected String getServiceName() {
@@ -73,10 +75,17 @@ class AboutHttpService extends RestService {
@Nullable
@Override
public String execute(@NotNull QueryStringDecoder urlDecoder, @NotNull FullHttpRequest request, @NotNull ChannelHandlerContext context) throws IOException {
BuildNumber build = ApplicationInfo.getInstance().getBuild();
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream();
JsonWriter writer = createJsonWriter(byteOut);
getAbout(byteOut, urlDecoder);
send(byteOut, request, context);
return null;
}
public static void getAbout(@NotNull OutputStream out, @Nullable QueryStringDecoder urlDecoder) throws IOException {
BuildNumber build = ApplicationInfo.getInstance().getBuild();
JsonWriter writer = createJsonWriter(out);
writer.beginObject();
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
@@ -94,7 +103,7 @@ class AboutHttpService extends RestService {
writer.name("buildNumber").value(build.getBuildNumber());
}
if (getBooleanParameter("registeredFileTypes", urlDecoder)) {
if (urlDecoder != null && getBooleanParameter("registeredFileTypes", urlDecoder)) {
writer.name("registeredFileTypes").beginArray();
for (FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
writer.beginObject();
@@ -106,8 +115,7 @@ class AboutHttpService extends RestService {
writer.endArray();
}
String uri = request.getUri();
if (uri != null && uri.endsWith("?more")) {
if (urlDecoder != null && getBooleanParameter("more", urlDecoder)) {
writer.name("vendor").value(appInfo.getCompanyName());
writer.name("isEAP").value(appInfo.isEAP());
writer.name("productCode").value(appInfo.getBuild().getProductCode());
@@ -122,12 +130,5 @@ class AboutHttpService extends RestService {
writer.endObject();
writer.close();
send(byteOut, request, context);
return null;
}
@Override
protected boolean activateToolBeforeExecution() {
return false;
}
}
@@ -38,6 +38,7 @@ public class ActivateApplicationHttpService extends RestService {
if (frame instanceof Window) {
sendOk(request, context);
Runnable runnable = new Runnable() {
@Override
public void run() {
Window window = (Window)frame;
window.toFront();
@@ -40,6 +40,8 @@ public class JetBrainsProtocolHandlerHttpService extends RestService {
final String url = reader.nextString();
reader.endObject();
activateLastFocusedFrame();
if (URL_PARAM_NAME.equals(name) && url != null && url.startsWith(JetBrainsProtocolHandler.PROTOCOL)) {
JetBrainsProtocolHandler.processJetBrainsLauncherParameters(url);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -67,6 +67,7 @@ public class ProjectSetRequestHandler extends RestService {
@Override
public void run() {
new ProjectSetReader().readDescriptor(descriptor, null);
activateLastFocusedFrame();
}
});
sendOk(request, context);
@@ -44,6 +44,7 @@ import org.jetbrains.io.Responses;
import java.awt.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
@@ -103,10 +104,6 @@ public abstract class RestService extends HttpRequestHandler {
return false;
}
protected boolean activateToolBeforeExecution() {
return true;
}
@NotNull
/**
* Use human-readable name or UUID if it is an internal service.
@@ -118,13 +115,6 @@ public abstract class RestService extends HttpRequestHandler {
@Override
public final boolean process(@NotNull QueryStringDecoder urlDecoder, @NotNull FullHttpRequest request, @NotNull ChannelHandlerContext context) throws IOException {
try {
if (activateToolBeforeExecution()) {
IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
if (frame instanceof Window) {
((Window)frame).toFront();
}
}
String error = execute(urlDecoder, request, context);
if (error != null) {
Responses.sendStatus(HttpResponseStatus.BAD_REQUEST, context.channel(), error, request);
@@ -147,6 +137,13 @@ public abstract class RestService extends HttpRequestHandler {
return true;
}
protected final void activateLastFocusedFrame() {
IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
if (frame instanceof Window) {
((Window)frame).toFront();
}
}
@Nullable("error text or null if successful")
/**
* Return error or send response using {@link #sendOk(FullHttpRequest, ChannelHandlerContext)}, {@link #send(BufferExposingByteArrayOutputStream, FullHttpRequest, ChannelHandlerContext)}
@@ -161,7 +158,7 @@ public abstract class RestService extends HttpRequestHandler {
}
@NotNull
protected static JsonWriter createJsonWriter(@NotNull BufferExposingByteArrayOutputStream out) {
protected static JsonWriter createJsonWriter(@NotNull OutputStream out) {
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, CharsetToolkit.UTF8_CHARSET));
writer.setIndent(" ");
return writer;
@@ -82,7 +82,7 @@ abstract class FastCgiService(project: Project) : SingleConnectionNetService(pro
promise = processHandler.get()
}
promise
(promise as Promise<Any?>)
.done { fastCgiRequest.writeToServerChannel(notEmptyContent, processChannel.get()!!) }
.rejected {
Promise.logError(LOG, it)
@@ -96,6 +96,10 @@ public class JsonRpcServer implements MessageServer {
if (!isBinary) {
reader.beginArray();
}
else {
// to allow top-level member to be not a object or array
reader.setLenient(true);
}
int messageId = reader.peek() == JsonToken.NUMBER ? reader.nextInt() : -1;
String domainName = reader.nextString();
@@ -155,7 +159,22 @@ public class JsonRpcServer implements MessageServer {
method.setAccessible(true);
Object result = method.invoke(isStatic ? null : domain, parameters);
if (messageId != -1) {
client.send(encodeMessage(client.getByteBufAllocator(), messageId, null, null, null, new Object[]{result}));
if (result instanceof ByteBuf) {
ByteBuf buffer = (ByteBuf)result;
boolean success = false;
try {
client.send(encodeMessage(client.getByteBufAllocator(), messageId, null, null, buffer, null));
success = true;
}
finally {
if (!success) {
buffer.release();
}
}
}
else {
client.send(encodeMessage(client.getByteBufAllocator(), messageId, null, null, null, new Object[]{result}));
}
}
return;
}
@@ -74,7 +74,6 @@ class RpcBinaryRequestHandler extends BinaryRequestHandler implements ExceptionH
private class MyDecoder extends MessageDecoder {
private State state = State.LENGTH;
private int contentLength;
private final SocketClient client;
@@ -56,7 +56,7 @@ internal class BinaryRequestHandlerTest {
try {
result.rejected(object : Consumer<Throwable> {
override fun consume(error: Throwable) {
TestCase.fail(error.getMessage())
TestCase.fail(error.message)
}
})
@@ -186,12 +186,7 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
}
if (onlyExisting || onlyPaths != null) {
val it = result.keySet().iterator()
while (it.hasNext()) {
if (isSkipFile(it.next())) {
it.remove()
}
}
result.keys.removeAll(::isSkipFile)
}
ServiceManagerImpl.processAllImplementationClasses(ApplicationManager.getApplication() as ApplicationImpl, object : PairProcessor<Class<*>, PluginDescriptor> {
@@ -362,7 +362,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
removeScheme(existingScheme)
}
else {
if (schemeExtension != extension && schemeToInfo.get(existingScheme)?.fileNameWithoutExtension == fileNameWithoutExtension) {
if (schemeExtension != extension && schemeToInfo.get(existingScheme as Scheme)?.fileNameWithoutExtension == fileNameWithoutExtension) {
// 1.oldExt is loading after 1.newExt - we should delete 1.oldExt
filesToDelete.add(fileName.toString())
}
@@ -678,11 +678,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
schemes.clear()
}
else {
for (i in schemes.indices.reversed()) {
if (removeCondition.value(schemes.get(i))) {
schemes.remove(i)
}
}
schemes.removeAll { removeCondition.value(it) }
}
retainExternalInfo(newSchemes)
@@ -741,8 +737,8 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
toReplace = i
if (replaceExisting && existing is ExternalizableScheme) {
val oldInfo = schemeToInfo.remove(existing as E)
if (oldInfo != null && scheme is ExternalizableScheme && !schemeToInfo.containsKey(scheme)) {
val oldInfo = schemeToInfo.remove(existing as ExternalizableScheme)
if (oldInfo != null && scheme is ExternalizableScheme && !schemeToInfo.containsKey(scheme as ExternalizableScheme)) {
@Suppress("UNCHECKED_CAST")
schemeToInfo.put(scheme as E, oldInfo)
}
@@ -762,7 +758,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
}
if (scheme is ExternalizableScheme && filesToDelete.isNotEmpty()) {
val info = schemeToInfo.get(scheme)
val info = schemeToInfo[scheme as ExternalizableScheme]
if (info != null) {
filesToDelete.remove("${info.fileName}")
}
@@ -841,9 +837,9 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
}
if (s is ExternalizableScheme) {
schemeToInfo.remove(s as E)?.scheduleDelete()
schemeToInfo.remove(s as ExternalizableScheme)?.scheduleDelete()
}
schemes.remove(i)
schemes.removeAt(i)
break
}
}
@@ -354,7 +354,7 @@ private fun checkSchemes(baseDir: File, expected: String, ignoreDeleted: Boolean
}
}
for (file in fileToSchemeMap.keySet()) {
for (file in fileToSchemeMap.keys) {
assertThat(File(baseDir, "$file.xml")).isFile()
}
@@ -62,7 +62,7 @@ internal class StorageManagerTest {
TestCase.fail("Exception expected")
}
catch (e: IllegalArgumentException) {
assertThat(e.getMessage()).isEqualTo("Unknown macro: \$UNKNOWN_MACRO$ in storage file spec: \$UNKNOWN_MACRO$/test.xml")
assertThat(e.message).isEqualTo("Unknown macro: \$UNKNOWN_MACRO$ in storage file spec: \$UNKNOWN_MACRO$/test.xml")
}
}
@@ -18,6 +18,5 @@
<orderEntry type="module" module-name="eclipse" scope="TEST" />
<orderEntry type="module" module-name="configuration-store-impl" />
<orderEntry type="module" module-name="util-tests" scope="TEST" />
<orderEntry type="module" module-name="test-framework-java8" />
</component>
</module>
@@ -30,8 +30,8 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
public static final RuntimeException OBSOLETE_ERROR = Promise.createError("Obsolete");
private volatile Consumer<T> done;
private volatile Consumer<Throwable> rejected;
private volatile Consumer<? super T> done;
private volatile Consumer<? super Throwable> rejected;
protected volatile State state = State.PENDING;
// result object or error message
@@ -45,7 +45,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@NotNull
@Override
public Promise<T> done(@NotNull Consumer<T> done) {
public Promise<T> done(@NotNull Consumer<? super T> done) {
if (isObsolete(done)) {
return this;
}
@@ -94,9 +94,9 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@SuppressWarnings("SynchronizeOnThis")
private static final class CompoundConsumer<T> implements Consumer<T> {
private List<Consumer<T>> consumers = new ArrayList<Consumer<T>>();
private List<Consumer<? super T>> consumers = new ArrayList<Consumer<? super T>>();
public CompoundConsumer(@NotNull Consumer<T> c1, @NotNull Consumer<T> c2) {
public CompoundConsumer(@NotNull Consumer<? super T> c1, @NotNull Consumer<? super T> c2) {
synchronized (this) {
consumers.add(c1);
consumers.add(c2);
@@ -105,14 +105,14 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@Override
public void consume(T t) {
List<Consumer<T>> list;
List<Consumer<? super T>> list;
synchronized (this) {
list = consumers;
consumers = null;
}
if (list != null) {
for (Consumer<T> consumer : list) {
for (Consumer<? super T> consumer : list) {
if (!isObsolete(consumer)) {
consumer.consume(t);
}
@@ -120,7 +120,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
}
}
public void add(@NotNull Consumer<T> consumer) {
public void add(@NotNull Consumer<? super T> consumer) {
synchronized (this) {
if (consumers != null) {
consumers.add(consumer);
@@ -131,7 +131,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@Override
@NotNull
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull final Function<T, SUB_RESULT> fulfilled) {
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull final Function<? super T, ? extends SUB_RESULT> fulfilled) {
switch (state) {
case PENDING:
break;
@@ -168,7 +168,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
}
@Override
public void notify(@NotNull final AsyncPromise<T> child) {
public void notify(@NotNull final AsyncPromise<? super T> child) {
LOG.assertTrue(child != this);
switch (state) {
@@ -203,7 +203,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@Override
@NotNull
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull final AsyncFunction<T, SUB_RESULT> fulfilled) {
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull final AsyncFunction<? super T, SUB_RESULT> fulfilled) {
switch (state) {
case PENDING:
break;
@@ -249,7 +249,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
@Override
@NotNull
public Promise<T> processed(@NotNull final AsyncPromise<T> fulfilled) {
public Promise<T> processed(@NotNull final AsyncPromise<? super T> fulfilled) {
switch (state) {
case PENDING:
break;
@@ -287,7 +287,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
}
@NotNull
private static <T> Consumer<T> setHandler(@Nullable Consumer<T> oldConsumer, @NotNull Consumer<T> newConsumer) {
private static <T> Consumer<? super T> setHandler(@Nullable Consumer<? super T> oldConsumer, @NotNull Consumer<? super T> newConsumer) {
if (oldConsumer == null) {
return newConsumer;
}
@@ -308,7 +308,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
this.result = result;
state = State.FULFILLED;
Consumer<T> done = this.done;
Consumer<? super T> done = this.done;
clearHandlers();
if (done != null && !isObsolete(done)) {
done.consume(result);
@@ -331,7 +331,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
result = error;
state = State.REJECTED;
Consumer<Throwable> rejected = this.rejected;
Consumer<? super Throwable> rejected = this.rejected;
clearHandlers();
if (rejected != null) {
if (!isObsolete(rejected)) {
@@ -350,7 +350,7 @@ public class AsyncPromise<T> extends Promise<T> implements Getter<T> {
}
@Override
public Promise<T> processed(@NotNull final Consumer<T> processed) {
public Promise<T> processed(@NotNull final Consumer<? super T> processed) {
done(processed);
rejected(new Consumer<Throwable>() {
@Override
@@ -29,7 +29,7 @@ class DonePromise<T> extends Promise<T> implements Getter<T> {
@NotNull
@Override
public Promise<T> done(@NotNull Consumer<T> done) {
public Promise<T> done(@NotNull Consumer<? super T> done) {
if (!AsyncPromise.isObsolete(done)) {
done.consume(result);
}
@@ -38,13 +38,13 @@ class DonePromise<T> extends Promise<T> implements Getter<T> {
@NotNull
@Override
public Promise<T> processed(@NotNull AsyncPromise<T> fulfilled) {
public Promise<T> processed(@NotNull AsyncPromise<? super T> fulfilled) {
fulfilled.setResult(result);
return this;
}
@Override
public Promise<T> processed(@NotNull Consumer<T> processed) {
public Promise<T> processed(@NotNull Consumer<? super T> processed) {
done(processed);
return this;
}
@@ -57,7 +57,7 @@ class DonePromise<T> extends Promise<T> implements Getter<T> {
@NotNull
@Override
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<T, SUB_RESULT> done) {
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<? super T, ? extends SUB_RESULT> done) {
if (done instanceof Obsolescent && ((Obsolescent)done).isObsolete()) {
return Promise.reject("obsolete");
}
@@ -68,7 +68,7 @@ class DonePromise<T> extends Promise<T> implements Getter<T> {
@NotNull
@Override
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<T, SUB_RESULT> done) {
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<? super T, SUB_RESULT> done) {
return done.fun(result);
}
@@ -84,7 +84,7 @@ class DonePromise<T> extends Promise<T> implements Getter<T> {
}
@Override
public void notify(@NotNull AsyncPromise<T> child) {
public void notify(@NotNull AsyncPromise<? super T> child) {
child.setResult(result);
}
}
@@ -138,21 +138,21 @@ public abstract class Promise<T> {
}
@NotNull
public abstract Promise<T> done(@NotNull Consumer<T> done);
public abstract Promise<T> done(@NotNull Consumer<? super T> done);
@NotNull
public abstract Promise<T> processed(@NotNull AsyncPromise<T> fulfilled);
public abstract Promise<T> processed(@NotNull AsyncPromise<? super T> fulfilled);
@NotNull
public abstract Promise<T> rejected(@NotNull Consumer<Throwable> rejected);
public abstract Promise<T> processed(@NotNull Consumer<T> processed);
public abstract Promise<T> processed(@NotNull Consumer<? super T> processed);
@NotNull
public abstract <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<T, SUB_RESULT> done);
public abstract <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<? super T, ? extends SUB_RESULT> done);
@NotNull
public abstract <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<T, SUB_RESULT> done);
public abstract <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<? super T, SUB_RESULT> done);
@NotNull
public abstract State getState();
@@ -195,5 +195,5 @@ public abstract class Promise<T> {
}
}
public abstract void notify(@NotNull AsyncPromise<T> child);
public abstract void notify(@NotNull AsyncPromise<? super T> child);
}
@@ -28,13 +28,13 @@ class RejectedPromise<T> extends Promise<T> {
@NotNull
@Override
public Promise<T> done(@NotNull Consumer<T> done) {
public Promise<T> done(@NotNull Consumer<? super T> done) {
return this;
}
@NotNull
@Override
public Promise<T> processed(@NotNull AsyncPromise<T> fulfilled) {
public Promise<T> processed(@NotNull AsyncPromise<? super T> fulfilled) {
fulfilled.setError(error);
return this;
}
@@ -49,21 +49,21 @@ class RejectedPromise<T> extends Promise<T> {
}
@Override
public RejectedPromise<T> processed(@NotNull Consumer<T> processed) {
public RejectedPromise<T> processed(@NotNull Consumer<? super T> processed) {
processed.consume(null);
return this;
}
@NotNull
@Override
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<T, SUB_RESULT> done) {
public <SUB_RESULT> Promise<SUB_RESULT> then(@NotNull Function<? super T, ? extends SUB_RESULT> done) {
//noinspection unchecked
return (Promise<SUB_RESULT>)this;
}
@NotNull
@Override
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<T, SUB_RESULT> done) {
public <SUB_RESULT> Promise<SUB_RESULT> thenAsync(@NotNull AsyncFunction<? super T, SUB_RESULT> done) {
//noinspection unchecked
return (Promise<SUB_RESULT>)this;
}
@@ -75,7 +75,7 @@ class RejectedPromise<T> extends Promise<T> {
}
@Override
public void notify(@NotNull AsyncPromise<T> child) {
public void notify(@NotNull AsyncPromise<? super T> child) {
child.setError(error);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -16,7 +16,6 @@
package com.intellij.util;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.util.io.URLUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -71,7 +70,7 @@ public final class UrlImpl implements Url {
@Override
public boolean isInLocalFileSystem() {
return StandardFileSystems.FILE_PROTOCOL.equals(scheme);
return URLUtil.FILE_PROTOCOL.equals(scheme);
}
@Nullable
@@ -16,10 +16,11 @@
package org.jetbrains.debugger
import org.jetbrains.concurrency.Promise
import org.jetbrains.concurrency.then
import org.jetbrains.debugger.values.ValueManager
abstract class EvaluateContextBase<VALUE_MANAGER : ValueManager>(val valueManager: VALUE_MANAGER) : EvaluateContext {
override fun withValueManager(objectGroup: String) = this
override fun refreshOnDone(promise: Promise<*>): Promise<*> = promise.then { valueManager.clearCaches() }
override fun refreshOnDone(promise: Promise<*>): Promise<*> = (promise as Promise<Any?>).then { valueManager.clearCaches() }
}
@@ -69,7 +69,7 @@ abstract class ContextDependentAsyncResultConsumer<T>(private val context: Suspe
}
inline fun <T> Promise<T>.done(context: SuspendContext<*>, crossinline handler: (result: T) -> Unit) = done(object : ContextDependentAsyncResultConsumer<T>(context) {
inline fun <T> Promise<out T>.done(context: SuspendContext<*>, crossinline handler: (result: T) -> Unit) = (this as Promise<T>).done(object : ContextDependentAsyncResultConsumer<T>(context) {
override fun consume(result: T, vm: Vm) = handler(result)
})
@@ -27,7 +27,7 @@ interface SuspendContextManager<CALL_FRAME : CallFrame> {
val contextOrFail: SuspendContext<CALL_FRAME>
fun isContextObsolete(context: SuspendContext<CALL_FRAME>): Boolean
fun isContextObsolete(context: SuspendContext<*>): Boolean
fun setOverlayMessage(message: String?)
@@ -44,7 +44,7 @@ abstract class SuspendContextManagerBase<T : SuspendContextBase<*, *, CALL_FRAME
protected fun dismissContextOnDone(promise: Promise<*>): Promise<*> {
val context = contextOrFail
promise.done { contextDismissed(context) }
(promise as Promise<Any?>).done { contextDismissed(context) }
return promise
}
@@ -72,7 +72,7 @@ abstract class SuspendContextManagerBase<T : SuspendContextBase<*, *, CALL_FRAME
protected abstract fun doSuspend(): Promise<*>
override fun isContextObsolete(context: SuspendContext<CALL_FRAME>) = this.context !== context
override fun isContextObsolete(context: SuspendContext<*>) = this.context !== context
override fun setOverlayMessage(message: String?) {
}
@@ -24,10 +24,7 @@ import com.intellij.util.io.socketConnection.ConnectionStatus
import com.intellij.xdebugger.DefaultDebugProcessHandler
import com.intellij.xdebugger.XDebugProcess
import com.intellij.xdebugger.XDebugSession
import com.intellij.xdebugger.breakpoints.XBreakpoint
import com.intellij.xdebugger.breakpoints.XBreakpointHandler
import com.intellij.xdebugger.breakpoints.XLineBreakpoint
import com.intellij.xdebugger.breakpoints.XLineBreakpointType
import com.intellij.xdebugger.breakpoints.*
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider
import com.intellij.xdebugger.frame.XSuspendContext
import com.intellij.xdebugger.stepping.XSmartStepIntoHandler
@@ -200,7 +197,7 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
}
override final fun startPausing() {
connection.vm.suspendContextManager.suspend().rejected(RejectErrorReporter(session, "Cannot pause"))
connection.vm!!.suspendContextManager.suspend().rejected(RejectErrorReporter(session, "Cannot pause"))
}
override final fun getCurrentStateMessage() = connection.state.message
@@ -218,7 +215,8 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
override fun isLibraryFrameFilterSupported() = true
}
class LineBreakpointHandler(breakpointTypeClass: Class<out XLineBreakpointType<*>>, private val manager: LineBreakpointManager) : XBreakpointHandler<XLineBreakpoint<*>>(breakpointTypeClass) {
class LineBreakpointHandler(breakpointTypeClass: Class<out XLineBreakpointType<*>>, private val manager: LineBreakpointManager)
: XBreakpointHandler<XLineBreakpoint<*>>(breakpointTypeClass as Class<out XBreakpointType<XLineBreakpoint<*>, out XBreakpointProperties<*>>>) {
override fun registerBreakpoint(breakpoint: XLineBreakpoint<*>) {
manager.setBreakpoint(breakpoint)
}
@@ -178,7 +178,7 @@ class VariableView(name: String, private val variable: Variable, private val con
}
if (hasIndexedProperties == hasNamedProperties || additionalProperties != null) {
Promise.all(promises).processed(object : ObsolescentConsumer<Any?>(node) {
(Promise.all(promises) as Promise<Any?>).processed(object : ObsolescentConsumer<Any?>(node) {
override fun consume(aVoid: Any?) = node.addChildren(XValueChildrenList.EMPTY, true)
})
}
@@ -302,7 +302,7 @@ class VariableView(name: String, private val variable: Variable, private val con
}
override fun setValue(expression: String, callback: XValueModifier.XModificationCallback) {
variable.valueModifier!!.setValue(variable, expression, evaluateContext)
(variable.valueModifier!!.setValue(variable, expression, evaluateContext) as Promise<Any?>)
.done {
value = null
callback.valueModified()
@@ -78,12 +78,13 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap<Class<*>, Ty
hasUnresolved = false
// refs can be modified - new items can be added
for (i in 0..refs.size - 1) {
val ref = refs.get(i)
ref.type = typeToTypeHandler.get(ref.typeClass)
val ref: TypeRef<out Any?> = refs.get(i)
val typeClass: Class<out Any?> = ref.typeClass
(ref as TypeRef<Any?>).type = typeToTypeHandler.get(typeClass) as TypeWriter<Any?>?
if (ref.type == null) {
createIfNotExists(ref.typeClass)
createIfNotExists(typeClass)
hasUnresolved = true
ref.type = typeToTypeHandler.get(ref.typeClass) ?: throw IllegalStateException()
(ref as TypeRef<Any?>).type = typeToTypeHandler.get(typeClass) as TypeWriter<Any?>? ?: throw IllegalStateException()
}
}
}
@@ -126,7 +127,7 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap<Class<*>, Ty
for (ref in refs) {
if (ref.typeClass == typeClass) {
assert(ref.type == null)
ref.type = typeWriter
(ref as TypeRef<Any?>).type = typeWriter as TypeWriter<Any?>
break
}
}
@@ -58,6 +58,7 @@ open class ApplicationRule : ExternalResource() {
override public final fun before() {
IdeaTestApplication.getInstance()
TestRunnerUtil.replaceIdeEventQueueSafely()
(PersistentFS.getInstance() as PersistentFSImpl).cleanPersistedContents()
}
}
@@ -0,0 +1,25 @@
/*
* 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.
*/
package com.intellij.testFramework
import java.nio.file.FileSystem
fun FileSystem.file(path: String, data: ByteArray): FileSystem {
getPath(path).write(data)
return this
}
fun FileSystem.file(path: String, data: String) = file(path, data.toByteArray())
@@ -1,3 +1,18 @@
/*
* 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.
*/
package com.intellij.testFramework
import com.intellij.openapi.util.io.FileUtil
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/test-framework-java8">
<sourceFolder url="file://$MODULE_DIR$/test-framework-java8/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test-framework-java8" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="testFramework" />
<orderEntry type="library" name="assertJ" level="project" />
</component>
</module>
@@ -1,10 +0,0 @@
package com.intellij.testFramework
import java.nio.file.FileSystem
fun FileSystem.file(path: String, data: ByteArray): FileSystem {
getPath(path).write(data)
return this
}
fun FileSystem.file(path: String, data: String) = file(path, data.toByteArray())
+2 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
@@ -25,5 +25,6 @@
<orderEntry type="module" module-name="images" exported="" scope="RUNTIME" />
<orderEntry type="module" module-name="RegExpSupport" exported="" scope="RUNTIME" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
</component>
</module>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* 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.
@@ -619,7 +619,7 @@ internal class XmlSerializerTest {
TestCase.assertEquals("bye", bean.STRING_V)
TestCase.assertNotNull(bean.actions)
TestCase.assertEquals(2, bean.actions!!.size())
TestCase.assertEquals(2, bean.actions!!.size)
TestCase.assertEquals(2, bean.actions!![0].getChildren().size)
TestCase.assertEquals(1, bean.actions!![1].getChildren().size)
@@ -676,7 +676,7 @@ internal class XmlSerializerTest {
val bb = doSerializerTest("<bean>\n <option name=\"myMap\">\n <map>\n <entry value=\"letters\">\n <key>\n <set>\n <option value=\"a\" />\n <option value=\"b\" />\n <option value=\"c\" />\n </set>\n </key>\n </entry>\n <entry value=\"numbers\">\n <key>\n <set>\n <option value=\"1\" />\n <option value=\"2\" />\n <option value=\"3\" />\n </set>\n </key>\n </entry>\n </map>\n </option>\n</bean>", bean)
for (collection in bb.myMap.keySet()) {
for (collection in bb.myMap.keys) {
assertThat(collection).isInstanceOf(Set::class.java)
}
}
@@ -109,7 +109,7 @@ class VisiblePackBuilderTest {
}
}
graph.providers.entrySet().iterator().next().getValue().setFilteredCommitsProvider(func)
graph.providers.entries.iterator().next().value.setFilteredCommitsProvider(func)
val visiblePack = graph.build(filters(VcsLogBranchFilterImpl.fromTextPresentation(setOf("-master"), setOf("master")), userFilter(DEFAULT_USER)))
val visibleGraph = visiblePack.getVisibleGraph()
assertEquals(3, visibleGraph.getVisibleCommitCount())
@@ -138,7 +138,7 @@ class VisiblePackBuilderTest {
})
val dataPack = DataPack.build(commits, mapOf(root to refs), providers, hashMap, true)
val detailsCache = data.entrySet().map {
val detailsCache = data.entries.map {
val hash = hashMap.getHash(it.key.getId())
val metadata = if (it.value.user == null)
null
@@ -226,7 +226,7 @@ class VisiblePackBuilderTest {
}
class ConstantVcsLogHashMap(val map: Map<Hash, Int>) : VcsLogHashMap {
val reverseMap = map.entrySet().map { Pair(it.value, it.key) }.toMap()
val reverseMap = map.entries.map { Pair(it.value, it.key) }.toMap()
override fun getCommitIndex(hash: Hash, root: VirtualFile) = map.get(hash)!!
@@ -1,3 +1,18 @@
/*
* 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.
*/
package com.intellij.xdebugger.breakpoints;
import com.intellij.openapi.project.Project;
@@ -8,7 +23,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class XLineBreakpointTypeBase extends XLineBreakpointType<XBreakpointProperties> {
public abstract class XLineBreakpointTypeBase extends XLineBreakpointType<XBreakpointProperties> {
private final XDebuggerEditorsProvider myEditorsProvider;
protected XLineBreakpointTypeBase(@NonNls @NotNull final String id, @Nls @NotNull final String title, @Nullable XDebuggerEditorsProvider editorsProvider) {
@@ -303,10 +303,10 @@
bundle="com.siyeh.InspectionGadgetsBundle" key="non.short.circuit.boolean.expression.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.bugs.NonShortCircuitBooleanInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="NullArgumentToVariableArgMethod" bundle="com.siyeh.InspectionGadgetsBundle"
key="null.argument.to.var.arg.method.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
implementationClass="com.siyeh.ig.bugs.NullArgumentToVariableArgMethodInspection"/>
<localInspection groupPath="Java" language="JAVA" suppressId="ConfusingArgumentToVarargsMethod" alternativeId="NullArgumentToVariableArgMethod"
shortName="NullArgumentToVariableArgMethod" bundle="com.siyeh.InspectionGadgetsBundle"
key="null.argument.to.var.arg.method.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs"
enabledByDefault="true" level="WARNING" implementationClass="com.siyeh.ig.bugs.NullArgumentToVariableArgMethodInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="NumberEquality" bundle="com.siyeh.InspectionGadgetsBundle" key="number.comparison.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
implementationClass="com.siyeh.ig.bugs.NumberEqualityInspection"/>
@@ -319,7 +319,8 @@
<localInspection groupPath="Java" language="JAVA" shortName="ObjectToString" bundle="com.siyeh.InspectionGadgetsBundle" key="default.tostring.call.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.probable.bugs" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.bugs.ObjectToStringInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="PrimitiveArrayArgumentToVariableArgMethod" bundle="com.siyeh.InspectionGadgetsBundle"
<localInspection groupPath="Java" language="JAVA" suppressId="PrimitiveArrayArgumentToVarargsMethod" alternativeId="PrimitiveArrayArgumentToVariableArgMethod"
shortName="PrimitiveArrayArgumentToVariableArgMethod" bundle="com.siyeh.InspectionGadgetsBundle"
key="primitive.array.argument.to.var.arg.method.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.probable.bugs" enabledByDefault="true" level="WARNING"
implementationClass="com.siyeh.ig.bugs.PrimitiveArrayArgumentToVariableArgMethodInspection"/>
@@ -128,10 +128,10 @@ misspelled.tostring.problem.descriptor=<code>#ref()</code> method should probabl
non.short.circuit.boolean.expression.display.name=Non-short-circuit boolean expression
non.short.circuit.boolean.expression.problem.descriptor=Non-short-circuit boolean expression <code>#ref</code> #loc
non.short.circuit.boolean.expression.replace.quickfix=Replace with short circuit expression
null.argument.to.var.arg.method.display.name=Confusing 'null' argument to var-arg method
null.argument.to.var.arg.method.problem.descriptor=Confusing <code>#ref</code> argument to var-arg method #loc
primitive.array.argument.to.var.arg.method.display.name=Confusing primitive array argument to var-arg method
primitive.array.argument.to.var.arg.method.problem.descriptor=Confusing primitive array argument to var-arg method #loc
null.argument.to.var.arg.method.display.name=Confusing argument to varargs method
null.argument.to.var.arg.method.problem.descriptor=Confusing argument <code>#ref</code>, unclear if a varargs or non-varargs call is desired #loc
primitive.array.argument.to.var.arg.method.display.name=Confusing primitive array argument to varargs method
primitive.array.argument.to.var.arg.method.problem.descriptor=Confusing primitive array argument to varargs method #loc
object.comparison.display.name=Object comparison using '==', instead of 'equals()'
object.comparison.enumerated.ignore.option=Ignore '==' between enumerated types
object.comparison.klass.ignore.option=Ignore '==' on 'java.lang.Class' objects
@@ -1874,8 +1874,8 @@ array.hash.code.display.name='hashCode()' called on array
array.hash.code.problem.descriptor=<code>#ref()</code> called on array should probably be 'Arrays.hashCode()' #loc
arrays.deep.hash.code.quickfix=Replace with 'Arrays.deepHashCode()'
arrays.hash.code.quickfix=Replace with 'Arrays.hashCode()'
method.can.be.variable.arity.method.display.name=Method can be variable arity method
method.can.be.variable.arity.method.problem.descriptor=<code>#ref()</code> can be converted to variable arity method #loc
method.can.be.variable.arity.method.display.name=Method can be varargs method
method.can.be.variable.arity.method.problem.descriptor=<code>#ref()</code> can be converted to varargs method #loc
method.can.be.variable.arity.method.ignore.byte.short.option=Ignore methods with a last parameter of type byte[] or short[]
method.can.be.variable.arity.method.ignore.multiple.arrays.option=Ignore methods with multiple array parameters
convert.to.variable.arity.method.quickfix=Convert to varargs method
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,29 +15,53 @@
*/
package com.siyeh.ig.bugs;
import com.intellij.codeInsight.daemon.impl.quickfix.AddTypeCastFix;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.ExpressionUtils;
import com.siyeh.ig.DelegatingFix;
import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class NullArgumentToVariableArgMethodInspection
extends BaseInspection {
public class NullArgumentToVariableArgMethodInspection extends BaseInspection {
@NotNull
@Override
public String getID() {
return "ConfusingArgumentToVarargsMethod";
}
@Nullable
@Override
public String getAlternativeID() {
return "NullArgumentToVariableArgMethod"; // old suppressions should keep working
}
@Override
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message(
"null.argument.to.var.arg.method.display.name");
return InspectionGadgetsBundle.message("null.argument.to.var.arg.method.display.name");
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message(
"null.argument.to.var.arg.method.problem.descriptor");
return InspectionGadgetsBundle.message("null.argument.to.var.arg.method.problem.descriptor");
}
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
final PsiExpression argument = (PsiExpression)infos[0];
final PsiType type1 = (PsiType)infos[1];
final PsiType type2 = (PsiType)infos[2];
return new InspectionGadgetsFix[] {
new DelegatingFix(new AddTypeCastFix(type1, argument)),
new DelegatingFix(new AddTypeCastFix(type2, argument))
};
}
@Override
@@ -55,21 +79,26 @@ public class NullArgumentToVariableArgMethodInspection
return new NullArgumentToVariableArgVisitor();
}
private static class NullArgumentToVariableArgVisitor
extends BaseInspectionVisitor {
private static class NullArgumentToVariableArgVisitor extends BaseInspectionVisitor {
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression call) {
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
super.visitMethodCallExpression(call);
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] args = argumentList.getExpressions();
if (args.length == 0) {
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length == 0) {
return;
}
final PsiExpression lastArg = args[args.length - 1];
if (!ExpressionUtils.isNullLiteral(lastArg)) {
final PsiExpression lastArgument = arguments[arguments.length - 1];
final PsiType type = lastArgument.getType();
final boolean checkArray;
if (PsiType.NULL.equals(type)) {
checkArray = false;
}
else if (type instanceof PsiArrayType) {
checkArray = true;
}
else {
return;
}
final PsiMethod method = call.resolveMethod();
@@ -77,16 +106,26 @@ public class NullArgumentToVariableArgMethodInspection
return;
}
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() != args.length) {
if (parameterList.getParametersCount() != arguments.length) {
return;
}
final PsiParameter[] parameters = parameterList.getParameters();
final PsiParameter lastParameter =
parameters[parameters.length - 1];
final PsiParameter lastParameter = parameters[parameters.length - 1];
if (!lastParameter.isVarArgs()) {
return;
}
registerError(lastArg);
final PsiType type1 = lastParameter.getType();
if (!(type1 instanceof PsiEllipsisType)) {
return;
}
final PsiEllipsisType ellipsisType = (PsiEllipsisType)type1;
final PsiType arrayType = ellipsisType.toArrayType();
if (checkArray) {
if (arrayType.equals(type) || !arrayType.isAssignableFrom(type)) {
return;
}
}
registerError(lastArgument, lastArgument, ellipsisType.getComponentType(), arrayType);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2014 Dave Griffith, Bas Leijdekkers
* Copyright 2006-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,34 @@
package com.siyeh.ig.bugs;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.daemon.impl.quickfix.AddTypeCastFix;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.DelegatingFix;
import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
public class PrimitiveArrayArgumentToVariableArgMethodInspection extends BaseInspection {
@NotNull
@Override
public String getID() {
return "PrimitiveArrayArgumentToVarargsMethod";
}
@Nullable
@Override
public String getAlternativeID() {
return "PrimitiveArrayArgumentToVariableArgMethod"; // keep old suppression working
}
@Override
@NotNull
public String getDisplayName() {
@@ -50,6 +66,14 @@ public class PrimitiveArrayArgumentToVariableArgMethodInspection extends BaseIns
return PsiUtil.isLanguageLevel5OrHigher(file);
}
@Nullable
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiExpression argument = (PsiExpression)infos[0];
final PsiType type = (PsiType)infos[1];
return new DelegatingFix(new AddTypeCastFix(type, argument));
}
@Override
public BaseInspectionVisitor buildVisitor() {
return new PrimitiveArrayArgumentToVariableArgVisitor();
@@ -84,11 +108,11 @@ public class PrimitiveArrayArgumentToVariableArgMethodInspection extends BaseIns
if (!lastParameter.isVarArgs()) {
return;
}
final PsiType parameterType = lastParameter.getType();
final PsiEllipsisType parameterType = (PsiEllipsisType)lastParameter.getType();
if (isDeepPrimitiveArrayType(parameterType, result.getSubstitutor())) {
return;
}
registerError(lastArgument);
registerError(lastArgument, lastArgument, parameterType.getComponentType());
}
}
@@ -39,7 +39,7 @@ public class EmptyClassInspectionBase extends BaseInspection {
@SuppressWarnings("PublicField")
public boolean ignoreThrowables = true;
@SuppressWarnings("PublicField")
public boolean commentsAreContent = false;
public boolean commentsAreContent = true;
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,12 +20,12 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.FileTypeUtils;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.ClassUtils;
import com.siyeh.ig.psiutils.ExpressionUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -98,8 +98,7 @@ public class PrivateMemberAccessBetweenOuterAndInnerClassInspection
}
@Override
public void doFix(Project project, ProblemDescriptor descriptor)
throws IncorrectOperationException {
public void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
if (constructor) {
makeConstructorPackageLocal(project, element);
@@ -127,8 +126,7 @@ public class PrivateMemberAccessBetweenOuterAndInnerClassInspection
modifiers.setModifierProperty(PsiModifier.PRIVATE, false);
}
private static void makeConstructorPackageLocal(Project project,
PsiElement element) {
private static void makeConstructorPackageLocal(Project project, PsiElement element) {
final PsiNewExpression newExpression =
PsiTreeUtil.getParentOfType(element,
PsiNewExpression.class);
@@ -175,8 +173,7 @@ public class PrivateMemberAccessBetweenOuterAndInnerClassInspection
return new PrivateMemberAccessFromInnerClassVisitor();
}
private static class PrivateMemberAccessFromInnerClassVisitor
extends BaseInspectionVisitor {
private static class PrivateMemberAccessFromInnerClassVisitor extends BaseInspectionVisitor {
@Override
public void visitNewExpression(PsiNewExpression expression) {
@@ -219,11 +216,9 @@ public class PrivateMemberAccessBetweenOuterAndInnerClassInspection
}
@Override
public void visitReferenceExpression(
@NotNull PsiReferenceExpression expression) {
public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
super.visitReferenceExpression(expression);
final PsiElement referenceNameElement =
expression.getReferenceNameElement();
final PsiElement referenceNameElement = expression.getReferenceNameElement();
if (referenceNameElement == null) {
return;
}
@@ -235,6 +230,10 @@ public class PrivateMemberAccessBetweenOuterAndInnerClassInspection
if (!member.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
final Object value = ExpressionUtils.computeConstantExpression(expression);
if (value != null) {
return; // no synthetic accessor created, compile time constant will be inlined by javac
}
final PsiElement containingClass = getContainingContextClass(expression);
if (containingClass == null) {
return;
@@ -21,6 +21,7 @@ import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.ClassUtils;
import com.siyeh.ig.psiutils.ExpressionUtils;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.TypeUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -40,8 +41,7 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
@NotNull
@Override
protected String buildErrorString(Object... infos) {
final String message = (String)infos[0];
return message;
return (String)infos[0];
}
@Override
@@ -70,7 +70,7 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
return;
}
final String fieldName = (String)value;
final PsiExpression firstArgument = arguments[0];
final PsiExpression firstArgument = ParenthesesUtils.stripParentheses(arguments[0]);
if (!(firstArgument instanceof PsiClassObjectAccessExpression)) {
return;
}
@@ -1,7 +1,5 @@
<html>
<body>
<html>
<body>
Reports issues on fields of type <b>java.util.concurrent.atomic.AtomicLongFieldUpdater</b>,
<b>java.util.concurrent.atomic.AtomicIntegerFieldUpdater</b> or <b>java.util.concurrent.atomic.AtomicReferenceFieldUpdater</b>.
The issues reported are identical to the runtime problems that can happen with atomic field updaters:
@@ -11,6 +9,4 @@ specified field not found, specified field not accessible, specified field of th
<p>
<small>New in 16</small>
</body>
</html>
</body>
</html>
@@ -1,19 +1,19 @@
<html>
<body>
Reports methods with which can be converted to be a variable
arity/varargs method, available in Java 5 and newer.
arity method, available in Java 5 and newer.
<p>
This inspection only reports if the project or module is configured to use a
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
Use the first checkbox below to not offer to convert <b>byte[]</b> or <b>short[]</b> parameters to vararg.
Use the first checkbox below to not offer to convert <b>byte[]</b> or <b>short[]</b> parameters to varargs.
<p>
Use the second checkbox below to ignore methods overriding or implementing a method from a superclass.
<p>
Use the third checkbox below to only report when the method is <b>public</b>
<p>
Use the fourth checkbox below ot ignore method with more than one array parameter.
Use the fourth checkbox below to ignore methods with two or more array parameters.
<p>
</body>
</html>
@@ -1,9 +1,9 @@
<html>
<body>
Reports any calls to a variable-argument method which has a <b>null</b>
in the variable-argument position (e.g <b>System.out.printf("%s", null)</b> ).
Such a <b>null</b> argument may be confusing, as it is not
wrapped as a single-element array, as may be expected.
Reports any calls to a variable arity method where the call has a single argument
in the variable arity parameter position, which is either a <b>null</b> or an array of a subtype of the variable arity parameter.
Such an argument may be confusing as it is unclear if a varargs or non-varargs call is desired.
For example <code>System.out.printf("%s", null)</code>.
<!-- tooltip end -->
<p>
@@ -1,7 +1,7 @@
<html>
<body>
Reports any calls to a variable-argument method which has a primitive array in
in the variable-argument position (e.g <b>System.out.printf("%s", new int[]{1, 2, 3})</b> ).
Reports any calls to a variable arity method where the call has a primitive array in
in the variable arity parameter position (e.g <b>System.out.printf("%s", new int[]{1, 2, 3})</b> ).
Such a primitive-array argument may be confusing, as it will wrapped as a single-element array, rather than each individual
element being boxed, as might be expected.
<!-- tooltip end -->
@@ -3,6 +3,9 @@
This inspection is intended for J2ME and other highly resource constrained environments.
Applying the results of this inspection without consideration might have negative effects on code clarity and design.
<p>
Reports references to non-constant <b>private</b> members of an outer class from inside an inner class or
to members of an inner class from a containing class.
<p>
An inner class and its containing class are compiled to separate
class files. The virtual machine normally prohibits access from a class to private fields and methods of
another class. To enable access from an inner class to private members of a
@@ -1,6 +1,7 @@
<html>
<body>
Reports methods overriding a variable arity (varargs) method with an array parameter. While this is legal Java, it can be confusing.
Reports methods overriding a variable arity method and replacing the variable arity parameter with an array parameter.
While this is legal Java, it can be confusing.
<!-- tooltip end -->
<p>
</body>
@@ -1,9 +1,10 @@
package com.siyeh.igtest.bugs.null_argument_to_variable_arg_method;
public class NullArgumentToVariableArgMethod {
public void foo()
public void foo(String[] ss)
{
String.format("%s", <warning descr="Confusing 'null' argument to var-arg method">null</warning>);
String.format("%s", <warning descr="Confusing argument 'null', unclear if a varargs or non-varargs call is desired">null</warning>);
String.format("%d", 1);
String.format("%s", <warning descr="Confusing argument 'ss', unclear if a varargs or non-varargs call is desired">ss</warning>);
}
}
@@ -6,7 +6,7 @@ public class PrimitiveArrayArgumentToVariableArgMethod
{
public static void main(String[] arg) throws Throwable
{
methodVarArgObject(<warning descr="Confusing primitive array argument to var-arg method">new byte[3]</warning>);
methodVarArgObject(<warning descr="Confusing primitive array argument to varargs method">new byte[3]</warning>);
methodVarArgByteArray(new byte[3]);
MethodHandle meh = null;
meh.invokeExact(new int[] { });
@@ -31,7 +31,7 @@ public class PrimitiveArrayArgumentToVariableArgMethod
}
void m() {
String.format("%s", <warning descr="Confusing primitive array argument to var-arg method">new int[]{1, 2, 3}</warning>);
String.format("%s", <warning descr="Confusing primitive array argument to varargs method">new int[]{1, 2, 3}</warning>);
}
static void bar1(java.lang.Object... objects) {
@@ -48,7 +48,7 @@ public class PrimitiveArrayArgumentToVariableArgMethod
public static void invoke() {
int[] ints = {1, 2, 3};
bar1(<warning descr="Confusing primitive array argument to var-arg method">ints</warning>); // warn here
bar1(<warning descr="Confusing primitive array argument to varargs method">ints</warning>); // warn here
bar2(ints); // no warning needed here
}
}
@@ -2,12 +2,14 @@ package com.siyeh.igtest.j2me.private_member_access_between_outer_and_inner_clas
public class PrivateMemberAccessBetweenOuterAndInnerClass {
private String caption = "Button";
private final int N = 100;
private void initialize() {
System.out.println(caption);
Object btn = new Object() {
public void foo() {
System.out.println(<warning descr="Access to private member of class 'PrivateMemberAccessBetweenOuterAndInnerClass'">caption</warning>);
System.out.println(N);
}
};
}
@@ -7,7 +7,7 @@ public class MethodCanBeVariableArity {
public void method(String... s) {}
public void <warning descr="'convertMe()' can be converted to variable arity method">convertMe</warning>(String[] ss) {}
public void <warning descr="'convertMe()' can be converted to varargs method">convertMe</warning>(String[] ss) {}
public void convertMeNot(byte[] bs) {}
}
@@ -31,7 +31,7 @@ class Annotated {
void m(String[] ss) {}
}
interface X {
void <warning descr="'m()' can be converted to variable arity method">m</warning>(String[] ss);
void <warning descr="'m()' can be converted to varargs method">m</warning>(String[] ss);
}
class Yes {
void m(int[] is, int[] js) {}
@@ -38,7 +38,7 @@ public class AtomicFieldUpdaterIssuesInspectionTest extends LightInspectionTestC
"class A {" +
" private static volatile int value = 0;" +
" private static final AtomicIntegerFieldUpdater updater = " +
" AtomicIntegerFieldUpdater.newUpdater(A.class, /*Field 'value' has 'static' modifier*/\"value\"/**/);" +
" AtomicIntegerFieldUpdater.newUpdater((A.class), /*Field 'value' has 'static' modifier*/(\"value\")/**/);" +
"}");
}
@@ -100,6 +100,20 @@ public class AtomicFieldUpdaterIssuesInspectionTest extends LightInspectionTestC
"}");
}
/**
* private fields are not accessible at runtime even from inner classes.
*/
public void testNotAccessible2() {
doTest("import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;" +
"class Z {" +
" private volatile int value = 0;" +
" static class A {\n" +
" private static final AtomicIntegerFieldUpdater updater = \n" +
" AtomicIntegerFieldUpdater.newUpdater(Z.class, /*'private' field 'value' is not accessible from here*/\"value\"/**/);\n" +
" }" +
"}");
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
@@ -53,7 +53,7 @@ import java.util.jar.Manifest
class IdeaDecompiler : ClassFileDecompilers.Light() {
companion object {
val BANNER = "//\n// Source code recreated from a .class file by IntelliJ IDEA\n// (powered by Fernflower decompiler)\n//\n\n"
const val BANNER = "//\n// Source code recreated from a .class file by IntelliJ IDEA\n// (powered by Fernflower decompiler)\n//\n\n"
private val LEGAL_NOTICE_KEY = "decompiler.legal.notice.accepted"
@@ -34,6 +34,5 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="test-framework-java8" />
</component>
</module>
@@ -44,7 +44,7 @@ fun syncAndNotify(syncType: SyncType, project: Project?, notifyIfUpToDate: Boole
}
catch (e: Exception) {
LOG.warn(e)
NOTIFICATION_GROUP.createNotification(icsMessage("sync.rejected.title"), e.getMessage() ?: "Internal error", NotificationType.ERROR, null).notify(project)
NOTIFICATION_GROUP.createNotification(icsMessage("sync.rejected.title"), e.message ?: "Internal error", NotificationType.ERROR, null).notify(project)
}
}
+2 -2
View File
@@ -48,7 +48,7 @@ fun wrapIfNeedAndReThrow(e: TransportException) {
throw org.jetbrains.settingsRepository.NoRemoteRepositoryException(e)
}
val message = e.getMessage()!!
val message = e.message!!
if (e.status == TransportException.Status.NOT_AUTHORIZED || e.status == TransportException.Status.NOT_PERMITTED ||
message.contains(JGitText.get().notAuthorized) || message.contains("Auth cancel") || message.contains("Auth fail") || message.contains(": reject HostKey:") /* JSch */) {
throw AuthenticationException(e)
@@ -73,7 +73,7 @@ fun Repository.fetch(remoteConfig: RemoteConfig, credentialsProvider: Credential
}
}
catch (e: TransportException) {
val message = e.getMessage()!!
val message = e.message!!
if (message.startsWith("Remote does not have ")) {
LOG.info(message)
// "Remote does not have refs/heads/master available for fetch." - remote repository is not initialized
+1 -1
View File
@@ -310,7 +310,7 @@ private fun resolveConflicts(mergeProvider: JGitMergeProvider<out Any>, unresolv
break
}
else {
unresolvedFiles.removeAll(mergedFiles)
unresolvedFiles.removeAll { it.path in mergedFiles }
}
}
@@ -96,7 +96,7 @@ public interface OSXKeychainLibrary : com.sun.jna.Library {
}
else {
val buf = CharArray(LIBRARY.CFStringGetLength(translated).toInt())
for (i in 0..buf.size() - 1) {
for (i in 0..buf.size - 1) {
buf[i] = LIBRARY.CFStringGetCharacterAtIndex(translated, i.toLong())
}
LIBRARY.CFRelease(translated)
@@ -97,10 +97,10 @@ fun createMergeActions(project: Project?, urlTextField: TextFieldWithBrowseButto
LOG.warn(e)
if (!upstreamSet || e is NoRemoteRepositoryException) {
Messages.showErrorDialog(dialogParent, icsMessage("set.upstream.failed.message", e.getMessage()), icsMessage("set.upstream.failed.title"))
Messages.showErrorDialog(dialogParent, icsMessage("set.upstream.failed.message", e.message), icsMessage("set.upstream.failed.title"))
}
else {
Messages.showErrorDialog(dialogParent, StringUtil.notNullize(e.getMessage(), "Internal error"), icsMessage(if (e is AuthenticationException) "sync.not.authorized.title" else "sync.rejected.title"))
Messages.showErrorDialog(dialogParent, StringUtil.notNullize(e.message, "Internal error"), icsMessage(if (e is AuthenticationException) "sync.not.authorized.title" else "sync.rejected.title"))
}
return
}
@@ -1,5 +1,6 @@
add.import=Add Import
class.to.import.chooser.title=Class to Import
method.to.import.chooser.title=Method to Import
access.static.via.class.reference.family=Access static via class reference
access.static.via.class.reference.text=Access static ''{1}.{0}'' via class ''{2}'' reference
add.default.constructor.family=Add Default Constructor