mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -496,12 +496,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
}
|
||||
|
||||
private static boolean shouldAddXdebugKey(Sdk jdk) {
|
||||
if (jdk == null) {
|
||||
return true; // conservative choice
|
||||
}
|
||||
if (DebuggerSettings.getInstance().DISABLE_JIT) {
|
||||
return true;
|
||||
}
|
||||
if (jdk == null) {
|
||||
return false; // assume newer jdk by default
|
||||
}
|
||||
|
||||
//if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
// need this in unit tests to avoid false alarms when comparing actual output with expected output
|
||||
@@ -520,7 +520,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
|
||||
private static boolean isJVMTIAvailable(Sdk jdk) {
|
||||
if (jdk == null) {
|
||||
return true; // assume newer jdk by default
|
||||
return false; // conservative choice
|
||||
}
|
||||
|
||||
final String version = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VERSION);
|
||||
|
||||
@@ -20,25 +20,26 @@ import com.intellij.codeInsight.completion.simple.ParenthesesTailType;
|
||||
import com.intellij.codeInsight.completion.simple.RParenthTailType;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
|
||||
public class TailTypes {
|
||||
public static final TailType CALL_RPARENTH = new RParenthTailType(){
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES && editor.getDocument().getCharsSequence().charAt(tailOffset - 1) != '(';
|
||||
}
|
||||
};
|
||||
public static final TailType IF_RPARENTH = new RParenthTailType(){
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_IF_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType WHILE_RPARENTH = new RParenthTailType(){
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_WHILE_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType CALL_RPARENTH_SEMICOLON = new RParenthTailType(){
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES;
|
||||
}
|
||||
|
||||
@@ -48,56 +49,56 @@ public class TailTypes {
|
||||
};
|
||||
|
||||
public static final TailType SYNCHRONIZED_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_SYNCHRONIZED_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_SYNCHRONIZED_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType CATCH_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_CATCH_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_CATCH_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType SWITCH_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_SWITCH_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_SWITCH_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType WHILE_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_WHILE_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_WHILE_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType FOR_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_FOR_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_FOR_PARENTHESES;
|
||||
}
|
||||
};
|
||||
public static final TailType IF_LPARENTH = new ParenthesesTailType() {
|
||||
protected boolean isSpaceBeforeParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceBeforeParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_BEFORE_IF_PARENTHESES;
|
||||
}
|
||||
|
||||
protected boolean isSpaceWithinParentheses(final CodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
protected boolean isSpaceWithinParentheses(final CommonCodeStyleSettings styleSettings, final Editor editor, final int tailOffset) {
|
||||
return styleSettings.SPACE_WITHIN_IF_PARENTHESES;
|
||||
}
|
||||
};
|
||||
|
||||
+2
-3
@@ -20,8 +20,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.ClassConditionKey;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -64,7 +63,7 @@ public class CastingLookupElementDecorator extends LookupElementDecorator<Lookup
|
||||
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(context.getProject());
|
||||
final CommonCodeStyleSettings settings = context.getCodeStyleSettings();
|
||||
String spaceWithin = settings.SPACE_WITHIN_CAST_PARENTHESES ? " " : "";
|
||||
String spaceAfter = settings.SPACE_AFTER_TYPE_CAST ? " " : "";
|
||||
final Editor editor = context.getEditor();
|
||||
|
||||
@@ -27,8 +27,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DefaultInsertHandler extends TemplateInsertHandler implements Cloneable {
|
||||
@@ -94,7 +93,7 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
}
|
||||
}
|
||||
else{
|
||||
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(context.getProject());
|
||||
final CommonCodeStyleSettings styleSettings = context.getCodeStyleSettings();
|
||||
myState.tailOffset = context.getSelectionEndOffset();
|
||||
myState.caretOffset = context.getSelectionEndOffset();
|
||||
|
||||
|
||||
@@ -30,7 +30,10 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.NullableLazyKey;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.PsiElementPattern;
|
||||
import com.intellij.patterns.PsiJavaPatterns;
|
||||
@@ -66,7 +69,10 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.patterns.PlatformPatterns.psiElement;
|
||||
|
||||
@@ -272,7 +278,7 @@ public class JavaCompletionUtil {
|
||||
|
||||
if (element instanceof PsiWhiteSpace &&
|
||||
( !element.textContains('\n') ||
|
||||
CodeStyleSettingsManager.getInstance(project).getCurrentSettings().METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE
|
||||
CodeStyleSettingsManager.getSettings(project).getCommonSettings(JavaLanguage.INSTANCE).METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE
|
||||
)
|
||||
){
|
||||
element = file.findElementAt(element.getTextRange().getEndOffset());
|
||||
@@ -541,7 +547,7 @@ public class JavaCompletionUtil {
|
||||
if (ref != null) {
|
||||
final PsiElement qualifier = ref.getQualifier();
|
||||
if (qualifier != null) {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(qualifier.getProject());
|
||||
final CommonCodeStyleSettings settings = context.getCodeStyleSettings();
|
||||
|
||||
final String parenSpace = settings.SPACE_WITHIN_PARENTHESES ? " " : "";
|
||||
document.insertString(qualifier.getTextRange().getEndOffset(), parenSpace + ")");
|
||||
@@ -821,7 +827,7 @@ public class JavaCompletionUtil {
|
||||
|
||||
PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getDocument());
|
||||
|
||||
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(context.getProject());
|
||||
final CommonCodeStyleSettings styleSettings = context.getCodeStyleSettings();
|
||||
ParenthesesInsertHandler.getInstance(hasParams,
|
||||
styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES,
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES && hasParams,
|
||||
|
||||
@@ -14,8 +14,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.patterns.PsiElementPattern;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiEmptyExpressionImpl;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -100,7 +99,7 @@ class SmartCastProvider extends CompletionProvider<CompletionParameters> {
|
||||
context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET));
|
||||
}
|
||||
|
||||
final CodeStyleSettings csSettings = CodeStyleSettingsManager.getSettings(context.getProject());
|
||||
final CommonCodeStyleSettings csSettings = context.getCodeStyleSettings();
|
||||
final int oldTail = context.getTailOffset();
|
||||
context.setTailOffset(RParenthTailType.addRParenth(editor, oldTail, csSettings.SPACE_WITHIN_CAST_PARENTHESES));
|
||||
|
||||
|
||||
+4
-5
@@ -18,20 +18,19 @@ package com.intellij.codeInsight.completion.simple;
|
||||
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class ParenthesesTailType extends TailType {
|
||||
|
||||
protected abstract boolean isSpaceBeforeParentheses(CodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
protected abstract boolean isSpaceBeforeParentheses(CommonCodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
|
||||
protected abstract boolean isSpaceWithinParentheses(CodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
protected abstract boolean isSpaceWithinParentheses(CommonCodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
|
||||
public int processTail(final Editor editor, int tailOffset) {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(editor.getProject());
|
||||
CommonCodeStyleSettings styleSettings = getLocalCodeStyleSettings(editor, tailOffset);
|
||||
if (isSpaceBeforeParentheses(styleSettings, editor, tailOffset)) {
|
||||
tailOffset = insertChar(editor, tailOffset, ' ');
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
@@ -50,10 +49,10 @@ public abstract class RParenthTailType extends TailType {
|
||||
return element == null ? new TextRange(0, document.getTextLength()) : element.getTextRange();
|
||||
}
|
||||
|
||||
protected abstract boolean isSpaceWithinParentheses(CodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
protected abstract boolean isSpaceWithinParentheses(CommonCodeStyleSettings styleSettings, Editor editor, final int tailOffset);
|
||||
|
||||
public int processTail(final Editor editor, int tailOffset) {
|
||||
return addRParenth(editor, tailOffset, isSpaceWithinParentheses(CodeStyleSettingsManager.getSettings(editor.getProject()), editor, tailOffset));
|
||||
return addRParenth(editor, tailOffset, isSpaceWithinParentheses(getLocalCodeStyleSettings(editor, tailOffset), editor, tailOffset));
|
||||
}
|
||||
|
||||
public static int addRParenth(Editor editor, int offset, boolean spaceWithinParens) {
|
||||
|
||||
+4
-29
@@ -353,41 +353,18 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
}
|
||||
return;
|
||||
}
|
||||
refElement.accept(new RefJavaVisitor() {
|
||||
@Override public void visitElement(final RefEntity elem) {
|
||||
if (elem instanceof RefElement) {
|
||||
final RefElement element = (RefElement)elem;
|
||||
if (isEntryPoint(element)) {
|
||||
getEntryPointsManager().addEntryPoint(element, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refElement.accept(new RefJavaVisitor() {
|
||||
@Override public void visitMethod(RefMethod method) {
|
||||
if (isAddMainsEnabled() && method.isAppMain()) {
|
||||
getEntryPointsManager().addEntryPoint(method, false);
|
||||
} else {
|
||||
super.visitMethod(method);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitClass(RefClass aClass) {
|
||||
final PsiClass psiClass = aClass.getElement();
|
||||
if (psiClass == null) return;
|
||||
if (
|
||||
isAddAppletEnabled() && aClass.isApplet() ||
|
||||
isAddServletEnabled() && aClass.isServlet()) {
|
||||
if (isAddAppletEnabled() && aClass.isApplet() ||
|
||||
isAddServletEnabled() && aClass.isServlet()) {
|
||||
getEntryPointsManager().addEntryPoint(aClass, false);
|
||||
} else if (psiClass.isAnnotationType()){
|
||||
getEntryPointsManager().addEntryPoint(aClass, false);
|
||||
final PsiMethod[] psiMethods = psiClass.getMethods();
|
||||
for (PsiMethod psiMethod : psiMethods) {
|
||||
getEntryPointsManager().addEntryPoint(getRefManager().getReference(psiMethod), false);
|
||||
}
|
||||
} else if (psiClass.isEnum()) {
|
||||
getEntryPointsManager().addEntryPoint(aClass, false);
|
||||
} else {
|
||||
super.visitClass(aClass);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -437,7 +414,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
myPhase = 1;
|
||||
}
|
||||
|
||||
private boolean isEntryPoint(final RefElement owner) {
|
||||
public boolean isEntryPoint(final RefElement owner) {
|
||||
final PsiElement element = owner.getElement();
|
||||
if (RefUtil.isImplicitUsage(element)) return true;
|
||||
if (element instanceof PsiModifierListOwner) {
|
||||
@@ -907,8 +884,6 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
@Override public void visitElement(RefEntity refEntity) {
|
||||
if (refEntity instanceof RefJavaElement) {
|
||||
final RefJavaElementImpl refElement = (RefJavaElementImpl)refEntity;
|
||||
final PsiElement element = refElement.getElement();
|
||||
if (element == null) return;
|
||||
if (!getContext().isToCheckMember(refElement, UnusedDeclarationInspection.this)) return;
|
||||
refElement.setReachable(false);
|
||||
}
|
||||
|
||||
@@ -15,14 +15,20 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.reference;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.SuppressionUtil;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManager;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.codeInspection.ex.Tools;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.UserDataCache;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
@@ -89,6 +95,41 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
return refPackage;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEntryPoint(final RefElement element) {
|
||||
UnusedDeclarationInspection tool = getDeadCodeTool(element);
|
||||
return tool != null && tool.isEntryPoint(element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private UnusedDeclarationInspection getDeadCodeTool(RefElement element) {
|
||||
PsiFile file = ((RefElementImpl)element).getContainingFile();
|
||||
if (file == null) return null;
|
||||
|
||||
return getDeadCodeTool(file);
|
||||
}
|
||||
|
||||
private static final UserDataCache<Ref<UnusedDeclarationInspection>, PsiFile, RefManagerImpl> DEAD_CODE_TOOL = new UserDataCache<Ref<UnusedDeclarationInspection>, PsiFile, RefManagerImpl>("DEAD_CODE_TOOL") {
|
||||
@Override
|
||||
protected Ref<UnusedDeclarationInspection> compute(PsiFile file, RefManagerImpl refManager) {
|
||||
Tools tools = refManager.getContext().getTools().get(UnusedDeclarationInspection.SHORT_NAME);
|
||||
InspectionProfileEntry tool = tools != null ? tools.getEnabledTool(file) : null;
|
||||
if (tool instanceof InspectionToolWrapper) tool = ((InspectionToolWrapper)tool).getTool();
|
||||
return Ref.create(tool instanceof UnusedDeclarationInspection ? (UnusedDeclarationInspection)tool : null);
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
private UnusedDeclarationInspection getDeadCodeTool(PsiElement element) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
return file != null ? DEAD_CODE_TOOL.get(file, myRefManager).get() : null;
|
||||
}
|
||||
|
||||
public boolean isEntryPoint(PsiElement element) {
|
||||
UnusedDeclarationInspection tool = getDeadCodeTool(element);
|
||||
return tool != null && tool.isEntryPoint(element);
|
||||
}
|
||||
|
||||
public RefPackage getDefaultPackage() {
|
||||
if (myDefaultPackage == null) {
|
||||
myDefaultPackage = getPackage(InspectionsBundle.message("inspection.reference.default.package"));
|
||||
@@ -269,6 +310,28 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityInitialized(RefElement refElement, PsiElement psiElement) {
|
||||
if (isEntryPoint(refElement)) {
|
||||
getEntryPointsManager().addEntryPoint(refElement, false);
|
||||
}
|
||||
|
||||
if (psiElement instanceof PsiClass) {
|
||||
PsiClass psiClass = (PsiClass)psiElement;
|
||||
|
||||
EntryPointsManager entryPointsManager = getEntryPointsManager();
|
||||
if (psiClass.isAnnotationType()){
|
||||
entryPointsManager.addEntryPoint(refElement, false);
|
||||
for (PsiMethod psiMethod : psiClass.getMethods()) {
|
||||
entryPointsManager.addEntryPoint(myRefManager.getReference(psiMethod), false);
|
||||
}
|
||||
}
|
||||
else if (psiClass.isEnum()) {
|
||||
entryPointsManager.addEntryPoint(refElement, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendPackageElement(final Element element, final String packageName) {
|
||||
final Element packageElement = new Element("package");
|
||||
packageElement.addContent(packageName.length() > 0 ? packageName : InspectionsBundle.message("inspection.export.results.default"));
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public static class G {
|
||||
public static void foo(String s1, String s2) {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String sss1 = "text";
|
||||
foo(sss1,<caret>);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public static class G {
|
||||
public static void foo(String s1, String s2) {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String sss1 = "text";
|
||||
foo(ss<caret>);
|
||||
}
|
||||
}
|
||||
+14
-12
@@ -5,10 +5,11 @@ import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupManagerImpl;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.statistics.StatisticsManager;
|
||||
import com.intellij.psi.statistics.impl.StatisticsManagerImpl;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
@@ -208,8 +209,9 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
}
|
||||
|
||||
public void testParensInSynchronized() throws Exception{
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_WITHIN_SYNCHRONIZED_PARENTHESES = true;
|
||||
CommonCodeStyleSettings styleSettings = getCodeStyleSettings();
|
||||
styleSettings.SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
|
||||
styleSettings.SPACE_WITHIN_SYNCHRONIZED_PARENTHESES = true;
|
||||
final String path = BASE_PATH;
|
||||
|
||||
configureByFile(path + "/before22.java");
|
||||
@@ -254,22 +256,17 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
|
||||
public void testCastParensStyle1() throws Exception{
|
||||
final String path = BASE_PATH;
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
final boolean space_within_cast_parentheses = styleSettings.SPACE_WITHIN_CAST_PARENTHESES;
|
||||
final boolean space_after_type_cast = styleSettings.SPACE_AFTER_TYPE_CAST;
|
||||
|
||||
styleSettings.SPACE_WITHIN_CAST_PARENTHESES = true;
|
||||
styleSettings.SPACE_AFTER_TYPE_CAST = false;
|
||||
getCodeStyleSettings().SPACE_WITHIN_CAST_PARENTHESES = true;
|
||||
getCodeStyleSettings().SPACE_AFTER_TYPE_CAST = false;
|
||||
configureByFile(path + "/before31.java");
|
||||
performSmartCompletion();
|
||||
checkResultByFile(path + "/after31.java");
|
||||
styleSettings.SPACE_WITHIN_CAST_PARENTHESES = space_within_cast_parentheses;
|
||||
styleSettings.SPACE_AFTER_TYPE_CAST = space_after_type_cast;
|
||||
}
|
||||
|
||||
public void testMethodParensStyle2() throws Exception{
|
||||
final String path = BASE_PATH;
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
CommonCodeStyleSettings styleSettings = getCodeStyleSettings();
|
||||
final boolean space_before_method_call_parentheses = styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES;
|
||||
styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true;
|
||||
configureByFile(path + "/before32.java");
|
||||
@@ -278,9 +275,14 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = space_before_method_call_parentheses;
|
||||
}
|
||||
|
||||
private static CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
public void testMethodParensStyle3() throws Exception{
|
||||
final String path = BASE_PATH;
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
CommonCodeStyleSettings styleSettings = getCodeStyleSettings();
|
||||
final boolean space_before_method_call_parentheses = styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES;
|
||||
final boolean space_within_method_call_parentheses = styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES;
|
||||
|
||||
|
||||
+15
-20
@@ -22,11 +22,12 @@ import com.intellij.codeInsight.lookup.Lookup
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.codeInsight.lookup.LookupManager
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
|
||||
import com.intellij.psi.*
|
||||
|
||||
public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
@@ -287,12 +288,9 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testMethodCallBeforeAnotherStatementWithParen2() throws Exception {
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
|
||||
boolean oldvalue = settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE;
|
||||
settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
|
||||
codeStyleSettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
|
||||
configureByFile("MethodLookup2.java");
|
||||
checkResultByFile("MethodLookup2_After2.java");
|
||||
settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = oldvalue;
|
||||
}
|
||||
|
||||
public void testSwitchEnumLabel() throws Exception {
|
||||
@@ -494,16 +492,14 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testPrivateInAnonymous() throws Throwable { doTest() }
|
||||
|
||||
public void testMethodParenthesesSpaces() throws Throwable {
|
||||
final settings = CodeStyleSettingsManager.getSettings(getProject())
|
||||
settings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true
|
||||
settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true
|
||||
codeStyleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true
|
||||
codeStyleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodParenthesesSpacesArgs() throws Throwable {
|
||||
final settings = CodeStyleSettingsManager.getSettings(getProject())
|
||||
settings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true
|
||||
settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true
|
||||
codeStyleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true
|
||||
codeStyleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -601,23 +597,18 @@ public class ListUtils {
|
||||
}
|
||||
|
||||
public void testNoSpaceInParensWithoutParams() throws Throwable {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
codeStyleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
codeStyleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void testTwoSpacesInParensWithParams() throws Throwable {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
codeStyleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFillCommonPrefixOnSecondCompletion() throws Throwable {
|
||||
@@ -1330,6 +1321,10 @@ public class ListUtils {
|
||||
public void testInterfaceImplementationNoCast() { doTest() }
|
||||
public void testStaticallyImportedMethodsBeforeExpression() { doTest() }
|
||||
|
||||
private CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
public void testCompatibleInterfacesCast() {
|
||||
configure()
|
||||
assert myFixture.lookupElementStrings.containsAll(['foo', 'bar'])
|
||||
|
||||
+15
-17
@@ -12,10 +12,12 @@ import com.intellij.codeInsight.template.TemplateContextType;
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
@@ -92,15 +94,9 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testParenAfterCall1_SpaceWithinMethodCallParens() throws Exception {
|
||||
String path = "/parenAfterCall";
|
||||
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
myFixture.configureByFile(path + "/before1.java");
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try{
|
||||
complete();
|
||||
}
|
||||
finally{
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
getCodeStyleSettings().SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
complete();
|
||||
checkResultByFile(path + "/after1_space.java");
|
||||
}
|
||||
|
||||
@@ -659,14 +655,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testUseIntConstantsInOr() throws Throwable { doTest(); }
|
||||
|
||||
public void testExtraSemicolonAfterMethodParam() throws Throwable {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try{
|
||||
doTest();
|
||||
}
|
||||
finally{
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
getCodeStyleSettings().SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAssignFromTheSameFieldOfAnotherObject() throws Throwable {
|
||||
@@ -1132,7 +1122,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
doTest(Lookup.NORMAL_SELECT_CHAR);
|
||||
}
|
||||
|
||||
private void doTest(final char c) throws Exception {
|
||||
private void doTest(final char c) {
|
||||
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION;
|
||||
if (c != Lookup.NORMAL_SELECT_CHAR) {
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = false;
|
||||
@@ -1173,4 +1163,12 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSpaceAfterCommaInMethodCall() {
|
||||
getCodeStyleSettings().SPACE_AFTER_COMMA = false;
|
||||
doTest(',');
|
||||
}
|
||||
|
||||
private CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,16 @@ import com.intellij.ide.Bootstrap;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.util.Restarter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
@@ -46,39 +50,30 @@ public class Main {
|
||||
System.setProperty("jna.nounpack", "false");
|
||||
}
|
||||
|
||||
// pre-load class before installing the patch to prevent class loader problems
|
||||
Restarter.isSupported();
|
||||
final int[] restartCode = {Restarter.getRestartCode()};
|
||||
|
||||
if (installPatch()) {
|
||||
boolean restarted = false;
|
||||
int restartCode = 0;
|
||||
try {
|
||||
restarted = Restarter.restart();
|
||||
restartCode = Restarter.getRestartCode();
|
||||
Runnable restart = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (restartCode[0] == 0) {
|
||||
try {
|
||||
if (Restarter.restart()) restartCode[0] = 1;
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
// can be either CannotRestartException
|
||||
// or something like class/method not found if they has been changed during update
|
||||
};
|
||||
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (installPatch(restart)) {
|
||||
if (restartCode[0] == 0) {
|
||||
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable ignore) { }
|
||||
|
||||
if (!restarted && restartCode == 0) {
|
||||
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { }
|
||||
String msg = "The application cannot start right away since some critical files have been changed.\nPlease restart it manually.";
|
||||
String msg = "Patch has been applied successfully, please restart application.";
|
||||
JOptionPane.showMessageDialog(null, msg, "Update", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
final int finalRestartCode = restartCode;
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.exit(finalRestartCode);
|
||||
}
|
||||
});
|
||||
|
||||
System.exit(restartCode[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,7 +119,7 @@ public class Main {
|
||||
return isHeadless;
|
||||
}
|
||||
|
||||
private static boolean installPatch() {
|
||||
private static boolean installPatch(Runnable restart) {
|
||||
try {
|
||||
File ideaHomeDir = getIdeaHomeDir();
|
||||
if (ideaHomeDir == null) return false;
|
||||
@@ -141,10 +136,12 @@ public class Main {
|
||||
File launcherFile = new File(ideaHomeDir, "bin/vistalauncher.exe");
|
||||
File launcherCopy = FileUtil.createTempFile("vistalauncher", ".exe");
|
||||
launcherCopy.deleteOnExit();
|
||||
copyFile(launcherFile, launcherCopy);
|
||||
FileUtil.copy(launcherFile, launcherCopy);
|
||||
args.add(launcherCopy.getPath());
|
||||
}
|
||||
|
||||
restart.run();
|
||||
|
||||
Collections.addAll(args,
|
||||
System.getProperty("java.home") + "/bin/java",
|
||||
"-classpath",
|
||||
@@ -160,13 +157,14 @@ public class Main {
|
||||
errThread.start();
|
||||
|
||||
try {
|
||||
boolean requiresRestart = process.waitFor() == 42;
|
||||
return requiresRestart;
|
||||
process.waitFor();
|
||||
}
|
||||
finally {
|
||||
outThread.join();
|
||||
errThread.join();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
finally {
|
||||
patchFile.delete();
|
||||
@@ -189,7 +187,7 @@ public class Main {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
copyStream(myIn, myOut);
|
||||
StreamUtil.copyStreamContent(myIn, myOut);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -217,44 +215,4 @@ public class Main {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyFile(File from, File to) throws IOException {
|
||||
to.getParentFile().mkdirs();
|
||||
|
||||
FileInputStream is = null;
|
||||
FileOutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(from);
|
||||
os = new FileOutputStream(to);
|
||||
|
||||
copyStream(is, os);
|
||||
}
|
||||
finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (os != null) {
|
||||
try {
|
||||
os.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyStream(InputStream from, OutputStream to) throws IOException {
|
||||
byte[] buffer = new byte[65536];
|
||||
while (true) {
|
||||
int read = from.read(buffer);
|
||||
if (read < 0) break;
|
||||
to.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,16 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -72,11 +77,11 @@ public abstract class TailType {
|
||||
};
|
||||
|
||||
public static final TailType SEMICOLON = new CharTailType(';');
|
||||
public static final TailType EXCLAMATION = new CharTailType('!');
|
||||
@Deprecated public static final TailType EXCLAMATION = new CharTailType('!');
|
||||
|
||||
public static final TailType COMMA = new TailType(){
|
||||
public int processTail(final Editor editor, int tailOffset) {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(editor.getProject());
|
||||
CommonCodeStyleSettings styleSettings = getLocalCodeStyleSettings(editor, tailOffset);
|
||||
if (styleSettings.SPACE_BEFORE_COMMA) tailOffset = insertChar(editor, tailOffset, ' ');
|
||||
tailOffset = insertChar(editor, tailOffset, ',');
|
||||
if (styleSettings.SPACE_AFTER_COMMA) tailOffset = insertChar(editor, tailOffset, ' ');
|
||||
@@ -87,6 +92,17 @@ public abstract class TailType {
|
||||
return "COMMA";
|
||||
}
|
||||
};
|
||||
|
||||
protected static CommonCodeStyleSettings getLocalCodeStyleSettings(Editor editor, int tailOffset) {
|
||||
Project project = editor.getProject();
|
||||
assert project != null;
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
assert psiFile != null;
|
||||
Language language = PsiUtilBase.getLanguageAtOffset(psiFile, tailOffset);
|
||||
|
||||
return CodeStyleSettingsManager.getSettings(project).getCommonSettings(language);
|
||||
}
|
||||
|
||||
/**
|
||||
* insert a space, overtype if already present
|
||||
*/
|
||||
|
||||
@@ -16,11 +16,15 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -132,4 +136,9 @@ public class InsertionContext {
|
||||
public boolean shouldAddCompletionChar() {
|
||||
return myAddCompletionChar;
|
||||
}
|
||||
|
||||
public CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
Language lang = PsiUtilBase.getLanguageAtOffset(getFile(), getTailOffset());
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(lang);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,13 +18,13 @@ package com.intellij.codeInspection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class is for the inspections that are gathered by another inspection,
|
||||
* This interface is for the inspections that are gathered by another inspection,
|
||||
* but should be shown under this inspection in the inspections result view.
|
||||
* This inspection is identified by the problem group, which is stored in the Annotation, HighlightInfo and ProblemDescriptor classes.
|
||||
*/
|
||||
public abstract class LocalDummyInspectionTool extends LocalInspectionTool {
|
||||
public interface DummyInspectionTool {
|
||||
@NotNull
|
||||
public abstract String getProblemGroup();
|
||||
String getProblemGroup();
|
||||
|
||||
public abstract boolean shouldBeShownInInspectionProfile();
|
||||
boolean shouldBeShownInInspectionProfile();
|
||||
}
|
||||
@@ -59,4 +59,6 @@ public interface RefManagerExtension<T> {
|
||||
boolean belongsToScope(final PsiElement psiElement);
|
||||
|
||||
void export(final RefEntity refEntity, final Element element);
|
||||
}
|
||||
|
||||
void onEntityInitialized(RefElement refEntity, PsiElement psiElement);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -78,7 +78,7 @@ public class EmacsStyleIndentAction extends BaseCodeInsightAction implements Dum
|
||||
final int newPos = codeStyleManager.adjustLineIndent(file, lineStart);
|
||||
final int newCol = newPos - lineStart;
|
||||
final int lineInc = document.getLineEndOffset(line) - initLineEnd;
|
||||
if (newCol >= col + lineInc) {
|
||||
if (newCol >= col + lineInc && newCol >= 0) {
|
||||
final LogicalPosition pos = new LogicalPosition(line, newCol);
|
||||
editor.getCaretModel().moveToLogicalPosition(pos);
|
||||
editor.getSelectionModel().removeSelection();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -36,7 +36,7 @@ public abstract class AbstractElementSignatureProvider implements ElementSignatu
|
||||
|
||||
@Nullable
|
||||
public PsiElement restoreBySignature(@NotNull PsiFile file, @NotNull String signature, @Nullable StringBuilder processingInfoStorage) {
|
||||
int semicolonIndex = signature.indexOf(';');
|
||||
int semicolonIndex = signature.indexOf(ELEMENTS_SEPARATOR);
|
||||
PsiElement parent;
|
||||
|
||||
if (semicolonIndex >= 0) {
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -42,6 +42,9 @@ public class CollapseSelectionHandler implements CodeInsightActionHandler {
|
||||
if (editor.getSelectionModel().hasSelection()) {
|
||||
int start = editor.getSelectionModel().getSelectionStart();
|
||||
int end = editor.getSelectionModel().getSelectionEnd();
|
||||
if (start + 1 >= end) {
|
||||
return;
|
||||
}
|
||||
Document doc = editor.getDocument();
|
||||
if (start < end && doc.getCharsSequence().charAt(end-1) == '\n') end--;
|
||||
FoldRegion region;
|
||||
@@ -52,7 +55,7 @@ public class CollapseSelectionHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
} else if (!foldingModel.intersectsRegion(start, end)) {
|
||||
region = foldingModel.addFoldRegion(start, end, ourPlaceHolderText);
|
||||
LOG.assertTrue(region != null);
|
||||
LOG.assertTrue(region != null, "Fold region is not created. Folding model: " + foldingModel);
|
||||
region.setExpanded(false);
|
||||
int offset = Math.min(start + ourPlaceHolderText.length(), doc.getTextLength());
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
|
||||
+11
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -67,7 +68,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
else {
|
||||
if (processingInfoStorage != null) {
|
||||
processingInfoStorage.append(String.format(
|
||||
"Stopping '%s' provider because it has top level marker but more than one non white-space child: %s",
|
||||
"Stopping '%s' provider because it has top level marker but more than one non white-space child: %s%n",
|
||||
getClass().getName(), Arrays.toString(file.getChildren())
|
||||
));
|
||||
}
|
||||
@@ -77,7 +78,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
}
|
||||
if (processingInfoStorage != null) {
|
||||
processingInfoStorage.append(String.format(
|
||||
"Finished processing of '%s' provider because all of its top-level children have been processed: %s",
|
||||
"Finished processing of '%s' provider because all of its top-level children have been processed: %s%n",
|
||||
getClass().getName(), Arrays.toString(file.getChildren())
|
||||
));
|
||||
}
|
||||
@@ -99,10 +100,17 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
}
|
||||
|
||||
if (!tokenizer.hasMoreTokens()) {
|
||||
if (processingInfoStorage != null) {
|
||||
processingInfoStorage.append(String.format("Stopping '%s' provider because it has no more data to process%n", getClass().getName()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
int index = Integer.parseInt(tokenizer.nextToken());
|
||||
if (processingInfoStorage != null) {
|
||||
processingInfoStorage.append(String.format("Looking for the child with a name '%s' # %d at the element '%s'%n",
|
||||
elementMarker, index, parent));
|
||||
}
|
||||
return restoreElementInternal(parent, elementMarker, index, PsiNamedElement.class);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
@@ -172,7 +180,7 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
|
||||
if (element instanceof PsiNamedElement) {
|
||||
PsiNamedElement named = (PsiNamedElement)element;
|
||||
final String name = named.getName();
|
||||
if (name == null) {
|
||||
if (StringUtil.isEmpty(name)) {
|
||||
return null;
|
||||
}
|
||||
int index = getChildIndex(named, element.getParent(), name, (Class<PsiNamedElement>)named.getClass());
|
||||
|
||||
+10
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.lang.folding.FoldingDescriptor;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.FoldingGroup;
|
||||
@@ -41,6 +42,9 @@ import static com.intellij.util.containers.CollectionFactory.newTroveMap;
|
||||
* @author cdr
|
||||
*/
|
||||
class UpdateFoldRegionsOperation implements Runnable {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + UpdateFoldRegionsOperation.class.getName());
|
||||
|
||||
private final Project myProject;
|
||||
private final Editor myEditor;
|
||||
private final PsiFile myFile;
|
||||
@@ -104,6 +108,11 @@ class UpdateFoldRegionsOperation implements Runnable {
|
||||
FoldingGroup group = descriptor.getGroup();
|
||||
TextRange range = descriptor.getRange();
|
||||
String placeholder = descriptor.getPlaceholderText();
|
||||
if (range.getEndOffset() > myEditor.getDocument().getTextLength()) {
|
||||
LOG.error(String.format("Invalid folding descriptor detected (%s). It ends beyond the document range (%d)",
|
||||
descriptor, myEditor.getDocument().getTextLength()));
|
||||
continue;
|
||||
}
|
||||
FoldRegion region = foldingModel.createFoldRegion(range.getStartOffset(), range.getEndOffset(),
|
||||
placeholder == null ? "..." : placeholder,
|
||||
group,
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.intellij.codeInspection.ex;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.DummyInspectionTool;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.codeInspection.LocalDummyInspectionTool;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
@@ -62,8 +62,8 @@ public class Descriptor {
|
||||
if (tool instanceof InspectionToolWrapper) {
|
||||
InspectionProfileEntry inspection = ((InspectionToolWrapper)tool).getTool();
|
||||
|
||||
if (inspection instanceof LocalDummyInspectionTool) {
|
||||
myShouldBeShown = ((LocalDummyInspectionTool)inspection).shouldBeShownInInspectionProfile();
|
||||
if (inspection instanceof DummyInspectionTool) {
|
||||
myShouldBeShown = ((DummyInspectionTool)inspection).shouldBeShownInInspectionProfile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -354,7 +354,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
|
||||
public boolean isToCheckFile(PsiFile file, final InspectionProfileEntry tool) {
|
||||
final Tools tools = myTools.get(tool.getShortName());
|
||||
if (tools != null) {
|
||||
if (tools != null && file != null) {
|
||||
for (ScopeToolState state : tools.getTools()) {
|
||||
final NamedScope namedScope = state.getScope(file.getProject());
|
||||
if (namedScope == null || namedScope.getValue().contains(file, getCurrentProfile().getProfileManager().getScopesManager())) {
|
||||
@@ -636,12 +636,12 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
InspectionToolWrapper toolWrapper = (InspectionToolWrapper)profileEntry;
|
||||
InspectionProfileEntry inspectionTool = toolWrapper.getTool();
|
||||
|
||||
if (inspectionTool instanceof LocalDummyInspectionTool) {
|
||||
if (inspectionTool instanceof DummyInspectionTool) {
|
||||
if (toolWrappers == null) {
|
||||
toolWrappers = new HashMap<String, DescriptorProviderInspection>();
|
||||
}
|
||||
|
||||
toolWrappers.put(((LocalDummyInspectionTool)inspectionTool).getProblemGroup(), toolWrapper);
|
||||
toolWrappers.put(((DummyInspectionTool)inspectionTool).getProblemGroup(), toolWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,10 @@ public class RefManagerImpl extends RefManager {
|
||||
}
|
||||
}
|
||||
|
||||
public GlobalInspectionContextImpl getContext() {
|
||||
return myContext;
|
||||
}
|
||||
|
||||
public void iterate(RefVisitor visitor) {
|
||||
myLock.readLock().lock();
|
||||
try {
|
||||
@@ -440,6 +444,9 @@ public class RefManagerImpl extends RefManager {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
refElement.initialize();
|
||||
for (RefManagerExtension extension : myExtensions.values()) {
|
||||
extension.onEntityInitialized(refElement, elem);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -84,7 +84,10 @@ public class FormattingDocumentModelImpl implements FormattingDocumentModel {
|
||||
|
||||
@Override
|
||||
public int getLineNumber(int offset) {
|
||||
LOG.assertTrue (offset <= myDocument.getTextLength());
|
||||
if (offset > myDocument.getTextLength()) {
|
||||
LOG.error(String.format("Invalid offset detected (%d). Document length: %d. Target file: %s",
|
||||
offset, myDocument.getTextLength(), myFile));
|
||||
}
|
||||
return myDocument.getLineNumber(offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
public void updateFinished(@NotNull Document doc) {
|
||||
if (doc != myEditor.getDocument() || myIsInUpdate) return;
|
||||
if (savedBeforeBulkCaretMarker != null && savedBeforeBulkCaretMarker.isValid()
|
||||
&& savedBeforeBulkCaretMarker.getStartOffset() != myOffset)
|
||||
&& savedBeforeBulkCaretMarker.getStartOffset() != myOffset && !myReportCaretMoves)
|
||||
{
|
||||
moveToOffset(savedBeforeBulkCaretMarker.getStartOffset());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
@@ -68,7 +69,13 @@ public class Restarter {
|
||||
int pid = kernel32.GetCurrentProcessId();
|
||||
|
||||
try {
|
||||
String command = "restarter " + Integer.toString(pid) + " " + cline;
|
||||
// to prevent blocking exe file during update we should copy it
|
||||
File restarterFile = new File(PathManager.getBinPath(), "restarter.exe");
|
||||
File restarterCopy = FileUtil.createTempFile("restarter", ".exe");
|
||||
|
||||
FileUtil.copy(restarterFile, restarterCopy);
|
||||
|
||||
String command = "\"" + restarterCopy + "\" " + Integer.toString(pid) + " " + cline;
|
||||
Runtime.getRuntime().exec(command, null, new File(PathManager.getBinPath()));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.util.List;
|
||||
*/
|
||||
public class InspectionDescriptionNotFoundInspection extends DevKitInspectionBase{
|
||||
@NonNls static final String INSPECTION_PROFILE_ENTRY = InspectionProfileEntry.class.getName();
|
||||
@NonNls static final String DUMMY_INSPECTION_TOOL = DummyInspectionTool.class.getName();
|
||||
@NonNls private static final String INSPECTION_DESCRIPTIONS = "inspectionDescriptions";
|
||||
|
||||
@Override
|
||||
@@ -51,8 +52,10 @@ public class InspectionDescriptionNotFoundInspection extends DevKitInspectionBas
|
||||
if (nameIdentifier == null || module == null || !PsiUtil.isInstantiatable(aClass)) return null;
|
||||
|
||||
final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INSPECTION_PROFILE_ENTRY, GlobalSearchScope.allScope(project));
|
||||
final PsiClass dummy = JavaPsiFacade.getInstance(project).findClass(DUMMY_INSPECTION_TOOL, GlobalSearchScope.allScope(project));
|
||||
|
||||
if (base == null || ! aClass.isInheritor(base, true) || isPathMethodsAreOverridden(aClass)) return null;
|
||||
if (dummy == null || aClass.isInheritor(dummy, true)) return null;
|
||||
|
||||
PsiMethod method = findNearestMethod("getShortName", aClass);
|
||||
if (method != null && method.getContainingClass().getQualifiedName().equals(INSPECTION_PROFILE_ENTRY)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class GitVcsPanel {
|
||||
|
||||
private static final String IDEA_SSH = ApplicationNamesInfo.getInstance().getProductName() + " " + GitBundle.getString("git.vcs.config.ssh.mode.idea"); // IDEA ssh value
|
||||
private static final String IDEA_SSH = GitBundle.getString("git.vcs.config.ssh.mode.idea"); // IDEA ssh value
|
||||
private static final String NATIVE_SSH = GitBundle.getString("git.vcs.config.ssh.mode.native"); // Native SSH value
|
||||
private static final String CRLF_CONVERT_TO_PROJECT = GitBundle.getString("git.vcs.config.convert.project");
|
||||
private static final String CRLF_DO_NOT_CONVERT = GitBundle.getString("git.vcs.config.convert.do.not.convert");
|
||||
|
||||
@@ -144,7 +144,7 @@ git.vcs.config.convert.tooltip=<html>Specify what to do if line separators in a
|
||||
Note that this setting has nothing common with Git autocrlf and other Git settings.\
|
||||
</html>
|
||||
git.vcs.config.path.label=Path to &Git Executable:
|
||||
git.vcs.config.ssh.mode.idea=ssh
|
||||
git.vcs.config.ssh.mode.idea=Built-in
|
||||
git.vcs.config.ssh.mode.native=Native
|
||||
git.vcs.config.ssh.mode.tooltip=<html>Specify which version of SSH to be used with Git.<ul><li><b>Native</b> means that the native SSH will be used.</li><li><b>{0} SSH</b> means that the implementation provided by the {0} will be used.</li></ul>The native implementation might cause hangups on some platforms. In native case, you also might need to configure <em>ssh-askpass</em> for your platform to receive GUI prompts for passwords.</html>
|
||||
git.vcs.config.ssh.mode=&SSH Executable:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -88,7 +88,9 @@ public class HtmlConditionalCommentInjector implements MultiHostInjector {
|
||||
ASTNode conditionalStart = pair.first;
|
||||
ASTNode conditionalEnd = pair.second;
|
||||
TextRange range = new TextRange(conditionalStart.getTextRange().getEndOffset() - startOffset, conditionalEnd.getStartOffset() - startOffset);
|
||||
registrar.startInjecting(language).addPlace(null, null, (PsiLanguageInjectionHost)host, range).doneInjecting();
|
||||
if (range.getStartOffset() < range.getEndOffset()) {
|
||||
registrar.startInjecting(language).addPlace(null, null, (PsiLanguageInjectionHost)host, range).doneInjecting();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user