mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -50,6 +50,9 @@ public class DeploymentUtilImpl extends DeploymentUtil {
|
||||
@Nullable Set<String> writtenPaths,
|
||||
@Nullable FileFilter fileFilter) throws IOException {
|
||||
if (fileFilter != null && !fileFilter.accept(fromFile)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Skipping " + fromFile.getAbsolutePath() + ": it wasn't accepted by filter " + fileFilter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
checkPathDoNotNavigatesUpFromFile(fromFile);
|
||||
@@ -69,13 +72,19 @@ public class DeploymentUtilImpl extends DeploymentUtil {
|
||||
}
|
||||
if (fromFile.equals(toFile)
|
||||
|| writtenPaths != null && !writtenPaths.add(toFile.getPath())) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Skipping " + fromFile.getAbsolutePath() + ": " + toFile.getAbsolutePath() + " is already written");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!FileUtil.isFilePathAcceptable(toFile, fileFilter)) return;
|
||||
if (context.getProgressIndicator() != null) {
|
||||
context.getProgressIndicator().setText("Copying files");
|
||||
context.getProgressIndicator().setText2(fromFile.getPath());
|
||||
if (!FileUtil.isFilePathAcceptable(toFile, fileFilter)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Skipping " + fromFile.getAbsolutePath() + ": " + toFile.getAbsolutePath() + " wasn't accepted by filter " + fileFilter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
context.getProgressIndicator().setText("Copying files");
|
||||
context.getProgressIndicator().setText2(fromFile.getPath());
|
||||
try {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Copy file '" + fromFile + "' to '"+toFile+"'");
|
||||
|
||||
+1
-1
@@ -694,7 +694,7 @@ public class HighlightControlFlowUtil {
|
||||
return highlightInfo;
|
||||
} else {
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(context, PsiLambdaExpression.class);
|
||||
if (lambdaExpression != null) {
|
||||
if (lambdaExpression != null && !PsiTreeUtil.isAncestor(lambdaExpression, variable, true)) {
|
||||
boolean effectivelyFinal;
|
||||
if (variable instanceof PsiParameter) {
|
||||
final PsiElement parent = variable.getParent();
|
||||
|
||||
+11
-1
@@ -266,7 +266,17 @@ public class BindFieldsFromParametersAction extends BaseIntentionAction implemen
|
||||
String[] names = suggestedNameInfo.names;
|
||||
|
||||
final boolean isFinal = !isMethodStatic && method.isConstructor();
|
||||
final String fieldName = usedNames.add(names[0]) ? names[0] : JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(names[0], myParameter, true);
|
||||
String name = names[0];
|
||||
if (targetClass != null) {
|
||||
for (String curName : names) {
|
||||
if (!usedNames.contains(curName) && targetClass.findFieldByName(curName, false) != null) {
|
||||
name = curName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String fieldName = usedNames.add(name) ? name
|
||||
: JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(name, myParameter, true);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
|
||||
-5
@@ -46,9 +46,4 @@ public class JavaFieldNameIndex extends StringStubIndexExtension<PsiField> {
|
||||
public Collection<PsiField> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(s, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-5
@@ -46,9 +46,4 @@ public class JavaFullClassNameIndex extends IntStubIndexExtension<PsiClass> {
|
||||
public Collection<PsiClass> get(final Integer integer, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(integer, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-5
@@ -46,9 +46,4 @@ public class JavaMethodNameIndex extends StringStubIndexExtension<PsiMethod> {
|
||||
public Collection<PsiMethod> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(s, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-5
@@ -46,9 +46,4 @@ public class JavaShortClassNameIndex extends StringStubIndexExtension<PsiClass>
|
||||
public Collection<PsiClass> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(s, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-5
@@ -45,9 +45,4 @@ public class JavaStaticMemberNameIndex extends StringStubIndexExtension<PsiMembe
|
||||
public Collection<PsiMember> getStaticMembers(final String name, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(name, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-5
@@ -45,9 +45,4 @@ public class JavaStaticMemberTypeIndex extends StringStubIndexExtension<PsiMembe
|
||||
public Collection<PsiMember> getStaticMembers(@NotNull final String shortTypeText, final Project project, @NotNull final GlobalSearchScope scope) {
|
||||
return super.get(shortTypeText, project, new JavaSourceFilterScope(scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -86,7 +86,8 @@ public class ReplaceExpressionUtil {
|
||||
else if (i == JavaElementType.LITERAL_EXPRESSION ||
|
||||
i == JavaElementType.THIS_EXPRESSION ||
|
||||
i == JavaElementType.SUPER_EXPRESSION ||
|
||||
i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION) {
|
||||
i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION ||
|
||||
i == JavaElementType.LAMBDA_EXPRESSION) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public @interface MyAnnotation {
|
||||
Class<? extends Enum<?>> enumClass() default <error descr="Incompatible types. Found: 'java.lang.Class<java.lang.Enum>', required: 'java.lang.Class<? extends java.lang.Enum<?>>'">Enum.class</error>;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.*;
|
||||
class Test {
|
||||
{
|
||||
Map<Number, String> map1 = null;
|
||||
Map<Integer, String> map2 = <error descr="Inconvertible types; cannot cast 'java.util.Map<java.lang.Number,java.lang.String>' to 'java.util.Map<java.lang.Integer,java.lang.String>'">(Map<Integer, String>) map1</error>;
|
||||
}
|
||||
}
|
||||
+21
@@ -70,3 +70,24 @@ public class XXX {
|
||||
foo(() -> <error descr="Variable used in lambda expression should be effectively final">y</error>=1);
|
||||
}
|
||||
}
|
||||
|
||||
class Sample {
|
||||
public static void main(String[] args) {
|
||||
Runnable runnable = () -> {
|
||||
Integer i;
|
||||
if (true) {
|
||||
i = 111;
|
||||
System.out.println(i);
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable2 = () -> {
|
||||
Integer i2 = 333;
|
||||
i2 = 444;
|
||||
System.out.println(i2);
|
||||
};
|
||||
|
||||
runnable.run(); // prints 111
|
||||
runnable2.run(); // prints 444
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Bind Method Parameters to Fields" "true"
|
||||
|
||||
class A{
|
||||
private final String myP;
|
||||
private final String myLongParameterName;
|
||||
private final String myName;
|
||||
|
||||
void f(String p, String longParameterName, String shortParameterName){
|
||||
myP = p;
|
||||
myLongParameterName = longParameterName;
|
||||
myName = shortParameterName;
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Bind Method Parameters to Fields" "true"
|
||||
|
||||
class A{
|
||||
private final String myP;
|
||||
private final String myLongParameterName;
|
||||
private final String myName;
|
||||
|
||||
void <caret>f(String p, String longParameterName, String shortParameterName){
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
|
||||
class Test {
|
||||
{
|
||||
Map<Number, String> map1 = null;
|
||||
Map<Integer, String> map2 = (Map<Integer, String>) (Map<?, ?>) map1;
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);}
|
||||
public void testIDEA57339() throws Exception {doTest(false);}
|
||||
public void testIDEA57340() throws Exception {doTest(false);}
|
||||
public void testIDEA89771() throws Exception {doTest(false);}
|
||||
public void testIDEA89801() throws Exception {doTest(false);}
|
||||
public void testInconvertibleTypes() throws Exception {doTest(false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.intellij.codeInsight.daemon;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/params";
|
||||
|
||||
public void testFormalParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferredParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodApplicability() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class RedundantCast15Test extends InspectionTestCase {
|
||||
public void testEnumConstant() throws Exception { doTest(); }
|
||||
|
||||
public void testRawCast() throws Exception { doTest();}
|
||||
public void testCastToUnboundWildcard() throws Exception { doTest();}
|
||||
|
||||
public void testRawCastsToAvoidIncompatibility() throws Exception { doTest();}
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.intellij.psi;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
@@ -219,8 +234,10 @@ public class PsiDocumentManagerImplTest extends PlatformTestCase {
|
||||
|
||||
public void testCommitInBackground() {
|
||||
PsiFile file = getPsiManager().findFile(createFile());
|
||||
assertNotNull(file);
|
||||
assertTrue(file.isPhysical());
|
||||
final Document document = getPsiDocumentManager().getDocument(file);
|
||||
assertNotNull(document);
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
@@ -231,7 +248,7 @@ public class PsiDocumentManagerImplTest extends PlatformTestCase {
|
||||
semaphore.up();
|
||||
}
|
||||
});
|
||||
waitAndPump(semaphore);
|
||||
waitAndPump(semaphore, 30000);
|
||||
assertTrue(getPsiDocumentManager().isCommitted(document));
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@@ -249,7 +266,7 @@ public class PsiDocumentManagerImplTest extends PlatformTestCase {
|
||||
semaphore.up();
|
||||
}
|
||||
});
|
||||
waitAndPump(semaphore);
|
||||
waitAndPump(semaphore, 30000);
|
||||
assertTrue(getPsiDocumentManager().isCommitted(document));
|
||||
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
@@ -298,10 +315,13 @@ public class PsiDocumentManagerImplTest extends PlatformTestCase {
|
||||
assertEquals(2, count.get());
|
||||
}
|
||||
|
||||
private static void waitAndPump(Semaphore semaphore) {
|
||||
while (!semaphore.waitFor(10)) {
|
||||
private static void waitAndPump(Semaphore semaphore, int timeout) {
|
||||
final long limit = System.currentTimeMillis() + timeout;
|
||||
while (System.currentTimeMillis() < limit) {
|
||||
if (semaphore.waitFor(10)) return;
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
fail("Timeout");
|
||||
}
|
||||
|
||||
public void testDocumentFromAlienProjectGetsCommittedInBackground() throws Exception {
|
||||
|
||||
+3
-1
@@ -28,6 +28,7 @@ import org.jetbrains.jps.incremental.BuildLoggingManager;
|
||||
import org.jetbrains.jps.incremental.CompileScope;
|
||||
import org.jetbrains.jps.incremental.IncProjectBuilder;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactService;
|
||||
@@ -114,7 +115,8 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
|
||||
protected JpsArtifact addArtifact(String name, LayoutElementTestUtil.LayoutElementCreator root) {
|
||||
assertFalse("JpsArtifact " + name + " already exists", getArtifactNames().contains(name));
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myJpsProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE);
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myJpsProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE,
|
||||
JpsElementFactory.getInstance().createDummyElement());
|
||||
artifact.setOutputPath(getAbsolutePath("out/artifacts/" + name));
|
||||
return artifact;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.jetbrains.jps.model.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DirectoryArtifactType extends JpsArtifactType {
|
||||
public class DirectoryArtifactType extends JpsArtifactType<JpsDummyElement> {
|
||||
public static final DirectoryArtifactType INSTANCE = new DirectoryArtifactType();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.jetbrains.jps.model.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarArtifactType extends JpsArtifactType {
|
||||
public class JarArtifactType extends JpsArtifactType<JpsDummyElement> {
|
||||
public static final JarArtifactType INSTANCE = new JarArtifactType();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jps.model.artifact;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsNamedElement;
|
||||
import org.jetbrains.jps.model.JpsReferenceableElement;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
|
||||
@@ -12,7 +13,7 @@ import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
|
||||
*/
|
||||
public interface JpsArtifact extends JpsNamedElement, JpsReferenceableElement<JpsArtifact>, JpsCompositeElement {
|
||||
@NotNull
|
||||
JpsArtifactType getArtifactType();
|
||||
JpsArtifactType<?> getArtifactType();
|
||||
|
||||
@Nullable
|
||||
String getOutputPath();
|
||||
@@ -31,4 +32,6 @@ public interface JpsArtifact extends JpsNamedElement, JpsReferenceableElement<Jp
|
||||
JpsArtifactReference createReference();
|
||||
|
||||
void setBuildOnMake(boolean buildOnMake);
|
||||
|
||||
JpsElement getProperties();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.artifact;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
@@ -16,14 +17,14 @@ public abstract class JpsArtifactService {
|
||||
return JpsServiceManager.getInstance().getService(JpsArtifactService.class);
|
||||
}
|
||||
|
||||
public abstract JpsArtifact createArtifact(String name, JpsCompositePackagingElement rootElement, JpsArtifactType type);
|
||||
public abstract <P extends JpsElement> JpsArtifact createArtifact(@NotNull String name, @NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType<P> type, @NotNull P properties);
|
||||
|
||||
public abstract List<JpsArtifact> getArtifacts(@NotNull JpsProject project);
|
||||
|
||||
public abstract JpsArtifact addArtifact(@NotNull JpsProject project,
|
||||
@NotNull String name,
|
||||
@NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType type);
|
||||
public abstract <P extends JpsElement> JpsArtifact addArtifact(@NotNull JpsProject project, @NotNull String name,
|
||||
@NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType<P> type, @NotNull P properties);
|
||||
|
||||
public abstract JpsArtifactReference createReference(@NotNull String artifactName);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package org.jetbrains.jps.model.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.DummyJpsElementProperties;
|
||||
import org.jetbrains.jps.model.JpsElementType;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsArtifactType extends JpsElementType<DummyJpsElementProperties> {
|
||||
@Override
|
||||
public DummyJpsElementProperties createCopy(DummyJpsElementProperties properties) {
|
||||
return DummyJpsElementProperties.INSTANCE;
|
||||
public abstract class JpsArtifactType<P extends JpsElement> {
|
||||
private final JpsElementChildRole<P> myPropertiesRole = new JpsElementChildRole<P>();
|
||||
|
||||
public final JpsElementChildRole<P> getPropertiesRole() {
|
||||
return myPropertiesRole;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,42 +3,42 @@ package org.jetbrains.jps.model.artifact.impl;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.DummyJpsElementProperties;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactType;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.impl.JpsNamedCompositeElementBase;
|
||||
import org.jetbrains.jps.model.impl.JpsTypedDataImpl;
|
||||
import org.jetbrains.jps.model.impl.JpsTypedDataRole;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsArtifactImpl extends JpsNamedCompositeElementBase<JpsArtifactImpl> implements JpsArtifact {
|
||||
public class JpsArtifactImpl<P extends JpsElement> extends JpsNamedCompositeElementBase<JpsArtifactImpl<P>> implements JpsArtifact {
|
||||
private static final JpsElementChildRole<JpsCompositePackagingElement>
|
||||
ROOT_ELEMENT_CHILD_ROLE = JpsElementChildRoleBase.create("root element");
|
||||
private static final JpsTypedDataRole<JpsArtifactType> TYPED_DATA_ROLE = new JpsTypedDataRole<JpsArtifactType>();
|
||||
private final JpsArtifactType<P> myArtifactType;
|
||||
private String myOutputPath;
|
||||
private boolean myBuildOnMake;
|
||||
|
||||
|
||||
public JpsArtifactImpl(@NotNull String name, @NotNull JpsCompositePackagingElement rootElement, @NotNull JpsArtifactType type) {
|
||||
public JpsArtifactImpl(@NotNull String name, @NotNull JpsCompositePackagingElement rootElement, @NotNull JpsArtifactType<P> type, @NotNull P properties) {
|
||||
super(name);
|
||||
myArtifactType = type;
|
||||
myContainer.setChild(ROOT_ELEMENT_CHILD_ROLE, rootElement);
|
||||
myContainer.setChild(TYPED_DATA_ROLE, new JpsTypedDataImpl<JpsArtifactType>(type, DummyJpsElementProperties.INSTANCE));
|
||||
myContainer.setChild(type.getPropertiesRole(), properties);
|
||||
}
|
||||
|
||||
private JpsArtifactImpl(JpsArtifactImpl original) {
|
||||
private JpsArtifactImpl(JpsArtifactImpl<P> original) {
|
||||
super(original);
|
||||
myArtifactType = original.myArtifactType;
|
||||
myOutputPath = original.myOutputPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsArtifactImpl createCopy() {
|
||||
return new JpsArtifactImpl(this);
|
||||
public JpsArtifactImpl<P> createCopy() {
|
||||
return new JpsArtifactImpl<P>(this);
|
||||
}
|
||||
|
||||
public String getOutputPath() {
|
||||
@@ -54,8 +54,8 @@ public class JpsArtifactImpl extends JpsNamedCompositeElementBase<JpsArtifactImp
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsArtifactType getArtifactType() {
|
||||
return myContainer.getChild(TYPED_DATA_ROLE).getType();
|
||||
public JpsArtifactType<P> getArtifactType() {
|
||||
return myArtifactType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -75,6 +75,11 @@ public class JpsArtifactImpl extends JpsNamedCompositeElementBase<JpsArtifactImp
|
||||
myContainer.setChild(ROOT_ELEMENT_CHILD_ROLE, rootElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public P getProperties() {
|
||||
return myContainer.getChild(myArtifactType.getPropertiesRole());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuildOnMake() {
|
||||
return myBuildOnMake;
|
||||
|
||||
+12
-5
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.artifact.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactReference;
|
||||
@@ -16,6 +17,7 @@ import java.util.List;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsArtifactServiceImpl extends JpsArtifactService {
|
||||
|
||||
@Override
|
||||
public List<JpsArtifact> getArtifacts(@NotNull JpsProject project) {
|
||||
JpsElementCollectionImpl<JpsArtifact> collection = project.getContainer().getChild(JpsArtifactRole.ARTIFACT_COLLECTION_ROLE);
|
||||
@@ -23,15 +25,20 @@ public class JpsArtifactServiceImpl extends JpsArtifactService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsArtifact addArtifact(@NotNull JpsProject project, @NotNull String name, @NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType type) {
|
||||
JpsArtifact artifact = createArtifact(name, rootElement, type);
|
||||
public <P extends JpsElement> JpsArtifact addArtifact(@NotNull JpsProject project,
|
||||
@NotNull String name,
|
||||
@NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType<P> type,
|
||||
@NotNull P properties) {
|
||||
JpsArtifact artifact = createArtifact(name, rootElement, type, properties);
|
||||
return project.getContainer().getOrSetChild(JpsArtifactRole.ARTIFACT_COLLECTION_ROLE).addChild(artifact);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JpsArtifact createArtifact(String name, JpsCompositePackagingElement rootElement, JpsArtifactType type) {
|
||||
return new JpsArtifactImpl(name, rootElement, type);
|
||||
public <P extends JpsElement> JpsArtifact createArtifact(@NotNull String name, @NotNull JpsCompositePackagingElement rootElement,
|
||||
@NotNull JpsArtifactType<P> type, @NotNull P properties) {
|
||||
return new JpsArtifactImpl<P>(name, rootElement, type, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsArtifactTypeSerializer;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsArtifactPropertiesSerializer;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsPackagingElementSerializer;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsModuleExtensionLoader;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
@@ -83,7 +83,7 @@ public abstract class JpsModelSerializerExtension {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<JpsArtifactTypeSerializer> getArtifactTypeSerializers() {
|
||||
public List<? extends JpsArtifactPropertiesSerializer<?>> getArtifactTypePropertiesSerializers() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.module.JpsModuleType;
|
||||
@@ -14,4 +15,6 @@ public abstract class JpsModulePropertiesSerializer<P extends JpsElement> extend
|
||||
}
|
||||
|
||||
public abstract P loadProperties(@Nullable Element moduleRootElement);
|
||||
|
||||
public abstract void saveProperties(@NotNull P properties, @NotNull Element moduleRootElement);
|
||||
}
|
||||
|
||||
+4
@@ -180,6 +180,10 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
public JpsDummyElement loadProperties(@Nullable Element moduleRootElement) {
|
||||
return JpsElementFactory.getInstance().createDummyElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProperties(@NotNull JpsDummyElement properties, @NotNull Element moduleRootElement) {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.jetbrains.jps.model.serialization.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsArtifactDummyPropertiesSerializer extends JpsArtifactPropertiesSerializer<JpsDummyElement> {
|
||||
public JpsArtifactDummyPropertiesSerializer(String typeId, JpsArtifactType<JpsDummyElement> type) {
|
||||
super(typeId, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsDummyElement loadProperties(List<ArtifactPropertiesState> stateList) {
|
||||
return JpsElementFactory.getInstance().createDummyElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProperties(JpsDummyElement properties, List<ArtifactPropertiesState> stateList) {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.jetbrains.jps.model.serialization.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactType;
|
||||
import org.jetbrains.jps.model.serialization.JpsElementPropertiesSerializer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsArtifactPropertiesSerializer<P extends JpsElement> extends JpsElementPropertiesSerializer<P, JpsArtifactType<P>> {
|
||||
public JpsArtifactPropertiesSerializer(String typeId, JpsArtifactType<P> type) {
|
||||
super(type, typeId);
|
||||
}
|
||||
|
||||
public abstract P loadProperties(List<ArtifactPropertiesState> stateList);
|
||||
|
||||
public abstract void saveProperties(P properties, List<ArtifactPropertiesState> stateList);
|
||||
}
|
||||
+31
-21
@@ -6,10 +6,7 @@ import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.artifact.*;
|
||||
import org.jetbrains.jps.model.artifact.elements.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
@@ -31,9 +28,9 @@ public class JpsArtifactSerializer {
|
||||
new LibraryFilesElementSerializer(),
|
||||
new ArtifactOutputElementSerializer()
|
||||
};
|
||||
private static final JpsArtifactTypeSerializer[] STANDARD_TYPE_SERIALIZERS = {
|
||||
new JpsArtifactTypeSerializer("plain", DirectoryArtifactType.INSTANCE),
|
||||
new JpsArtifactTypeSerializer("jar", JarArtifactType.INSTANCE)
|
||||
private static final JpsArtifactPropertiesSerializer<?>[] STANDARD_TYPE_SERIALIZERS = {
|
||||
new JpsArtifactDummyPropertiesSerializer("plain", DirectoryArtifactType.INSTANCE),
|
||||
new JpsArtifactDummyPropertiesSerializer("jar", JarArtifactType.INSTANCE)
|
||||
};
|
||||
private static final String ELEMENT_TAG = "element";
|
||||
private static final String ID_ATTRIBUTE = "id";
|
||||
@@ -45,13 +42,18 @@ public class JpsArtifactSerializer {
|
||||
for (Element artifactElement : JDOMUtil.getChildren(componentElement, "artifact")) {
|
||||
ArtifactState state = XmlSerializer.deserialize(artifactElement, ArtifactState.class);
|
||||
if (state == null) continue;
|
||||
JpsArtifactType artifactType = getTypeSerializer(state.getArtifactType()).getType();
|
||||
JpsPackagingElement rootElement = loadPackagingElement(state.getRootElement());
|
||||
if (rootElement != null) {
|
||||
JpsArtifact artifact = service.addArtifact(project, state.getName(), (JpsCompositePackagingElement)rootElement, artifactType);
|
||||
artifact.setBuildOnMake(state.isBuildOnMake());
|
||||
artifact.setOutputPath(state.getOutputPath());
|
||||
}
|
||||
JpsArtifactPropertiesSerializer<?> serializer = getTypePropertiesSerializer(state.getArtifactType());
|
||||
loadArtifact(project, service, state, serializer);
|
||||
}
|
||||
}
|
||||
|
||||
private static <P extends JpsElement> void loadArtifact(JpsProject project, JpsArtifactService service, ArtifactState state, JpsArtifactPropertiesSerializer<P> serializer) {
|
||||
JpsPackagingElement rootElement = loadPackagingElement(state.getRootElement());
|
||||
if (rootElement != null) {
|
||||
JpsArtifact artifact = service.addArtifact(project, state.getName(), (JpsCompositePackagingElement)rootElement,
|
||||
serializer.getType(), serializer.loadProperties(state.getPropertiesList()));
|
||||
artifact.setBuildOnMake(state.isBuildOnMake());
|
||||
artifact.setOutputPath(state.getOutputPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +62,16 @@ public class JpsArtifactSerializer {
|
||||
state.setName(artifact.getName());
|
||||
state.setBuildOnMake(artifact.isBuildOnMake());
|
||||
state.setOutputPath(artifact.getOutputPath());
|
||||
state.setArtifactType(getTypeSerializer(artifact.getArtifactType()).getTypeId());
|
||||
JpsArtifactPropertiesSerializer<?> serializer = getTypePropertiesSerializer(artifact.getArtifactType());
|
||||
doSaveArtifact(artifact, componentElement, state, serializer);
|
||||
}
|
||||
|
||||
private static <P extends JpsElement> void doSaveArtifact(JpsArtifact artifact, Element componentElement, ArtifactState state,
|
||||
JpsArtifactPropertiesSerializer<P> serializer) {
|
||||
state.setArtifactType(serializer.getTypeId());
|
||||
state.setRootElement(savePackagingElement(artifact.getRootElement()));
|
||||
//noinspection unchecked
|
||||
serializer.saveProperties((P)artifact.getProperties(), state.getPropertiesList());
|
||||
componentElement.addContent(XmlSerializer.serialize(state, SERIALIZATION_FILTERS));
|
||||
}
|
||||
|
||||
@@ -138,14 +148,14 @@ public class JpsArtifactSerializer {
|
||||
throw new IllegalArgumentException("Serializer not found for " + elementClass);
|
||||
}
|
||||
|
||||
private static JpsArtifactTypeSerializer getTypeSerializer(String typeId) {
|
||||
for (JpsArtifactTypeSerializer serializer : STANDARD_TYPE_SERIALIZERS) {
|
||||
private static JpsArtifactPropertiesSerializer<?> getTypePropertiesSerializer(String typeId) {
|
||||
for (JpsArtifactPropertiesSerializer serializer : STANDARD_TYPE_SERIALIZERS) {
|
||||
if (serializer.getTypeId().equals(typeId)) {
|
||||
return serializer;
|
||||
}
|
||||
}
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
for (JpsArtifactTypeSerializer serializer : extension.getArtifactTypeSerializers()) {
|
||||
for (JpsArtifactPropertiesSerializer serializer : extension.getArtifactTypePropertiesSerializers()) {
|
||||
if (serializer.getTypeId().equals(typeId)) {
|
||||
return serializer;
|
||||
}
|
||||
@@ -154,14 +164,14 @@ public class JpsArtifactSerializer {
|
||||
return STANDARD_TYPE_SERIALIZERS[0];
|
||||
}
|
||||
|
||||
private static JpsArtifactTypeSerializer getTypeSerializer(JpsArtifactType type) {
|
||||
for (JpsArtifactTypeSerializer serializer : STANDARD_TYPE_SERIALIZERS) {
|
||||
private static JpsArtifactPropertiesSerializer<?> getTypePropertiesSerializer(JpsArtifactType type) {
|
||||
for (JpsArtifactPropertiesSerializer serializer : STANDARD_TYPE_SERIALIZERS) {
|
||||
if (serializer.getType().equals(type)) {
|
||||
return serializer;
|
||||
}
|
||||
}
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
for (JpsArtifactTypeSerializer serializer : extension.getArtifactTypeSerializers()) {
|
||||
for (JpsArtifactPropertiesSerializer serializer : extension.getArtifactTypePropertiesSerializers()) {
|
||||
if (serializer.getType().equals(type)) {
|
||||
return serializer;
|
||||
}
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jps.model.serialization.artifact;
|
||||
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactType;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsArtifactTypeSerializer {
|
||||
private final String myTypeId;
|
||||
private final JpsArtifactType myType;
|
||||
|
||||
public JpsArtifactTypeSerializer(String typeId, JpsArtifactType type) {
|
||||
myTypeId = typeId;
|
||||
myType = type;
|
||||
}
|
||||
|
||||
public String getTypeId() {
|
||||
return myTypeId;
|
||||
}
|
||||
|
||||
public JpsArtifactType getType() {
|
||||
return myType;
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -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.
|
||||
@@ -30,14 +30,18 @@ public class VFileContentChangeEvent extends VFileEvent {
|
||||
private final long myOldModificationStamp;
|
||||
private final long myNewModificationStamp;
|
||||
|
||||
public VFileContentChangeEvent(final Object requestor, @NotNull VirtualFile file, long oldModificationStamp, long newModificationStamp, boolean isFromRefresh) {
|
||||
public VFileContentChangeEvent(final Object requestor,
|
||||
@NotNull final VirtualFile file,
|
||||
final long oldModificationStamp,
|
||||
final long newModificationStamp,
|
||||
final boolean isFromRefresh) {
|
||||
super(requestor, isFromRefresh);
|
||||
|
||||
myFile = file;
|
||||
myOldModificationStamp = oldModificationStamp;
|
||||
myNewModificationStamp = newModificationStamp == -1 ? LocalTimeCounter.currentTime() : newModificationStamp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
|
||||
@@ -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.
|
||||
@@ -30,13 +30,14 @@ public class VFileMoveEvent extends VFileEvent {
|
||||
private final VirtualFile myOldParent;
|
||||
private final VirtualFile myNewParent;
|
||||
|
||||
public VFileMoveEvent(Object requestor, final VirtualFile file, final VirtualFile newParent) {
|
||||
public VFileMoveEvent(final Object requestor, @NotNull final VirtualFile file, final VirtualFile newParent) {
|
||||
super(requestor, false);
|
||||
myFile = file;
|
||||
myNewParent = newParent;
|
||||
myOldParent = file.getParent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
|
||||
+8
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,12 @@ public class VFilePropertyChangeEvent extends VFileEvent {
|
||||
private final Object myOldValue;
|
||||
private final Object myNewValue;
|
||||
|
||||
public VFilePropertyChangeEvent(Object requestor, @NotNull VirtualFile file, @NotNull String propertyName, Object oldValue, Object newValue, boolean isFromRefresh) {
|
||||
public VFilePropertyChangeEvent(final Object requestor,
|
||||
@NotNull final VirtualFile file,
|
||||
@NotNull final String propertyName,
|
||||
final Object oldValue,
|
||||
final Object newValue,
|
||||
final boolean isFromRefresh) {
|
||||
super(requestor, isFromRefresh);
|
||||
myFile = file;
|
||||
myPropertyName = propertyName;
|
||||
@@ -39,6 +44,7 @@ public class VFilePropertyChangeEvent extends VFileEvent {
|
||||
myNewValue = newValue;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
|
||||
@@ -34,9 +34,4 @@ public abstract class AbstractStubIndex<Key, Psi extends PsiElement> implements
|
||||
}
|
||||
|
||||
public int getCacheSize() { return 2 * 1024; }
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,4 @@ public interface StubIndexExtension<Key, Psi extends PsiElement> {
|
||||
KeyDescriptor<Key> getKeyDescriptor();
|
||||
|
||||
int getCacheSize();
|
||||
|
||||
boolean isKeyHighlySelective();
|
||||
}
|
||||
@@ -140,9 +140,4 @@ public class FilenameIndex extends ScalarIndexExtension<String> {
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyHighlySelective() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -118,8 +118,9 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter {
|
||||
if (type == myLineCommentType) {
|
||||
final String restString = editorCharSequence.subSequence(caret, document.getLineEndOffset(lineNumber)).toString();
|
||||
if (!StringUtil.isEmptyOrSpaces(restString)) {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, "\n" + lineIndent + myLineCommentPrefix);
|
||||
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(lineNumber + 1, 1));
|
||||
final String linePrefix = lineIndent + myLineCommentPrefix;
|
||||
EditorModificationUtil.insertStringAtCaret(editor, "\n" + linePrefix);
|
||||
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(lineNumber + 1, linePrefix.length()));
|
||||
return Result.Stop;
|
||||
}
|
||||
else if (iterator.getStart() < lineStartOffset) {
|
||||
|
||||
+98
-45
@@ -18,14 +18,14 @@ package com.intellij.codeInsight.editorActions.wordSelection;
|
||||
|
||||
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiPlainText;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -38,28 +38,31 @@ public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBa
|
||||
return e instanceof PsiPlainText || e instanceof PsiComment;
|
||||
}
|
||||
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
if (!selectionModel.hasSelection()) {
|
||||
return Collections.emptyList();
|
||||
private static TextRange findParagraphRange(String text, int start, int end) {
|
||||
int paragraphStart = text.lastIndexOf("\n\n", start);
|
||||
int paragraphEnd = text.indexOf("\n\n", end);
|
||||
return new TextRange(paragraphStart >= 0 ? paragraphStart + 2 : 0, paragraphEnd < 0 ? text.length() : paragraphEnd);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TextRange findCustomRange(String text, int start, int end, char startChar, char endChar) {
|
||||
int prev = text.lastIndexOf(startChar, start);
|
||||
int next = text.indexOf(endChar, end);
|
||||
if (prev < 0 || next < 0) {
|
||||
return null;
|
||||
}
|
||||
if (prev + 1 < start || next > end) {
|
||||
return new TextRange(prev + 1, next);
|
||||
}
|
||||
|
||||
int sentenceStart = selectionModel.getSelectionStart();
|
||||
final int elementStart = e.getTextRange().getStartOffset();
|
||||
if (sentenceStart <= elementStart) return Collections.emptyList();
|
||||
return new TextRange(prev, next + 1);
|
||||
}
|
||||
|
||||
int paragraphStart = editorText.subSequence(elementStart, sentenceStart).toString().lastIndexOf("\n\n");
|
||||
if (paragraphStart < 0) paragraphStart = elementStart;
|
||||
else paragraphStart += 2 + elementStart;
|
||||
boolean isParagraph = paragraphStart == sentenceStart;
|
||||
private static TextRange findSentenceRange(String editorText, int start, int end) {
|
||||
int sentenceStart = start;
|
||||
|
||||
while (sentenceStart > paragraphStart) {
|
||||
final char c = editorText.charAt(sentenceStart - 1);
|
||||
if (!isNatural(c)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (SENTENCE_END.contains(c)) {
|
||||
while (sentenceStart > 0) {
|
||||
if (isSentenceEnd(editorText, sentenceStart - 1) || !isNatural(editorText.charAt(sentenceStart - 1))) {
|
||||
break;
|
||||
}
|
||||
sentenceStart--;
|
||||
@@ -68,40 +71,90 @@ public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBa
|
||||
sentenceStart++;
|
||||
}
|
||||
|
||||
int sentenceEnd = selectionModel.getSelectionEnd();
|
||||
final int elementEnd = e.getTextRange().getEndOffset();
|
||||
if (sentenceEnd > elementEnd) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int paragraphEnd = editorText.subSequence(sentenceEnd, elementEnd).toString().indexOf("\n\n");
|
||||
if (paragraphEnd < 0) paragraphEnd = elementEnd;
|
||||
else paragraphEnd += sentenceEnd;
|
||||
isParagraph &= paragraphEnd == sentenceEnd;
|
||||
|
||||
if (isParagraph) {
|
||||
return Collections.emptyList(); //whole text
|
||||
}
|
||||
|
||||
if (sentenceEnd > elementStart) sentenceEnd--;
|
||||
while (sentenceEnd < paragraphEnd) {
|
||||
final char c = editorText.charAt(sentenceEnd);
|
||||
if (!isNatural(c)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int sentenceEnd = Math.max(0, end - 1);
|
||||
|
||||
while (sentenceEnd < editorText.length()) {
|
||||
sentenceEnd++;
|
||||
|
||||
if (SENTENCE_END.contains(c)) {
|
||||
if (isSentenceEnd(editorText, sentenceEnd - 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new TextRange(sentenceStart, sentenceEnd);
|
||||
}
|
||||
|
||||
private static boolean isSentenceEnd(String text, final int i) {
|
||||
return SENTENCE_END.contains(text.charAt(i)) && (i + 1 == text.length() || Character.isWhitespace(text.charAt(i + 1)));
|
||||
}
|
||||
|
||||
private static TextRange findNaturalRange(String editorText, int start, int end) {
|
||||
while (start > 0) {
|
||||
if (!isNatural(editorText.charAt(start - 1))) {
|
||||
break;
|
||||
}
|
||||
start--;
|
||||
}
|
||||
|
||||
if (sentenceStart == selectionModel.getSelectionStart() && sentenceEnd == selectionModel.getSelectionEnd()) {
|
||||
return Arrays.asList(new TextRange(paragraphStart, paragraphEnd));
|
||||
while (end < editorText.length()) {
|
||||
final char c = editorText.charAt(end);
|
||||
if (!isNatural(c)) {
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
return new TextRange(start, end);
|
||||
}
|
||||
|
||||
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
|
||||
TextRange range = expandSelection(e, editorText, cursorOffset, cursorOffset);
|
||||
if (range == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.asList(new TextRange(sentenceStart, sentenceEnd));
|
||||
ArrayList<TextRange> result = new ArrayList<TextRange>();
|
||||
result.add(range);
|
||||
while (true) {
|
||||
TextRange next = expandSelection(e, editorText, range.getStartOffset(), range.getEndOffset());
|
||||
if (next == null || next.equals(range)) {
|
||||
break;
|
||||
}
|
||||
result.add(next);
|
||||
range = next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static TextRange expandSelection(PsiElement e, CharSequence editorText, int selStart, int selEnd) {
|
||||
TextRange range = e.getTextRange();
|
||||
int shift = range.getStartOffset();
|
||||
if (selStart <= shift || selEnd >= range.getEndOffset()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String elementText = editorText.subSequence(shift, range.getEndOffset()).toString();
|
||||
int start = selStart - shift;
|
||||
int end = selEnd - shift;
|
||||
|
||||
TextRange best = findSentenceRange(elementText, start, end);
|
||||
best = narrowRange(best, findCustomRange(elementText, start, end, '\"', '\"'));
|
||||
best = narrowRange(best, findCustomRange(elementText, start, end, '(', ')'));
|
||||
|
||||
TextRange natural = findNaturalRange(elementText, start, end);
|
||||
if (!natural.contains(best)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TextRange paragraph = findParagraphRange(elementText, start, end);
|
||||
if (best.getStartOffset() == start && best.getEndOffset() == end || !paragraph.contains(best)) {
|
||||
return paragraph.shiftRight(shift);
|
||||
}
|
||||
|
||||
|
||||
return best.shiftRight(shift);
|
||||
}
|
||||
|
||||
private static TextRange narrowRange(TextRange best, TextRange candidate) {
|
||||
return candidate != null && best.contains(candidate) ? candidate : best;
|
||||
}
|
||||
|
||||
private static boolean isNatural(char c) {
|
||||
|
||||
@@ -60,6 +60,10 @@ public abstract class ProjectConverter {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean isConversionNeeded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void preProcessingFinished() throws CannotConvertException {
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,11 @@ public class ConversionRunner {
|
||||
myProcessProjectLibraries = myProjectLibrariesConverter != null
|
||||
&& myProjectLibrariesConverter.isConversionNeeded(myContext.getProjectLibrariesSettings());
|
||||
|
||||
return myProcessProjectFile || myProcessWorkspaceFile || myProcessRunConfigurations || !myModulesFilesToProcess.isEmpty();
|
||||
return myProcessProjectFile ||
|
||||
myProcessWorkspaceFile ||
|
||||
myProcessRunConfigurations ||
|
||||
!myModulesFilesToProcess.isEmpty() ||
|
||||
myConverter.isConversionNeeded();
|
||||
}
|
||||
|
||||
public boolean isModuleConversionNeeded(File moduleFile) throws CannotConvertException {
|
||||
|
||||
@@ -84,6 +84,10 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
for (Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity : myRunningConfigurations) {
|
||||
Disposer.dispose(trinity.first);
|
||||
}
|
||||
myRunningConfigurations.clear();
|
||||
}
|
||||
|
||||
public RunContentManager getContentManager() {
|
||||
@@ -316,6 +320,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
private void forgetRunContentDescriptor(RunContentDescriptor runContentDescriptor) {
|
||||
for (Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity : myRunningConfigurations) {
|
||||
if (trinity.getFirst() == runContentDescriptor) {
|
||||
//runContentDescriptor.dispose();
|
||||
myRunningConfigurations.remove(trinity);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -292,21 +293,36 @@ public class FileStructurePopup implements Disposable {
|
||||
}
|
||||
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myTree, true);
|
||||
myFilteringStructure.rebuild();
|
||||
myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTreeHasBuilt.setDone();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
myFilteringStructure.rebuild();
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
|
||||
myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectPsiElement(myInitialPsiElement);
|
||||
myTreeHasBuilt.setDone();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectPsiElement(myInitialPsiElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
installUpdater();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void installUpdater() {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, myPopup);
|
||||
alarm.addRequest(new Runnable() {
|
||||
@@ -330,24 +346,26 @@ public class FileStructurePopup implements Disposable {
|
||||
myAbstractTreeBuilder.refilter(null, false, false).doWhenProcessed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTree.repaint();
|
||||
if (isBackspace && handleBackspace(filter)) {
|
||||
return;
|
||||
}
|
||||
if (myFilteringStructure.getRootElement().getChildren().length == 0) {
|
||||
for (JCheckBox box : myCheckBoxes.values()) {
|
||||
if (!box.isSelected()) {
|
||||
myAutoClicked.add(box);
|
||||
myTriggeredCheckboxes.add(0, Pair.create(filter, box));
|
||||
box.doClick();
|
||||
filter = "";
|
||||
break;
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTree.repaint();
|
||||
if (isBackspace && handleBackspace(filter)) {
|
||||
return;
|
||||
}
|
||||
if (myFilteringStructure.getRootElement().getChildren().length == 0) {
|
||||
for (JCheckBox box : myCheckBoxes.values()) {
|
||||
if (!box.isSelected()) {
|
||||
myAutoClicked.add(box);
|
||||
myTriggeredCheckboxes.add(0, Pair.create(filter, box));
|
||||
box.doClick();
|
||||
filter = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (mySpeedSearch.isPopupActive()) {
|
||||
// mySpeedSearch.refreshSelection();
|
||||
//}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,8 +131,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
IndexInfrastructure.getStorageFile(indexKey),
|
||||
extension.getKeyDescriptor(),
|
||||
new StubIdExternalizer(),
|
||||
extension.getCacheSize(),
|
||||
extension.isKeyHighlySelective()
|
||||
extension.getCacheSize()
|
||||
);
|
||||
final MemoryIndexStorage<K, StubIdList> memStorage = new MemoryIndexStorage<K, StubIdList>(storage);
|
||||
myIndices.put(indexKey, new MyIndex<K>(memStorage));
|
||||
|
||||
@@ -80,6 +80,11 @@ public class ReplacePromptDialog extends DialogWrapper {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return "ReplaceDuplicatesPrompt";
|
||||
}
|
||||
|
||||
private class DoAction extends AbstractAction {
|
||||
private final int myExitCode;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.io.storage.AbstractStorage;
|
||||
import gnu.trove.TIntHashSet;
|
||||
@@ -87,7 +86,7 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
}
|
||||
|
||||
private static long getVFSTimestamp() {
|
||||
return ((PersistentFS)ManagingFS.getInstance()).getCreationTimestamp();
|
||||
return ManagingFS.getInstance().getCreationTimestamp();
|
||||
}
|
||||
|
||||
private void handleError(Throwable e, @Nullable String message) {
|
||||
@@ -125,11 +124,10 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
|
||||
public static void notifyUser(String message) {
|
||||
final String logFile = PathManager.getLogPath();
|
||||
String createIssuePart = "<br>" +
|
||||
/*String createIssuePart = "<br>" +
|
||||
"<br>" +
|
||||
"Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
|
||||
"to the <a href=\"url\">YouTrack issue</a>";
|
||||
|
||||
"to the <a href=\"url\">YouTrack issue</a>";*/
|
||||
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
|
||||
"Local History is broken",
|
||||
message /*+ createIssuePart*/,
|
||||
|
||||
@@ -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.
|
||||
@@ -51,6 +51,8 @@ public abstract class ManagingFS implements FileSystemInterface, FileSystemPersi
|
||||
|
||||
public abstract int getFilesystemModificationCount();
|
||||
|
||||
public abstract long getCreationTimestamp();
|
||||
|
||||
public abstract boolean areChildrenLoaded(@NotNull VirtualFile dir);
|
||||
|
||||
public abstract boolean wereChildrenAccessed(@NotNull VirtualFile dir);
|
||||
@@ -65,7 +67,6 @@ public abstract class ManagingFS implements FileSystemInterface, FileSystemPersi
|
||||
@NotNull
|
||||
public abstract VirtualFile[] getRoots(@NotNull NewVirtualFileSystem fs);
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract VirtualFile[] getLocalRoots();
|
||||
|
||||
|
||||
@@ -89,8 +89,18 @@ public abstract class Property<T extends PropertiesContainer> {
|
||||
public void setValue(@NotNull T container, @Nullable Object value) throws Exception {
|
||||
}
|
||||
|
||||
public final boolean isRecursiveDefault(@NotNull T container) throws Exception {
|
||||
for (Property<T> child : getChildren(container)) {
|
||||
boolean isDefault = child.isRecursiveDefault(container);
|
||||
if (!isDefault) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return isDefaultValue(container);
|
||||
}
|
||||
|
||||
public boolean isDefaultValue(@NotNull T container) throws Exception {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setDefaultValue(@NotNull T container) throws Exception {
|
||||
@@ -144,6 +154,10 @@ public abstract class Property<T extends PropertiesContainer> {
|
||||
myDeprecated = deprecated;
|
||||
}
|
||||
|
||||
public boolean showAsDefault(@NotNull T container) throws Exception {
|
||||
return isRecursiveDefault(container);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract PropertyRenderer getRenderer();
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public abstract class PropertyTable extends JBTable {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
for (PropertiesContainer component : myContainers) {
|
||||
if (!property.isDefaultValue(component)) {
|
||||
if (!property.isRecursiveDefault(component)) {
|
||||
property.setDefaultValue(component);
|
||||
}
|
||||
}
|
||||
@@ -427,16 +427,16 @@ public abstract class PropertyTable extends JBTable {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillProperties(PropertiesContainer<?> component, List<Property> properties) {
|
||||
for (Property property : component.getProperties()) {
|
||||
addProperty(component, property, properties);
|
||||
private void fillProperties(PropertiesContainer<?> container, List<Property> properties) {
|
||||
for (Property property : container.getProperties()) {
|
||||
addProperty(container, property, properties);
|
||||
}
|
||||
}
|
||||
|
||||
private void addProperty(PropertiesContainer<?> component, Property property, List<Property> properties) {
|
||||
private void addProperty(PropertiesContainer<?> container, Property property, List<Property> properties) {
|
||||
if (property.isExpert() && !myShowExpertProperties) {
|
||||
try {
|
||||
if (property.isDefaultValue(component)) {
|
||||
if (property.isRecursiveDefault(container)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -449,7 +449,7 @@ public abstract class PropertyTable extends JBTable {
|
||||
|
||||
if (isExpanded(property)) {
|
||||
for (Property child : getChildren(property)) {
|
||||
addProperty(component, child, properties);
|
||||
addProperty(container, child, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -557,7 +557,7 @@ public abstract class PropertyTable extends JBTable {
|
||||
|
||||
public boolean isDefault(Property property) throws Exception {
|
||||
for (PropertiesContainer component : myContainers) {
|
||||
if (!property.isDefaultValue(component)) {
|
||||
if (!property.isRecursiveDefault(component)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1142,7 +1142,12 @@ public abstract class PropertyTable extends JBTable {
|
||||
|
||||
boolean isDefault = true;
|
||||
try {
|
||||
isDefault = isDefault(property);
|
||||
for (PropertiesContainer container : myContainers) {
|
||||
if (!property.showAsDefault(container)) {
|
||||
isDefault = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.debug(e);
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
});
|
||||
((PersistentFS)ManagingFS.getInstance()).clearIdCache();
|
||||
PersistentFS.getInstance().clearIdCache();
|
||||
|
||||
for (VirtualFile root : ManagingFS.getInstance().getRoots(this)) {
|
||||
if (root instanceof VirtualDirectoryImpl) {
|
||||
|
||||
+16
-10
@@ -69,7 +69,10 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
// guarded by this
|
||||
private Object myChildren; // Either Map<String, VFile> or VFile[]
|
||||
|
||||
public VirtualDirectoryImpl(@NotNull String name, final VirtualDirectoryImpl parent, @NotNull NewVirtualFileSystem fs, final int id) {
|
||||
public VirtualDirectoryImpl(@NotNull final String name,
|
||||
@Nullable final VirtualDirectoryImpl parent,
|
||||
@NotNull final NewVirtualFileSystem fs,
|
||||
final int id) {
|
||||
super(name, parent, id);
|
||||
myFS = fs;
|
||||
}
|
||||
@@ -151,7 +154,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
|
||||
synchronized (this) {
|
||||
// do not extract getId outside the synchronized block since it will cause a concurrency problem.
|
||||
int id = PersistentFS.getId(this, name, delegate);
|
||||
int id = ourPersistence.getId(this, name, delegate);
|
||||
if (id > 0) {
|
||||
// maybe another doFindChild() sneaked in the middle
|
||||
VirtualFileSystemEntry lastTry = map.get(name);
|
||||
@@ -171,7 +174,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
public VirtualFileSystemEntry createChild(@NotNull String name, int id) {
|
||||
final VirtualFileSystemEntry child;
|
||||
final NewVirtualFileSystem fs = getFileSystem();
|
||||
if (PersistentFS.isDirectory(id)) {
|
||||
if (ourPersistence.isDirectory(id)) {
|
||||
child = new VirtualDirectoryImpl(name, this, fs, id);
|
||||
}
|
||||
else {
|
||||
@@ -379,8 +382,8 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
return Arrays.asList(getChildren());
|
||||
}
|
||||
|
||||
final String[] names = PersistentFS.listPersisted(this);
|
||||
NewVirtualFileSystem delegate = PersistentFS.replaceWithNativeFS(getFileSystem());
|
||||
final String[] names = ourPersistence.listPersisted(this);
|
||||
final NewVirtualFileSystem delegate = PersistentFS.replaceWithNativeFS(getFileSystem());
|
||||
for (String name : names) {
|
||||
findChild(name, false, false, delegate);
|
||||
}
|
||||
@@ -397,7 +400,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
return children;
|
||||
}
|
||||
|
||||
Pair<String[], int[]> pair = PersistentFS.listAll(this);
|
||||
Pair<String[], int[]> pair = ourPersistence.listAll(this);
|
||||
final int[] childrenIds = pair.second;
|
||||
if (childrenIds.length == 0) {
|
||||
children = EMPTY_ARRAY;
|
||||
@@ -481,8 +484,9 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
private Map<String, VirtualFileSystemEntry> asMap() {
|
||||
Object children = myChildren;
|
||||
if (children instanceof Map) {
|
||||
//noinspection unchecked
|
||||
return (Map<String, VirtualFileSystemEntry>)children;
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
final Map<String, VirtualFileSystemEntry> map = (Map<String, VirtualFileSystemEntry>)children;
|
||||
return map;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -495,8 +499,9 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
myChildren = map;
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
map = (Map<String, VirtualFileSystemEntry>)myChildren;
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
final Map<String, VirtualFileSystemEntry> aMap = (Map<String, VirtualFileSystemEntry>)myChildren;
|
||||
map = aMap;
|
||||
}
|
||||
|
||||
return map;
|
||||
@@ -573,6 +578,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
|
||||
@TestOnly
|
||||
public synchronized void cleanupCachedChildren(@NotNull Set<VirtualFile> survivors) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
if (survivors.contains(this)) {
|
||||
for (VirtualFile file : getCachedChildren()) {
|
||||
if (file instanceof VirtualDirectoryImpl) {
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ import com.intellij.openapi.vfs.VfsBundle;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingRegistry;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
@@ -45,7 +44,7 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
private static final Key<String> SYMLINK_TARGET = Key.create("SYMLINK_TARGET");
|
||||
public static final VirtualFileSystemEntry[] EMPTY_ARRAY = new VirtualFileSystemEntry[0];
|
||||
|
||||
protected static final PersistentFS ourPersistence = (PersistentFS)ManagingFS.getInstance();
|
||||
protected static final PersistentFS ourPersistence = PersistentFS.getInstance();
|
||||
|
||||
private static final byte DIRTY_FLAG = 0x01;
|
||||
private static final byte HAS_SYMLINK_FLAG = 0x02;
|
||||
|
||||
+33
-1122
File diff suppressed because it is too large
Load Diff
+1173
File diff suppressed because it is too large
Load Diff
+10
-5
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileAttributes;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.newvfs.events.*;
|
||||
@@ -64,7 +63,7 @@ public class RefreshWorker {
|
||||
fs = PersistentFS.replaceWithNativeFS(fs);
|
||||
}
|
||||
|
||||
final PersistentFS persistence = (PersistentFS)ManagingFS.getInstance();
|
||||
final PersistentFS persistence = PersistentFS.getInstance();
|
||||
|
||||
while (!myRefreshQueue.isEmpty()) {
|
||||
final VirtualFileSystemEntry file = (VirtualFileSystemEntry)myRefreshQueue.pullFirst();
|
||||
@@ -100,8 +99,13 @@ public class RefreshWorker {
|
||||
}
|
||||
|
||||
for (String name : newNames) {
|
||||
boolean isDirectory = fs.isDirectory(new FakeVirtualFile(file, name));
|
||||
scheduleCreation(file, name, isDirectory);
|
||||
final FileAttributes childAttributes = fs.getAttributes(new FakeVirtualFile(file, name));
|
||||
if (childAttributes != null) {
|
||||
scheduleCreation(file, name, childAttributes.isDirectory());
|
||||
}
|
||||
else {
|
||||
LOG.warn("fs=" + fs + " dir=" + file + " name=" + name);
|
||||
}
|
||||
}
|
||||
|
||||
for (VirtualFile child : file.getChildren()) {
|
||||
@@ -111,7 +115,8 @@ public class RefreshWorker {
|
||||
checkAndScheduleChildRefresh(file, child, childAttributes);
|
||||
}
|
||||
else {
|
||||
LOG.error(child + " on " + fs);
|
||||
LOG.warn("fs=" + fs + " dir=" + file + " name=" + child.getName());
|
||||
scheduleDeletion(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.javaee.ExternalResourceManager"
|
||||
serviceImplementation="com.intellij.javaee.ExternalResourceManagerImpl"/>
|
||||
<project.converterProvider implementation="com.intellij.javaee.DefaultHtmlDoctypeConverter"/>
|
||||
|
||||
<standardResourceProvider implementation="com.intellij.javaee.InternalResourceProvider"/>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.vfs.newvfs.ManagingFS</interface-class>
|
||||
<implementation-class>com.intellij.openapi.vfs.newvfs.persistent.PersistentFS</implementation-class>
|
||||
<implementation-class>com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
||||
+22
-1
@@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
|
||||
import com.intellij.testFramework.PlatformLangTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
|
||||
@@ -209,7 +210,7 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
|
||||
assertEquals(5, virtualFile.getLength());
|
||||
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
PersistentFS.cleanPersistedContents();
|
||||
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
|
||||
s = VfsUtilCore.loadText(virtualFile);
|
||||
assertEquals("new content", s);
|
||||
assertEquals(11, virtualFile.getLength());
|
||||
@@ -318,4 +319,24 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
|
||||
assertFalse(virtualFile.exists());
|
||||
assertFalse(virtualFile.isValid());
|
||||
}
|
||||
|
||||
public void testBadFileName() throws Exception {
|
||||
if (!SystemInfo.isUnix) {
|
||||
System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
final File dir = FileUtil.createTempDirectory("test.", ".dir");
|
||||
final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);
|
||||
|
||||
final VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
|
||||
assertNotNull(vDir);
|
||||
assertEquals(0, vDir.getChildren().length);
|
||||
|
||||
((VirtualFileSystemEntry)vDir).markDirtyRecursively();
|
||||
vDir.refresh(false, true);
|
||||
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
|
||||
assertNull(vFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManagerImpl;
|
||||
import com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -185,7 +186,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
}
|
||||
|
||||
private static void cleanPersistedVFSContent() {
|
||||
PersistentFS.cleanPersistedContents();
|
||||
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
|
||||
}
|
||||
|
||||
public static boolean isLight(Project project) {
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
@@ -157,7 +158,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
|
||||
}
|
||||
|
||||
private static void cleanPersistedVFSContent() {
|
||||
PersistentFS.cleanPersistedContents();
|
||||
((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,11 +33,11 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class ContainerUtilRt {
|
||||
private static final int ARRAY_COPY_THRESHOLD = 20;
|
||||
|
||||
public static <K, V> HashMap<K,V> newHashMap() {
|
||||
public static <K, V> HashMap<K, V> newHashMap() {
|
||||
return new HashMap<K, V>();
|
||||
}
|
||||
|
||||
public static <K, V> HashMap<K,V> newHashMap(Map<K, V> map) {
|
||||
public static <K, V> HashMap<K, V> newHashMap(Map<K, V> map) {
|
||||
return new HashMap<K, V>(map);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ContainerUtilRt {
|
||||
return new ArrayList<T>();
|
||||
}
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(E ... array) {
|
||||
public static <E> ArrayList<E> newArrayList(E... array) {
|
||||
ArrayList<E> list = new ArrayList<E>(computeArrayListCapacity(array.length));
|
||||
Collections.addAll(list, array);
|
||||
return list;
|
||||
@@ -65,9 +65,8 @@ public class ContainerUtilRt {
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(Iterable<? extends E> iterable) {
|
||||
ArrayList<E> list = newArrayList();
|
||||
Iterator<? extends E> elements = iterable.iterator();
|
||||
while (elements.hasNext()) {
|
||||
list.add(elements.next());
|
||||
for (E anIterable : iterable) {
|
||||
list.add(anIterable);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -76,7 +75,7 @@ public class ContainerUtilRt {
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> newHashSet(T ... elements) {
|
||||
public static <T> HashSet<T> newHashSet(T... elements) {
|
||||
HashSet<T> set = newHashSet();
|
||||
Collections.addAll(set, elements);
|
||||
return set;
|
||||
@@ -88,7 +87,7 @@ public class ContainerUtilRt {
|
||||
|
||||
public static <T> HashSet<T> newHashSet(Iterator<? extends T> iterator) {
|
||||
HashSet<T> set = newHashSet();
|
||||
while(iterator.hasNext()) set.add(iterator.next());
|
||||
while (iterator.hasNext()) set.add(iterator.next());
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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.
|
||||
@@ -19,6 +19,8 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings("ClassNameSameAsAncestorName")
|
||||
public class HashMap<K, V> extends java.util.HashMap<K, V> {
|
||||
public HashMap() { }
|
||||
|
||||
public HashMap(int i, float v) {
|
||||
super(i, v);
|
||||
}
|
||||
@@ -27,8 +29,6 @@ public class HashMap<K, V> extends java.util.HashMap<K, V> {
|
||||
super(i);
|
||||
}
|
||||
|
||||
public HashMap() { }
|
||||
|
||||
public <K1 extends K, V1 extends V> HashMap(Map<K1, V1> map) {
|
||||
super(map);
|
||||
}
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,8 @@ package com.intellij.util.containers;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class HashSet<E> extends java.util.HashSet<E>{
|
||||
@SuppressWarnings("ClassNameSameAsAncestorName")
|
||||
public class HashSet<E> extends java.util.HashSet<E> {
|
||||
public HashSet() { }
|
||||
|
||||
public HashSet(Collection<? extends E> collection) {
|
||||
@@ -67,7 +67,7 @@ public class FileSystemUtil {
|
||||
final boolean forceUseNio2 = SystemProperties.getBooleanProperty(FORCE_USE_NIO2_KEY, false);
|
||||
|
||||
if (!forceUseNio2) {
|
||||
if (SystemInfo.isWindows) {
|
||||
if (SystemInfo.isWindows && IdeaWin32.isAvailable()) {
|
||||
try {
|
||||
return check(new IdeaWin32MediatorImpl());
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class FileSystemUtil {
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
@Nullable
|
||||
public static FileAttributes getAttributes(@NotNull final File file) {
|
||||
return getAttributes(file.getAbsolutePath());
|
||||
return getAttributes(file.getPath());
|
||||
}
|
||||
|
||||
public static boolean isSymLink(@NotNull final String path) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class IdeaWin32 {
|
||||
LOG.info("Native filesystem for Windows is operational");
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.warn("Failed to initialize native filesystem for Windows", t);
|
||||
LOG.error("Failed to initialize native filesystem for Windows", t);
|
||||
}
|
||||
}
|
||||
ourInstance = instance;
|
||||
|
||||
@@ -37,6 +37,70 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class ContainerUtil extends ContainerUtilRt {
|
||||
private static final int INSERTION_SORT_THRESHOLD = 10;
|
||||
|
||||
public static <K, V> HashMap<K, V> newHashMap() {
|
||||
return ContainerUtilRt.newHashMap();
|
||||
}
|
||||
|
||||
public static <K, V> HashMap<K, V> newHashMap(Map<K, V> map) {
|
||||
return ContainerUtilRt.newHashMap(map);
|
||||
}
|
||||
|
||||
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
|
||||
return ContainerUtilRt.newTreeMap();
|
||||
}
|
||||
|
||||
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
|
||||
return ContainerUtilRt.newLinkedHashMap();
|
||||
}
|
||||
|
||||
public static <T> LinkedList<T> newLinkedList() {
|
||||
return ContainerUtilRt.newLinkedList();
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> newArrayList() {
|
||||
return ContainerUtilRt.newArrayList();
|
||||
}
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(E... array) {
|
||||
return ContainerUtilRt.newArrayList(array);
|
||||
}
|
||||
|
||||
public static <E> ArrayList<E> newArrayList(Iterable<? extends E> iterable) {
|
||||
return ContainerUtilRt.newArrayList(iterable);
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> newHashSet() {
|
||||
return ContainerUtilRt.newHashSet();
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> newHashSet(T... elements) {
|
||||
return ContainerUtilRt.newHashSet(elements);
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> newHashSet(Iterable<? extends T> iterable) {
|
||||
return ContainerUtilRt.newHashSet(iterable);
|
||||
}
|
||||
|
||||
public static <T> HashSet<T> newHashSet(Iterator<? extends T> iterator) {
|
||||
return ContainerUtilRt.newHashSet(iterator);
|
||||
}
|
||||
|
||||
public static <T> TreeSet<T> newTreeSet() {
|
||||
return ContainerUtilRt.newTreeSet();
|
||||
}
|
||||
|
||||
public static <T> TreeSet<T> newTreeSet(Comparator<? super T> comparator) {
|
||||
return ContainerUtilRt.newTreeSet(comparator);
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> newArrayListWithExpectedSize(int size) {
|
||||
return ContainerUtilRt.newArrayListWithExpectedSize(size);
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> newArrayListWithCapacity(int size) {
|
||||
return ContainerUtilRt.newArrayListWithCapacity(size);
|
||||
}
|
||||
|
||||
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
|
||||
return new ConcurrentHashMap<K, V>();
|
||||
}
|
||||
|
||||
@@ -108,6 +108,12 @@ public class FileAttributesReadingTest {
|
||||
assertFileAttributes(new File(file.getPath().replace(File.separator, File.separator + "." + File.separator)));
|
||||
assertFileAttributes(new File(myTempDirectory,
|
||||
File.separator + ".." + File.separator + myTempDirectory.getName() + File.separator + file.getName()));
|
||||
|
||||
if (SystemInfo.isUnix) {
|
||||
final File backSlashFile = FileUtil.createTempFile(myTempDirectory, "test\\", "\\txt", true);
|
||||
FileUtil.writeToFile(backSlashFile, myTestData);
|
||||
assertFileAttributes(backSlashFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -61,7 +62,7 @@ public final class VcsConfiguration implements PersistentStateComponent<Element>
|
||||
private Project myProject;
|
||||
|
||||
public boolean OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT = true;
|
||||
public boolean CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = true;
|
||||
public boolean CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT = !PlatformUtils.isPyCharm() && !PlatformUtils.isRubyMine();
|
||||
public boolean CHECK_NEW_TODO = true;
|
||||
public TodoPanelSettings myTodoPanelSettings = new TodoPanelSettings();
|
||||
public boolean PERFORM_UPDATE_IN_BACKGROUND = true;
|
||||
|
||||
@@ -152,7 +152,7 @@ default.tostring.call.problem.descriptor=Call to default 'toString()' on <code>#
|
||||
octal.and.decimal.integers.in.same.array.display.name=Octal and decimal integers in same array
|
||||
octal.and.decimal.integers.in.same.array.problem.descriptor=Octal and decimal integers in the same array initializer #loc
|
||||
result.of.object.allocation.ignored.display.name=Result of object allocation ignored
|
||||
result.of.object.allocation.ignored.problem.descriptor=Result of <code>new #ref()</code> is ignored. #loc
|
||||
result.of.object.allocation.ignored.problem.descriptor=Result of <code>new #ref()</code> is ignored #loc
|
||||
use.0index.in.jdbc.resultset.display.name=Use of index 0 in JDBC ResultSet
|
||||
use.0index.in.jdbc.resultset.problem.descriptor=Use of index '0' in JDBC ResultSet #loc
|
||||
use.0index.in.jdbc.prepared.statement.problem.descriptor=Use of index '0' in JDBC PreparedStatement #loc
|
||||
@@ -951,8 +951,8 @@ throw.caught.locally.problem.descriptor=<code>#ref</code> caught by containing '
|
||||
throw.caught.locally.ignore.option=Ignore rethrown exceptions
|
||||
return.from.finally.block.problem.descriptor=<code>#ref</code> inside 'finally' block #loc
|
||||
continue.or.break.from.finally.block.problem.descriptor=<code>#ref</code> inside 'finally' block #loc
|
||||
bad.exception.declared.problem.descriptor=Prohibited exception <code>#ref</code> declared. #loc
|
||||
bad.exception.caught.problem.descriptor=Prohibited exception <code>#ref</code> caught. #loc
|
||||
bad.exception.declared.problem.descriptor=Prohibited exception <code>#ref</code> declared #loc
|
||||
bad.exception.caught.problem.descriptor=Prohibited exception <code>#ref</code> caught #loc
|
||||
checked.exception.class.problem.descriptor=Checked exception class <code>#ref</code> #loc
|
||||
unchecked.exception.class.problem.descriptor=Unchecked exception class <code>#ref</code> #loc
|
||||
thread.death.rethrown.problem.descriptor=<code>#ref</code> not rethrown #loc
|
||||
@@ -1458,6 +1458,8 @@ interface.never.implemented.option=Ignore interfaces which only declare constant
|
||||
size.replaceable.by.isempty.display.name='size() == 0' replaceable with 'isEmpty()'
|
||||
size.replaceable.by.isempty.quickfix=Replace with 'isEmpty()'
|
||||
size.replaceable.by.isempty.negation.ignore.option=Ignore expressions which would be replaced with '!isEmpty()'
|
||||
ignored.classes.table=Ignored classes
|
||||
choose.class.type.to.ignore=Choose class type to ignore
|
||||
loop.condition.not.updated.inside.loop.display.name=Loop variable not updated inside loop
|
||||
loop.condition.not.updated.inside.loop.problem.descriptor='#ref' is not updated inside loop #loc
|
||||
utility.class.without.private.constructor.option=Ignore classes with only a main method
|
||||
|
||||
@@ -150,12 +150,8 @@ public class EmptyClassInspection extends BaseInspection {
|
||||
if (initializers.length > 0) {
|
||||
return;
|
||||
}
|
||||
if (ignoreClassWithParameterization) {
|
||||
final PsiReferenceList extendsList = aClass.getExtendsList();
|
||||
final PsiReferenceList implementsList = aClass.getImplementsList();
|
||||
if (isSuperParameterization(extendsList) || isSuperParameterization(implementsList)) {
|
||||
return;
|
||||
}
|
||||
if (ignoreClassWithParameterization && isSuperParametrization(aClass)) {
|
||||
return;
|
||||
}
|
||||
if (AnnotationUtil.isAnnotated(aClass, ignorableAnnotations)) {
|
||||
return;
|
||||
@@ -166,7 +162,7 @@ public class EmptyClassInspection extends BaseInspection {
|
||||
registerClassError(aClass, aClass);
|
||||
}
|
||||
|
||||
private boolean isSuperParameterization(PsiReferenceList extendsList) {
|
||||
private boolean hasTypeArguments(PsiReferenceList extendsList) {
|
||||
if (extendsList == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -183,5 +179,26 @@ public class EmptyClassInspection extends BaseInspection {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSuperParametrization(PsiClass aClass) {
|
||||
if (!(aClass instanceof PsiAnonymousClass)) {
|
||||
final PsiReferenceList extendsList = aClass.getExtendsList();
|
||||
final PsiReferenceList implementsList = aClass.getImplementsList();
|
||||
return hasTypeArguments(extendsList) || hasTypeArguments(implementsList);
|
||||
}
|
||||
final PsiAnonymousClass anonymousClass = (PsiAnonymousClass)aClass;
|
||||
final PsiJavaCodeReferenceElement reference = anonymousClass.getBaseClassReference();
|
||||
final PsiReferenceParameterList parameterList = reference.getParameterList();
|
||||
if (parameterList == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiTypeElement[] elements = parameterList.getTypeParameterElements();
|
||||
for (PsiTypeElement element : elements) {
|
||||
if (element != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2011 Bas Leijdekkers
|
||||
* Copyright 2006-2012 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,15 @@
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.codeInspection.ui.ListTable;
|
||||
import com.intellij.codeInspection.ui.ListWrappingTableModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import com.intellij.util.ui.CheckBox;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
@@ -28,36 +32,47 @@ import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.ComparisonUtils;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
import com.siyeh.ig.ui.UiUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class SizeReplaceableByIsEmptyInspection extends BaseInspection {
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public boolean ignoreNegations = false;
|
||||
|
||||
@SuppressWarnings("PublicField")
|
||||
public OrderedSet<String> ignoredTypes = new OrderedSet();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"size.replaceable.by.isempty.display.name");
|
||||
return InspectionGadgetsBundle.message("size.replaceable.by.isempty.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"expression.can.be.replaced.problem.descriptor", infos[0]);
|
||||
return InspectionGadgetsBundle.message("expression.can.be.replaced.problem.descriptor", infos[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JComponent createOptionsPanel() {
|
||||
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message(
|
||||
final JComponent panel = new JPanel(new BorderLayout());
|
||||
final ListTable table =
|
||||
new ListTable(new ListWrappingTableModel(ignoredTypes, InspectionGadgetsBundle.message("ignored.classes.table")));
|
||||
JPanel tablePanel =
|
||||
UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.class.type.to.ignore"));
|
||||
final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message(
|
||||
"size.replaceable.by.isempty.negation.ignore.option"), this, "ignoreNegations");
|
||||
panel.add(tablePanel, BorderLayout.CENTER);
|
||||
panel.add(checkBox, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,8 +86,7 @@ public class SizeReplaceableByIsEmptyInspection extends BaseInspection {
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"size.replaceable.by.isempty.quickfix");
|
||||
return InspectionGadgetsBundle.message("size.replaceable.by.isempty.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,6 +209,11 @@ public class SizeReplaceableByIsEmptyInspection extends BaseInspection {
|
||||
if (aClass == null) {
|
||||
return null;
|
||||
}
|
||||
for (String ignoredType : ignoredTypes) {
|
||||
if (InheritanceUtil.isInheritor(aClass, ignoredType)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final PsiMethod[] methods = aClass.findMethodsByName("isEmpty", true);
|
||||
for (PsiMethod method : methods) {
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
|
||||
@@ -4,6 +4,10 @@ This inspection reports any <b>.size()</b> or <b>.length()</b>
|
||||
comparisons with a <b>0</b> literal which can be replaced with a call to <b>.isEmpty()</b>.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the table below to add classes for which any <b>.size()</b> or <b>.length()</b> comparisons should not be replaced.
|
||||
<p>
|
||||
Use the checkbox below to ignore any expressions which would be replaced with '!isEmpty()'.
|
||||
<p>
|
||||
<small>Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
</html>
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.siyeh.igtest.classlayout.emptyclass;
|
||||
|
||||
public class EmptyClass {
|
||||
|
||||
{
|
||||
System.out.println("");
|
||||
final java.util.ArrayList<String> stringList = new java.util.ArrayList<String>() {};
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
class MyList extends java.util.ArrayList<String> {}
|
||||
|
||||
-10
@@ -93,16 +93,6 @@ public class CompoundProperty extends Property<RadViewComponent> implements IPro
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultValue(@NotNull RadViewComponent component) throws Exception {
|
||||
for (Property<RadViewComponent> childProperty : myChildren) {
|
||||
if (!childProperty.isDefaultValue(component)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValue(@NotNull RadViewComponent component) throws Exception {
|
||||
for (Property<RadViewComponent> childProperty : myChildren) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<grid id="bf5ad" binding="myProGuardPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none">
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.android.sdk;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -77,7 +78,10 @@ public class AndroidSdkConfigurable implements AdditionalDataConfigurable {
|
||||
public boolean isModified() {
|
||||
final AndroidSdkAdditionalData data = (AndroidSdkAdditionalData)mySdk.getSdkAdditionalData();
|
||||
Sdk javaSdk = data != null ? data.getJavaSdk() : null;
|
||||
return javaSdk != myForm.getSelectedSdk();
|
||||
final String javaSdkHomePath = javaSdk != null ? javaSdk.getHomePath() : null;
|
||||
final Sdk selectedSdk = myForm.getSelectedSdk();
|
||||
final String selectedSdkHomePath = selectedSdk != null ? selectedSdk.getHomePath() : null;
|
||||
return !FileUtil.pathsEqual(javaSdkHomePath, selectedSdkHomePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,6 +49,8 @@ class AndroidSdkConfigurableForm {
|
||||
private final DefaultComboBoxModel myBuildTargetsModel = new DefaultComboBoxModel();
|
||||
private String mySdkLocation;
|
||||
|
||||
private boolean myFreeze = false;
|
||||
|
||||
public AndroidSdkConfigurableForm(@NotNull SdkModel sdkModel, @NotNull final SdkModificator sdkModificator) {
|
||||
mySdkModel = sdkModel;
|
||||
myInternalJdkComboBox.setModel(myJdksModel);
|
||||
@@ -76,6 +78,9 @@ class AndroidSdkConfigurableForm {
|
||||
|
||||
myBuildTargetComboBox.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
if (myFreeze) {
|
||||
return;
|
||||
}
|
||||
final IAndroidTarget target = (IAndroidTarget)e.getItem();
|
||||
|
||||
List<OrderRoot> roots = AndroidSdkUtils.getLibraryRootsForTarget(target, mySdkLocation);
|
||||
@@ -138,18 +143,10 @@ class AndroidSdkConfigurableForm {
|
||||
|
||||
mySdkLocation = androidSdk != null ? androidSdk.getHomePath() : null;
|
||||
AndroidSdkData androidSdkData = mySdkLocation != null ? AndroidSdkData.parse(mySdkLocation, new EmptySdkLog()) : null;
|
||||
updateBuildTargets(androidSdkData);
|
||||
|
||||
if (buildTarget != null) {
|
||||
for (int i = 0; i < myBuildTargetsModel.getSize(); i++) {
|
||||
IAndroidTarget target = (IAndroidTarget)myBuildTargetsModel.getElementAt(i);
|
||||
if (buildTarget.hashString().equals(target.hashString())) {
|
||||
myBuildTargetComboBox.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
myBuildTargetComboBox.setSelectedItem(null);
|
||||
myFreeze = true;
|
||||
updateBuildTargets(androidSdkData, buildTarget);
|
||||
myFreeze = false;
|
||||
}
|
||||
|
||||
private void updateJdks() {
|
||||
@@ -161,7 +158,7 @@ class AndroidSdkConfigurableForm {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBuildTargets(AndroidSdkData androidSdkData) {
|
||||
private void updateBuildTargets(AndroidSdkData androidSdkData, IAndroidTarget buildTarget) {
|
||||
myBuildTargetsModel.removeAllElements();
|
||||
|
||||
if (androidSdkData != null) {
|
||||
@@ -169,6 +166,17 @@ class AndroidSdkConfigurableForm {
|
||||
myBuildTargetsModel.addElement(target);
|
||||
}
|
||||
}
|
||||
|
||||
if (buildTarget != null) {
|
||||
for (int i = 0; i < myBuildTargetsModel.getSize(); i++) {
|
||||
IAndroidTarget target = (IAndroidTarget)myBuildTargetsModel.getElementAt(i);
|
||||
if (buildTarget.hashString().equals(target.hashString())) {
|
||||
myBuildTargetComboBox.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
myBuildTargetComboBox.setSelectedItem(null);
|
||||
}
|
||||
|
||||
public void addJavaSdk(Sdk sdk) {
|
||||
|
||||
+6
-3
@@ -27,6 +27,7 @@ import org.jetbrains.jps.devkit.model.JpsIdeaSdkType;
|
||||
import org.jetbrains.jps.devkit.model.JpsPluginModuleProperties;
|
||||
import org.jetbrains.jps.incremental.artifacts.JpsSyntheticArtifactProvider;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsSimpleElement;
|
||||
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
|
||||
@@ -61,8 +62,10 @@ public class JpsPluginSyntheticArtifactProvider extends JpsSyntheticArtifactProv
|
||||
for (JpsModule module : model.getProject().getModules()) {
|
||||
JpsElement propertiesElement = module.getProperties();
|
||||
if (propertiesElement instanceof JpsSimpleElement) {
|
||||
JpsPluginModuleProperties properties = ((JpsSimpleElement<JpsPluginModuleProperties>)propertiesElement).getProperties();
|
||||
artifacts.add(createArtifact(module, properties));
|
||||
Object properties = ((JpsSimpleElement)propertiesElement).getProperties();
|
||||
if (properties instanceof JpsPluginModuleProperties) {
|
||||
artifacts.add(createArtifact(module, (JpsPluginModuleProperties)properties));
|
||||
}
|
||||
}
|
||||
}
|
||||
return artifacts;
|
||||
@@ -120,7 +123,7 @@ public class JpsPluginSyntheticArtifactProvider extends JpsSyntheticArtifactProv
|
||||
}
|
||||
|
||||
String name = module.getName() + ":plugin";
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().createArtifact(name, root, DirectoryArtifactType.INSTANCE);
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().createArtifact(name, root, DirectoryArtifactType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
|
||||
|
||||
JpsTypedLibrary<JpsIdeaSdkProperties> sdk = module.getSdk(JpsIdeaSdkType.INSTANCE);
|
||||
if (sdk != null) {
|
||||
|
||||
+11
-5
@@ -15,21 +15,27 @@
|
||||
*/
|
||||
package org.jetbrains.jps.devkit.model;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsPluginModuleProperties {
|
||||
private final String myPluginXmlUrl;
|
||||
private final String myManifestFileUrl;
|
||||
|
||||
public JpsPluginModuleProperties(String pluginXmlUrl) {
|
||||
public JpsPluginModuleProperties(@Nullable String pluginXmlUrl, @Nullable String manifestFileUrl) {
|
||||
myPluginXmlUrl = pluginXmlUrl;
|
||||
myManifestFileUrl = manifestFileUrl;
|
||||
}
|
||||
|
||||
public JpsPluginModuleProperties(JpsPluginModuleProperties properties) {
|
||||
myPluginXmlUrl = properties.getPluginXmlUrl();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPluginXmlUrl() {
|
||||
return myPluginXmlUrl;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getManifestFileUrl() {
|
||||
return myManifestFileUrl;
|
||||
}
|
||||
}
|
||||
|
||||
+23
-3
@@ -76,15 +76,35 @@ public class JpsDevKitModelSerializerExtension extends JpsModelSerializerExtensi
|
||||
}
|
||||
|
||||
private static class JpsPluginModulePropertiesSerializer extends JpsModulePropertiesSerializer<JpsSimpleElement<JpsPluginModuleProperties>> {
|
||||
private static final String URL_ATTRIBUTE = "url";
|
||||
private static final String MANIFEST_ATTRIBUTE = "manifest";
|
||||
private static final String COMPONENT_NAME = "DevKit.ModuleBuildProperties";
|
||||
|
||||
private JpsPluginModulePropertiesSerializer() {
|
||||
super(JpsPluginModuleType.INSTANCE, "PLUGIN_MODULE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsSimpleElement<JpsPluginModuleProperties> loadProperties(@Nullable Element moduleRootElement) {
|
||||
Element component = JpsLoaderBase.findComponent(moduleRootElement, "DevKit.ModuleBuildProperties");
|
||||
String pluginXmlUrl = component != null ? component.getAttributeValue("url") : null;
|
||||
return JpsElementFactory.getInstance().createSimpleElement(new JpsPluginModuleProperties(pluginXmlUrl));
|
||||
Element component = JpsLoaderBase.findComponent(moduleRootElement, COMPONENT_NAME);
|
||||
String pluginXmlUrl = component != null ? component.getAttributeValue(URL_ATTRIBUTE) : null;
|
||||
String manifestFileUrl = component != null ? component.getAttributeValue(MANIFEST_ATTRIBUTE) : null;
|
||||
return JpsElementFactory.getInstance().createSimpleElement(new JpsPluginModuleProperties(pluginXmlUrl, manifestFileUrl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProperties(@NotNull JpsSimpleElement<JpsPluginModuleProperties> element, @NotNull Element moduleRootElement) {
|
||||
Element component = JpsLoaderBase.findComponent(moduleRootElement, COMPONENT_NAME);
|
||||
if (component != null) {
|
||||
String pluginXmlUrl = element.getProperties().getPluginXmlUrl();
|
||||
if (pluginXmlUrl != null) {
|
||||
component.setAttribute(URL_ATTRIBUTE, pluginXmlUrl);
|
||||
}
|
||||
String manifestFileUrl = element.getProperties().getManifestFileUrl();
|
||||
if (manifestFileUrl != null) {
|
||||
component.setAttribute(MANIFEST_ATTRIBUTE, manifestFileUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-13
@@ -20,6 +20,8 @@ import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
@@ -103,18 +105,19 @@ public class ConvertConcatenationToGstringIntention extends Intention {
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
final Document document = editor.getDocument();
|
||||
if (expressions.size() == 1) {
|
||||
invokeImpl(expressions.get(0));
|
||||
invokeImpl(expressions.get(0), document);
|
||||
}
|
||||
else if (expressions.size() > 0) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
invokeImpl(expressions.get(expressions.size() - 1));
|
||||
invokeImpl(expressions.get(expressions.size() - 1), document);
|
||||
return;
|
||||
}
|
||||
IntroduceTargetChooser.showChooser(editor, expressions,
|
||||
new Pass<GrExpression>() {
|
||||
public void pass(final GrExpression selectedValue) {
|
||||
invokeImpl(selectedValue);
|
||||
invokeImpl(selectedValue, document);
|
||||
}
|
||||
},
|
||||
new Function<GrExpression, String>() {
|
||||
@@ -127,7 +130,7 @@ public class ConvertConcatenationToGstringIntention extends Intention {
|
||||
}
|
||||
}
|
||||
|
||||
private static void invokeImpl(PsiElement element) {
|
||||
private static void invokeImpl(final PsiElement element, Document document) {
|
||||
boolean isMultiline = containsMultilineStrings((GrExpression)element);
|
||||
|
||||
StringBuilder builder = new StringBuilder(element.getTextLength());
|
||||
@@ -145,16 +148,21 @@ public class ConvertConcatenationToGstringIntention extends Intention {
|
||||
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(element.getProject());
|
||||
final GrExpression newExpr = factory.createExpressionFromText(GrStringUtil.addQuotes(text, true));
|
||||
|
||||
final AccessToken accessToken = WriteAction.start();
|
||||
try {
|
||||
final GrExpression expression = ((GrExpression)element).replaceWithExpression(newExpr, true);
|
||||
if (expression instanceof GrString) {
|
||||
GrStringUtil.removeUnnecessaryBracesInGString((GrString)expression);
|
||||
CommandProcessor.getInstance().executeCommand(element.getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final AccessToken accessToken = WriteAction.start();
|
||||
try {
|
||||
final GrExpression expression = ((GrExpression)element).replaceWithExpression(newExpr, true);
|
||||
if (expression instanceof GrString) {
|
||||
GrStringUtil.removeUnnecessaryBracesInGString((GrString)expression);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
}, null, null, document);
|
||||
}
|
||||
|
||||
private static boolean containsMultilineStrings(GrExpression expr) {
|
||||
|
||||
+7
@@ -20,8 +20,10 @@ import com.intellij.psi.PsiReference;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.console.GroovyShellAction;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyScriptTypeDetector;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrForStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -45,6 +47,11 @@ public class GroovyCompletionConfidence extends CompletionConfidence {
|
||||
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
|
||||
final PsiElement position = parameters.getPosition();
|
||||
|
||||
PsiFile file = position.getContainingFile();
|
||||
if (file instanceof GroovyFile && GroovyScriptTypeDetector.getScriptType((GroovyFile)file) != GroovyScriptTypeDetector.DEFAULT_TYPE) {
|
||||
return ThreeState.NO;
|
||||
}
|
||||
|
||||
if (position.getParent() instanceof GrReferenceElement &&
|
||||
psiElement().afterLeaf(psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) {
|
||||
return ThreeState.NO;
|
||||
|
||||
+1
-2
@@ -531,7 +531,6 @@ public abstract class GroovyRefactoringUtil {
|
||||
argText.append("[");
|
||||
for (PsiElement argument : arguments) {
|
||||
argText.append(argument.getText()).append(", ");
|
||||
argument.delete();
|
||||
}
|
||||
if (arguments.size() > 0) {
|
||||
argText.delete(argText.length() - 2, argText.length());
|
||||
@@ -547,7 +546,7 @@ public abstract class GroovyRefactoringUtil {
|
||||
}
|
||||
return GroovyPsiElementFactory.getInstance(project).createExpressionFromText(argText.toString());
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasSideEffect(@NotNull GroovyPsiElement statement) {
|
||||
final Ref<Boolean> hasSideEffect = new Ref<Boolean>(false);
|
||||
statement.accept(new GroovyRecursiveElementVisitor() {
|
||||
|
||||
+3
@@ -516,6 +516,9 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
(i != parameters.length - 1 || !parameter.isVarargType())) {
|
||||
final PsiType type = parameter.createType(changeInfo.getMethod().getParameterList(), argumentList.getManager());
|
||||
final GrExpression arg = GroovyRefactoringUtil.generateArgFromMultiArg(substitutor, arguments, type, element.getProject());
|
||||
for (PsiElement argument : arguments) {
|
||||
argument.delete();
|
||||
}
|
||||
anchor = argumentList.addAfter(arg, anchor);
|
||||
GrReferenceAdjuster.shortenReferences(anchor);
|
||||
}
|
||||
|
||||
+42
-52
@@ -13,39 +13,33 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.groovy.refactoring.inline;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.refactoring.InlineHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.refactoring.inline.GenericInlineHandler;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
import java.util.List;
|
||||
package org.jetbrains.plugins.groovy.refactoring.inline
|
||||
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.lang.refactoring.InlineHandler
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil
|
||||
import com.intellij.psi.impl.source.tree.TreeElement
|
||||
import com.intellij.refactoring.inline.GenericInlineHandler
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import junit.framework.Assert
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
|
||||
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return TestUtils.getTestDataPath() + "groovy/refactoring/inlineMethod/";
|
||||
}
|
||||
final String basePath = TestUtils.testDataPath + "groovy/refactoring/inlineMethod/";
|
||||
|
||||
public void testAbstr1() throws Throwable { doTest(); }
|
||||
public void testBlock1() throws Throwable { doTest(); }
|
||||
@@ -105,31 +99,27 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testVarargs() {doTest();}
|
||||
|
||||
public void testInlineAll() throws Throwable {
|
||||
public void testInlineAll() {
|
||||
doTest(new GroovyInlineHandler() {
|
||||
@Override
|
||||
public Settings prepareInlineElement(PsiElement element, Editor editor, boolean invokedOnReference) {
|
||||
return new Settings() {
|
||||
public InlineHandler.Settings prepareInlineElement(PsiElement element, Editor editor, boolean invokedOnReference) {
|
||||
return new InlineHandler.Settings() {
|
||||
@Override
|
||||
public boolean isOnlyOneReferenceToInline() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
boolean isOnlyOneReferenceToInline() {false}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
public void testInlineNamedArgs() {
|
||||
doTest();
|
||||
}
|
||||
public void testInlineNamedArgs() {doTest(); }
|
||||
public void testInlineVarargs() {doTest()}
|
||||
|
||||
protected void doTest() {
|
||||
doTest(new GroovyInlineHandler());
|
||||
|
||||
}
|
||||
|
||||
protected void doTest(InlineHandler handler) {
|
||||
doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", handler);
|
||||
doInlineTest(myFixture, testDataPath + getTestName(true) + ".test", handler);
|
||||
}
|
||||
|
||||
public static void doInlineTest(final JavaCodeInsightTestFixture fixture,
|
||||
@@ -140,32 +130,32 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
fixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, fileText);
|
||||
|
||||
final PsiFile file = fixture.getFile();
|
||||
final Editor editor = fixture.getEditor();
|
||||
setIndentationToNode(file.getNode());
|
||||
int startOffset = editor.getSelectionModel().getSelectionStart();
|
||||
int endOffset = editor.getSelectionModel().getSelectionEnd();
|
||||
editor.getCaretModel().moveToOffset(endOffset);
|
||||
final PsiFile file = fixture.file;
|
||||
final Editor editor = fixture.editor;
|
||||
indentationToNode = file.node;
|
||||
int startOffset = editor.selectionModel.selectionStart;
|
||||
int endOffset = editor.selectionModel.selectionEnd;
|
||||
editor.caretModel.moveToOffset(endOffset);
|
||||
|
||||
GroovyPsiElement selectedArea = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, GrReferenceExpression.class);
|
||||
if (selectedArea == null) {
|
||||
PsiElement identifier = GroovyRefactoringUtil.findElementInRange(file, startOffset, endOffset, PsiElement.class);
|
||||
if (identifier != null){
|
||||
Assert.assertTrue("Selected area doesn't point to method", identifier.getParent() instanceof GrVariable);
|
||||
selectedArea = (GroovyPsiElement)identifier.getParent();
|
||||
Assert.assertTrue("Selected area doesn't point to method", identifier.parent instanceof GrVariable);
|
||||
selectedArea = (GroovyPsiElement)identifier.parent;
|
||||
}
|
||||
}
|
||||
Assert.assertNotNull("Selected area reference points to nothing", selectedArea);
|
||||
PsiElement element = selectedArea instanceof GrExpression ? selectedArea.getReference().resolve() : selectedArea;
|
||||
PsiElement element = selectedArea instanceof GrExpression ? selectedArea.reference.resolve() : selectedArea;
|
||||
Assert.assertNotNull("Cannot resolve selected reference expression", element);
|
||||
|
||||
try {
|
||||
GenericInlineHandler.invoke(element, editor, inlineHandler);
|
||||
editor.getSelectionModel().removeSelection();
|
||||
editor.selectionModel.removeSelection();
|
||||
fixture.checkResult(data.get(1), true);
|
||||
}
|
||||
catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
|
||||
assertEquals(data.get(1), "FAIL: " + e.getMessage());
|
||||
assertEquals(data.get(1), "FAIL: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +164,7 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase {
|
||||
CodeEditUtil.setOldIndentation(((TreeElement) element), 0);
|
||||
}
|
||||
for (ASTNode node : element.getChildren(null)) {
|
||||
setIndentationToNode(node);
|
||||
indentationToNode = node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
void foo(String... s) {
|
||||
println 'hello'
|
||||
bar(s)
|
||||
}
|
||||
|
||||
void bar(String... s) {}
|
||||
|
||||
<selection>foo</selection>("foo", "bar")
|
||||
-----
|
||||
void foo(String... s) {
|
||||
println 'hello'
|
||||
bar(s)
|
||||
}
|
||||
|
||||
void bar(String... s) {}
|
||||
|
||||
println 'hello'
|
||||
bar(["foo", "bar"] as java.lang.String[])
|
||||
@@ -73,7 +73,7 @@ public class MavenDomUtil {
|
||||
|
||||
String name = file.getName();
|
||||
return name.equals(MavenConstants.POM_XML) ||
|
||||
name.endsWith("." + MavenConstants.POM_EXTENSION) ||
|
||||
name.endsWith(".pom") ||
|
||||
name.equals(MavenConstants.SUPER_POM_XML);
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -135,7 +135,7 @@ public class MavenFoldersImporter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Pair<Path, Boolean>> normalize(@NotNull List<Pair<Path, Boolean>> folders) {
|
||||
private static List<Pair<Path, Boolean>> normalize(@NotNull List<Pair<Path, Boolean>> folders) {
|
||||
List<Pair<Path, Boolean>> result = new ArrayList<Pair<Path, Boolean>>(folders.size());
|
||||
for (Pair<Path, Boolean> eachToAdd : folders) {
|
||||
addSourceFolder(eachToAdd, result);
|
||||
@@ -143,7 +143,7 @@ public class MavenFoldersImporter {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addSourceFolder(Pair<Path, Boolean> folder, List<Pair<Path, Boolean>> result) {
|
||||
private static void addSourceFolder(Pair<Path, Boolean> folder, List<Pair<Path, Boolean>> result) {
|
||||
for (Pair<Path, Boolean> eachExisting : result) {
|
||||
if (MavenRootModelAdapter.isEqualOrAncestor(eachExisting.first.getPath(), folder.first.getPath())
|
||||
|| MavenRootModelAdapter.isEqualOrAncestor(folder.first.getPath(), eachExisting.first.getPath())) {
|
||||
@@ -178,9 +178,11 @@ public class MavenFoldersImporter {
|
||||
configGeneratedSourceFolder(f, isGeneratedTestSources);
|
||||
}
|
||||
else {
|
||||
if (myModel.hasRegisteredSourceSubfolder(f)) continue;
|
||||
if (myModel.isAlreadyExcluded(f)) continue;
|
||||
myModel.addExcludedFolder(f.getPath());
|
||||
if (myImportingSettings.isExcludeTargetFolder()) {
|
||||
if (myModel.hasRegisteredSourceSubfolder(f)) continue;
|
||||
if (myModel.isAlreadyExcluded(f)) continue;
|
||||
myModel.addExcludedFolder(f.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,8 +198,14 @@ public class MavenFoldersImporter {
|
||||
myModel.addExcludedFolder(eachFolder);
|
||||
}
|
||||
|
||||
if (!myModel.hasRegisteredSourceSubfolder(targetDir)) {
|
||||
myModel.addExcludedFolder(targetDir.getPath());
|
||||
if (myImportingSettings.isExcludeTargetFolder()) {
|
||||
if (!myModel.hasRegisteredSourceSubfolder(targetDir)) {
|
||||
myModel.addExcludedFolder(targetDir.getPath());
|
||||
}
|
||||
}
|
||||
else {
|
||||
myModel.addExcludedFolder(myMavenProject.getOutputDirectory());
|
||||
myModel.addExcludedFolder(myMavenProject.getTestOutputDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ public class MavenModuleImporter {
|
||||
|
||||
List<String> processors = myMavenProject.getDeclaredAnnotationProcessors();
|
||||
|
||||
if (processors == null && options.isEmpty() && "target/generated-sources/annotations".equals(annotationProcessorDirectory)) {
|
||||
if (processors == null && options.isEmpty() && "target/generated-sources/annotations".equals(annotationProcessorDirectory.replace('\\', '/'))) {
|
||||
if (moduleProfile != null) {
|
||||
compilerConfiguration.removeModuleProcessorProfile(moduleProfile);
|
||||
}
|
||||
|
||||
+5
@@ -86,6 +86,7 @@ public class MavenProjectImporter {
|
||||
myModuleModel = modelsProvider.getModuleModel();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<MavenProjectsProcessorTask> importProject() {
|
||||
List<MavenProjectsProcessorTask> postTasks = new ArrayList<MavenProjectsProcessorTask>();
|
||||
|
||||
@@ -100,6 +101,8 @@ public class MavenProjectImporter {
|
||||
|
||||
mapMavenProjectsToModulesAndNames();
|
||||
|
||||
if (myProject.isDisposed()) return null;
|
||||
|
||||
boolean projectsHaveChanges = projectsToImportHaveChanges();
|
||||
if (projectsHaveChanges) {
|
||||
hasChanges = true;
|
||||
@@ -112,6 +115,8 @@ public class MavenProjectImporter {
|
||||
configModuleGroups();
|
||||
}
|
||||
|
||||
if (myProject.isDisposed()) return null;
|
||||
|
||||
boolean modulesDeleted = deleteObsoleteModules();
|
||||
hasChanges |= modulesDeleted;
|
||||
if (hasChanges) {
|
||||
|
||||
+4
@@ -77,6 +77,7 @@
|
||||
<properties>
|
||||
<margin top="2" left="0" bottom="2" right="3"/>
|
||||
<text value="Work &offline"/>
|
||||
<toolTipText value="<html>Add option <b>--offline</b> to command line when run maven goals</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2d2f9" class="javax.swing.JCheckBox" binding="checkboxUsePluginRegistry">
|
||||
@@ -86,6 +87,7 @@
|
||||
<properties>
|
||||
<margin top="2" left="0" bottom="2" right="3"/>
|
||||
<text value="Use plugin &registry"/>
|
||||
<toolTipText value="<html>Add option <b>--no-plugin-registry</b> if this option is not selected</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="86396" class="javax.swing.JCheckBox" binding="checkboxRecursive">
|
||||
@@ -97,6 +99,7 @@
|
||||
<properties>
|
||||
<margin top="2" left="0" bottom="2" right="3"/>
|
||||
<text value="Execute &goals recursively "/>
|
||||
<toolTipText value="<html>Add option <b>--non-recursive</b> if this option is not selected</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6fd1" class="javax.swing.JCheckBox" binding="checkboxProduceExceptionErrorMessages">
|
||||
@@ -107,6 +110,7 @@
|
||||
<alignmentY value="0.5"/>
|
||||
<margin top="2" left="0" bottom="2" right="0"/>
|
||||
<text value="Print &exception stack traces"/>
|
||||
<toolTipText value="<html>Add option <b>--errors</b> to command line when run maven goals</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<nested-form id="3edfe" form-file="org/jetbrains/idea/maven/project/MavenEnvironmentForm.form" binding="mavenPathsForm">
|
||||
|
||||
+10
@@ -40,6 +40,7 @@ public class MavenImportingSettings implements Cloneable {
|
||||
private boolean importAutomatically = false;
|
||||
private boolean createModulesForAggregators = true;
|
||||
private boolean createModuleGroups = false;
|
||||
private boolean excludeTargetFolder = true;
|
||||
private boolean keepSourceFolders = true;
|
||||
private boolean useMavenOutput = true;
|
||||
private String updateFoldersOnImportPhase = UPDATE_FOLDERS_DEFAULT_PHASE;
|
||||
@@ -115,6 +116,14 @@ public class MavenImportingSettings implements Cloneable {
|
||||
this.keepSourceFolders = keepSourceFolders;
|
||||
}
|
||||
|
||||
public boolean isExcludeTargetFolder() {
|
||||
return excludeTargetFolder;
|
||||
}
|
||||
|
||||
public void setExcludeTargetFolder(boolean excludeTargetFolder) {
|
||||
this.excludeTargetFolder = excludeTargetFolder;
|
||||
}
|
||||
|
||||
public boolean isUseMavenOutput() {
|
||||
return useMavenOutput;
|
||||
}
|
||||
@@ -173,6 +182,7 @@ public class MavenImportingSettings implements Cloneable {
|
||||
if (downloadSourcesAutomatically != that.downloadSourcesAutomatically) return false;
|
||||
if (lookForNested != that.lookForNested) return false;
|
||||
if (keepSourceFolders != that.keepSourceFolders) return false;
|
||||
if (excludeTargetFolder != that.excludeTargetFolder) return false;
|
||||
if (useMavenOutput != that.useMavenOutput) return false;
|
||||
if (generatedSourcesFolder != that.generatedSourcesFolder) return false;
|
||||
if (!dedicatedModuleDir.equals(that.dedicatedModuleDir)) return false;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user