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:
@@ -86,13 +86,17 @@ BITS=$?
|
||||
if [ $OPEN_JDK -eq 0 ]; then
|
||||
echo "WARNING: You are launching the IDE using OpenJDK Java runtime."
|
||||
echo
|
||||
echo " THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS!"
|
||||
echo " ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!"
|
||||
echo " SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!"
|
||||
echo
|
||||
echo "NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed"
|
||||
echo " please validate either @@product_uc@@_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
|
||||
echo " See http://ow.ly/6TuKQ for more info on switching default JDK."
|
||||
echo
|
||||
echo "Press Enter to continue."
|
||||
# ---------------------------------------------------------------------
|
||||
# COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING
|
||||
# ---------------------------------------------------------------------
|
||||
read IGNORE
|
||||
fi
|
||||
if [ $BITS -eq 0 ]; then
|
||||
@@ -141,7 +145,7 @@ if [ "$IS_EAP" = "true" ]; then
|
||||
OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'`
|
||||
AGENT_LIB="yjpagent-$OS_NAME$BITS"
|
||||
if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
|
||||
AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablecounts,disablealloc,sessionname=@@system_selector@@"
|
||||
AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,sessionname=@@system_selector@@"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ libraryLicense(name: "Maven3", libraryNames: ["Maven3", "maven-dependency-tree-1
|
||||
libraryLicense(name: "markdownj", attachedTo: "tasks-core", version: "", license: "BSD", url: "http://markdownj.org/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php")
|
||||
libraryLicense(name: "mercurial_prompthooks", attachedTo: "hg4idea", version: "", license: "GPLv2 (used as hg extension called from hg executable)", url: "https://github.com/willemv/mercurial_prompthooks", licenseUrl: "https://github.com/willemv/mercurial_prompthooks/blob/master/LICENSE.txt")
|
||||
libraryLicense(name: "Microba", libraryName: "microba", version: "0.4.2", license: "BSD", url: "http://microba.sourceforge.net/", licenseUrl: "http://microba.sourceforge.net/license.txt")
|
||||
libraryLicense(name: "MigLayout", libraryName: "miglayout-swing", version: "3.7.1", license: "BSD", url: "http://www.miglayout.com/", licenseUrl: "http://www.miglayout.com/mavensite/license.html")
|
||||
libraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng", url: "http://nanoxml.cyberelf.be/", licenseUrl: "http://devkix.com/nanoxml.php")
|
||||
libraryLicense(name: "nekohtml", libraryName: "nekohtml", version: "1.9.14", license: "Apache 2.0", url: "http://nekohtml.sourceforge.net/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0.txt")
|
||||
libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "3.3", license: "CPL 1.0", url: "http://www.eclipse.org/jdt/core/index.php")
|
||||
|
||||
@@ -60,10 +60,10 @@ binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDump
|
||||
binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() })
|
||||
binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() })
|
||||
binding.setVariable("vmOptions32yjp", { String systemSelector ->
|
||||
"${vmOptions32()} -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim()
|
||||
"${vmOptions32()} -agentlib:yjpagent=disablej2ee,disablealloc,sessionname=$systemSelector".trim()
|
||||
})
|
||||
binding.setVariable("vmOptions64yjp", { String systemSelector ->
|
||||
"${vmOptions64()} -agentlib:yjpagent64=disablej2ee,disablecounts,disablealloc,sessionname=$systemSelector".trim()
|
||||
"${vmOptions64()} -agentlib:yjpagent64=disablej2ee,disablealloc,sessionname=$systemSelector".trim()
|
||||
})
|
||||
|
||||
binding.setVariable("isDefined", {String key ->
|
||||
@@ -252,7 +252,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
|
||||
|
||||
String vmOptions = "${vmOptions()} -Xverify:none"
|
||||
if (isEap() && !args.mac_no_yjp) {
|
||||
vmOptions += " -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=${args.system_selector}"
|
||||
vmOptions += " -agentlib:yjpagent=disablej2ee,disablealloc,sessionname=${args.system_selector}"
|
||||
}
|
||||
|
||||
String version = isEap() ? "EAP $args.buildNumber" : "${p("component.version.major")}.${p("component.version.minor")}"
|
||||
|
||||
@@ -71,11 +71,20 @@ public abstract class SelectImportedProjectsStep<T> extends ProjectImportWizardS
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected boolean isElementEnabled(T element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateStep() {
|
||||
fileChooser.clear();
|
||||
for (T element : getContext().getList()) {
|
||||
fileChooser.addElement(element, getContext().isMarked(element));
|
||||
boolean isEnabled = isElementEnabled(element);
|
||||
fileChooser.addElement(element, isEnabled && getContext().isMarked(element));
|
||||
if (!isEnabled) {
|
||||
fileChooser.disableElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
fileChooser.setBorder(IdeBorderFactory.createTitledBorder(
|
||||
IdeBundle.message("project.import.select.title", getContext().getName()), false));
|
||||
openModuleSettingsCheckBox.setSelected(getBuilder().isOpenProjectSettingsAfter());
|
||||
|
||||
+7
@@ -973,6 +973,13 @@ public class GenericsHighlightUtil {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, ref, JavaErrorMessages.message("generics.cannot.instanceof.type.parameters"));
|
||||
}
|
||||
|
||||
if (resolved instanceof PsiClass) {
|
||||
final PsiClass containingClass = ((PsiClass)resolved).getContainingClass();
|
||||
if (containingClass != null && ref.getQualifier() == null && containingClass.getTypeParameters().length > 0) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, typeElement, JavaErrorMessages.message("illegal.generic.type.for.instanceof"));
|
||||
}
|
||||
}
|
||||
|
||||
final PsiType[] parameters = ref.getTypeParameters();
|
||||
for (PsiType parameterType : parameters) {
|
||||
if (parameterType != null &&
|
||||
|
||||
@@ -1506,6 +1506,10 @@ public class JavaDocInfoGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof PsiCapturedWildcardType) {
|
||||
type = ((PsiCapturedWildcardType)type).getWildcard();
|
||||
}
|
||||
|
||||
if (type instanceof PsiWildcardType){
|
||||
PsiWildcardType wt = ((PsiWildcardType)type);
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ public class DummyEntryPointsTool extends FilteringInspectionTool {
|
||||
|
||||
public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {}
|
||||
|
||||
public void exportResults(@NotNull Element parentNode) {}
|
||||
@Override
|
||||
public void exportResults(@NotNull Element parentNode, RefEntity refEntity) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JobDescriptor[] getJobDescriptors(GlobalInspectionContext globalInspectionContext) {
|
||||
|
||||
+34
-36
@@ -631,45 +631,43 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
return myComposer;
|
||||
}
|
||||
|
||||
public void exportResults(@NotNull final Element parentNode) {
|
||||
@Override
|
||||
public void exportResults(@NotNull final Element parentNode, RefEntity refEntity) {
|
||||
if (!(refEntity instanceof RefJavaElement)) return;
|
||||
final WeakUnreferencedFilter filter = new WeakUnreferencedFilter(this);
|
||||
getRefManager().iterate(new RefJavaVisitor() {
|
||||
@Override public void visitElement(RefEntity refEntity) {
|
||||
if (!(refEntity instanceof RefJavaElement)) return;
|
||||
if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
|
||||
if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass();
|
||||
Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
|
||||
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
|
||||
if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
|
||||
if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass();
|
||||
Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
|
||||
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
|
||||
|
||||
if (refEntity instanceof RefElement) {
|
||||
final RefElement refElement = (RefElement)refEntity;
|
||||
final HighlightSeverity severity = getCurrentSeverity(refElement);
|
||||
final String attributeKey = getTextAttributeKey(refElement.getElement().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
problemClassElement.setAttribute("severity", severity.myName);
|
||||
problemClassElement.setAttribute("attribute_key", attributeKey);
|
||||
}
|
||||
|
||||
problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code"));
|
||||
element.addContent(problemClassElement);
|
||||
|
||||
@NonNls Element hintsElement = new Element("hints");
|
||||
|
||||
for (String hint : HINTS) {
|
||||
@NonNls Element hintElement = new Element("hint");
|
||||
hintElement.setAttribute("value", hint);
|
||||
hintsElement.addContent(hintElement);
|
||||
}
|
||||
element.addContent(hintsElement);
|
||||
|
||||
|
||||
Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
|
||||
StringBuffer buf = new StringBuffer();
|
||||
DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf);
|
||||
descriptionElement.addContent(buf.toString());
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
if (refEntity instanceof RefElement) {
|
||||
final RefElement refElement = (RefElement)refEntity;
|
||||
final HighlightSeverity severity = getCurrentSeverity(refElement);
|
||||
final String attributeKey =
|
||||
getTextAttributeKey(refElement.getElement().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
problemClassElement.setAttribute("severity", severity.myName);
|
||||
problemClassElement.setAttribute("attribute_key", attributeKey);
|
||||
}
|
||||
});
|
||||
|
||||
problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code"));
|
||||
element.addContent(problemClassElement);
|
||||
|
||||
@NonNls Element hintsElement = new Element("hints");
|
||||
|
||||
for (String hint : HINTS) {
|
||||
@NonNls Element hintElement = new Element("hint");
|
||||
hintElement.setAttribute("value", hint);
|
||||
hintsElement.addContent(hintElement);
|
||||
}
|
||||
element.addContent(hintsElement);
|
||||
|
||||
|
||||
Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
|
||||
StringBuffer buf = new StringBuffer();
|
||||
DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf);
|
||||
descriptionElement.addContent(buf.toString());
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
}
|
||||
|
||||
public QuickFixAction[] getQuickFixes(final RefEntity[] refElements) {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
if (refConstructor == null) { // No explicit constructor referenced. Should use default one.
|
||||
PsiType newType = newExpr.getType();
|
||||
if (newType instanceof PsiClassType) {
|
||||
processClassReference(PsiUtil.resolveClassInType(newType), refFrom, psiFrom);
|
||||
processClassReference(PsiUtil.resolveClassInType(newType), refFrom, psiFrom, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,22 +124,38 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
final PsiTypeElement operand = expression.getOperand();
|
||||
final PsiType type = operand.getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
processClassReference(((PsiClassType)type).resolve(), refFrom, psiFrom);
|
||||
processClassReference(((PsiClassType)type).resolve(), refFrom, psiFrom, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void processClassReference(final PsiClass psiClass, final RefJavaElementImpl refFrom, final PsiModifierListOwner psiFrom) {
|
||||
private void processClassReference(final PsiClass psiClass,
|
||||
final RefJavaElementImpl refFrom,
|
||||
final PsiModifierListOwner psiFrom,
|
||||
boolean defaultConstructorOnly) {
|
||||
if (psiClass != null) {
|
||||
RefClassImpl refClass = (RefClassImpl)refFrom.getRefManager().getReference(psiClass);
|
||||
|
||||
if (refClass != null) {
|
||||
RefMethodImpl refDefaultConstructor = (RefMethodImpl)refClass.getDefaultConstructor();
|
||||
boolean hasConstructorsMarked = false;
|
||||
|
||||
if (refDefaultConstructor != null && !(refDefaultConstructor instanceof RefImplicitConstructor)) {
|
||||
refDefaultConstructor.addInReference(refFrom);
|
||||
refFrom.addOutReference(refDefaultConstructor);
|
||||
if (defaultConstructorOnly) {
|
||||
RefMethodImpl refDefaultConstructor = (RefMethodImpl)refClass.getDefaultConstructor();
|
||||
if (refDefaultConstructor != null && !(refDefaultConstructor instanceof RefImplicitConstructor)) {
|
||||
refDefaultConstructor.addInReference(refFrom);
|
||||
refFrom.addOutReference(refDefaultConstructor);
|
||||
hasConstructorsMarked = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (RefMethod cons : refClass.getConstructors()) {
|
||||
if (cons instanceof RefImplicitConstructor) continue;
|
||||
((RefMethodImpl)cons).addInReference(refFrom);
|
||||
refFrom.addOutReference(cons);
|
||||
hasConstructorsMarked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasConstructorsMarked) {
|
||||
refFrom.addReference(refClass, psiClass, psiFrom, false, true, null);
|
||||
}
|
||||
}
|
||||
@@ -385,4 +401,4 @@ public class RefJavaUtilImpl extends RefJavaUtil{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class A<T> {
|
||||
public void foo(Object object) {
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">B</error>) {}
|
||||
if (object instanceof A.B) {}
|
||||
if (object instanceof A<?>.B) {}
|
||||
if (object instanceof A<?>) {}
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">A<String></error>) {}
|
||||
if (object instanceof A) {}
|
||||
if (object instanceof A[]) {}
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">B[]</error>) {}
|
||||
if (object instanceof A.B[]) {}
|
||||
}
|
||||
|
||||
private class B {
|
||||
}
|
||||
}
|
||||
|
||||
class A1 {
|
||||
public void foo(Object object) {
|
||||
if (object instanceof B1) {}
|
||||
if (object instanceof A1.B1) {}
|
||||
if (object instanceof B1[]) {}
|
||||
}
|
||||
|
||||
private class B1 {
|
||||
}
|
||||
}
|
||||
+27
@@ -1,3 +1,4 @@
|
||||
import java.lang.Override;
|
||||
import java.util.*;
|
||||
class GenericsTest<T> {
|
||||
|
||||
@@ -91,4 +92,30 @@ class GenericsTest2<T> {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
class Example {
|
||||
private static <T> void assertThat(T actual, Matcher<? super T> matcher) {
|
||||
assert actual != null;
|
||||
assert matcher != null;
|
||||
}
|
||||
|
||||
private static <E> Matcher<? super Collection<? extends E>> hasSize(int size) {
|
||||
assert size >=0;
|
||||
return new Matcher<Collection<? extends E>>() {
|
||||
@Override
|
||||
public void foo(Collection<? extends E> es) {
|
||||
System.out.println(es);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Boolean> list = <warning descr="Unchecked assignment: 'java.util.ArrayList' to 'java.util.List<java.lang.Boolean>'">new ArrayList()</warning>;
|
||||
System.out.println(list);
|
||||
assertThat(new ArrayList<Boolean>(), hasSize(0));
|
||||
}
|
||||
|
||||
private interface Matcher<T> {
|
||||
void foo(T t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.lang.Class;
|
||||
import java.lang.String;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
Test.class.getDeclaredConstructor(String.class).newInstance("Foo");
|
||||
}
|
||||
|
||||
public Test(String param) {
|
||||
System.out.println("This is used!");
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA74899() throws Exception {doTest(false);}
|
||||
public void testIDEA63291() throws Exception {doTest(false);}
|
||||
public void testIDEA72912() throws Exception {doTest(false);}
|
||||
public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
@@ -184,4 +184,8 @@ public class UnusedDeclarationTest extends InspectionTestCase {
|
||||
public void testAbstractClassWithSerializableSubclasses() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testclassLiteralRef() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,20 +379,19 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
findModel.setWholeWordsOnly(false);
|
||||
assertSize(2, findUsages(findModel));
|
||||
|
||||
/* todo
|
||||
findModel.setWholeWordsOnly(true);
|
||||
assertSize(2, findUsages(findModel));
|
||||
*/
|
||||
}
|
||||
|
||||
public void testLocalScopeSearchPerformance() throws Exception {
|
||||
final int count = 3000;
|
||||
public void testLocalScopeSearchPerformance() throws Throwable {
|
||||
final int fileCount = 3000;
|
||||
final int lineCount = 500;
|
||||
TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
|
||||
fixture.setUp();
|
||||
|
||||
try {
|
||||
String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount);
|
||||
for (int i = 0; i < fileCount; i++) {
|
||||
fixture.createFile("a" + i + ".txt", sampleText);
|
||||
}
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));
|
||||
@@ -409,15 +408,15 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
ThrowableRunnable test = new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
assertSize(count, findUsages(findModel));
|
||||
assertSize(lineCount, findUsages(findModel));
|
||||
}
|
||||
};
|
||||
|
||||
findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
|
||||
PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming();
|
||||
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
|
||||
|
||||
findModel.setCustomScope(new LocalSearchScope(psiFile));
|
||||
PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming();
|
||||
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
|
||||
}
|
||||
finally {
|
||||
fixture.tearDown();
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
Date: 16 Apr 2012
|
||||
Changed classes:
|
||||
gnu.trove.THash
|
||||
gnu.trove.TPrimitiveHash
|
||||
gnu.trove.TObjectHash
|
||||
gnu.trove.TIterator
|
||||
gnu.trove.benchmark.Main
|
||||
and many others
|
||||
- implement autocompact on removing keys. Failure to do so leads to linear access time
|
||||
|
||||
Date: 15 Jan 2008
|
||||
Changed classes:
|
||||
gnu.trove.THashMap - fixed bug in put() method for null value
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
Copyright (c) 2011 MiG InfoCom AB
|
||||
All rights reserved.
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -35,8 +35,6 @@ public class ProjectScopeImpl extends GlobalSearchScope {
|
||||
public boolean contains(VirtualFile file) {
|
||||
if (file instanceof VirtualFileWindow) return true;
|
||||
|
||||
if (myFileIndex.isInLibraryClasses(file) && !myFileIndex.isInSourceContent(file)) return false;
|
||||
|
||||
return myFileIndex.isInContent(file);
|
||||
}
|
||||
|
||||
|
||||
+17
-11
@@ -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.
|
||||
@@ -133,28 +133,34 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP
|
||||
|
||||
@Override
|
||||
protected boolean dressDescription(@NotNull final Editor editor) {
|
||||
final String[] problems = UIUtil.getHtmlBody(myText).split(BORDER_LINE);
|
||||
final List<String> problems = StringUtil.split(UIUtil.getHtmlBody(myText), BORDER_LINE);
|
||||
String text = "";
|
||||
for (String problem : problems) {
|
||||
final String ref = getLinkRef(problem);
|
||||
if (ref != null) {
|
||||
String description = TooltipLinkHandlerEP.getDescription(ref, editor);
|
||||
if (description != null) {
|
||||
final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL);
|
||||
final Matcher matcher = pattern.matcher(description);
|
||||
int startFindIdx = 0;
|
||||
while (matcher.find(startFindIdx)) {
|
||||
final int end = matcher.end(1);
|
||||
startFindIdx = end;
|
||||
description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end);
|
||||
description = UIUtil.getHtmlBody(description);
|
||||
final int descriptionEnd = description.indexOf("<!-- tooltip end -->");
|
||||
if (descriptionEnd < 0) {
|
||||
final Pattern pattern = Pattern.compile(".*Use.*(the (panel|checkbox|checkboxes|field|button|controls).*below).*", Pattern.DOTALL);
|
||||
final Matcher matcher = pattern.matcher(description);
|
||||
int startFindIdx = 0;
|
||||
while (matcher.find(startFindIdx)) {
|
||||
final int end = matcher.end(1);
|
||||
startFindIdx = end;
|
||||
description = description.substring(0, matcher.start(1)) + " inspection settings " + description.substring(end);
|
||||
}
|
||||
} else {
|
||||
description = description.substring(0, descriptionEnd);
|
||||
}
|
||||
text += UIUtil.getHtmlBody(problem).replace(DaemonBundle.message("inspection.extended.description"),
|
||||
DaemonBundle.message("inspection.collapse.description")) +
|
||||
BORDER_LINE + UIUtil.getHtmlBody(description) + BORDER_LINE;
|
||||
BORDER_LINE + description + BORDER_LINE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (text.length() > 0) { //otherwise do not change anything
|
||||
if (!text.isEmpty()) { //otherwise do not change anything
|
||||
myText = "<html><body>" + StringUtil.trimEnd(text, BORDER_LINE) + "</body></html>";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,14 @@ package com.intellij.codeInsight.lookup.impl;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.ui.HeavyweightHint;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -36,6 +39,17 @@ public class CompletionExtender extends HeavyweightHint {
|
||||
myElement = element;
|
||||
myLookup = lookup;
|
||||
myIndex = myLookup.getList().getSelectedIndex();
|
||||
myLookup.getComponent().addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
recalculateLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
recalculateLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public LookupElement getLookupElement() {
|
||||
@@ -74,6 +88,18 @@ public class CompletionExtender extends HeavyweightHint {
|
||||
return false;
|
||||
}
|
||||
|
||||
void recalculateLocation() {
|
||||
if (!isVisible()) return;
|
||||
final JList list = myLookup.getList();
|
||||
final Point p = list.getLocationOnScreen();
|
||||
p.y += list.indexToLocation(list.getSelectedIndex()).y;
|
||||
final JComponent rootPane = UIUtil.getRootPane(myLookup.getEditor().getContentComponent());
|
||||
if (rootPane != null) {
|
||||
SwingUtilities.convertPointFromScreen(p, rootPane);
|
||||
setLocation(new RelativePoint(rootPane, p));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.GlobalInspectionContext;
|
||||
import com.intellij.codeInspection.InspectionEP;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.codeInspection.reference.RefVisitor;
|
||||
import com.intellij.codeInspection.ui.InspectionNode;
|
||||
import com.intellij.codeInspection.ui.InspectionTreeNode;
|
||||
import org.jdom.Element;
|
||||
@@ -111,7 +112,7 @@ public class CommonInspectionToolWrapper extends InspectionToolWrapper<Inspectio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportResults(@NotNull Element parentNode) {
|
||||
getTool().exportResults(parentNode);
|
||||
public void exportResults(@NotNull Element parentNode, RefEntity refEntity) {
|
||||
getTool().exportResults(parentNode, refEntity);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-13
@@ -20,7 +20,6 @@ import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.codeInspection.reference.RefModule;
|
||||
import com.intellij.codeInspection.reference.RefVisitor;
|
||||
import com.intellij.codeInspection.ui.ProblemDescriptionNode;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
@@ -105,7 +104,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
final File file = new File(fileName);
|
||||
final CharArrayWriter writer = new CharArrayWriter();
|
||||
if (!file.exists()) {
|
||||
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" is_local_tool=\"")
|
||||
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextImpl.LOCAL_TOOL_ATTRIBUTE + "=\"")
|
||||
.append(Boolean.toString(this instanceof LocalInspectionToolWrapper)).append("\">\n");
|
||||
}
|
||||
for (Object o : list) {
|
||||
@@ -263,19 +262,16 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
return myComposer;
|
||||
}
|
||||
|
||||
public void exportResults(@NotNull final Element parentNode) {
|
||||
getRefManager().iterate(new RefVisitor() {
|
||||
@Override public void visitElement(final RefEntity refEntity) {
|
||||
synchronized (lock) {
|
||||
if (getProblemElements().containsKey(refEntity)) {
|
||||
CommonProblemDescriptor[] descriptions = getDescriptions(refEntity);
|
||||
if (descriptions != null) {
|
||||
exportResults(descriptions, refEntity, parentNode);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void exportResults(final @NotNull Element parentNode, RefEntity refEntity) {
|
||||
synchronized (lock) {
|
||||
if (getProblemElements().containsKey(refEntity)) {
|
||||
CommonProblemDescriptor[] descriptions = getDescriptions(refEntity);
|
||||
if (descriptions != null) {
|
||||
exportResults(descriptions, refEntity, parentNode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void exportResults(@NotNull final CommonProblemDescriptor[] descriptions, final RefEntity refEntity, final Element parentNode) {
|
||||
|
||||
+34
-14
@@ -105,6 +105,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
private final Map<String, Tools> myTools = new THashMap<String, Tools>();
|
||||
|
||||
private AnalysisUIOptions myUIOptions;
|
||||
@NonNls static final String LOCAL_TOOL_ATTRIBUTE = "is_local_tool";
|
||||
|
||||
public GlobalInspectionContextImpl(Project project, NotNullLazyValue<ContentManager> contentManager) {
|
||||
myProject = project;
|
||||
@@ -296,44 +297,63 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
|
||||
public void run() {
|
||||
performInspectionsWithProgress(scope, manager);
|
||||
@NonNls final String ext = ".xml";
|
||||
final Map<Element, Tools> globalTools = new HashMap<Element, Tools>();
|
||||
for (Map.Entry<String,Tools> stringSetEntry : myTools.entrySet()) {
|
||||
final Element root = new Element(InspectionsBundle.message("inspection.problems"));
|
||||
final Document doc = new Document(root);
|
||||
final Tools sameTools = stringSetEntry.getValue();
|
||||
boolean hasProblems = false;
|
||||
boolean isLocalTool = false;
|
||||
String toolName = stringSetEntry.getKey();
|
||||
if (sameTools != null) {
|
||||
for (ScopeToolState toolDescr : sameTools.getTools()) {
|
||||
final InspectionTool tool = (InspectionTool)toolDescr.getTool();
|
||||
if (tool instanceof LocalInspectionToolWrapper) {
|
||||
hasProblems = new File(outputPath, toolName + ext).exists();
|
||||
isLocalTool = true;
|
||||
}
|
||||
else {
|
||||
tool.updateContent();
|
||||
if (tool.hasReportedProblems()) {
|
||||
hasProblems = true;
|
||||
tool.exportResults(root);
|
||||
final Element root = new Element(InspectionsBundle.message("inspection.problems"));
|
||||
globalTools.put(root, sameTools);
|
||||
LOG.assertTrue(!hasProblems, toolName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasProblems) continue;
|
||||
@NonNls final String isLocalToolAttribute = "is_local_tool";
|
||||
root.setAttribute(isLocalToolAttribute, String.valueOf(isLocalTool));
|
||||
try {
|
||||
new File(outputPath).mkdirs();
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
if (isLocalTool) {
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes("UTF-8"), true);
|
||||
}
|
||||
else {
|
||||
PathMacroManager.getInstance(getProject()).collapsePaths(doc.getRootElement());
|
||||
JDOMUtil.writeDocument(doc, file, "\n");
|
||||
FileUtil.writeToFile(file, ("</" + InspectionsBundle.message("inspection.problems") + ">").getBytes("UTF-8"), true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
getRefManager().iterate(new RefVisitor() {
|
||||
@Override
|
||||
public void visitElement(final RefEntity refEntity) {
|
||||
for (Element element : globalTools.keySet()) {
|
||||
final Tools tools = globalTools.get(element);
|
||||
for (ScopeToolState state : tools.getTools()) {
|
||||
((InspectionTool)state.getTool()).exportResults(element, refEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Element element : globalTools.keySet()) {
|
||||
final String toolName = globalTools.get(element).getShortName();
|
||||
element.setAttribute(LOCAL_TOOL_ATTRIBUTE, Boolean.toString(false));
|
||||
final Document doc = new Document(element);
|
||||
PathMacroManager.getInstance(getProject()).collapsePaths(doc.getRootElement());
|
||||
try {
|
||||
new File(outputPath).mkdirs();
|
||||
final File file = new File(outputPath, toolName + ext);
|
||||
inspectionsResults.add(file);
|
||||
JDOMUtil.writeDocument(doc, file, "\n");
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.codeInspection.reference.RefManager;
|
||||
import com.intellij.codeInspection.reference.RefModule;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.codeInspection.ui.InspectionNode;
|
||||
import com.intellij.codeInspection.ui.InspectionTreeNode;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
@@ -69,7 +66,16 @@ public abstract class InspectionTool extends InspectionProfileEntry {
|
||||
|
||||
public abstract void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager);
|
||||
|
||||
public abstract void exportResults(@NotNull Element parentNode);
|
||||
public void exportResults(@NotNull final Element parentNode) {
|
||||
getRefManager().iterate(new RefVisitor(){
|
||||
@Override
|
||||
public void visitElement(RefEntity elem) {
|
||||
exportResults(parentNode, elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract void exportResults(@NotNull Element parentNode, RefEntity refEntity);
|
||||
|
||||
public abstract boolean isGraphNeeded();
|
||||
@Nullable
|
||||
|
||||
@@ -78,6 +78,7 @@ com.siyeh.ig.classlayout.EmptyClassInspection
|
||||
com.siyeh.ig.classlayout.InnerClassOnInterfaceInspection
|
||||
com.siyeh.ig.classlayout.ListenerMayUseAdapterInspection
|
||||
com.siyeh.ig.classlayout.MissingOverrideAnnotationInspection
|
||||
com.siyeh.ig.classlayout.UtilityClassInspection
|
||||
com.siyeh.ig.classlayout.UtilityClassWithoutPrivateConstructorInspection
|
||||
com.siyeh.ig.classmetrics.AnonymousClassComplexityInspection
|
||||
com.siyeh.ig.classmetrics.AnonymousClassMethodCountInspection
|
||||
|
||||
@@ -439,7 +439,17 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
if (!(settings.getConfiguration() instanceof UnknownRunConfiguration)) {
|
||||
final List<BeforeRunTask> tasks = getBeforeRunTasks(settings.getConfiguration());
|
||||
final Element methodsElement = new Element(METHOD);
|
||||
Map<Key<BeforeRunTask>,BeforeRunTask> templateTasks = null;
|
||||
if (!settings.isTemplate()) {
|
||||
List<BeforeRunTask> beforeRunTasks = getBeforeRunTasks(getConfigurationTemplate(settings.getFactory()).getConfiguration());
|
||||
templateTasks = new HashMap<Key<BeforeRunTask>, BeforeRunTask>();
|
||||
for (BeforeRunTask task : beforeRunTasks) {
|
||||
templateTasks.put(task.getProviderId(), task);
|
||||
}
|
||||
}
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (templateTasks != null && task.equals(templateTasks.get(task.getProviderId())))
|
||||
continue; // not neccesary saving if the task is the same as template
|
||||
final Element child = new Element(OPTION);
|
||||
child.setAttribute(NAME_ATTR, task.getProviderId().toString());
|
||||
task.writeExternal(child);
|
||||
@@ -793,7 +803,11 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
List<BeforeRunTask> tasks = getBeforeRunTasks(settings);
|
||||
List<BeforeRunTask> tasks = myConfigurationToBeforeTasksMap.get(settings);
|
||||
if (tasks == null) {
|
||||
tasks = getBeforeRunTasks(settings);
|
||||
myConfigurationToBeforeTasksMap.put(settings, tasks);
|
||||
}
|
||||
List<T> result = new ArrayList<T>();
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (task.getProviderId() == taskProviderID)
|
||||
@@ -859,7 +873,20 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, List<BeforeRunTask> tasks) {
|
||||
myConfigurationToBeforeTasksMap.put(runConfiguration, tasks);
|
||||
List<BeforeRunTask> templates = getBeforeRunTasks(runConfiguration);//here may be some disabled templates
|
||||
Set<Key<BeforeRunTask>> idsToSet = new HashSet<Key<BeforeRunTask>>();
|
||||
List<BeforeRunTask> result = new ArrayList<BeforeRunTask>(tasks);
|
||||
for (BeforeRunTask task : tasks) {
|
||||
idsToSet.add(task.getProviderId());
|
||||
}
|
||||
int i = 0;
|
||||
for (BeforeRunTask template : templates) {
|
||||
if (!idsToSet.contains(template.getProviderId())) {
|
||||
result.add(i, template);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
myConfigurationToBeforeTasksMap.put(runConfiguration, result);
|
||||
fireBeforeRunTasksUpdated();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public class CloneElementAction extends CopyElementAction {
|
||||
}
|
||||
|
||||
protected void updateForToolWindow(String id, DataContext dataContext,Presentation presentation) {
|
||||
if (!ToolWindowId.COMMANDER.equals(id)) {
|
||||
presentation.setVisible(false);
|
||||
return;
|
||||
}
|
||||
// work only with single selection
|
||||
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
|
||||
presentation.setEnabled(elements != null && elements.length == 1 && CopyHandler.canClone(elements));
|
||||
presentation.setVisible(true);
|
||||
|
||||
if (!ToolWindowId.COMMANDER.equals(id)) {
|
||||
presentation.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ public class BookmarksAction extends AnAction implements DumbAware {
|
||||
myFile = PlatformDataKeys.VIRTUAL_FILE.getData(myDataContext);
|
||||
myLine = -1;
|
||||
|
||||
if (myBookmarkAtPlace == null) {
|
||||
if (myBookmarkAtPlace == null && myFile != null) {
|
||||
myBookmarkAtPlace = bookmarkManager.findFileBookmark(myFile);
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -34,6 +34,13 @@ public class InspectionsConfigTreeComparator implements Comparator<InspectionCon
|
||||
if (userObject1 instanceof String && userObject2 instanceof String) {
|
||||
s1 = (String)userObject1;
|
||||
s2 = (String)userObject2;
|
||||
} else {
|
||||
if (userObject1 instanceof String) return -1;
|
||||
if (userObject2 instanceof String) return 1;
|
||||
}
|
||||
|
||||
if (s1 != null) {
|
||||
return getDisplayTextToSort(s1).compareToIgnoreCase(getDisplayTextToSort(s2));
|
||||
}
|
||||
|
||||
final Descriptor descriptor1 = o1.getDesriptor();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class CopyHandler {
|
||||
if (elements.length > 0) {
|
||||
final CopyHandlerDelegate[] copyHandlers = Extensions.getExtensions(CopyHandlerDelegate.EP_NAME);
|
||||
for (CopyHandlerDelegate delegate : copyHandlers) {
|
||||
if (delegate.canCopy(elements)) {
|
||||
if (delegate instanceof CopyHandlerDelegateBase ? ((CopyHandlerDelegateBase)delegate).canCopy(elements, true) : delegate.canCopy(elements)) {
|
||||
if (delegate instanceof CopyHandlerDelegateBase && ((CopyHandlerDelegateBase)delegate).forbidToClone(elements, true)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Tool implements SchemeElement {
|
||||
@@ -300,7 +301,15 @@ public class Tool implements SchemeElement {
|
||||
commandLine.setWorkDirectory(MacroManager.getInstance().expandMacrosInString(workingDir, false, dataContext));
|
||||
exePath = MacroManager.getInstance().expandMacrosInString(exePath, false, dataContext);
|
||||
if (exePath == null) return null;
|
||||
commandLine.setExePath(exePath);
|
||||
|
||||
File exeFile = new File(exePath);
|
||||
if (exeFile.isDirectory() && exeFile.getName().endsWith(".app")) {
|
||||
commandLine.setExePath("open");
|
||||
commandLine.getParametersList().prependAll("-a", exePath);
|
||||
}
|
||||
else {
|
||||
commandLine.setExePath(exePath);
|
||||
}
|
||||
}
|
||||
catch (Macro.ExecutionCancelledException e) {
|
||||
return null;
|
||||
|
||||
@@ -21,9 +21,10 @@ import com.intellij.ide.macro.MacroManager;
|
||||
import com.intellij.ide.macro.MacrosDialog;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.fileChooser.PathChooserDialog;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
@@ -34,6 +35,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.util.Consumer;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
@@ -42,6 +44,7 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ToolEditorDialog extends DialogWrapper {
|
||||
private final JTextField myNameField = new JTextField();
|
||||
@@ -179,7 +182,7 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private JPanel createCommandPane() {
|
||||
JPanel pane = new JPanel(new GridBagLayout());
|
||||
final JPanel pane = new JPanel(new GridBagLayout());
|
||||
pane.setBorder(IdeBorderFactory.createTitledBorder(ToolsBundle.message("tools.tool.group"), true));
|
||||
GridBagConstraints constr;
|
||||
|
||||
@@ -196,18 +199,24 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
browseCommandButton.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
|
||||
if (file != null) {
|
||||
myTfCommand.setText(file.getPresentableUrl());
|
||||
String workingDirectory = myTfCommandWorkingDirectory.getText();
|
||||
if (workingDirectory == null || workingDirectory.length() == 0){
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null && parent.isDirectory()) {
|
||||
myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
|
||||
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
|
||||
chooser.choose(null, new Consumer<List<VirtualFile>>() {
|
||||
@Override
|
||||
public void consume(List<VirtualFile> files) {
|
||||
VirtualFile file = files.size() > 0 ? files.get(0) : null;
|
||||
if (file != null) {
|
||||
myTfCommand.setText(file.getPresentableUrl());
|
||||
String workingDirectory = myTfCommandWorkingDirectory.getText();
|
||||
if (workingDirectory == null || workingDirectory.length() == 0){
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null && parent.isDirectory()) {
|
||||
myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -276,10 +285,17 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
|
||||
if (file != null) {
|
||||
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
|
||||
}
|
||||
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
|
||||
|
||||
chooser.choose(null, new Consumer<List<VirtualFile>>() {
|
||||
@Override
|
||||
public void consume(List<VirtualFile> files) {
|
||||
VirtualFile file = files.size() > 0 ? files.get(0) : null;
|
||||
if (file != null) {
|
||||
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -463,4 +479,4 @@ public class ToolEditorDialog extends DialogWrapper {
|
||||
if (s.length() == 0) return null;
|
||||
return s.replace('/', File.separatorChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ public class FileChooserDescriptor implements Cloneable {
|
||||
|
||||
@Nullable
|
||||
public final VirtualFile getFileToSelect(VirtualFile file) {
|
||||
if (file.isDirectory() && myChooseFolders) {
|
||||
if (file.isDirectory() && (myChooseFolders || isFileSelectable(file))) {
|
||||
return file;
|
||||
}
|
||||
boolean isJar = file.getFileType() == FileTypes.ARCHIVE;
|
||||
|
||||
+16
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.fileChooser;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.UIBundle;
|
||||
|
||||
@@ -39,6 +40,21 @@ public class FileChooserDescriptorFactory {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false);
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleFileOrExecutableAppDescriptor() {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileSelectable(VirtualFile file) {
|
||||
if (super.isFileSelectable(file)) return true;
|
||||
|
||||
if (SystemInfo.isMac && file.isDirectory() && "app".equals(file.getExtension())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleLocalFileDescriptor() {
|
||||
return new FileChooserDescriptor(true, true, true, true, false, false);
|
||||
}
|
||||
|
||||
+78
-6
@@ -130,9 +130,11 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
new SynchronousQueue<Runnable>(),
|
||||
new ThreadFactory() {
|
||||
int i;
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
final int count = myAliveThreads.incrementAndGet();
|
||||
final Thread thread = new Thread(r, "ApplicationImpl pooled thread "+i++) {
|
||||
@Override
|
||||
public void interrupt() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Interrupted worker, will remove from pool");
|
||||
@@ -140,6 +142,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
super.interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
super.run();
|
||||
@@ -166,18 +169,20 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
private Boolean myActive;
|
||||
|
||||
private static final ThreadLocal<Integer> ourEdtSafe = new ThreadLocal<Integer>();
|
||||
private static final ModalityState ANY = new ModalityState() {
|
||||
@NonNls private static final ModalityState ANY = new ModalityState() {
|
||||
@Override
|
||||
public boolean dominates(@NotNull ModalityState anotherState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ANY";
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void bootstrapPicoContainer() {
|
||||
super.bootstrapPicoContainer();
|
||||
getPicoContainer().registerComponentImplementation(IComponentStore.class, StoresFactory.getApplicationStoreClass());
|
||||
@@ -260,7 +265,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
registerFont("/fonts/Inconsolata.ttf");
|
||||
}
|
||||
|
||||
private void registerFont(String name) {
|
||||
private void registerFont(@NonNls String name) {
|
||||
if (isHeadlessEnvironment()) return;
|
||||
|
||||
InputStream is = null;
|
||||
@@ -271,7 +276,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
@@ -287,11 +293,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
ShutDownTracker.getInstance(); // Necessary to avoid creating an instance while already shutting down.
|
||||
|
||||
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isDisposed() || isDisposeInProgress()) {
|
||||
return;
|
||||
}
|
||||
ShutDownTracker.invokeAndWait(isUnitTestMode(), true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (ApplicationManager.getApplication() != ApplicationImpl.this) return;
|
||||
try {
|
||||
@@ -299,7 +307,9 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
saveAll();
|
||||
}
|
||||
finally {
|
||||
disposeSelf(true);
|
||||
if (!disposeSelf(true)) {
|
||||
myDisposeInProgress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -313,6 +323,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) {
|
||||
try {
|
||||
commandProcessor.executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ProjectManagerImpl manager = (ProjectManagerImpl)ProjectManagerEx.getInstanceEx();
|
||||
if (!manager.closeProject(project, true, true, checkCanCloseProject)) {
|
||||
@@ -325,7 +336,6 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
LOG.error(e);
|
||||
}
|
||||
if (!canClose.get()) {
|
||||
myDisposeInProgress = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -335,11 +345,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean holdsReadLock() {
|
||||
return myActionsLock.isReadLockAcquired();
|
||||
}
|
||||
@@ -406,14 +418,17 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MutablePicoContainer createPicoContainer() {
|
||||
return Extensions.getRootArea().getPicoContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInternal() {
|
||||
return myIsInternal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnitTestMode() {
|
||||
return myTestModeFlag;
|
||||
}
|
||||
@@ -422,16 +437,20 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
myTestModeFlag = testModeFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeadlessEnvironment() {
|
||||
return myHeadlessMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandLine() {
|
||||
return myCommandLineMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<?> executeOnPooledThread(@NotNull final Runnable action) {
|
||||
return ourThreadExecutorsService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
action.run();
|
||||
@@ -453,6 +472,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
@Override
|
||||
public <T> Future<T> executeOnPooledThread(@NotNull final Callable<T> action) {
|
||||
return ourThreadExecutorsService.submit(new Callable<T>() {
|
||||
@Override
|
||||
public T call() {
|
||||
try {
|
||||
return action.call();
|
||||
@@ -474,32 +494,39 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
|
||||
private static Thread ourDispatchThread = null;
|
||||
|
||||
@Override
|
||||
public boolean isDispatchThread() {
|
||||
return EventQueue.isDispatchThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityInvokator getInvokator() {
|
||||
return myInvokator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invokeLater(@NotNull final Runnable runnable) {
|
||||
myInvokator.invokeLater(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeLater(@NotNull final Runnable runnable, @NotNull final Condition expired) {
|
||||
myInvokator.invokeLater(runnable, expired);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state) {
|
||||
myInvokator.invokeLater(runnable, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition expired) {
|
||||
myInvokator.invokeLater(runnable, state, expired);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(String path) throws IOException, InvalidDataException {
|
||||
getStateStore().setOptionsPath(path);
|
||||
getStateStore().setConfigPath(PathManager.getConfigPath());
|
||||
@@ -564,6 +591,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
fireApplicationExiting();
|
||||
|
||||
@@ -584,6 +612,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process,
|
||||
@NotNull String progressTitle,
|
||||
boolean canBeCanceled,
|
||||
@@ -591,6 +620,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return runProcessWithProgressSynchronously(process, progressTitle, canBeCanceled, project, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process,
|
||||
@NotNull final String progressTitle,
|
||||
final boolean canBeCanceled,
|
||||
@@ -599,6 +629,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return runProcessWithProgressSynchronously(process, progressTitle, canBeCanceled, project, parentComponent, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runProcessWithProgressSynchronously(@NotNull final Runnable process,
|
||||
@NotNull final String progressTitle,
|
||||
final boolean canBeCanceled,
|
||||
@@ -627,12 +658,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
myExceptionalThreadWithReadAccessRunnable = process;
|
||||
final boolean[] threadStarted = {false};
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myExceptionalThreadWithReadAccessRunnable != process) {
|
||||
LOG.error("myExceptionalThreadWithReadAccessRunnable != process, process = " + myExceptionalThreadWithReadAccessRunnable);
|
||||
}
|
||||
|
||||
executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myExceptionalThreadWithReadAccessRunnable != process) {
|
||||
LOG.error("myExceptionalThreadWithReadAccessRunnable != process, process = " + myExceptionalThreadWithReadAccessRunnable);
|
||||
@@ -674,6 +707,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return !progress.isCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInModalProgressThread() {
|
||||
if (myExceptionalThreadWithReadAccessRunnable == null || !isExceptionalThreadWithReadAccess()) {
|
||||
return false;
|
||||
@@ -682,6 +716,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return progressIndicator.isModal() && ((ProgressIndicatorEx)progressIndicator).isModalityEntered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeAndWait(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
if (isDispatchThread()) {
|
||||
LOG.error("invokeAndWait must not be called from event queue thread");
|
||||
@@ -701,12 +736,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
LaterInvocator.invokeAndWait(runnable, modalityState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityState getCurrentModalityState() {
|
||||
Object[] entities = LaterInvocator.getCurrentModalEntities();
|
||||
return entities.length > 0 ? new ModalityStateEx(entities) : getNoneModalityState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityState getModalityStateForComponent(@NotNull Component c) {
|
||||
Window window = c instanceof Window ? (Window)c : SwingUtilities.windowForComponent(c);
|
||||
@@ -719,6 +756,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return ANY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityState getDefaultModalityState() {
|
||||
if (EventQueue.isDispatchThread()) {
|
||||
@@ -730,23 +768,28 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ModalityState getNoneModalityState() {
|
||||
return MODALITY_STATE_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartTime() {
|
||||
return myStartTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getIdleTime() {
|
||||
return IdeEventQueue.getInstance().getIdleTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
exit(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(final boolean force) {
|
||||
exit(force, true);
|
||||
}
|
||||
@@ -757,6 +800,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!force && !showConfirmation()) {
|
||||
saveAll();
|
||||
@@ -859,6 +903,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runReadAction(@NotNull final Runnable action) {
|
||||
final AccessToken token = acquireReadActionLockImpl(false);
|
||||
|
||||
@@ -887,6 +932,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T runReadAction(@NotNull final Computable<T> computation) {
|
||||
final AccessToken token = acquireReadActionLockImpl(false);
|
||||
|
||||
@@ -898,6 +944,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runWriteAction(@NotNull final Runnable action) {
|
||||
final AccessToken token = acquireWriteActionLock(action.getClass());
|
||||
try {
|
||||
@@ -908,6 +955,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T runWriteAction(@NotNull final Computable<T> computation) {
|
||||
final AccessToken token = acquireWriteActionLock(computation.getClass());
|
||||
try {
|
||||
@@ -918,16 +966,18 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWriteAction(@Nullable Class<?> actionClass) {
|
||||
assertCanRunWriteAction();
|
||||
|
||||
for (int i = myWriteActionsStack.size() - 1; i >= 0; i--) {
|
||||
Class action = myWriteActionsStack.get(i);
|
||||
if (actionClass == action || action != null && ReflectionCache.isAssignable(actionClass, action)) return true;
|
||||
if (actionClass == action || action != null && actionClass != null && ReflectionCache.isAssignable(actionClass, action)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertReadAccessAllowed() {
|
||||
if (myHeadlessMode) return;
|
||||
if (!isReadAccessAllowed()) {
|
||||
@@ -958,6 +1008,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadAccessAllowed() {
|
||||
Thread currentThread = Thread.currentThread();
|
||||
return ourDispatchThread == currentThread ||
|
||||
@@ -971,6 +1022,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
assertIsDispatchThread("Write access is allowed from event dispatch thread only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertIsDispatchThread() {
|
||||
assertIsDispatchThread("Access is allowed from event dispatch thread only.");
|
||||
}
|
||||
@@ -994,6 +1046,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
"SystemEventQueueThread: " + describe(getEventQueueThread()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEdtSafeAction(@NotNull Runnable runnable) {
|
||||
Integer value = ourEdtSafe.get();
|
||||
if (value == null) {
|
||||
@@ -1011,6 +1064,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertIsDispatchThread(@Nullable final JComponent component) {
|
||||
if (component == null) return;
|
||||
|
||||
@@ -1031,11 +1085,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertTimeConsuming() {
|
||||
if (myTestModeFlag || myHeadlessMode || ShutDownTracker.isShutdownHookRunning()) return;
|
||||
LOG.assertTrue(!isDispatchThread(), "This operation is time consuming and must not be called on EDT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryRunReadAction(@NotNull Runnable action) {
|
||||
/** if we are inside read action, do not try to acquire read lock again since it will deadlock if there is a pending writeAction
|
||||
* see {@link com.intellij.util.concurrency.ReentrantWriterPreferenceReadWriteLock#allowReader()} */
|
||||
@@ -1084,6 +1140,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
if (isUnitTestMode()) return true;
|
||||
|
||||
@@ -1195,11 +1252,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertWriteAccessAllowed() {
|
||||
LOG.assertTrue(isWriteAccessAllowed(),
|
||||
"Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction())");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWriteAccessAllowed() {
|
||||
return myActionsLock.isWriteLockAcquired(Thread.currentThread());
|
||||
}
|
||||
@@ -1213,14 +1272,17 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
LOG.assertTrue(myInEditorPaintCounter >= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addApplicationListener(@NotNull ApplicationListener l) {
|
||||
myDispatcher.addListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addApplicationListener(@NotNull ApplicationListener l, @NotNull Disposable parent) {
|
||||
myDispatcher.addListener(l, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeApplicationListener(@NotNull ApplicationListener l) {
|
||||
myDispatcher.removeListener(l);
|
||||
}
|
||||
@@ -1254,6 +1316,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
else {
|
||||
LOG.info("Saving application settings failed", ex);
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (ex instanceof PluginException) {
|
||||
final PluginException pluginException = (PluginException)ex;
|
||||
@@ -1279,11 +1342,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
if (myDoNotSave) return;
|
||||
_saveSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
if (myDoNotSave) return;
|
||||
|
||||
@@ -1298,30 +1363,37 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNotSave() {
|
||||
doNotSave(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNotSave(boolean value) {
|
||||
myDoNotSave = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDoNotSave() {
|
||||
return myDoNotSave;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
|
||||
return Extensions.getRootArea().getExtensionPoint(extensionPointName).getExtensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisposeInProgress() {
|
||||
return myDisposeInProgress || ShutDownTracker.isShutdownHookRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRestartCapable() {
|
||||
return Restarter.isSupported() || myRestartCode > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
boolean restarted = false;
|
||||
try {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx
|
||||
return addRangeHighlighterAndChangeAttributes(offset, offset, layer, textAttributes, HighlighterTargetArea.LINES_IN_RANGE, true, null);
|
||||
}
|
||||
|
||||
static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) {
|
||||
private static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) {
|
||||
int lineStart = doc.getLineStartOffset(lineNumber);
|
||||
int lineEnd = doc.getLineEndOffset(lineNumber);
|
||||
CharSequence text = doc.getCharsSequence();
|
||||
|
||||
@@ -430,12 +430,17 @@ public class EditorWindow {
|
||||
else if (myTabbedPane != null) {
|
||||
final boolean focusEditor = ToolWindowManager.getInstance(getManager().getProject()).isEditorComponentActive();
|
||||
final VirtualFile currentFile = getSelectedFile();
|
||||
if (currentFile != null) {
|
||||
// do not close associated language console on tab placement change
|
||||
currentFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, Boolean.TRUE);
|
||||
}
|
||||
final VirtualFile[] files = getFiles();
|
||||
for (VirtualFile file : files) {
|
||||
closeFile(file, false);
|
||||
}
|
||||
disposeTabs();
|
||||
if (currentFile != null) {
|
||||
currentFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null);
|
||||
getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this);
|
||||
}
|
||||
else {
|
||||
|
||||
+8
-8
@@ -134,23 +134,23 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
}
|
||||
|
||||
private static boolean startsWith(final String url, final String pointerUrl) {
|
||||
String urlSuffix = stripSuffix(url);
|
||||
String pointerPrefix = stripToJarPrefix(pointerUrl);
|
||||
if (urlSuffix.length() > 0) {
|
||||
return Comparing.equal(stripToJarPrefix(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) &&
|
||||
StringUtil.startsWith(urlSuffix, stripSuffix(pointerUrl));
|
||||
String urlSuffix = substringAfterJarSeparator(url);
|
||||
String pointerPrefix = substringBeforeJarSeparator(pointerUrl);
|
||||
if (!urlSuffix.isEmpty()) {
|
||||
return Comparing.equal(substringBeforeJarSeparator(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) &&
|
||||
StringUtil.startsWith(urlSuffix, substringAfterJarSeparator(pointerUrl));
|
||||
}
|
||||
|
||||
return FileUtil.startsWith(pointerPrefix, stripToJarPrefix(url));
|
||||
return FileUtil.startsWith(pointerPrefix, substringBeforeJarSeparator(url));
|
||||
}
|
||||
|
||||
private static String stripToJarPrefix(String url) {
|
||||
private static String substringBeforeJarSeparator(String url) {
|
||||
int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
if (separatorIndex < 0) return url;
|
||||
return url.substring(0, separatorIndex);
|
||||
}
|
||||
|
||||
private static String stripSuffix(String url) {
|
||||
private static String substringAfterJarSeparator(String url) {
|
||||
int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
if (separatorIndex < 0) return "";
|
||||
return url.substring(separatorIndex + JarFileSystem.JAR_SEPARATOR.length());
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
|
||||
@@ -76,11 +77,10 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
|
||||
|
||||
String[] jarPaths;
|
||||
synchronized (LOCK) {
|
||||
if (jarPathsCache == null) {
|
||||
Set<String> jarPathsSet = myHandlers.keySet();
|
||||
jarPathsCache = jarPathsSet.toArray(new String[jarPathsSet.size()]);
|
||||
}
|
||||
jarPaths = jarPathsCache;
|
||||
if (jarPaths == null) {
|
||||
jarPathsCache = jarPaths = ArrayUtil.toStringArray(myHandlers.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
for (String jarPath : jarPaths) {
|
||||
|
||||
@@ -15,16 +15,19 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @ author Bas Leijdekkers
|
||||
* This class is programmatically instantiated and registered when opening and closing projects
|
||||
@@ -115,7 +118,15 @@ public class ProjectWindowAction extends ToggleAction implements DumbAware {
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
ProjectUtil.focusProjectWindow(project, true);
|
||||
final JFrame projectFrame = WindowManager.getInstance().getFrame(project);
|
||||
final int frameState = projectFrame.getExtendedState();
|
||||
if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) {
|
||||
// restore the frame if it is minimized
|
||||
projectFrame.setExtendedState(frameState ^ Frame.ICONIFIED);
|
||||
}
|
||||
projectFrame.toFront();
|
||||
projectFrame.requestFocus();
|
||||
//ProjectUtil.focusProjectWindow(project, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.openapi.util;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,6 +40,7 @@ public class ShutDownTracker implements Runnable {
|
||||
private static final ShutDownTracker ourInstance = new ShutDownTracker();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ShutDownTracker getInstance() {
|
||||
return ShutDownTrackerHolder.ourInstance;
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public class ShutDownTracker implements Runnable {
|
||||
return getInstance().myIsShutdownHookRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
myIsShutdownHookRunning = true;
|
||||
|
||||
@@ -128,28 +129,27 @@ public class ShutDownTracker implements Runnable {
|
||||
myShutdownTasks.remove(task);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private synchronized <T> T removeLast(LinkedList<T> list) {
|
||||
private synchronized <T> T removeLast(@NotNull LinkedList<T> list) {
|
||||
return list.isEmpty()? null : list.removeLast();
|
||||
}
|
||||
|
||||
public static void invokeAndWait(boolean timed, boolean edt, final Runnable runnable) {
|
||||
public static void invokeAndWait(boolean timed, boolean edt, @NotNull final Runnable runnable) {
|
||||
if (!edt) {
|
||||
if (!timed) {
|
||||
if (timed) {
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runnable.run();
|
||||
semaphore.up();
|
||||
}
|
||||
}).start();
|
||||
semaphore.waitFor(1000);
|
||||
}
|
||||
else {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runnable.run();
|
||||
semaphore.up();
|
||||
}
|
||||
}).start();
|
||||
semaphore.waitFor(1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,8 @@ public final class ObjectTree<T> {
|
||||
private final CopyOnWriteArraySet<ObjectTreeListener> myListeners = new CopyOnWriteArraySet<ObjectTreeListener>();
|
||||
|
||||
// identity used here to prevent problems with hashCode/equals overridden by not very bright minds
|
||||
private final THashSet<T> myRootObjects = new MyTHashSet<T>();
|
||||
private final THashMap<T, ObjectNode<T>> myObject2NodeMap = new THashMap<T, ObjectNode<T>>(TObjectHashingStrategy.IDENTITY) {
|
||||
public void compact() {
|
||||
if (((int)(capacity() * _loadFactor)/ Math.max(1, size())) >= 3) {
|
||||
super.compact();
|
||||
}
|
||||
}
|
||||
};
|
||||
private final THashSet<T> myRootObjects = new THashSet<T>(TObjectHashingStrategy.IDENTITY);
|
||||
private final THashMap<T, ObjectNode<T>> myObject2NodeMap = new THashMap<T, ObjectNode<T>>(TObjectHashingStrategy.IDENTITY);
|
||||
|
||||
private final List<ObjectNode<T>> myExecutedNodes = new ArrayList<ObjectNode<T>>();
|
||||
private final List<T> myExecutedUnregisteredNodes = new ArrayList<T>();
|
||||
@@ -118,26 +112,18 @@ public final class ObjectTree<T> {
|
||||
}
|
||||
|
||||
public final boolean executeAll(@NotNull T object, boolean disposeTree, @NotNull ObjectTreeAction<T> action, boolean processUnregistered) {
|
||||
try {
|
||||
ObjectNode<T> node = getNode(object);
|
||||
if (node == null) {
|
||||
if (processUnregistered) {
|
||||
executeUnregistered(object, action);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
ObjectNode<T> node = getNode(object);
|
||||
if (node == null) {
|
||||
if (processUnregistered) {
|
||||
executeUnregistered(object, action);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return node.execute(disposeTree, action);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
synchronized (treeLock) {
|
||||
myObject2NodeMap.compact();
|
||||
myRootObjects.compact();
|
||||
}
|
||||
else {
|
||||
return node.execute(disposeTree, action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,18 +272,6 @@ public final class ObjectTree<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyTHashSet<T> extends THashSet<T> {
|
||||
private MyTHashSet() {
|
||||
super(IDENTITY);
|
||||
}
|
||||
|
||||
public void compact() {
|
||||
if (((int)(capacity() * _loadFactor)/ Math.max(1, size())) >= 3) {
|
||||
super.compact();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getModification() {
|
||||
return myModification;
|
||||
}
|
||||
|
||||
@@ -1399,7 +1399,7 @@ public class UIUtil {
|
||||
|
||||
@NonNls String fontFamilyAndSize = "font-family:" + font.getFamily() + "; font-size:" + font.getSize() + ";";
|
||||
@NonNls @Language("HTML")
|
||||
String body = "body, div, td {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}";
|
||||
String body = "body, div, td, p {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}";
|
||||
if (resource != null) {
|
||||
body += "ul {list-style-image: " + resource.toExternalForm() +"}";
|
||||
}
|
||||
|
||||
@@ -1970,4 +1970,5 @@ ambiguous.field.access.hides.parameter.problem.descriptor=Field <code>#ref</code
|
||||
ambiguous.field.access.hides.field.problem.descriptor=Field <code>#ref</code> from super class ''{0}'' accessed, while field access from surrounding class might be expected #loc
|
||||
ambiguous.field.access.quickfix=Qualify field access with 'super.'
|
||||
string.builder.replaceable.by.string.quickfix=Replace 'StringBuilder' with 'String'
|
||||
string.buffer.replaceable.by.string.quickfix=Replace 'StringBuffer' with 'String'
|
||||
string.buffer.replaceable.by.string.quickfix=Replace 'StringBuffer' with 'String'
|
||||
add.0.to.ignore.if.annotated.by.list.quickfix=Add ''{0}'' to ''Ignore if annotated by'' list
|
||||
+14
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,14 +17,13 @@ package com.siyeh.ig.abstraction;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.psiutils.LibraryUtil;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
@@ -57,14 +56,17 @@ public class PublicMethodNotExposedInInterfaceInspection
|
||||
"public.method.not.in.interface.problem.descriptor");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner)infos[0], ignorableAnnotations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
final JPanel annotationsListControl =
|
||||
SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
ignorableAnnotations,
|
||||
InspectionGadgetsBundle.message(
|
||||
"ignore.if.annotated.by"));
|
||||
final JPanel annotationsListControl = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
|
||||
final GridBagConstraints constraints = new GridBagConstraints();
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 0;
|
||||
@@ -74,8 +76,7 @@ public class PublicMethodNotExposedInInterfaceInspection
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
panel.add(annotationsListControl, constraints);
|
||||
final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
|
||||
"public.method.not.in.interface.option"),
|
||||
this, "onlyWarnIfContainingClassImplementsAnInterface");
|
||||
"public.method.not.in.interface.option"), this, "onlyWarnIfContainingClassImplementsAnInterface");
|
||||
constraints.gridy = 1;
|
||||
constraints.weighty = 0.0;
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
@@ -141,7 +142,7 @@ public class PublicMethodNotExposedInInterfaceInspection
|
||||
if (TestUtils.isJUnitTestMethod(method)) {
|
||||
return;
|
||||
}
|
||||
registerMethodError(method);
|
||||
registerMethodError(method, method);
|
||||
}
|
||||
|
||||
private boolean exposedInInterface(PsiMethod method) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -87,6 +89,16 @@ public class EmptyClassInspection extends BaseInspection {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final Object info = infos[0];
|
||||
if (!(info instanceof PsiModifierListOwner)) {
|
||||
return InspectionGadgetsFix.EMPTY_ARRAY;
|
||||
}
|
||||
return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner)info, ignorableAnnotations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new EmptyClassVisitor();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,31 +15,57 @@
|
||||
*/
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.psiutils.UtilityClassUtil;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class UtilityClassInspection extends BaseInspection {
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message("utility.class.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"utility.class.problem.descriptor");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
return AddToIgnoreIfAnnotatedByListQuickFix.build((PsiModifierListOwner) infos[0], ignorableAnnotations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new UtilityClassVisitor();
|
||||
}
|
||||
|
||||
private static class UtilityClassVisitor extends BaseInspectionVisitor {
|
||||
private class UtilityClassVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
@@ -47,7 +73,10 @@ public class UtilityClassInspection extends BaseInspection {
|
||||
if (!UtilityClassUtil.isUtilityClass(aClass)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass);
|
||||
if (AnnotationUtil.isAnnotated(aClass, ignorableAnnotations)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass, aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-35
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.psi.*;
|
||||
@@ -27,25 +28,32 @@ import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.psiutils.UtilityClassUtil;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UtilityClassWithoutPrivateConstructorInspection
|
||||
extends BaseInspection {
|
||||
|
||||
/**
|
||||
* @noinspection PublicField for externalization
|
||||
*/
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public boolean ignoreClassesWithOnlyMain = false;
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
@@ -63,30 +71,34 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
@Override
|
||||
@Nullable
|
||||
public JComponent createOptionsPanel() {
|
||||
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message(
|
||||
"utility.class.without.private.constructor.option"), this,
|
||||
"ignoreClassesWithOnlyMain");
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JPanel annotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
|
||||
panel.add(annotationsPanel, BorderLayout.CENTER);
|
||||
final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("utility.class.without.private.constructor.option"),
|
||||
this, "ignoreClassesWithOnlyMain");
|
||||
panel.add(checkBox, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final List<InspectionGadgetsFix> fixes = new ArrayList();
|
||||
final PsiClass aClass = (PsiClass)infos[0];
|
||||
final PsiMethod constructor = getNullArgConstructor(aClass);
|
||||
if (constructor == null) {
|
||||
return new CreateEmptyPrivateConstructor();
|
||||
fixes.add(new CreateEmptyPrivateConstructor());
|
||||
}
|
||||
else {
|
||||
final Query<PsiReference> query =
|
||||
ReferencesSearch.search(constructor,
|
||||
constructor.getUseScope());
|
||||
final Query<PsiReference> query = ReferencesSearch.search(constructor, constructor.getUseScope());
|
||||
final PsiReference reference = query.findFirst();
|
||||
if (reference == null) {
|
||||
return new MakeConstructorPrivateFix();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
fixes.add(new MakeConstructorPrivateFix());
|
||||
}
|
||||
}
|
||||
AddToIgnoreIfAnnotatedByListQuickFix.build(aClass, ignorableAnnotations, fixes);
|
||||
return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
|
||||
}
|
||||
|
||||
private static class CreateEmptyPrivateConstructor
|
||||
@@ -131,14 +143,12 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
final PsiModifierList modifierList = constructor.getModifierList();
|
||||
modifierList.setModifierProperty(PsiModifier.PRIVATE, true);
|
||||
aClass.add(constructor);
|
||||
final CodeStyleManager styleManager =
|
||||
CodeStyleManager.getInstance(project);
|
||||
final CodeStyleManager styleManager = CodeStyleManager.getInstance(project);
|
||||
styleManager.reformat(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MakeConstructorPrivateFix
|
||||
extends InspectionGadgetsFix {
|
||||
private static class MakeConstructorPrivateFix extends InspectionGadgetsFix {
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
@@ -154,13 +164,11 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
if (aClass == null) {
|
||||
return;
|
||||
}
|
||||
final PsiMethod[] constructurs = aClass.getConstructors();
|
||||
for (final PsiMethod constructor : constructurs) {
|
||||
final PsiParameterList parameterList =
|
||||
constructor.getParameterList();
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
for (final PsiMethod constructor : constructors) {
|
||||
final PsiParameterList parameterList = constructor.getParameterList();
|
||||
if (parameterList.getParametersCount() == 0) {
|
||||
final PsiModifierList modifiers =
|
||||
constructor.getModifierList();
|
||||
final PsiModifierList modifiers = constructor.getModifierList();
|
||||
modifiers.setModifierProperty(PsiModifier.PUBLIC, false);
|
||||
modifiers.setModifierProperty(PsiModifier.PROTECTED, false);
|
||||
modifiers.setModifierProperty(PsiModifier.PRIVATE, true);
|
||||
@@ -174,8 +182,7 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
return new UtilityClassWithoutPrivateConstructorVisitor();
|
||||
}
|
||||
|
||||
private class UtilityClassWithoutPrivateConstructorVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private class UtilityClassWithoutPrivateConstructorVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
@@ -192,10 +199,11 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
if (hasPrivateConstructor(aClass)) {
|
||||
return;
|
||||
}
|
||||
final SearchScope scope =
|
||||
GlobalSearchScope.projectScope(aClass.getProject());
|
||||
final Query<PsiClass> query =
|
||||
ClassInheritorsSearch.search(aClass, scope, true, true);
|
||||
if (AnnotationUtil.isAnnotated(aClass, ignorableAnnotations)) {
|
||||
return;
|
||||
}
|
||||
final SearchScope scope = GlobalSearchScope.projectScope(aClass.getProject());
|
||||
final Query<PsiClass> query = ClassInheritorsSearch.search(aClass, scope, true, true);
|
||||
final PsiClass subclass = query.findFirst();
|
||||
if (subclass != null) {
|
||||
return;
|
||||
@@ -229,8 +237,7 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
if (!PsiType.VOID.equals(returnType)) {
|
||||
return false;
|
||||
}
|
||||
final PsiParameterList parameterList =
|
||||
method.getParameterList();
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
if (parameterList.getParametersCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+10
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.fixes.EncapsulateVariableFix;
|
||||
import com.siyeh.ig.psiutils.ClassUtils;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
@@ -31,6 +32,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PublicFieldInspection extends BaseInspection {
|
||||
|
||||
@@ -66,10 +69,14 @@ public class PublicFieldInspection extends BaseInspection {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final List<InspectionGadgetsFix> fixes = new ArrayList();
|
||||
final PsiField field = (PsiField)infos[0];
|
||||
return new EncapsulateVariableFix(field.getName());
|
||||
fixes.add(new EncapsulateVariableFix(field.getName()));
|
||||
AddToIgnoreIfAnnotatedByListQuickFix.build(field, ignorableAnnotations, fixes);
|
||||
return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.siyeh.ig.fixes;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.util.Processor;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.DelegatingFix;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class AddToIgnoreIfAnnotatedByListQuickFix {
|
||||
|
||||
private AddToIgnoreIfAnnotatedByListQuickFix() {}
|
||||
|
||||
public static InspectionGadgetsFix[] build(PsiModifierListOwner modifierListOwner, List<String> configurationList) {
|
||||
final List<InspectionGadgetsFix> fixes = build(modifierListOwner, configurationList, new ArrayList());
|
||||
return fixes.isEmpty() ? InspectionGadgetsFix.EMPTY_ARRAY : fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
|
||||
}
|
||||
|
||||
public static List<InspectionGadgetsFix> build(final PsiModifierListOwner modifierListOwner,
|
||||
final List<String> configurationList,
|
||||
final List<InspectionGadgetsFix> fixes) {
|
||||
processAnnotationTexts(modifierListOwner, new Processor<String>() {
|
||||
@Override
|
||||
public boolean process(String annotationText) {
|
||||
fixes.add(new DelegatingFix(SpecialAnnotationsUtil.createAddToSpecialAnnotationsListQuickFix(
|
||||
InspectionGadgetsBundle.message("add.0.to.ignore.if.annotated.by.list.quickfix", annotationText),
|
||||
QuickFixBundle.message("fix.add.special.annotation.family"),
|
||||
configurationList, annotationText, modifierListOwner)));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return fixes;
|
||||
}
|
||||
|
||||
private static void processAnnotationTexts(final PsiModifierListOwner owner, final Processor<String> processor) {
|
||||
final PsiModifierList modifierList = owner.getModifierList();
|
||||
if (modifierList == null) {
|
||||
return;
|
||||
}
|
||||
final PsiAnnotation[] annotations = modifierList.getAnnotations();
|
||||
for (PsiAnnotation annotation : annotations) {
|
||||
@NonNls final String text = annotation.getText();
|
||||
if (text.startsWith("java.") || text.startsWith("javax.") || text.startsWith("org.jetbrains.")) {
|
||||
continue;
|
||||
}
|
||||
if (!processor.process(text)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,8 @@ import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.psiutils.ClassUtils;
|
||||
import com.siyeh.ig.psiutils.UninitializedReadCollector;
|
||||
import org.jdom.Element;
|
||||
@@ -39,8 +41,7 @@ import java.awt.GridBagLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InstanceVariableUninitializedUseInspection
|
||||
extends BaseInspection {
|
||||
public class InstanceVariableUninitializedUseInspection extends BaseInspection {
|
||||
|
||||
/**
|
||||
* @noinspection PublicField
|
||||
@@ -94,10 +95,8 @@ public class InstanceVariableUninitializedUseInspection
|
||||
public JComponent createOptionsPanel() {
|
||||
final JComponent panel = new JPanel(new GridBagLayout());
|
||||
|
||||
final JPanel annotationsPanel =
|
||||
SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
annotationNames, InspectionGadgetsBundle.message(
|
||||
"ignore.if.annotated.by"));
|
||||
final JPanel annotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
|
||||
annotationNames, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
|
||||
final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
|
||||
"primitive.fields.ignore.option"), this, "m_ignorePrimitives");
|
||||
|
||||
@@ -117,13 +116,19 @@ public class InstanceVariableUninitializedUseInspection
|
||||
return panel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final PsiField field = (PsiField)infos[0];
|
||||
return AddToIgnoreIfAnnotatedByListQuickFix.build(field, annotationNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new InstanceVariableInitializationVisitor();
|
||||
}
|
||||
|
||||
private class InstanceVariableInitializationVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private class InstanceVariableInitializationVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitField(@NotNull PsiField field) {
|
||||
@@ -133,8 +138,7 @@ public class InstanceVariableUninitializedUseInspection
|
||||
if (field.getInitializer() != null) {
|
||||
return;
|
||||
}
|
||||
final PsiAnnotation annotation =
|
||||
AnnotationUtil.findAnnotation(field, annotationNames);
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, annotationNames);
|
||||
if (annotation != null) {
|
||||
return;
|
||||
}
|
||||
@@ -154,26 +158,21 @@ public class InstanceVariableUninitializedUseInspection
|
||||
return;
|
||||
}
|
||||
}
|
||||
final UninitializedReadCollector uninitializedReadsCollector =
|
||||
new UninitializedReadCollector();
|
||||
if (!isInitializedInInitializer(field,
|
||||
uninitializedReadsCollector)) {
|
||||
final UninitializedReadCollector uninitializedReadsCollector = new UninitializedReadCollector();
|
||||
if (!isInitializedInInitializer(field, uninitializedReadsCollector)) {
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
for (final PsiMethod constructor : constructors) {
|
||||
final PsiCodeBlock body = constructor.getBody();
|
||||
uninitializedReadsCollector.blockAssignsVariable(body,
|
||||
field);
|
||||
uninitializedReadsCollector.blockAssignsVariable(body, field);
|
||||
}
|
||||
}
|
||||
final PsiExpression[] badReads =
|
||||
uninitializedReadsCollector.getUninitializedReads();
|
||||
final PsiExpression[] badReads = uninitializedReadsCollector.getUninitializedReads();
|
||||
for (PsiExpression expression : badReads) {
|
||||
registerError(expression);
|
||||
registerError(expression, field);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInitializedInInitializer(
|
||||
@NotNull PsiField field,
|
||||
private boolean isInitializedInInitializer(@NotNull PsiField field,
|
||||
UninitializedReadCollector uninitializedReadsCollector) {
|
||||
final PsiClass aClass = field.getContainingClass();
|
||||
if (aClass == null) {
|
||||
@@ -183,8 +182,7 @@ public class InstanceVariableUninitializedUseInspection
|
||||
for (final PsiClassInitializer initializer : initializers) {
|
||||
if (!initializer.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
final PsiCodeBlock body = initializer.getBody();
|
||||
if (uninitializedReadsCollector.blockAssignsVariable(body,
|
||||
field)) {
|
||||
if (uninitializedReadsCollector.blockAssignsVariable(body, field)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2006-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,14 +23,15 @@ import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.AddToIgnoreIfAnnotatedByListQuickFix;
|
||||
import com.siyeh.ig.psiutils.SerializationUtils;
|
||||
import com.siyeh.ig.ui.ExternalizableStringSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class NonSerializableFieldInSerializableClassInspection
|
||||
extends SerializableInspection {
|
||||
public class NonSerializableFieldInSerializableClassInspection extends SerializableInspection {
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public final ExternalizableStringSet ignorableAnnotations = new ExternalizableStringSet();
|
||||
@@ -55,6 +56,13 @@ public class NonSerializableFieldInSerializableClassInspection
|
||||
ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"))};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final PsiField field = (PsiField)infos[0];
|
||||
return AddToIgnoreIfAnnotatedByListQuickFix.build(field, ignorableAnnotations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NonSerializableFieldInSerializableClassVisitor();
|
||||
@@ -90,7 +98,7 @@ public class NonSerializableFieldInSerializableClassInspection
|
||||
if (AnnotationUtil.isAnnotated(field, ignorableAnnotations)) {
|
||||
return;
|
||||
}
|
||||
registerFieldError(field);
|
||||
registerFieldError(field, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
This inspection reports empty classes and Java files without any defined classes. A class is empty if it
|
||||
doesn't have any fields, methods, constructors or initializers. Empty classes are often left over
|
||||
after large changes or refactorings.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Classes annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
|
||||
+6
-2
@@ -2,10 +2,14 @@
|
||||
<body>
|
||||
This inspection reports reads of instance variables which are not yet initialized.
|
||||
<p>
|
||||
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
|
||||
<p>
|
||||
Note: This inspection uses a very conservative dataflow algorithm, and may report instance variables
|
||||
as uninitialized incorrectly. Variables reported as initialized will always be initialized.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Fields annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
<p>
|
||||
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
|
||||
+5
-1
@@ -10,12 +10,16 @@ method. For purposes of this inspection, fields with
|
||||
<b>java.util.Map</b> types are assumed to be
|
||||
<b>Serializable</b>, unless the types
|
||||
they are declared to contain are non-<b>Serializable</b>.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the table below to specify what specific classes and inheritors should be excluded
|
||||
Use the first list below to specify what specific classes and inheritors should be excluded
|
||||
from being checked by this inspection. This is meant for those classes which, although they inherit
|
||||
Serializable from a superclass, are not intended for serialization. Such classes would lead this
|
||||
inspection to report unnecessarily.
|
||||
<p>
|
||||
Use the second list below to specify special annotations. Fields annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
This inspection reports <b>public</b> instance variables.
|
||||
Constants (i.e. variables marked <b>static</b> and <b>final</b>) are not reported.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Fields annotated with one of these annotations will be ignored by this inspection.
|
||||
<p>
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
This inspection reports <b>public</b> methods in classes
|
||||
which are not exposed as in interface. Exposing all <b>public</b> methods via interface is important for
|
||||
maintaining loose coupling, and may be necessary for certain component-based programming styles.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Methods annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
This inspection reports utility classes.
|
||||
Utility classes have all fields and methods declared <b>static</b>, and their
|
||||
presence may indicate a lack of object-oriented design.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Classes annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
|
||||
+6
@@ -3,6 +3,12 @@
|
||||
This inspection reports utility classes which do not have <b>private</b> constructors.
|
||||
Utility classes have all fields and methods declared <b>static</b>. Giving such classes a <b>private</b>
|
||||
constructor prevents them from being inadvertently instantiated.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the list below to specify special annotations. Classes annotated with one of
|
||||
these annotations will be ignored by this inspection.
|
||||
<p>
|
||||
Use the checkbox below to ignore classes which only have a main method and no other methods.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
|
||||
@@ -263,7 +263,7 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler {
|
||||
final String[] libPackages = getLibPackages(module, packageName);
|
||||
|
||||
final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet);
|
||||
if (circularDepLibWithSamePackage != null) {
|
||||
if (circularDepLibWithSamePackage != null && !facet.getConfiguration().LIBRARY_PROJECT) {
|
||||
myContext.addMessage(CompilerMessageCategory.WARNING,
|
||||
AndroidBundle.message("android.compilation.warning.circular.app.dependency",
|
||||
packageName, module.getName(),
|
||||
|
||||
@@ -163,7 +163,7 @@ public class AndroidAutogenerator {
|
||||
final String manifestFileOsPath = FileUtil.toSystemDependentName(manifestFile.getPath());
|
||||
|
||||
final Module circularDepLibWithSamePackage = AndroidCompileUtil.findCircularDependencyOnLibraryWithSamePackage(facet);
|
||||
if (circularDepLibWithSamePackage != null) {
|
||||
if (circularDepLibWithSamePackage != null && !facet.getConfiguration().LIBRARY_PROJECT) {
|
||||
context.addMessage(CompilerMessageCategory.WARNING, AndroidBundle.message("android.compilation.warning.circular.app.dependency",
|
||||
packageName, module.getName(),
|
||||
circularDepLibWithSamePackage.getName()), null, -1, -1);
|
||||
|
||||
@@ -655,19 +655,20 @@ public class AndroidCompileUtil {
|
||||
final GlobalSearchScope moduleScope = facet.getModule().getModuleScope();
|
||||
|
||||
initializeGenSourceRoot(module, AndroidRootUtil.getRenderscriptGenSourceRootPath(facet),
|
||||
FileTypeIndex.getFiles(AndroidRenderscriptFileType.INSTANCE, moduleScope).size() > 0);
|
||||
FileTypeIndex.getFiles(AndroidRenderscriptFileType.INSTANCE, moduleScope).size() > 0, true);
|
||||
|
||||
if (AndroidAptCompiler.isToCompileModule(module, facet.getConfiguration())) {
|
||||
initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true);
|
||||
initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true, true);
|
||||
}
|
||||
else {
|
||||
// we need to include generated-sources/r to compilation, because it contains R.java generated by Maven,
|
||||
// which should be used in Maven-based resource processing mode
|
||||
initializeGenSourceRoot(module, AndroidRootUtil.getAptGenSourceRootPath(facet), true, false);
|
||||
includeAaptGenSourceRootToCompilation(facet);
|
||||
}
|
||||
|
||||
initializeGenSourceRoot(module, AndroidRootUtil.getAidlGenSourceRootPath(facet),
|
||||
FileTypeIndex.getFiles(AndroidIdlFileType.ourFileType, moduleScope).size() > 0);
|
||||
FileTypeIndex.getFiles(AndroidIdlFileType.ourFileType, moduleScope).size() > 0, true);
|
||||
}
|
||||
|
||||
private static void includeAaptGenSourceRootToCompilation(AndroidFacet facet) {
|
||||
@@ -686,7 +687,7 @@ public class AndroidCompileUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializeGenSourceRoot(@NotNull Module module, @Nullable String sourceRootPath, boolean createIfNotExist) {
|
||||
private static void initializeGenSourceRoot(@NotNull Module module, @Nullable String sourceRootPath, boolean createIfNotExist, boolean exclude) {
|
||||
if (sourceRootPath == null) {
|
||||
return;
|
||||
}
|
||||
@@ -701,7 +702,7 @@ public class AndroidCompileUtil {
|
||||
if (sourceRoot == null) {
|
||||
sourceRoot = LocalFileSystem.getInstance().findFileByPath(sourceRootPath);
|
||||
}
|
||||
if (sourceRoot != null) {
|
||||
if (sourceRoot != null && exclude) {
|
||||
excludeFromCompilation(module.getProject(), sourceRoot);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-13
@@ -19,14 +19,16 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.CommandLineBuilder;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.android.util.ExecutionStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.execution.MavenExternalParameters;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunner;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
|
||||
@@ -42,24 +44,39 @@ public class AndroidMavenExecutor {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.compiler.tools.AndroidMavenExecutor");
|
||||
|
||||
private static final String BUILD_ERROR_INDICATOR = "[error]";
|
||||
private static final String FAILED_TO_RESOLVE_ARTIFACT_INDICATOR = "[info] failed to resolve artifact";
|
||||
|
||||
private AndroidMavenExecutor() {
|
||||
}
|
||||
|
||||
public static Map<CompilerMessageCategory, List<String>> generateResources(Module module) {
|
||||
public static Map<CompilerMessageCategory, List<String>> generateResources(final Module module) {
|
||||
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
|
||||
|
||||
MavenRunnerParameters parameters =
|
||||
final MavenRunnerParameters parameters =
|
||||
new MavenRunnerParameters(true, projectsManager.findProject(module).getDirectory(),
|
||||
Collections.singletonList("process-resources"),
|
||||
projectsManager.getExplicitProfiles());
|
||||
|
||||
Map<CompilerMessageCategory, List<String>> result = new HashMap<CompilerMessageCategory, List<String>>();
|
||||
final Map<CompilerMessageCategory, List<String>> result = new HashMap<CompilerMessageCategory, List<String>>();
|
||||
result.put(CompilerMessageCategory.ERROR, new ArrayList<String>());
|
||||
|
||||
try {
|
||||
JavaParameters javaParams = MavenExternalParameters.createJavaParameters(module.getProject(), parameters);
|
||||
JavaParameters javaParams = ApplicationManager.getApplication().runReadAction(new Computable<JavaParameters>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaParameters compute() {
|
||||
try {
|
||||
return MavenExternalParameters.createJavaParameters(module.getProject(), parameters);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.info(e);
|
||||
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (javaParams == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
GeneralCommandLine commandLine = CommandLineBuilder.createFromJavaParameters(javaParams);
|
||||
StringBuilder messageBuilder = new StringBuilder();
|
||||
@@ -70,13 +87,7 @@ public class AndroidMavenExecutor {
|
||||
String lcmessage = message.toLowerCase();
|
||||
int buildErrorIndex = lcmessage.indexOf(BUILD_ERROR_INDICATOR);
|
||||
if (buildErrorIndex >= 0) {
|
||||
int failedToResolveIndex = lcmessage.indexOf(FAILED_TO_RESOLVE_ARTIFACT_INDICATOR);
|
||||
/*if (failedToResolveIndex >= 0) {
|
||||
result.get(CompilerMessageCategory.ERROR).add("Failed to copy Android resources from Maven artifacts");
|
||||
}
|
||||
else {*/
|
||||
result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex));
|
||||
//}
|
||||
result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -129,14 +129,21 @@ public class EclipseClasspathWriter {
|
||||
}
|
||||
else {
|
||||
boolean newVarLibrary = false;
|
||||
|
||||
boolean link = false;
|
||||
String eclipseVariablePath = eclipseModuleManager.getEclipseVariablePath(files[0]);
|
||||
if (eclipseVariablePath == null) {
|
||||
eclipseVariablePath = eclipseModuleManager.getEclipseLinkedVarPath(files[0]);
|
||||
link = eclipseVariablePath != null;
|
||||
}
|
||||
|
||||
if (eclipseVariablePath == null && !eclipseModuleManager.isEclipseLibUrl(files[0])) { //new library was added
|
||||
newVarLibrary = true;
|
||||
eclipseVariablePath = EPathUtil.collapse2EclipseVariabledPath(libraryOrderEntry, OrderRootType.CLASSES);
|
||||
}
|
||||
Element orderEntry;
|
||||
if (eclipseVariablePath != null) {
|
||||
orderEntry = addOrderEntry(EclipseXml.VAR_KIND, eclipseVariablePath, classpathRoot);
|
||||
orderEntry = addOrderEntry(link ? EclipseXml.LIB_KIND : EclipseXml.VAR_KIND, eclipseVariablePath, classpathRoot);
|
||||
}
|
||||
else {
|
||||
LOG.assertTrue(!StringUtil.isEmptyOrSpaces(files[0]), "Library: " + libraryName);
|
||||
@@ -156,6 +163,9 @@ public class EclipseClasspathWriter {
|
||||
srcRelativePath = EPathUtil.collapse2EclipsePath(srcFile, myModel);
|
||||
if (eclipseVariablePath != null) {
|
||||
eclipseSrcVariablePath = eclipseModuleManager.getEclipseSrcVariablePath(srcFile);
|
||||
if (eclipseSrcVariablePath == null) {
|
||||
eclipseSrcVariablePath = eclipseModuleManager.getEclipseLinkedSrcVariablePath(srcFile);
|
||||
}
|
||||
if (eclipseSrcVariablePath == null) {
|
||||
eclipseSrcVariablePath = EPathUtil.collapse2EclipseVariabledPath(libraryOrderEntry, OrderRootType.SOURCES);
|
||||
if (eclipseSrcVariablePath != null) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="lib" path="3rdParty/subdir/empty.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>eclipse_project</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsensis.installoptions.InstallOptionsBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>net.sf.eclipsensis.installoptions.InstallOptionsNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>3rdParty</name>
|
||||
<type>2</type>
|
||||
<locationURI>variable/project1</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
@@ -45,4 +45,8 @@ public class EclipseLinkedResourcesTest extends EclipseVarsTest{
|
||||
public void testResolvedVarsInLibImlCheck() throws Exception {
|
||||
EclipseImlTest.doTest("/test", getProject());
|
||||
}
|
||||
|
||||
public void testResolvedVarsInLibImlCheck1() throws Exception {
|
||||
EclipseClasspathTest.doTest("/test", getProject());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +223,11 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber {
|
||||
h.addParameters("--timestamp", "--max-count=1", rev);
|
||||
h.endOptions();
|
||||
final String output = h.run();
|
||||
return parseRevlistOutputAsRevisionNumber(h, output);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GitRevisionNumber parseRevlistOutputAsRevisionNumber(@NotNull GitSimpleHandler h, @NotNull String output) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(output, "\n\r \t", false);
|
||||
Date timestamp = GitUtil.parseTimestampWithNFEReport(tokenizer.nextToken(), h, output);
|
||||
return new GitRevisionNumber(tokenizer.nextToken(), timestamp);
|
||||
|
||||
@@ -728,4 +728,9 @@ public abstract class GitHandler {
|
||||
public String toString() {
|
||||
return myCommandLine.toString();
|
||||
}
|
||||
|
||||
public void dontEscapeQuotes() {
|
||||
myCommandLine.putUserData(GeneralCommandLine.DO_NOT_ESCAPE_QUOTES, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class GitVcsPanel {
|
||||
!crlfPolicyItem(settings).equals(myConvertTextFilesComboBox.getSelectedItem()) ||
|
||||
!settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() ||
|
||||
((settings.getSyncSetting() == GitBranchSyncSetting.SYNC) != mySyncBranchControl.isSelected() ||
|
||||
settings.isAutoCommitOnCherryPick() == myAutoCommitOnCherryPick.isSelected());
|
||||
settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,21 +79,12 @@ public class GitStashChangesSaver extends GitChangesSaver {
|
||||
}
|
||||
|
||||
public void load() throws VcsException {
|
||||
Collection<VirtualFile> conflictedRoots = new ArrayList<VirtualFile>();
|
||||
for (VirtualFile root : myStashedRoots) {
|
||||
boolean conflict = loadRoot(root);
|
||||
if (conflict) {
|
||||
conflictedRoots.add(root);
|
||||
}
|
||||
loadRoot(root);
|
||||
}
|
||||
|
||||
boolean conflictsResolved = new UnstashConflictResolver(myProject, myGit, myStashedRoots, myParams).merge();
|
||||
if (conflictsResolved) {
|
||||
LOG.info("load: all conflicts resolved, dropping stash in " + myStashedRoots);
|
||||
for (VirtualFile root : conflictedRoots) {
|
||||
GitStashUtils.dropStash(myProject, root);
|
||||
}
|
||||
}
|
||||
LOG.info("load: conflicts resolved status is " + conflictsResolved + " in roots " + myStashedRoots);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package git4idea.ui;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -173,27 +174,18 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
ProgressManager.getInstance().run(new Task.Modal(myProject, "Removing stash " + stash.getStash(), false) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
GitSimpleHandler h = dropHandler(stash.getStash());
|
||||
final GitSimpleHandler h = dropHandler(stash.getStash());
|
||||
try {
|
||||
h.run();
|
||||
h.unsilence();
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
try {
|
||||
//noinspection HardCodedStringLiteral
|
||||
if (ex.getMessage().startsWith("fatal: Needed a single revision")) {
|
||||
h = dropHandler(translateStash(stash.getStash()));
|
||||
h.run();
|
||||
catch (final VcsException ex) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine());
|
||||
}
|
||||
else {
|
||||
h.unsilence();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (VcsException ex2) {
|
||||
GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine());
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -205,7 +197,8 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
private GitSimpleHandler dropHandler(String stash) {
|
||||
GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH);
|
||||
h.setNoSSH(true);
|
||||
h.addParameters("drop", stash);
|
||||
h.addParameters("drop");
|
||||
addStashParameter(h, stash);
|
||||
return h;
|
||||
}
|
||||
});
|
||||
@@ -215,23 +208,18 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
String resolvedStash;
|
||||
String selectedStash = getSelectedStash().getStash();
|
||||
try {
|
||||
resolvedStash = GitRevisionNumber.resolve(myProject, root, selectedStash).asString();
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REV_LIST);
|
||||
h.setNoSSH(true);
|
||||
h.setSilent(true);
|
||||
h.addParameters("--timestamp", "--max-count=1");
|
||||
addStashParameter(h, selectedStash);
|
||||
h.endOptions();
|
||||
final String output = h.run();
|
||||
resolvedStash = GitRevisionNumber.parseRevlistOutputAsRevisionNumber(h, output).asString();
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
try {
|
||||
//noinspection HardCodedStringLiteral
|
||||
if (ex.getMessage().startsWith("fatal: bad revision 'stash@")) {
|
||||
selectedStash = translateStash(selectedStash);
|
||||
resolvedStash = GitRevisionNumber.resolve(myProject, root, selectedStash).asString();
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (VcsException ex2) {
|
||||
GitUIUtil.showOperationError(myProject, ex, "resolving revision");
|
||||
return;
|
||||
}
|
||||
GitUIUtil.showOperationError(myProject, ex, "resolving revision");
|
||||
return;
|
||||
}
|
||||
GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, resolvedStash, root);
|
||||
}
|
||||
@@ -241,13 +229,16 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate stash name so that { } are escaped.
|
||||
*
|
||||
* @param selectedStash a selected stash
|
||||
* @return translated name
|
||||
* Adds {@code stash@{x}} parameter to the handler, quotes it if needed.
|
||||
*/
|
||||
private static String translateStash(String selectedStash) {
|
||||
return selectedStash.replaceAll("([\\{}])", "\\\\$1");
|
||||
private void addStashParameter(@NotNull GitHandler handler, @NotNull String stash) {
|
||||
if (GitVersionSpecialty.NEEDS_QUOTES_IN_STASH_NAME.existsIn(myVcs.getVersion())) {
|
||||
handler.addParameters("\"" + stash + "\"");
|
||||
handler.dontEscapeQuotes();
|
||||
}
|
||||
else {
|
||||
handler.addParameters(stash);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,6 +320,7 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
catch (VcsException e) {
|
||||
// ignore error
|
||||
}
|
||||
myStashList.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,10 +331,9 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param escaped if true stash name will be escaped
|
||||
* @return unstash handler
|
||||
*/
|
||||
private GitLineHandler handler(boolean escaped) {
|
||||
private GitLineHandler handler() {
|
||||
GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
|
||||
h.setNoSSH(true);
|
||||
String branch = myBranchTextField.getText();
|
||||
@@ -356,12 +347,7 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
h.addParameters("branch", branch);
|
||||
}
|
||||
String selectedStash = getSelectedStash().getStash();
|
||||
if (escaped) {
|
||||
selectedStash = translateStash(selectedStash);
|
||||
} else if (GitVersionSpecialty.NEEDS_QUOTES_IN_STASH_NAME.existsIn(myVcs.getVersion())) { // else if, because escaping {} also solves the issue
|
||||
selectedStash = "\"" + selectedStash + "\"";
|
||||
}
|
||||
h.addParameters(selectedStash);
|
||||
addStashParameter(h, selectedStash);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -396,6 +382,11 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
return "reference.VersionControl.Git.Unstash";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myStashList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show unstash dialog and process its result
|
||||
*
|
||||
@@ -414,32 +405,22 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
return;
|
||||
}
|
||||
affectedRoots.add(d.getGitRoot());
|
||||
GitLineHandler h = d.handler(false);
|
||||
final AtomicBoolean needToEscapedBraces = new AtomicBoolean(false);
|
||||
GitLineHandler h = d.handler();
|
||||
final AtomicBoolean conflict = new AtomicBoolean();
|
||||
|
||||
h.addLineListener(new GitLineHandlerAdapter() {
|
||||
public void onLineAvailable(String line, Key outputType) {
|
||||
if (line.startsWith("fatal: Needed a single revision")) {
|
||||
needToEscapedBraces.set(true);
|
||||
} else if (line.contains("Merge conflict")) {
|
||||
if (line.contains("Merge conflict")) {
|
||||
conflict.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
int rc = GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false);
|
||||
if (needToEscapedBraces.get()) {
|
||||
h = d.handler(true);
|
||||
rc = GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false);
|
||||
}
|
||||
|
||||
if (conflict.get()) {
|
||||
VirtualFile root = d.getGitRoot();
|
||||
boolean conflictsResolved = new UnstashConflictResolver(project, root, d.getSelectedStash()).merge();
|
||||
if (conflictsResolved) {
|
||||
LOG.info("loadRoot " + root + " conflicts resolved, dropping stash");
|
||||
GitStashUtils.dropStash(project, root);
|
||||
}
|
||||
LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved);
|
||||
} else if (rc != 0) {
|
||||
GitUIUtil.showOperationErrors(project, h.errors(), h.printableCommandLine());
|
||||
}
|
||||
|
||||
@@ -1012,7 +1012,7 @@
|
||||
<projectStructureDetector implementation="org.jetbrains.plugins.groovy.griffon.GriffonProjectStructureDetector"/>
|
||||
<programRunner implementation="org.jetbrains.plugins.groovy.griffon.GriffonDebuggerRunner"/>
|
||||
<configurationType implementation="org.jetbrains.plugins.groovy.griffon.GriffonRunConfigurationType"/>
|
||||
<toolWindow id="Griffon View" anchor="left" secondary="false" icon="/icons/griffon/griffon.png"
|
||||
<toolWindow id="Griffon View" anchor="left" secondary="false" icon="/icons/griffon/griffonToolWindow.png"
|
||||
factoryClass="org.jetbrains.plugins.groovy.griffon.GriffonToolWindowFactory"
|
||||
conditionClass="org.jetbrains.plugins.groovy.griffon.GriffonToolWindowFactory"/>
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -143,7 +143,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
if (profileGroovyc) {
|
||||
parameters.getVMParametersList().defineProperty("java.library.path", PathManager.getBinPath());
|
||||
parameters.getVMParametersList().defineProperty("profile.groovy.compiler", "true");
|
||||
parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=GroovyCompiler");
|
||||
parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablealloc,sessionname=GroovyCompiler");
|
||||
classPathBuilder.add(PathManager.findFileInLibDirectory("yjp-controller-api-redist.jar").getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class GriffonFramework extends MvcFramework {
|
||||
public static final Icon GRIFFON_ICON = IconLoader.getIcon("/icons/griffon/griffon.png");
|
||||
public static final Icon GRIFFON_TOOLWINDOW_ICON = IconLoader.getIcon("/icons/griffon/griffonToolWindow.png");
|
||||
|
||||
@NonNls private static final String GRIFFON_COMMON_PLUGINS = "-griffonPlugins";
|
||||
private static final String GLOBAL_PLUGINS_MODULE_NAME = "GriffonGlobalPlugins";
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ public class GriffonToolWindowFactory extends MvcToolWindowDescriptor {
|
||||
|
||||
@Override
|
||||
public Icon getModuleNodeIcon() {
|
||||
return GriffonFramework.GRIFFON_TOOLWINDOW_ICON;
|
||||
return GriffonFramework.GRIFFON_ICON;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -422,6 +422,7 @@ public class MvcModuleStructureSynchronizer extends AbstractProjectComponent {
|
||||
|
||||
if (shouldShow && toolWindow == null) {
|
||||
toolWindow = toolWindowManager.registerToolWindow(id, true, ToolWindowAnchor.LEFT, myProject, true);
|
||||
toolWindow.setIcon(IconLoader.getIcon(ep.icon));
|
||||
descriptor.createToolWindowContent(myProject, toolWindow);
|
||||
}
|
||||
else if (!shouldShow && toolWindow != null) {
|
||||
|
||||
-1
@@ -51,7 +51,6 @@ public abstract class MvcToolWindowDescriptor implements ToolWindowFactory, Cond
|
||||
}
|
||||
|
||||
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
|
||||
toolWindow.setIcon(myFramework.getIcon());
|
||||
toolWindow.setAvailable(true, null);
|
||||
toolWindow.setToHideOnEmptyContent(true);
|
||||
toolWindow.setTitle(myFramework.getDisplayName());
|
||||
|
||||
+16
-1
@@ -23,11 +23,13 @@ package org.jetbrains.idea.maven.wizards;
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.ProjectWizardStepFactory;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.projectImport.ProjectImportProvider;
|
||||
import com.intellij.projectImport.SelectImportedProjectsStep;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -36,7 +38,7 @@ public class MavenProjectImportProvider extends ProjectImportProvider {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
public ModuleWizardStep[] createSteps(WizardContext wizardContext) {
|
||||
public ModuleWizardStep[] createSteps(final WizardContext wizardContext) {
|
||||
final ProjectWizardStepFactory stepFactory = ProjectWizardStepFactory.getInstance();
|
||||
return new ModuleWizardStep[]{new MavenProjectImportStep(wizardContext), new SelectProfilesStep(wizardContext),
|
||||
new SelectImportedProjectsStep<MavenProject>(wizardContext) {
|
||||
@@ -50,9 +52,22 @@ public class MavenProjectImportProvider extends ProjectImportProvider {
|
||||
stringBuilder.append(" [").append(relPath).append("]");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isElementEnabled(project)) {
|
||||
stringBuilder.append(" (project is ignored. See Settings -> Maven -> Ignored Files)");
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isElementEnabled(MavenProject mavenProject) {
|
||||
Project project = wizardContext.getProject();
|
||||
if (project == null) return true;
|
||||
|
||||
return !MavenProjectsManager.getInstance(project).isIgnored(mavenProject);
|
||||
}
|
||||
|
||||
public void updateDataModel() {
|
||||
super.updateDataModel();
|
||||
getWizardContext().setProjectName(((MavenProjectBuilder)getBuilder()).getSuggestedProjectName());
|
||||
|
||||
@@ -43,8 +43,8 @@ public class CreateHtmlFileAction extends CreateFileFromTemplateAction implement
|
||||
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
|
||||
builder
|
||||
.setTitle(XmlBundle.message("new.html.file.action"))
|
||||
.addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME)
|
||||
.addKind("HTML5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME)
|
||||
.addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME)
|
||||
.addKind("HTML4 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME)
|
||||
.addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,8 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDefaultHtmlDoctype(@NotNull Project project) {
|
||||
return getProjectResources(project).myDefaultHtmlDoctype;
|
||||
final String doctype = getProjectResources(project).myDefaultHtmlDoctype;
|
||||
return XmlUtil.XHTML_URI.equals(doctype) ? XmlUtil.XHTML4_SCHEMA_LOCATION : doctype;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,7 +80,7 @@ public class HtmlLanguageLevelForm {
|
||||
}
|
||||
|
||||
public void resetFromDoctype(String doctype) {
|
||||
if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML_URI)) {
|
||||
if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML4_SCHEMA_LOCATION)) {
|
||||
myHtml4RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.xml.Html5SchemaProvider;
|
||||
import com.intellij.xml.XmlExtension;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.util.XmlNSDescriptorSequence;
|
||||
@@ -207,12 +208,19 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
if (nsDescriptor == null) {
|
||||
String htmlns = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(getProject());
|
||||
if (htmlns == null || htmlns.length() == 0) {
|
||||
htmlns = XmlUtil.XHTML_URI;
|
||||
htmlns = Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
nsDescriptor = getDefaultNSDescriptor(htmlns, false);
|
||||
}
|
||||
return new HtmlNSDescriptorImpl(nsDescriptor);
|
||||
}
|
||||
else if (XmlUtil.XHTML_URI.equals(namespace)) {
|
||||
String xhtmlNamespace = XmlUtil.getDefaultXhtmlNamespace(getProject());
|
||||
if (xhtmlNamespace == null || xhtmlNamespace.length() == 0) {
|
||||
xhtmlNamespace = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
return getDefaultNSDescriptor(xhtmlNamespace, false);
|
||||
}
|
||||
else if (namespace != null && namespace != XmlUtil.EMPTY_URI) {
|
||||
if (doctype == null || !namespace.equals(XmlUtil.getDtdUri(doctype))) {
|
||||
boolean documentIsSchemaThatDefinesNs = namespace.equals(XmlUtil.getTargetSchemaNsFromTag(getRootTag()));
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.codeInsight.daemon.Validator;
|
||||
import com.intellij.javaee.ExternalResourceManager;
|
||||
import com.intellij.javaee.ExternalResourceManagerEx;
|
||||
import com.intellij.javaee.ExternalResourceManagerImpl;
|
||||
import com.intellij.javaee.UriUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -35,9 +36,11 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.patterns.StandardPatterns;
|
||||
import com.intellij.patterns.StringPattern;
|
||||
@@ -74,6 +77,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -152,10 +156,16 @@ public class XmlUtil {
|
||||
@NonNls public static final String WSDL_SCHEMA_URI = "http://schemas.xmlsoap.org/wsdl/";
|
||||
public static final Key<PsiAnchor> ORIGINAL_ELEMENT = Key.create("ORIGINAL_ELEMENT");
|
||||
|
||||
public static final String XHTML4_SCHEMA_LOCATION;
|
||||
|
||||
private XmlUtil() {
|
||||
}
|
||||
|
||||
static {
|
||||
final URL xhtml4SchemaLocationUrl = XmlUtil.class.getResource(ExternalResourceManagerImpl.STANDARD_SCHEMAS + "xhtml1-transitional.xsd");
|
||||
XHTML4_SCHEMA_LOCATION = VfsUtil.urlToPath(VfsUtil.fixURLforIDEA(FileUtil.unquote(xhtml4SchemaLocationUrl.toExternalForm())));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getSchemaLocation(XmlTag tag, String namespace) {
|
||||
final String uri = ExternalResourceManagerEx.getInstanceEx().getResourceLocation(namespace, tag.getProject());
|
||||
@@ -604,11 +614,10 @@ public class XmlUtil {
|
||||
}
|
||||
|
||||
public static String getDefaultXhtmlNamespace(Project project) {
|
||||
String defaultHtmlDoctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project);
|
||||
if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(defaultHtmlDoctype)) {
|
||||
defaultHtmlDoctype = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
return defaultHtmlDoctype;
|
||||
final String doctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project);
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(doctype)
|
||||
? Html5SchemaProvider.XHTML5_SCHEMA_LOCATION
|
||||
: doctype;
|
||||
}
|
||||
//
|
||||
//public static void expandTag(@NotNull XmlTag tag) {
|
||||
|
||||
Reference in New Issue
Block a user