mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+5
@@ -56,4 +56,9 @@ public class QualifyStaticConstantFix extends StaticImportConstantFix {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showMembersFromDefaultPackage() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -50,6 +50,11 @@ public class QualifyStaticMethodCallFix extends StaticImportMethodFix {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showMembersFromDefaultPackage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void qualifyStatically(PsiMember toImport,
|
||||
Project project,
|
||||
PsiReferenceExpression qualifiedExpression) {
|
||||
|
||||
+9
-2
@@ -31,6 +31,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class StaticImportConstantFix extends StaticImportMemberFix<PsiField> {
|
||||
public static final String BASE_TEXT = "Import static constant";
|
||||
|
||||
protected final SmartPsiElementPointer<PsiJavaCodeReferenceElement> myRef;
|
||||
|
||||
public StaticImportConstantFix(@NotNull PsiJavaCodeReferenceElement referenceElement) {
|
||||
@@ -40,7 +42,7 @@ public class StaticImportConstantFix extends StaticImportMemberFix<PsiField> {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getBaseText() {
|
||||
return "Import static constant";
|
||||
return BASE_TEXT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -64,7 +66,7 @@ public class StaticImportConstantFix extends StaticImportMemberFix<PsiField> {
|
||||
element.getParent() instanceof PsiAnnotation) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final StaticMembersProcessor<PsiField> processor = new StaticMembersProcessor<PsiField>(element) {
|
||||
final StaticMembersProcessor<PsiField> processor = new StaticMembersProcessor<PsiField>(element, showMembersFromDefaultPackage()) {
|
||||
@Override
|
||||
protected boolean isApplicable(PsiField field, PsiElement place) {
|
||||
final PsiType expectedType = getExpectedType();
|
||||
@@ -105,4 +107,9 @@ public class StaticImportConstantFix extends StaticImportMemberFix<PsiField> {
|
||||
final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)getElement();
|
||||
return referenceElement != null ? referenceElement.advancedResolve(true).getElement() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showMembersFromDefaultPackage() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -77,6 +77,8 @@ public abstract class StaticImportMemberFix<T extends PsiMember> implements Inte
|
||||
|
||||
@NotNull protected abstract List<T> getMembersToImport(boolean applicableOnly);
|
||||
|
||||
protected abstract boolean showMembersFromDefaultPackage();
|
||||
|
||||
public static boolean isExcluded(PsiMember method) {
|
||||
String name = PsiUtil.getMemberQualifiedName(method);
|
||||
return name != null && JavaProjectCodeInsightSettings.getSettings(method.getProject()).isExcluded(name);
|
||||
|
||||
+8
-3
@@ -61,11 +61,16 @@ public class StaticImportMethodFix extends StaticImportMemberFix<PsiMethod> {
|
||||
PsiReferenceExpression reference = element == null ? null : element.getMethodExpression();
|
||||
String name = reference == null ? null : reference.getReferenceName();
|
||||
if (name == null) return Collections.emptyList();
|
||||
final StaticMembersProcessor<PsiMethod> processor = new MyStaticMethodProcessor(element);
|
||||
final StaticMembersProcessor<PsiMethod> processor = new MyStaticMethodProcessor(element, showMembersFromDefaultPackage());
|
||||
cache.processMethodsWithName(name, element.getResolveScope(), processor);
|
||||
return processor.getMembersToImport(applicableOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showMembersFromDefaultPackage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected StaticImportMethodQuestionAction<PsiMethod> createQuestionAction(List<PsiMethod> methodsToImport, @NotNull Project project, Editor editor) {
|
||||
return new StaticImportMethodQuestionAction<>(project, editor, methodsToImport, myMethodCall);
|
||||
@@ -93,8 +98,8 @@ public class StaticImportMethodFix extends StaticImportMemberFix<PsiMethod> {
|
||||
|
||||
private static class MyStaticMethodProcessor extends StaticMembersProcessor<PsiMethod> {
|
||||
|
||||
private MyStaticMethodProcessor(PsiMethodCallExpression place) {
|
||||
super(place);
|
||||
private MyStaticMethodProcessor(@NotNull PsiMethodCallExpression place, boolean showMembersFromDefaultPackage) {
|
||||
super(place, showMembersFromDefaultPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-5
@@ -36,10 +36,12 @@ abstract class StaticMembersProcessor<T extends PsiMember & PsiDocCommentOwner>
|
||||
private final Map<PsiClass, Boolean> myPossibleClasses = new HashMap<>();
|
||||
|
||||
private final PsiElement myPlace;
|
||||
private final boolean myShowMembersFromDefaultPackage;
|
||||
private PsiType myExpectedType;
|
||||
|
||||
protected StaticMembersProcessor(PsiElement place) {
|
||||
protected StaticMembersProcessor(@NotNull PsiElement place, boolean showMembersFromDefaultPackage) {
|
||||
myPlace = place;
|
||||
myShowMembersFromDefaultPackage = showMembersFromDefaultPackage && PsiUtil.isFromDefaultPackage(place);
|
||||
myExpectedType = PsiType.NULL;
|
||||
}
|
||||
|
||||
@@ -94,10 +96,7 @@ abstract class StaticMembersProcessor<T extends PsiMember & PsiDocCommentOwner>
|
||||
}
|
||||
}
|
||||
|
||||
PsiFile file = member.getContainingFile();
|
||||
if (file instanceof PsiJavaFile
|
||||
//do not show methods from default package
|
||||
&& !((PsiJavaFile)file).getPackageName().isEmpty()) {
|
||||
if (myShowMembersFromDefaultPackage || !PsiUtil.isFromDefaultPackage(member)) {
|
||||
mySuggestions.putValue(containingClass, member);
|
||||
}
|
||||
return processCondition();
|
||||
|
||||
+2
-2
@@ -19,9 +19,9 @@ import com.intellij.psi.PsiClassOwner;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassAwareRenameFileAction extends RenameFileAction {
|
||||
public class ClassAwareRenameFileProvider implements RenameFileActionProvider {
|
||||
@Override
|
||||
protected boolean enabledInProjectView(@NotNull PsiFile file) {
|
||||
public boolean enabledInProjectView(@NotNull PsiFile file) {
|
||||
return file instanceof PsiClassOwner;
|
||||
}
|
||||
}
|
||||
@@ -1209,7 +1209,11 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
}
|
||||
|
||||
public static boolean isFromDefaultPackage(PsiClass aClass) {
|
||||
final PsiFile containingFile = aClass.getContainingFile();
|
||||
return isFromDefaultPackage((PsiElement)aClass);
|
||||
}
|
||||
|
||||
public static boolean isFromDefaultPackage(PsiElement element) {
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
return containingFile instanceof PsiClassOwner && StringUtil.isEmpty(((PsiClassOwner)containingFile).getPackageName());
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Qualify static call..." "true"
|
||||
class Test {
|
||||
void m() {
|
||||
staticMet<caret>hod();
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Qualify static call..." "true"
|
||||
package org.intellij;
|
||||
|
||||
class Test {
|
||||
void m() {
|
||||
staticMet<caret>hod();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Import static method 'java.lang.Integer.parseInt'" "true"
|
||||
class Test {
|
||||
void m() {
|
||||
staticMet<caret>hod();
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Import static method 'java.lang.Integer.parseInt'" "true"
|
||||
package org.intellij;
|
||||
|
||||
class Test {
|
||||
void m() {
|
||||
staticMet<caret>hod();
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
public class QualifyCallByClassFromDefaultPackageTest extends LightCodeInsightFixtureTestCase {
|
||||
private static final String QUALIFY_METHOD_FIX_TEXT = "Qualify static call 'Util.staticMethod'";
|
||||
private static final String QUALIFY_CONST_FIX_TEXT = "Qualify static constant access 'Util.STATIC_FIELD'";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.addClass("public class Util {" +
|
||||
" public static void staticMethod() {}" +
|
||||
" public static final String STATIC_FIELD = \"XXX\";" +
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testMethodCallFromDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "class Main {" +
|
||||
" void m() { staticMeth<caret>od(); }" +
|
||||
"}");
|
||||
assertOneElement(myFixture.filterAvailableIntentions(QUALIFY_METHOD_FIX_TEXT));
|
||||
}
|
||||
|
||||
public void testMethodCallFromNonDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "package org.some; " +
|
||||
"class Main {" +
|
||||
" void m() { staticMeth<caret>od(); }" +
|
||||
"}");
|
||||
assertEmpty(myFixture.filterAvailableIntentions(QUALIFY_METHOD_FIX_TEXT));
|
||||
}
|
||||
|
||||
public void testFieldCallFromDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "class Main {" +
|
||||
" void m() { STATIC_FIE<caret>LD; }" +
|
||||
"}");
|
||||
assertOneElement(myFixture.filterAvailableIntentions(QUALIFY_CONST_FIX_TEXT));
|
||||
}
|
||||
|
||||
public void testFieldCallFromNonDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "package org.some; " +
|
||||
"class Main {" +
|
||||
" void m() { STATIC_FIE<caret>LD; }" +
|
||||
"}");
|
||||
assertEmpty(myFixture.filterAvailableIntentions(QUALIFY_CONST_FIX_TEXT));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.StaticImportConstantFix;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
public class StaticImportFromDefaultPackageTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.addClass("public class Util {" +
|
||||
" public static void staticMethod() {}" +
|
||||
" public static final String STATIC_FIELD = \"XXX\";" +
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testMethodCallFromDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "class Main { void m () {" +
|
||||
" staticMeht<caret>od();" +
|
||||
"}}");
|
||||
assertFixForMethodIsNotAvailable();
|
||||
}
|
||||
|
||||
public void testMethodCallFromNonDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "package org;" +
|
||||
"class Main { void m () {" +
|
||||
" staticMeht<caret>od();" +
|
||||
"}}");
|
||||
assertFixForMethodIsNotAvailable();
|
||||
}
|
||||
|
||||
public void testFieldCallFromDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "class Main { void m () {" +
|
||||
" STATIC_<caret>FIELD();" +
|
||||
"}}");
|
||||
assertFixForFieldIsNotAvailable();
|
||||
}
|
||||
|
||||
public void testFieldCallFromNonDefaultPackage() {
|
||||
myFixture.configureByText("Main.java", "package org;" +
|
||||
"class Main { void m () {" +
|
||||
" STATIC_<caret>FIELD();" +
|
||||
"}}");
|
||||
assertFixForFieldIsNotAvailable();
|
||||
}
|
||||
|
||||
private void assertFixForMethodIsNotAvailable() {
|
||||
assertEmpty(myFixture.filterAvailableIntentions(QuickFixBundle.message("static.import.method.text")));
|
||||
}
|
||||
|
||||
private void assertFixForFieldIsNotAvailable() {
|
||||
assertEmpty(myFixture.filterAvailableIntentions(StaticImportConstantFix.BASE_TEXT));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.jetbrains.io.fastCgi;
|
||||
|
||||
public final class FastCgiConstants {
|
||||
public static final int HEADER_LENGTH = 8;
|
||||
}
|
||||
@@ -8,13 +8,15 @@ import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.util.CharsetUtil
|
||||
import org.jetbrains.io.Decoder
|
||||
|
||||
internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>, private val responseHandler: FastCgiService) : Decoder(), Decoder.FullMessageConsumer<Void> {
|
||||
private enum class State {
|
||||
HEADER,
|
||||
CONTENT
|
||||
}
|
||||
internal const val HEADER_LENGTH = 8
|
||||
|
||||
private var state = State.HEADER
|
||||
private enum class DecodeRecordState {
|
||||
HEADER,
|
||||
CONTENT
|
||||
}
|
||||
|
||||
internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>, private val responseHandler: FastCgiService) : Decoder(), Decoder.FullMessageConsumer<Void> {
|
||||
private var state = DecodeRecordState.HEADER
|
||||
|
||||
private enum class ProtocolStatus {
|
||||
REQUEST_COMPLETE,
|
||||
@@ -29,8 +31,8 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
|
||||
val STDERR = 7
|
||||
}
|
||||
|
||||
private var type: Int = 0
|
||||
private var id: Int = 0
|
||||
private var type = 0
|
||||
private var id = 0
|
||||
private var contentLength: Int = 0
|
||||
private var paddingLength: Int = 0
|
||||
|
||||
@@ -39,7 +41,7 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
|
||||
override fun messageReceived(context: ChannelHandlerContext, input: ByteBuf) {
|
||||
while (true) {
|
||||
when (state) {
|
||||
FastCgiDecoder.State.HEADER -> {
|
||||
DecodeRecordState.HEADER -> {
|
||||
if (paddingLength > 0) {
|
||||
if (input.readableBytes() > paddingLength) {
|
||||
input.skipBytes(paddingLength)
|
||||
@@ -52,22 +54,21 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
|
||||
}
|
||||
}
|
||||
|
||||
val buffer = getBufferIfSufficient(input, FastCgiConstants.HEADER_LENGTH, context) ?: return
|
||||
|
||||
decodeHeader(buffer)
|
||||
state = State.CONTENT
|
||||
|
||||
if (contentLength > 0) {
|
||||
readContent(input, context, contentLength, this)
|
||||
}
|
||||
state = State.HEADER
|
||||
val buffer = getBufferIfSufficient(input, HEADER_LENGTH, context) ?: return
|
||||
buffer.skipBytes(1)
|
||||
type = buffer.readUnsignedByte().toInt()
|
||||
id = buffer.readUnsignedShort()
|
||||
contentLength = buffer.readUnsignedShort()
|
||||
paddingLength = buffer.readUnsignedByte().toInt()
|
||||
buffer.skipBytes(1)
|
||||
state = DecodeRecordState.CONTENT
|
||||
}
|
||||
|
||||
FastCgiDecoder.State.CONTENT -> {
|
||||
DecodeRecordState.CONTENT -> {
|
||||
if (contentLength > 0) {
|
||||
readContent(input, context, contentLength, this)
|
||||
}
|
||||
state = State.HEADER
|
||||
state = DecodeRecordState.HEADER
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,52 +94,30 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
|
||||
}
|
||||
}
|
||||
|
||||
private fun decodeHeader(buffer: ByteBuf) {
|
||||
buffer.skipBytes(1)
|
||||
type = buffer.readUnsignedByte().toInt()
|
||||
id = buffer.readUnsignedShort()
|
||||
contentLength = buffer.readUnsignedShort()
|
||||
paddingLength = buffer.readUnsignedByte().toInt()
|
||||
buffer.skipBytes(1)
|
||||
}
|
||||
|
||||
override fun contentReceived(buffer: ByteBuf, context: ChannelHandlerContext, isCumulateBuffer: Boolean): Void? {
|
||||
when (type) {
|
||||
RecordType.END_REQUEST -> {
|
||||
val appStatus = buffer.readInt()
|
||||
val protocolStatus = buffer.readUnsignedByte().toInt()
|
||||
if (appStatus != 0 || protocolStatus != ProtocolStatus.REQUEST_COMPLETE.ordinal) {
|
||||
LOG.warn("Protocol status $protocolStatus")
|
||||
dataBuffers.remove(id)
|
||||
responseHandler.responseReceived(id, null)
|
||||
}
|
||||
else if (protocolStatus == ProtocolStatus.REQUEST_COMPLETE.ordinal) {
|
||||
responseHandler.responseReceived(id, dataBuffers.remove(id))
|
||||
}
|
||||
}
|
||||
|
||||
RecordType.STDOUT -> {
|
||||
var data = dataBuffers.get(id)
|
||||
val sliced = if (isCumulateBuffer) buffer else buffer.slice(buffer.readerIndex(), contentLength)
|
||||
if (data == null) {
|
||||
dataBuffers.put(id, sliced)
|
||||
}
|
||||
else if (data is CompositeByteBuf) {
|
||||
data.addComponent(sliced)
|
||||
data.writerIndex(data.writerIndex() + sliced.readableBytes())
|
||||
}
|
||||
else {
|
||||
if (sliced is CompositeByteBuf) {
|
||||
data = sliced.addComponent(0, data)
|
||||
data.writerIndex(data.writerIndex() + data.readableBytes())
|
||||
when (data) {
|
||||
null -> dataBuffers.put(id, sliced)
|
||||
is CompositeByteBuf -> {
|
||||
data.addComponent(sliced)
|
||||
data.writerIndex(data.writerIndex() + sliced.readableBytes())
|
||||
}
|
||||
else {
|
||||
// must be computed here before we set data to new composite buffer
|
||||
val newLength = data.readableBytes() + sliced.readableBytes()
|
||||
data = context.alloc().compositeBuffer(Decoder.DEFAULT_MAX_COMPOSITE_BUFFER_COMPONENTS).addComponents(data, sliced)
|
||||
data.writerIndex(data.writerIndex() + newLength)
|
||||
else -> {
|
||||
if (sliced is CompositeByteBuf) {
|
||||
data = sliced.addComponent(0, data)
|
||||
data.writerIndex(data.writerIndex() + data.readableBytes())
|
||||
}
|
||||
else {
|
||||
// must be computed here before we set data to new composite buffer
|
||||
val newLength = data.readableBytes() + sliced.readableBytes()
|
||||
data = context.alloc().compositeBuffer(Decoder.DEFAULT_MAX_COMPOSITE_BUFFER_COMPONENTS).addComponents(data, sliced)
|
||||
data.writerIndex(data.writerIndex() + newLength)
|
||||
}
|
||||
dataBuffers.put(id, data)
|
||||
}
|
||||
dataBuffers.put(id, data)
|
||||
}
|
||||
sliced.retain()
|
||||
}
|
||||
@@ -152,7 +131,25 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer<String>,
|
||||
}
|
||||
}
|
||||
|
||||
else -> LOG.error("Unknown type $type")
|
||||
RecordType.END_REQUEST -> {
|
||||
val appStatus = buffer.readInt()
|
||||
val protocolStatus = buffer.readUnsignedByte().toInt()
|
||||
if (appStatus != 0 || protocolStatus != ProtocolStatus.REQUEST_COMPLETE.ordinal) {
|
||||
LOG.warn("Protocol status $protocolStatus")
|
||||
dataBuffers.remove(id)
|
||||
responseHandler.responseReceived(id, null)
|
||||
}
|
||||
else if (protocolStatus == ProtocolStatus.REQUEST_COMPLETE.ordinal) {
|
||||
responseHandler.responseReceived(id, dataBuffers.remove(id))
|
||||
}
|
||||
else {
|
||||
LOG.warn("protocolStatus $protocolStatus")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
LOG.error("Unknown type $type")
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class FastCgiRequest(val requestId: Int, allocator: ByteBufAllocator) {
|
||||
private var buffer: ByteBuf? = allocator.ioBuffer(4096)
|
||||
|
||||
init {
|
||||
writeHeader(buffer!!, BEGIN_REQUEST, FastCgiConstants.HEADER_LENGTH)
|
||||
writeHeader(buffer!!, BEGIN_REQUEST, HEADER_LENGTH)
|
||||
buffer!!.writeShort(RESPONDER)
|
||||
buffer!!.writeByte(FCGI_KEEP_CONNECTION)
|
||||
// reserved[5]
|
||||
@@ -128,7 +128,7 @@ class FastCgiRequest(val requestId: Int, allocator: ByteBufAllocator) {
|
||||
// channel.write releases
|
||||
releaseContent = false
|
||||
|
||||
val headerBuffer = fastCgiChannel.alloc().ioBuffer(FastCgiConstants.HEADER_LENGTH, FastCgiConstants.HEADER_LENGTH)
|
||||
val headerBuffer = fastCgiChannel.alloc().ioBuffer(HEADER_LENGTH, HEADER_LENGTH)
|
||||
writeHeader(headerBuffer, STDIN, 0)
|
||||
fastCgiChannel.write(headerBuffer)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
skip: diff_frame*
|
||||
skip: icon_small.png
|
||||
skip: icon_CEsmall.png
|
||||
skip: icon_CEsmall@2x.png
|
||||
deprecated: diff/Diff.png
|
||||
+1
@@ -80,6 +80,7 @@ public class AppEditorFontConfigurable implements SearchableConfigurable, NoScro
|
||||
AppEditorFontOptionsPanel optionsPanel = getFontPanel().getOptionsPanel();
|
||||
optionsPanel.updateWarning();
|
||||
optionsPanel.updateOptionsList();
|
||||
getFontPanel().updatePreview();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+9
-1
@@ -20,6 +20,7 @@ import com.intellij.application.options.colors.FontEditorPreview;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.EditorFontCache;
|
||||
import com.intellij.openapi.editor.colors.impl.FontPreferencesImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -44,12 +45,19 @@ public class AppEditorFontPanel implements Disposable {
|
||||
new ColorAndFontSettingsListener.Abstract() {
|
||||
@Override
|
||||
public void fontChanged() {
|
||||
myPreview.updateView();
|
||||
updatePreview();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void updatePreview() {
|
||||
if (myPreviewScheme instanceof EditorFontCache) {
|
||||
((EditorFontCache)myPreviewScheme).reset();
|
||||
}
|
||||
myPreview.updateView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myPreview.disposeUIResources();
|
||||
|
||||
@@ -435,12 +435,6 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat
|
||||
|
||||
UIUtil.addUndoRedoActions(textComponent);
|
||||
|
||||
if (UIUtil.isUnderWindowsLookAndFeel()) {
|
||||
textComponent.setFont(UIManager.getFont("TextField.font"));
|
||||
} else {
|
||||
Utils.setSmallerFont(textComponent);
|
||||
}
|
||||
|
||||
textComponent.putClientProperty("AuxEditorComponent", Boolean.TRUE);
|
||||
textComponent.setBackground(UIUtil.getTextFieldBackground());
|
||||
textComponent.addFocusListener(new FocusListener() {
|
||||
|
||||
@@ -96,6 +96,13 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList
|
||||
myTextArea = textArea;
|
||||
mySearchMode = searchMode;
|
||||
myInfoMode = infoMode;
|
||||
|
||||
if (UIUtil.isUnderWindowsLookAndFeel()) {
|
||||
myTextArea.setFont(UIManager.getFont("TextField.font"));
|
||||
} else {
|
||||
Utils.setSmallerFont(myTextArea);
|
||||
}
|
||||
|
||||
myTextArea.addPropertyChangeListener("background", this);
|
||||
myTextArea.addPropertyChangeListener("font", this);
|
||||
myTextArea.addFocusListener(this);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -60,6 +61,10 @@ public class RenameFileAction extends AnAction implements DumbAware {
|
||||
}
|
||||
|
||||
protected boolean enabledInProjectView(@NotNull PsiFile file) {
|
||||
return true;
|
||||
for (RenameFileActionProvider provider : Extensions.getExtensions(RenameFileActionProvider.EP_NAME)) {
|
||||
if (provider.enabledInProjectView(file)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface RenameFileActionProvider {
|
||||
ExtensionPointName<RenameFileActionProvider> EP_NAME = ExtensionPointName.create("com.intellij.renameFileActionProvider");
|
||||
|
||||
/*
|
||||
* Check whether 'Rename File Action' is available for current psi file in the Project View or not
|
||||
*/
|
||||
default boolean enabledInProjectView(@NotNull PsiFile file) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,7 @@ import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.ui.TableSpeedSearch;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.CatchingConsumer;
|
||||
import com.intellij.util.IconUtil;
|
||||
@@ -92,7 +89,7 @@ public class InstalledPackagesPanel extends JPanel {
|
||||
upgradeAction();
|
||||
}
|
||||
};
|
||||
myInstallButton = new AnActionButton("Install", IconUtil.getAddIcon()) {
|
||||
myInstallButton = new DumbAwareActionButton("Install", IconUtil.getAddIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
if (myPackageManagementService != null) {
|
||||
|
||||
@@ -567,6 +567,7 @@
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="renameInputValidator" interface="com.intellij.refactoring.rename.RenameInputValidator"/>
|
||||
<extensionPoint name="renameFileActionProvider" interface="com.intellij.refactoring.actions.RenameFileActionProvider"/>
|
||||
|
||||
<extensionPoint name="findUsagesHandlerFactory" interface="com.intellij.find.findUsages.FindUsagesHandlerFactory" area="IDEA_PROJECT"/>
|
||||
<extensionPoint name="customUsageSearcher" interface="com.intellij.find.findUsages.CustomUsageSearcher"/>
|
||||
|
||||
@@ -1034,5 +1034,9 @@
|
||||
<action id="RunDashboard.RemoveConfiguration" class="com.intellij.execution.dashboard.actions.RemoveConfigurationAction"
|
||||
use-shortcut-of="$Delete"/>
|
||||
</group>
|
||||
|
||||
<action id="RenameFile" class="com.intellij.refactoring.actions.RenameFileAction">
|
||||
<add-to-group group-id="EditorTabPopupMenuEx" anchor="after" relative-to-action="AddAllToFavorites"/>
|
||||
</action>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
|
||||
+130
-137
@@ -40,7 +40,8 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 4/16/13
|
||||
* @author Vassiliy Kudryashov
|
||||
* Date: 4/16/13
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class FileEditorManagerTest extends FileEditorManagerTestCase {
|
||||
@@ -51,105 +52,101 @@ public class FileEditorManagerTest extends FileEditorManagerTestCase {
|
||||
assertOpenFiles("1.txt", "foo.xml", "2.txt", "3.txt");
|
||||
}
|
||||
|
||||
public void testTabLimit() throws Exception {
|
||||
int limit = UISettings.getInstance().getEditorTabLimit();
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
openFiles(STRING);
|
||||
// note that foo.xml is pinned
|
||||
assertOpenFiles("foo.xml", "3.txt");
|
||||
UISettings template = new UISettings();
|
||||
UISettings.getInstance().setEditorTabLimit(template.getEditorTabLimit());
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(template.getReuseNotModifiedTabs());
|
||||
UISettings.getInstance().setEditorTabPlacement(template.getEditorTabPlacement());
|
||||
}
|
||||
finally {
|
||||
UISettings.getInstance().setEditorTabLimit(limit);
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testTabLimit() throws Exception {
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
openFiles(STRING);
|
||||
// note that foo.xml is pinned
|
||||
assertOpenFiles("foo.xml", "3.txt");
|
||||
}
|
||||
|
||||
public void testSingleTabLimit() throws Exception {
|
||||
int limit = UISettings.getInstance().getEditorTabLimit();
|
||||
try {
|
||||
UISettings.getInstance().setEditorTabLimit(1);
|
||||
openFiles(STRING.replace("pinned=\"true\"", "pinned=\"false\""));
|
||||
assertOpenFiles("3.txt");
|
||||
UISettings.getInstance().setEditorTabLimit(1);
|
||||
openFiles(STRING.replace("pinned=\"true\"", "pinned=\"false\""));
|
||||
assertOpenFiles("3.txt");
|
||||
|
||||
myManager.closeAllFiles();
|
||||
myManager.closeAllFiles();
|
||||
|
||||
openFiles(STRING);
|
||||
// note that foo.xml is pinned
|
||||
assertOpenFiles("foo.xml");
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
assertOpenFiles("3.txt", "foo.xml");//limit is still 1 but pinned prevent closing tab and actual tab number may exceed the limit
|
||||
openFiles(STRING);
|
||||
// note that foo.xml is pinned
|
||||
assertOpenFiles("foo.xml");
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
assertOpenFiles("3.txt", "foo.xml");//limit is still 1 but pinned prevent closing tab and actual tab number may exceed the limit
|
||||
|
||||
myManager.closeAllFiles();
|
||||
myManager.closeAllFiles();
|
||||
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("foo.xml");
|
||||
callTrimToSize();
|
||||
assertOpenFiles("foo.xml");
|
||||
}
|
||||
finally {
|
||||
UISettings.getInstance().setEditorTabLimit(limit);
|
||||
}
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("foo.xml");
|
||||
callTrimToSize();
|
||||
assertOpenFiles("foo.xml");
|
||||
}
|
||||
|
||||
public void testReuseNotModifiedTabs() {
|
||||
int limit = UISettings.getInstance().getEditorTabLimit();
|
||||
boolean reuse = UISettings.getInstance().getReuseNotModifiedTabs();
|
||||
try {
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(false);
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(false);
|
||||
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("3.txt","foo.xml");
|
||||
UISettings.getInstance().setEditorTabLimit(1);
|
||||
callTrimToSize();
|
||||
assertOpenFiles("foo.xml");
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("3.txt", "foo.xml");
|
||||
UISettings.getInstance().setEditorTabLimit(1);
|
||||
callTrimToSize();
|
||||
assertOpenFiles("foo.xml");
|
||||
UISettings.getInstance().setEditorTabLimit(2);
|
||||
|
||||
myManager.closeAllFiles();
|
||||
myManager.closeAllFiles();
|
||||
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(true);
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
assertOpenFiles("3.txt");
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("foo.xml");
|
||||
} finally {
|
||||
UISettings.getInstance().setEditorTabLimit(limit);
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(reuse);
|
||||
}
|
||||
UISettings.getInstance().setReuseNotModifiedTabs(true);
|
||||
myManager.openFile(getFile("/src/3.txt"), true);
|
||||
assertOpenFiles("3.txt");
|
||||
myManager.openFile(getFile("/src/foo.xml"), true);
|
||||
assertOpenFiles("foo.xml");
|
||||
}
|
||||
|
||||
private void callTrimToSize() {
|
||||
for (EditorsSplitters each: myManager.getAllSplitters()) {
|
||||
for (EditorsSplitters each : myManager.getAllSplitters()) {
|
||||
each.trimToSize(UISettings.getInstance().getEditorTabLimit());
|
||||
}
|
||||
}
|
||||
|
||||
public void testOpenRecentEditorTab() throws Exception {
|
||||
PlatformTestUtil.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
PlatformTestUtil
|
||||
.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
|
||||
openFiles(" <component name=\"FileEditorManager\">\n" +
|
||||
" <leaf>\n" +
|
||||
" <file leaf-file-name=\"foo.xsd\" pinned=\"false\" current=\"true\" current-in-tab=\"true\">\n" +
|
||||
" <entry selected=\"true\" file=\"file://$PROJECT_DIR$/src/1.txt\">\n" +
|
||||
" <provider editor-type-id=\"mock\" selected=\"true\">\n" +
|
||||
" <state />\n" +
|
||||
" </provider>\n" +
|
||||
" <provider editor-type-id=\"text-editor\">\n" +
|
||||
" <state/>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" </leaf>\n" +
|
||||
" </component>\n");
|
||||
" <leaf>\n" +
|
||||
" <file leaf-file-name=\"foo.xsd\" pinned=\"false\" current=\"true\" current-in-tab=\"true\">\n" +
|
||||
" <entry selected=\"true\" file=\"file://$PROJECT_DIR$/src/1.txt\">\n" +
|
||||
" <provider editor-type-id=\"mock\" selected=\"true\">\n" +
|
||||
" <state />\n" +
|
||||
" </provider>\n" +
|
||||
" <provider editor-type-id=\"text-editor\">\n" +
|
||||
" <state/>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" </leaf>\n" +
|
||||
" </component>\n");
|
||||
FileEditor[] selectedEditors = myManager.getSelectedEditors();
|
||||
assertEquals(1, selectedEditors.length);
|
||||
assertEquals("mockEditor", selectedEditors[0].getName());
|
||||
}
|
||||
|
||||
public void testTrackSelectedEditor() throws Exception {
|
||||
PlatformTestUtil.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
PlatformTestUtil
|
||||
.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
VirtualFile file = getFile("/src/1.txt");
|
||||
assertNotNull(file);
|
||||
FileEditor[] editors = myManager.openFile(file, true);
|
||||
@@ -178,47 +175,43 @@ public class FileEditorManagerTest extends FileEditorManagerTestCase {
|
||||
}
|
||||
|
||||
public void testStoringCaretStateForFileWithFoldingsWithNoTabs() throws Exception {
|
||||
int savedValue = UISettings.getInstance().getEditorTabPlacement();
|
||||
UISettings.getInstance().setEditorTabPlacement(UISettings.TABS_NONE);
|
||||
try {
|
||||
VirtualFile file = getFile("/src/Test.java");
|
||||
assertNotNull(file);
|
||||
FileEditor[] editors = myManager.openFile(file, false);
|
||||
assertEquals(1, editors.length);
|
||||
assertTrue(editors[0] instanceof TextEditor);
|
||||
Editor editor = ((TextEditor)editors[0]).getEditor();
|
||||
EditorTestUtil.waitForLoading(editor);
|
||||
final FoldingModel foldingModel = editor.getFoldingModel();
|
||||
assertEquals(2, foldingModel.getAllFoldRegions().length);
|
||||
foldingModel.runBatchFoldingOperation(() -> {
|
||||
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
|
||||
region.setExpanded(false);
|
||||
}
|
||||
});
|
||||
int textLength = editor.getDocument().getTextLength();
|
||||
editor.getCaretModel().moveToOffset(textLength);
|
||||
editor.getSelectionModel().setSelection(textLength - 1, textLength);
|
||||
VirtualFile file = getFile("/src/Test.java");
|
||||
assertNotNull(file);
|
||||
FileEditor[] editors = myManager.openFile(file, false);
|
||||
assertEquals(1, editors.length);
|
||||
assertTrue(editors[0] instanceof TextEditor);
|
||||
Editor editor = ((TextEditor)editors[0]).getEditor();
|
||||
EditorTestUtil.waitForLoading(editor);
|
||||
final FoldingModel foldingModel = editor.getFoldingModel();
|
||||
assertEquals(2, foldingModel.getAllFoldRegions().length);
|
||||
foldingModel.runBatchFoldingOperation(() -> {
|
||||
for (FoldRegion region : foldingModel.getAllFoldRegions()) {
|
||||
region.setExpanded(false);
|
||||
}
|
||||
});
|
||||
int textLength = editor.getDocument().getTextLength();
|
||||
editor.getCaretModel().moveToOffset(textLength);
|
||||
editor.getSelectionModel().setSelection(textLength - 1, textLength);
|
||||
|
||||
myManager.openFile(getFile("/src/1.txt"), false);
|
||||
assertEquals(0, myManager.getEditors(file).length);
|
||||
editors = myManager.openFile(file, false);
|
||||
myManager.openFile(getFile("/src/1.txt"), false);
|
||||
assertEquals(0, myManager.getEditors(file).length);
|
||||
editors = myManager.openFile(file, false);
|
||||
|
||||
assertEquals(1, editors.length);
|
||||
assertTrue(editors[0] instanceof TextEditor);
|
||||
editor = ((TextEditor)editors[0]).getEditor();
|
||||
EditorTestUtil.waitForLoading(editor);
|
||||
assertEquals(textLength, editor.getCaretModel().getOffset());
|
||||
assertEquals(textLength - 1, editor.getSelectionModel().getSelectionStart());
|
||||
assertEquals(textLength, editor.getSelectionModel().getSelectionEnd());
|
||||
}
|
||||
finally {
|
||||
UISettings.getInstance().setEditorTabPlacement(savedValue);
|
||||
}
|
||||
assertEquals(1, editors.length);
|
||||
assertTrue(editors[0] instanceof TextEditor);
|
||||
editor = ((TextEditor)editors[0]).getEditor();
|
||||
EditorTestUtil.waitForLoading(editor);
|
||||
assertEquals(textLength, editor.getCaretModel().getOffset());
|
||||
assertEquals(textLength - 1, editor.getSelectionModel().getSelectionStart());
|
||||
assertEquals(textLength, editor.getSelectionModel().getSelectionEnd());
|
||||
}
|
||||
|
||||
public void testOpenInDumbMode() throws Exception {
|
||||
PlatformTestUtil.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
PlatformTestUtil.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new DumbAwareProvider(), myFixture.getTestRootDisposable());
|
||||
PlatformTestUtil
|
||||
.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new MyFileEditorProvider(), myFixture.getTestRootDisposable());
|
||||
PlatformTestUtil
|
||||
.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new DumbAwareProvider(), myFixture.getTestRootDisposable());
|
||||
try {
|
||||
DumbServiceImpl.getInstance(getProject()).setDumb(true);
|
||||
VirtualFile file = getFile("/src/foo.bar");
|
||||
@@ -234,41 +227,41 @@ public class FileEditorManagerTest extends FileEditorManagerTestCase {
|
||||
}
|
||||
|
||||
private static final String STRING = "<component name=\"FileEditorManager\">\n" +
|
||||
" <leaf>\n" +
|
||||
" <file leaf-file-name=\"1.txt\" pinned=\"false\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/1.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"foo.xml\" pinned=\"true\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/foo.xml\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"2.txt\" pinned=\"false\" current=\"true\" current-in-tab=\"true\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/2.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"3.txt\" pinned=\"false\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/3.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" </leaf>\n" +
|
||||
" </component>\n";
|
||||
" <leaf>\n" +
|
||||
" <file leaf-file-name=\"1.txt\" pinned=\"false\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/1.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"foo.xml\" pinned=\"true\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/foo.xml\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"2.txt\" pinned=\"false\" current=\"true\" current-in-tab=\"true\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/2.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" <file leaf-file-name=\"3.txt\" pinned=\"false\" current=\"false\" current-in-tab=\"false\">\n" +
|
||||
" <entry file=\"file://$PROJECT_DIR$/src/3.txt\">\n" +
|
||||
" <provider selected=\"true\" editor-type-id=\"text-editor\">\n" +
|
||||
" <state line=\"0\" column=\"0\" selection-start=\"0\" selection-end=\"0\" vertical-scroll-proportion=\"0.0\">\n" +
|
||||
" </state>\n" +
|
||||
" </provider>\n" +
|
||||
" </entry>\n" +
|
||||
" </file>\n" +
|
||||
" </leaf>\n" +
|
||||
" </component>\n";
|
||||
|
||||
private void assertOpenFiles(String... fileNames) {
|
||||
EditorWithProviderComposite[] files = myManager.getSplitters().getEditorsComposites();
|
||||
|
||||
@@ -225,8 +225,8 @@ abstract class FirstStart(val ideType: IdeType) {
|
||||
class IdeaCommunityFirstStart : FirstStart(ideType = IdeType.IDEA_COMMUNITY) {
|
||||
|
||||
override fun completeFirstStart() {
|
||||
acceptAgreement()
|
||||
completeInstallation()
|
||||
acceptAgreement()
|
||||
customizeIntellijIdea()
|
||||
waitWelcomeFrameAndClose()
|
||||
}
|
||||
@@ -235,8 +235,8 @@ class IdeaCommunityFirstStart : FirstStart(ideType = IdeType.IDEA_COMMUNITY) {
|
||||
class IdeaUltimateFirstStart : FirstStart(ideType = IdeType.IDEA_ULTIMATE) {
|
||||
|
||||
override fun completeFirstStart() {
|
||||
acceptAgreement()
|
||||
completeInstallation()
|
||||
acceptAgreement()
|
||||
customizeIntellijIdea()
|
||||
waitWelcomeFrameAndClose()
|
||||
}
|
||||
@@ -247,8 +247,8 @@ class IdeaUltimateFirstStart : FirstStart(ideType = IdeType.IDEA_ULTIMATE) {
|
||||
class WebStormFirstStart : FirstStart(ideType = IdeType.WEBSTORM) {
|
||||
|
||||
override fun completeFirstStart() {
|
||||
acceptAgreement()
|
||||
completeInstallation()
|
||||
acceptAgreement()
|
||||
waitWelcomeFrame()
|
||||
webStormInitialConfiguration()
|
||||
waitWelcomeFrameAndClose()
|
||||
|
||||
@@ -472,7 +472,7 @@ open class GuiTestCase : GuiTestBase() {
|
||||
if (containingItem == null) true //if were searching for any jList()
|
||||
else {
|
||||
val elements = (0..jList.model.size - 1).map { it -> extCellReader.valueAt(jList, it) }
|
||||
elements.any { it.toString() == containingItem }
|
||||
elements.any { it.toString() == containingItem } && jList.isShowing
|
||||
}
|
||||
}
|
||||
val jListFixture = JListFixture(myRobot, myJList)
|
||||
|
||||
@@ -132,6 +132,80 @@ public class RestLexerTest extends TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public void testSubstitutions() throws IOException {
|
||||
doTest(".. |end-user| replace:: :term:`user`\n" +
|
||||
".. |PNS ID| replace:: :term:`user`\n" +
|
||||
".. |PNS.ID| replace:: :term:`user`",
|
||||
"[.. , EXPLISIT_MARKUP_START]",
|
||||
"[|end-user|, SUBSTITUTION]",
|
||||
"[ , WHITESPACE]",
|
||||
"[replace::, DIRECTIVE]",
|
||||
"[ :term:`user`, LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[.. , EXPLISIT_MARKUP_START]",
|
||||
"[|PNS ID|, SUBSTITUTION]",
|
||||
"[ , WHITESPACE]",
|
||||
"[replace::, DIRECTIVE]",
|
||||
"[ :term:`user`, LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[.. , EXPLISIT_MARKUP_START]",
|
||||
"[|PNS.ID|, SUBSTITUTION]",
|
||||
"[ , WHITESPACE]",
|
||||
"[replace::, DIRECTIVE]",
|
||||
"[ :term:`user`, LINE]"
|
||||
);
|
||||
}
|
||||
|
||||
public void testLinks() throws IOException {
|
||||
doTest("link_/\n" +
|
||||
"link_!\n" +
|
||||
"\"link_\"\n" +
|
||||
"'link_'\n" +
|
||||
"link_;\n",
|
||||
"[link_, REFERENCE_NAME]",
|
||||
"[/, LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[link_, REFERENCE_NAME]",
|
||||
"[!, LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[\", LINE]",
|
||||
"[link_, REFERENCE_NAME]",
|
||||
"[\", LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[', LINE]",
|
||||
"[link_, REFERENCE_NAME]",
|
||||
"[', LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[link_, REFERENCE_NAME]",
|
||||
"[;, LINE]",
|
||||
"[\n, WHITESPACE]"
|
||||
);
|
||||
}
|
||||
|
||||
public void testFieldInCodeBlock() throws IOException {
|
||||
doTest(".. code-block:: python\n" +
|
||||
" :class: extra-css-class\n" +
|
||||
"\n" +
|
||||
" def thing(x): # comment\n" +
|
||||
" print(\"{x} is a thing\".format(x=x))",
|
||||
"[.. , EXPLISIT_MARKUP_START]",
|
||||
"[code-block::, CUSTOM_DIRECTIVE]",
|
||||
"[ , WHITESPACE]",
|
||||
"[python\n, LINE]",
|
||||
"[ , WHITESPACE]",
|
||||
"[ , WHITESPACE]",
|
||||
"[:class:, FIELD]",
|
||||
"[ extra-css-class, LINE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[\n, WHITESPACE]",
|
||||
"[ , PYTHON_LINE]",
|
||||
"[def thing(x): # comment, PYTHON_LINE]",
|
||||
"[\n, PYTHON_LINE]",
|
||||
"[ , PYTHON_LINE]",
|
||||
"[print(\"{x} is a thing\".format(x=x)), PYTHON_LINE]"
|
||||
);
|
||||
}
|
||||
|
||||
public void testInterpreted() throws IOException {
|
||||
doTest(":kbd:`1`\n" +
|
||||
"\n" +
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,10 +20,11 @@ SPACE=[\ \t]
|
||||
|
||||
ADORNMENT_SYMBOL="="|"-"|"`"|":"|"."|"'"|\"|"~"|"^"|"_"|"*"|"+"|"#"|">"
|
||||
ADORNMENT=("="+|"-"+|"`"+|":"+|"."+|"'"+|\"+|"~"+|"^"+|"_"+|"*"+|"+"+|"#"+)" "*{CRLF}
|
||||
SEPARATOR=[\n .:,()\{\}\[\]\-]
|
||||
SEPARATOR=[\n .:,()\{\}\[\]\-;!\\/'\"]
|
||||
USUAL_TYPES="attention"|"caution"|"danger"|"error"|"hint"|"important"|"note"|"tip"|"warning"|"admonition"|"image"|"figure"|"topic"|"sidebar"|"parsed-literal"|"rubric"|"epigraph"|"highlights"|"pull-quote"|"compound"|"container"|"table"|"csv-table"|"list-table"|"contents"|"sectnum"|"section-autonumbering"|"header"|"footer"|"target-notes"|"footnotes"|"citations"|"meta"|"replace"|"unicode"|"date"|"include"|"raw"|"class"|"role"|"default-role"|"title"|"restructuredtext-test-directive"
|
||||
HIGHLIGHT_TYPES= "highlight" | "sourcecode" | "code-block"
|
||||
NOT_BACKQUOTE = [^`]
|
||||
LINK = [0-9A-Za-z][0-9A-Za-z\-:+_]*"_""_"?
|
||||
|
||||
%state IN_EXPLISIT_MARKUP
|
||||
%state IN_COMMENT
|
||||
@@ -40,6 +41,8 @@ NOT_BACKQUOTE = [^`]
|
||||
%state IN_VALUE
|
||||
%state IN_FOOTNOTE
|
||||
%state IN_LINEBEGIN
|
||||
%state FIELD_IN_INLINE
|
||||
%state FIELD_LINE
|
||||
%state INIT
|
||||
|
||||
%{
|
||||
@@ -58,7 +61,7 @@ NOT_BACKQUOTE = [^`]
|
||||
|
||||
%%
|
||||
<YYINITIAL> {
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(1); return FIELD;}
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(1); return FIELD;}
|
||||
. { yypushback(1); yybegin(INIT); }
|
||||
}
|
||||
|
||||
@@ -85,10 +88,10 @@ NOT_BACKQUOTE = [^`]
|
||||
|
||||
"`"[^`\n\r ][^`\n\r]*"`" { return INTERPRETED;}
|
||||
"`"{NOT_BACKQUOTE}+"`_""_"?{SEPARATOR} {yypushback(1); return REFERENCE_NAME;}
|
||||
[0-9A-Za-z][0-9A-Za-z\-:+_]*"_""_"?{SEPARATOR} {yypushback(1); return REFERENCE_NAME;}
|
||||
//"["([0-9]* | #?[0-9A-Za-z]* | "*")"]_"{SEPARATOR} {yypushback(1); return REFERENCE_NAME;}
|
||||
{LINK}{SEPARATOR} {yypushback(1); return REFERENCE_NAME;}
|
||||
[\"']{LINK}[\"'] {yypushback(yylength()-1); return LINE;}
|
||||
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[`] { yypushback(1); yybegin(INIT); return FIELD;}
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[`] { yypushback(1); yybegin(INIT); return FIELD;}
|
||||
{CRLF} { yybegin(IN_LINEBEGIN); return WHITESPACE;}
|
||||
. { yypushback(1); yybegin(IN_LINE); }
|
||||
{SPACE}+ { yybegin(IN_LINEBEGIN); return WHITESPACE;}
|
||||
@@ -99,7 +102,7 @@ NOT_BACKQUOTE = [^`]
|
||||
{SPACE} { return LINE;}
|
||||
{CRLF} { return WHITESPACE;}
|
||||
"__" { yybegin(IN_VALUE); return ANONYMOUS_HYPERLINK;}
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(1); yybegin(INIT); return FIELD;}
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(1); yybegin(INIT); return FIELD;}
|
||||
. { yypushback(1); yybegin(INIT);}
|
||||
}
|
||||
|
||||
@@ -122,12 +125,23 @@ NOT_BACKQUOTE = [^`]
|
||||
//Two posibilities -- quoted-block, indented block
|
||||
|
||||
{CRLF} { return WHITESPACE;}
|
||||
{SPACE}+":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(yylength()-1); yybegin(FIELD_IN_INLINE); return WHITESPACE;}
|
||||
|
||||
{SPACE}+ { yybegin(PRE_INDENTED); myIndent = yylength(); return chooseType();}
|
||||
{ADORNMENT_SYMBOL} { yybegin(PRE_QUOTED); return SPEC_SYMBOL;}
|
||||
|
||||
//{CRLF}{2}~{CRLF}{2} { yybegin(INIT); return LINE;}
|
||||
}
|
||||
|
||||
<FIELD_IN_INLINE> {
|
||||
{SPACE}+ { return WHITESPACE;}
|
||||
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] {yypushback(1); yybegin(FIELD_LINE); return FIELD;}
|
||||
}
|
||||
|
||||
<FIELD_LINE> {
|
||||
.* {yybegin(IN_INLINE); return LINE;}
|
||||
}
|
||||
|
||||
<PRE_QUOTED> {
|
||||
.+ { return chooseType();}
|
||||
{CRLF} { yybegin(QUOTED); return chooseType();}
|
||||
@@ -164,7 +178,7 @@ NOT_BACKQUOTE = [^`]
|
||||
{USUAL_TYPES}"::" { yybegin(IN_VALUE); return DIRECTIVE;}
|
||||
{HIGHLIGHT_TYPES}"::" { yybegin(IN_HIGHLIGHT); return CUSTOM_DIRECTIVE;}
|
||||
[0-9A-Za-z\-:]*"::" { yybegin(IN_VALUE); return CUSTOM_DIRECTIVE;}
|
||||
"|"[0-9A-Za-z_]*"|" { return SUBSTITUTION;}
|
||||
"|"[^|]*"|" { return SUBSTITUTION;}
|
||||
[0-9A-Za-z_\[|.]+ { yybegin(IN_COMMENT); return COMMENT;}
|
||||
{CRLF}{2} { yybegin(INIT); return COMMENT;}
|
||||
{SPACE}*{CRLF}+ { return WHITESPACE; }
|
||||
@@ -179,7 +193,7 @@ NOT_BACKQUOTE = [^`]
|
||||
<IN_HIGHLIGHT> {
|
||||
{SPACE}+ { return WHITESPACE;}
|
||||
{CRLF} { yybegin(INIT); return WHITESPACE; }
|
||||
[A-Za-z+]+{CRLF}{CRLF} { String value = yytext().toString().trim();
|
||||
[A-Za-z+]+{CRLF} { String value = yytext().toString().trim();
|
||||
if ("python".equalsIgnoreCase(value)) {
|
||||
myState = 1;
|
||||
yybegin(IN_INLINE);
|
||||
|
||||
@@ -470,7 +470,7 @@ public class PyTypeChecker {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (substitution instanceof PyGenericType && substitution != type) {
|
||||
if (substitution instanceof PyGenericType && !typeVar.equals(substitution)) {
|
||||
final PyType recursive = substitute(substitution, substitutions, context);
|
||||
if (recursive != null) {
|
||||
return recursive;
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiLanguageInjectionHost;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.jetbrains.python.documentation.PythonDocumentationProvider;
|
||||
@@ -957,6 +953,21 @@ public class PyTypingTest extends PyTestCase {
|
||||
"expr = f(True, 1, 'foo')\n");
|
||||
}
|
||||
|
||||
// PY-24260
|
||||
public void testGenericClassParameterTakenFromGenericClassObject() {
|
||||
doTest("MyClass[TypeVar('T')]",
|
||||
"from typing import TypeVar, Generic, Type\n" +
|
||||
"\n" +
|
||||
"T = TypeVar(\"T\")\n" +
|
||||
"\n" +
|
||||
"class MyClass(Generic[T]):\n" +
|
||||
" def __init__(self, type: Type[T]):\n" +
|
||||
" pass\n" +
|
||||
"\n" +
|
||||
"def f(x: Type[T]):\n" +
|
||||
" expr = MyClass(x)\n");
|
||||
}
|
||||
|
||||
private void doTestNoInjectedText(@NotNull String text) {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject());
|
||||
|
||||
@@ -1701,6 +1701,7 @@
|
||||
<nameSuggestionProvider implementation="com.intellij.refactoring.rename.JavaNameSuggestionProvider" id="java"/>
|
||||
|
||||
<vetoRenameCondition implementation="com.intellij.refactoring.rename.JavaVetoRenameCondition"/>
|
||||
<renameFileActionProvider implementation="com.intellij.refactoring.actions.ClassAwareRenameFileProvider"/>
|
||||
|
||||
<readWriteAccessDetector implementation="com.intellij.codeInsight.highlighting.JavaReadWriteAccessDetector" id="java"/>
|
||||
<elementDescriptionProvider implementation="com.intellij.codeInsight.highlighting.JavaHighlightUsagesDescriptionProvider"/>
|
||||
|
||||
@@ -83,9 +83,8 @@
|
||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="IntroduceFunctionalParameter"/>
|
||||
</action>
|
||||
|
||||
<action id="RenameFile" class="com.intellij.refactoring.actions.ClassAwareRenameFileAction">
|
||||
<action id="RefactoringMenuRenameFile" class="com.intellij.refactoring.actions.RenameFileAction">
|
||||
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="RenameElement"/>
|
||||
<add-to-group group-id="EditorTabPopupMenuEx" anchor="after" relative-to-action="AddAllToFavorites"/>
|
||||
</action>
|
||||
|
||||
<group id="RefactoringMenu4">
|
||||
|
||||
Reference in New Issue
Block a user