mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -53,7 +53,7 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder {
|
||||
}
|
||||
|
||||
public int getStubVersion() {
|
||||
return JavaFileElementType.STUB_VERSION + 2;
|
||||
return JavaFileElementType.STUB_VERSION + 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.impl.compiled;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClsBinaryExpressionImpl extends ClsElementImpl implements PsiBinaryExpression {
|
||||
private final ClsElementImpl myParent;
|
||||
private final PsiExpression myLOperand;
|
||||
private final PsiJavaToken myOperation;
|
||||
private final PsiExpression myROperand;
|
||||
|
||||
public ClsBinaryExpressionImpl(ClsElementImpl parent,
|
||||
ClsLiteralExpressionImpl lOperand,
|
||||
ClsJavaTokenImpl operation,
|
||||
ClsLiteralExpressionImpl rOperand) {
|
||||
myParent = parent;
|
||||
myLOperand = lOperand;
|
||||
myOperation = operation;
|
||||
myROperand = rOperand;
|
||||
lOperand.setParent(this);
|
||||
operation.setParent(this);
|
||||
rOperand.setParent(this);
|
||||
}
|
||||
|
||||
public ClsBinaryExpressionImpl(ClsElementImpl parent,
|
||||
ClsPrefixExpressionImpl lOperand,
|
||||
ClsJavaTokenImpl operation,
|
||||
ClsLiteralExpressionImpl rOperand) {
|
||||
myParent = parent;
|
||||
myLOperand = lOperand;
|
||||
myOperation = operation;
|
||||
myROperand = rOperand;
|
||||
lOperand.setParent(this);
|
||||
operation.setParent(this);
|
||||
rOperand.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(int indentLevel, StringBuilder buffer) {
|
||||
buffer.append(getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) {
|
||||
setMirrorCheckingType(element, JavaElementType.BINARY_EXPRESSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return StringUtil.join(myLOperand.getText(), " ", myOperation.getText(), " ", myROperand.getText());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement[] getChildren() {
|
||||
return new PsiElement[]{myLOperand, myOperation, myROperand};
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof JavaElementVisitor) {
|
||||
((JavaElementVisitor)visitor).visitBinaryExpression(this);
|
||||
}
|
||||
else {
|
||||
visitor.visitElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiExpression getLOperand() {
|
||||
return myLOperand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiExpression getROperand() {
|
||||
return myROperand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiJavaToken getOperationSign() {
|
||||
return myOperation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IElementType getOperationTokenType() {
|
||||
return myOperation.getTokenType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getType() {
|
||||
return myLOperand.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiBinaryExpression:" + getText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.impl.compiled;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClsJavaTokenImpl extends ClsElementImpl implements PsiJavaToken {
|
||||
private ClsElementImpl myParent;
|
||||
private final IElementType myTokenType;
|
||||
private final String myTokenText;
|
||||
|
||||
public ClsJavaTokenImpl(ClsElementImpl parent, IElementType tokenType, String tokenText) {
|
||||
myParent = parent;
|
||||
myTokenType = tokenType;
|
||||
myTokenText = tokenText;
|
||||
}
|
||||
|
||||
void setParent(ClsElementImpl parent) {
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementType getTokenType() {
|
||||
return myTokenType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return myTokenText;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement[] getChildren() {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(final int indentLevel, final StringBuilder buffer) {
|
||||
buffer.append(getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) {
|
||||
setMirrorCheckingType(element, myTokenType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof JavaElementVisitor) {
|
||||
((JavaElementVisitor)visitor).visitJavaToken(this);
|
||||
}
|
||||
else {
|
||||
visitor.visitElement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ClsLiteralExpressionImpl extends ClsElementImpl implements PsiLiter
|
||||
}
|
||||
|
||||
public void setMirror(@NotNull TreeElement element) {
|
||||
setMirrorCheckingType(element, ElementType.LITERAL_EXPRESSION);
|
||||
setMirrorCheckingType(element, JavaElementType.LITERAL_EXPRESSION);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -122,11 +122,10 @@ public class ClsParsingUtil {
|
||||
return new ClsLiteralExpressionImpl(parent, expr.getText(), expr.getType(), ((PsiLiteralExpression)expr).getValue());
|
||||
}
|
||||
else if (expr instanceof PsiPrefixExpression) {
|
||||
final PsiExpression operand = ((PsiPrefixExpression) expr).getOperand();
|
||||
final ClsLiteralExpressionImpl literal = (ClsLiteralExpressionImpl) psiToClsExpression(operand, null);
|
||||
final ClsPrefixExpressionImpl prefixExpression = new ClsPrefixExpressionImpl(parent, literal);
|
||||
literal.setParent(prefixExpression);
|
||||
return prefixExpression;
|
||||
final PsiPrefixExpression prefixExpr = (PsiPrefixExpression)expr;
|
||||
final ClsJavaTokenImpl operation = new ClsJavaTokenImpl(null, prefixExpr.getOperationTokenType(), prefixExpr.getOperationSign().getText());
|
||||
final ClsLiteralExpressionImpl literal = (ClsLiteralExpressionImpl) psiToClsExpression(prefixExpr.getOperand(), null);
|
||||
return new ClsPrefixExpressionImpl(parent, operation, literal);
|
||||
}
|
||||
else if (expr instanceof PsiClassObjectAccessExpression) {
|
||||
final String canonicalClassText = ((PsiClassObjectAccessExpression)expr).getOperand().getType().getCanonicalText();
|
||||
@@ -135,14 +134,27 @@ public class ClsParsingUtil {
|
||||
else if (expr instanceof PsiReferenceExpression) {
|
||||
return new ClsReferenceExpressionImpl(parent, (PsiReferenceExpression)expr);
|
||||
}
|
||||
else if (expr instanceof PsiBinaryExpression) {
|
||||
final PsiBinaryExpression binaryExpr = (PsiBinaryExpression)expr;
|
||||
final PsiExpression lOperand = psiToClsExpression(binaryExpr.getLOperand(), null);
|
||||
final ClsJavaTokenImpl operation = new ClsJavaTokenImpl(null, binaryExpr.getOperationTokenType(), binaryExpr.getOperationSign().getText());
|
||||
final PsiExpression rOperand = psiToClsExpression(binaryExpr.getROperand(), null);
|
||||
if (lOperand instanceof ClsLiteralExpressionImpl) {
|
||||
return new ClsBinaryExpressionImpl(parent, (ClsLiteralExpressionImpl)lOperand, operation, (ClsLiteralExpressionImpl)rOperand);
|
||||
}
|
||||
else if (lOperand instanceof ClsPrefixExpressionImpl) {
|
||||
return new ClsBinaryExpressionImpl(parent, (ClsPrefixExpressionImpl)lOperand, operation, (ClsLiteralExpressionImpl)rOperand);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final PsiConstantEvaluationHelper evaluator = JavaPsiFacade.getInstance(expr.getProject()).getConstantEvaluationHelper();
|
||||
final Object value = evaluator.computeConstantExpression(expr);
|
||||
if (value != null) {
|
||||
return new ClsLiteralExpressionImpl(parent, expr.getText(), expr.getType(), value);
|
||||
}
|
||||
LOG.error("Unable to compute expression value: " + expr);
|
||||
return null;
|
||||
}
|
||||
|
||||
LOG.error("Unable to compute expression value: " + expr);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
@@ -22,55 +23,72 @@ import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClsPrefixExpressionImpl extends ClsElementImpl implements PsiPrefixExpression {
|
||||
private final ClsElementImpl myParent;
|
||||
private ClsElementImpl myParent;
|
||||
private final PsiJavaToken myOperation;
|
||||
private final PsiExpression myOperand;
|
||||
|
||||
private final MySign mySign = new MySign();
|
||||
|
||||
public ClsPrefixExpressionImpl(ClsElementImpl parent, PsiExpression operand) {
|
||||
public ClsPrefixExpressionImpl(ClsElementImpl parent, ClsJavaTokenImpl operation, ClsLiteralExpressionImpl operand) {
|
||||
myParent = parent;
|
||||
myOperation = operation;
|
||||
myOperand = operand;
|
||||
operation.setParent(this);
|
||||
operand.setParent(this);
|
||||
}
|
||||
|
||||
void setParent(ClsElementImpl parent) {
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiExpression getOperand() {
|
||||
return myOperand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiJavaToken getOperationSign() {
|
||||
return mySign;
|
||||
return myOperation;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IElementType getOperationTokenType() {
|
||||
return getOperationSign().getTokenType();
|
||||
return myOperation.getTokenType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getType() {
|
||||
return myOperand.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement[] getChildren() {
|
||||
return new PsiElement[]{getOperationSign(), getOperand()};
|
||||
return new PsiElement[]{myOperation, myOperand};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "-" + myOperand.getText();
|
||||
return StringUtil.join(myOperation.getText(), myOperand.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendMirrorText(final int indentLevel, final StringBuilder buffer) {
|
||||
buffer.append(getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(@NotNull TreeElement element) {
|
||||
setMirrorCheckingType(element, JavaElementType.PREFIX_EXPRESSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof JavaElementVisitor) {
|
||||
((JavaElementVisitor)visitor).visitPrefixExpression(this);
|
||||
@@ -80,39 +98,8 @@ public class ClsPrefixExpressionImpl extends ClsElementImpl implements PsiPrefix
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PsiPrefixExpression:" + getText();
|
||||
}
|
||||
|
||||
private class MySign extends ClsElementImpl implements PsiJavaToken {
|
||||
public IElementType getTokenType() {
|
||||
return JavaTokenType.MINUS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiElement[] getChildren() {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public PsiElement getParent() {
|
||||
return ClsPrefixExpressionImpl.this;
|
||||
}
|
||||
|
||||
public void appendMirrorText(final int indentLevel, final StringBuilder buffer) {
|
||||
buffer.append("-");
|
||||
}
|
||||
|
||||
public void setMirror(@NotNull TreeElement element) {
|
||||
setMirrorCheckingType(element, JavaTokenType.MINUS);
|
||||
}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof JavaElementVisitor) {
|
||||
((JavaElementVisitor)visitor).visitJavaToken(this);
|
||||
}
|
||||
else {
|
||||
visitor.visitElement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,14 @@ import java.util.regex.Pattern;
|
||||
public class ClsStubBuilder {
|
||||
private static final Pattern REGEX_PATTERN = Pattern.compile("(?<=[^\\$])\\${1}(?=[^\\$])");
|
||||
|
||||
public static final String DOUBLE_POSITIVE_INF = "1.0 / 0.0";
|
||||
public static final String DOUBLE_NEGATIVE_INF = "-1.0 / 0.0";
|
||||
public static final String DOUBLE_NAN = "0.0d / 0.0";
|
||||
|
||||
public static final String FLOAT_POSITIVE_INF = "1.0f / 0.0";
|
||||
public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0";
|
||||
public static final String FLOAT_NAN = "0.0f / 0.0";
|
||||
|
||||
private ClsStubBuilder() { }
|
||||
|
||||
@Nullable
|
||||
@@ -679,26 +687,28 @@ public class ClsStubBuilder {
|
||||
if (value instanceof Long) return value.toString() + "L";
|
||||
|
||||
if (value instanceof Double) {
|
||||
final double v = ((Double)value).doubleValue();
|
||||
if (Double.isInfinite(v)) {
|
||||
return StringUtil.join(CommonClassNames.JAVA_LANG_DOUBLE, ".", (v > 0 ? "POSITIVE_INFINITY" : "NEGATIVE_INFINITY"));
|
||||
final double d = ((Double)value).doubleValue();
|
||||
if (Double.isInfinite(d)) {
|
||||
return d > 0 ? DOUBLE_POSITIVE_INF : DOUBLE_NEGATIVE_INF;
|
||||
}
|
||||
else if (Double.isNaN(v)) {
|
||||
return StringUtil.join(CommonClassNames.JAVA_LANG_DOUBLE, ".", "NaN");
|
||||
else if (Double.isNaN(d)) {
|
||||
return DOUBLE_NAN;
|
||||
}
|
||||
return Double.toString(v);
|
||||
return Double.toString(d);
|
||||
}
|
||||
|
||||
if (value instanceof Float) {
|
||||
final float v = ((Float)value).floatValue();
|
||||
|
||||
if (Float.isInfinite(v)) {
|
||||
return StringUtil.join(CommonClassNames.JAVA_LANG_FLOAT, ".", (v > 0 ? "POSITIVE_INFINITY" : "NEGATIVE_INFINITY"));
|
||||
return v > 0 ? FLOAT_POSITIVE_INF : FLOAT_NEGATIVE_INF;
|
||||
}
|
||||
else if (Float.isNaN(v)) {
|
||||
return StringUtil.join(CommonClassNames.JAVA_LANG_FLOAT, ".", "NaN");
|
||||
return FLOAT_NAN;
|
||||
}
|
||||
else {
|
||||
return Float.toString(v) + "f";
|
||||
}
|
||||
return Float.toString(v) + "f";
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+16
-18
@@ -1,33 +1,31 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class AnnotationsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/annotations";
|
||||
@NonNls
|
||||
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/annotations";
|
||||
|
||||
private void doTest(boolean checkWarnings) throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(true) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
public void testnotValueNameOmmited() throws Exception { doTest(false); }
|
||||
public void testcannotFindMethod() throws Exception { doTest(false); }
|
||||
public void testincompatibleType1() throws Exception { doTest(false); }
|
||||
public void testincompatibleType2() throws Exception { doTest(false); }
|
||||
public void testincompatibleType3() throws Exception { doTest(false); }
|
||||
public void testincompatibleType4() throws Exception { doTest(false); }
|
||||
public void testmissingAttribute() throws Exception { doTest(false); }
|
||||
public void testduplicateAnnotation() throws Exception { doTest(false); }
|
||||
public void testnonconstantInitializer() throws Exception { doTest(false); }
|
||||
public void testinvalidType() throws Exception { doTest(false); }
|
||||
public void testinapplicable() throws Exception { doTest(false); }
|
||||
public void testduplicateAttribute() throws Exception { doTest(false); }
|
||||
public void testduplicateTarget() throws Exception { doTest(false); }
|
||||
public void testNotValueNameOmitted() throws Exception { doTest(false); }
|
||||
public void testCannotFindMethod() throws Exception { doTest(false); }
|
||||
public void testIncompatibleType1() throws Exception { doTest(false); }
|
||||
public void testIncompatibleType2() throws Exception { doTest(false); }
|
||||
public void testIncompatibleType3() throws Exception { doTest(false); }
|
||||
public void testIncompatibleType4() throws Exception { doTest(false); }
|
||||
public void testMissingAttribute() throws Exception { doTest(false); }
|
||||
public void testDuplicateAnnotation() throws Exception { doTest(false); }
|
||||
public void testNonConstantInitializer() throws Exception { doTest(false); }
|
||||
public void testInvalidType() throws Exception { doTest(false); }
|
||||
public void testInapplicable() throws Exception { doTest(false); }
|
||||
public void testDuplicateAttribute() throws Exception { doTest(false); }
|
||||
public void testDuplicateTarget() throws Exception { doTest(false); }
|
||||
public void testTypeAnnotations() throws Exception { doTest(false); }
|
||||
|
||||
public void testInvalidPackageAnnotationTarget() throws Exception {
|
||||
|
||||
@@ -664,9 +664,9 @@ public class ClsRepositoryUseTest extends PsiTestCase{
|
||||
assert method instanceof PsiAnnotationMethod : method;
|
||||
try {
|
||||
final PsiAnnotationMemberValue defaultValue = ((PsiAnnotationMethod)method).getDefaultValue();
|
||||
assert defaultValue instanceof PsiReferenceExpression : defaultValue;
|
||||
final String type = method.getName().startsWith("f") ? "Float." : "Double";
|
||||
assert defaultValue.getText().contains(type) : defaultValue;
|
||||
assert defaultValue instanceof PsiBinaryExpression : defaultValue;
|
||||
final PsiPrimitiveType type = method.getName().startsWith("f") ? PsiType.FLOAT : PsiType.DOUBLE;
|
||||
assertEquals(type, ((PsiBinaryExpression)defaultValue).getType());
|
||||
}
|
||||
catch (Exception e) {
|
||||
final String valueText = ((PsiMethodStub)((StubBasedPsiElement)method).getStub()).getDefaultValueText();
|
||||
|
||||
@@ -7,19 +7,13 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.lang.java.JavaRefactoringSupportProvider;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.introduceField.InplaceIntroduceFieldPopup;
|
||||
import com.intellij.refactoring.rename.RenameProcessor;
|
||||
import com.intellij.refactoring.rename.RenameWrongRefHandler;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
||||
import sun.misc.Ref;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
@@ -103,7 +97,7 @@ public class RenameLocalTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
private void doRenameWrongRef(final String newName) throws Exception {
|
||||
final String name = getTestName(true);
|
||||
final String name = getTestName(false);
|
||||
configureByFile(BASE_PATH + name + ".java");
|
||||
|
||||
final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(getProject());
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package com.intellij.analysis;
|
||||
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -322,11 +318,7 @@ public class AnalysisScope {
|
||||
final FileIndex projectFileIndex,
|
||||
final PsiManager psiManager, final boolean needReadAction) {
|
||||
if (fileOrDir.isDirectory()) return true;
|
||||
final FileType fileType = fileOrDir.getFileType();
|
||||
if (fileType instanceof WorkspaceFileType ||
|
||||
fileType instanceof ProjectFileType ||
|
||||
fileType instanceof ModuleFileType ||
|
||||
fileOrDir.getPath().contains("/.idea/")) return true;
|
||||
if (ProjectUtil.isProjectOrWorkspaceFile(fileOrDir)) return true;
|
||||
if (projectFileIndex.isInContent(fileOrDir) && (myIncludeTestSource || !projectFileIndex.isInTestSourceContent(fileOrDir))) {
|
||||
return processFile(fileOrDir, visitor, psiManager, needReadAction);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.ide.highlighter.InternalFileType;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -26,6 +31,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFilePathWrapper;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -33,6 +39,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ProjectUtil {
|
||||
@NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = ".idea";
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
|
||||
@@ -91,4 +99,14 @@ public class ProjectUtil {
|
||||
public static Project guessProjectForFile(VirtualFile file) {
|
||||
return ProjectLocator.getInstance().guessProjectForFile(file);
|
||||
}
|
||||
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file) {
|
||||
return isProjectOrWorkspaceFile(file, file.getFileType());
|
||||
}
|
||||
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file,
|
||||
final FileType fileType) {
|
||||
if (fileType instanceof InternalFileType) return true;
|
||||
return file.getPath().contains("/"+ DIRECTORY_BASED_PROJECT_DIR +"/");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
@@ -285,7 +285,7 @@ public class ConsoleHistoryController {
|
||||
}
|
||||
|
||||
private void saveHistory(final XmlSerializer out) throws IOException {
|
||||
out.startDocument("UTF8", null);
|
||||
out.startDocument("UTF-8", null);
|
||||
out.startTag(null, "console-history");
|
||||
out.attribute(null, "id", myId);
|
||||
for (String s : myModel.getHistory()) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.find.impl;
|
||||
|
||||
import com.intellij.find.*;
|
||||
import com.intellij.find.ngrams.TrigramIndex;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
@@ -39,6 +38,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.FileIndexImplUtil;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.intellij.psi.impl.cache.impl.id;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lang.cacheBuilder.CacheBuilderRegistry;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
|
||||
+1
-1
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.psi.impl.cache.impl.todo;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
@@ -24,6 +23,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdTableBuilding;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.ide.highlighter;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
public interface InternalFileType extends FileType {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ModuleFileType implements FileType {
|
||||
public class ModuleFileType implements InternalFileType {
|
||||
@NonNls public static final String DEFAULT_EXTENSION = "iml";
|
||||
@NonNls public static final String DOT_DEFAULT_EXTENSION = ".iml";
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ProjectFileType implements FileType {
|
||||
public class ProjectFileType implements InternalFileType {
|
||||
@NonNls public static final String DEFAULT_EXTENSION = "ipr";
|
||||
@NonNls public static final String DOT_DEFAULT_EXTENSION = ".ipr";
|
||||
private static final Icon ICON = IconLoader.getIcon("/nodes/ideaProject.png");
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class WorkspaceFileType implements FileType {
|
||||
public class WorkspaceFileType implements InternalFileType {
|
||||
private static final Icon ICON = IconLoader.getIcon("/nodes/ideaWorkspace.png");
|
||||
@NonNls public static final String DEFAULT_EXTENSION = "iws";
|
||||
@NonNls public static final String DOT_DEFAULT_EXTENSION = "." + DEFAULT_EXTENSION;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
@@ -23,6 +22,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
|
||||
@@ -18,13 +18,10 @@ package com.intellij.ide.impl;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
@@ -42,7 +39,6 @@ import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.projectImport.ProjectOpenProcessor;
|
||||
import com.intellij.ui.AppIcon;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -55,7 +51,6 @@ import java.io.IOException;
|
||||
*/
|
||||
public class ProjectUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.impl.ProjectUtil");
|
||||
@NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = ".idea";
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
@@ -109,7 +104,7 @@ public class ProjectUtil {
|
||||
}
|
||||
|
||||
if (path.endsWith(ProjectFileType.DOT_DEFAULT_EXTENSION) ||
|
||||
virtualFile.isDirectory() && virtualFile.findChild(DIRECTORY_BASED_PROJECT_DIR) != null) {
|
||||
virtualFile.isDirectory() && virtualFile.findChild(com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR) != null) {
|
||||
return openProject(path, projectToClose, forceOpenInNewFrame);
|
||||
}
|
||||
|
||||
@@ -138,8 +133,8 @@ public class ProjectUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (file.isDirectory() && !new File(file, DIRECTORY_BASED_PROJECT_DIR).exists()) {
|
||||
Messages.showMessageDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle(),
|
||||
if (file.isDirectory() && !new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) {
|
||||
Messages.showMessageDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle(),
|
||||
Messages.getErrorIcon());
|
||||
return null;
|
||||
}
|
||||
@@ -238,22 +233,4 @@ public class ProjectUtil {
|
||||
IdeFocusManager.getInstance(p).requestFocus(cmd, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file) {
|
||||
return isProjectOrWorkspaceFile(file, file.getFileType());
|
||||
}
|
||||
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file,
|
||||
final FileType fileType) {
|
||||
final boolean iprBased = fileType instanceof WorkspaceFileType || fileType instanceof ProjectFileType || fileType instanceof ModuleFileType;
|
||||
if (iprBased) return true;
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null) {
|
||||
if (parent.getName().equals(DIRECTORY_BASED_PROJECT_DIR)) return true;
|
||||
parent = parent.getParent();
|
||||
if (parent != null && parent.getName().equals(DIRECTORY_BASED_PROJECT_DIR)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.diff.impl.mergeTool;
|
||||
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.ide.highlighter.WorkspaceFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.undo.DocumentReference;
|
||||
@@ -31,6 +28,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
@@ -93,8 +91,7 @@ public interface MergeVersion {
|
||||
FileDocumentManager.getInstance().saveDocument(myDocument);
|
||||
final VirtualFile file = getFile();
|
||||
if (file != null) {
|
||||
final FileType fileType = file.getFileType();
|
||||
if (fileType instanceof ProjectFileType || fileType instanceof WorkspaceFileType || fileType instanceof ModuleFileType) {
|
||||
if (ProjectUtil.isProjectOrWorkspaceFile(file)) {
|
||||
ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.maddyhome.idea.copyright.util;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lang.Commenter;
|
||||
import com.intellij.lang.LanguageCommenters;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
package com.intellij.xml.util;
|
||||
|
||||
import com.intellij.ide.highlighter.XmlFileType;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.impl.include.FileIncludeInfo;
|
||||
import com.intellij.psi.impl.include.FileIncludeProvider;
|
||||
@@ -27,7 +27,6 @@ import com.intellij.util.text.CharSequenceReader;
|
||||
import com.intellij.util.xml.NanoXmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user