mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -35,7 +35,7 @@ public class MainParseTest extends BaseParseTestcase {
|
||||
enum Result {
|
||||
OK, ERR
|
||||
}
|
||||
class Test {
|
||||
static class Test {
|
||||
boolean showWarnings = true;
|
||||
boolean showInfo = false;
|
||||
Result expectedResult;
|
||||
@@ -158,8 +158,9 @@ public class MainParseTest extends BaseParseTestcase {
|
||||
}
|
||||
|
||||
private void doTest(String prefix) throws IOException {
|
||||
int n = 0, failed = 0;
|
||||
for (String name : myMap.keySet()) {
|
||||
int n = 0;
|
||||
int failed = 0;
|
||||
for (String name : myMap.keySet()) {
|
||||
if (prefix == null && name.contains("/")) {
|
||||
continue;
|
||||
}
|
||||
@@ -174,8 +175,7 @@ public class MainParseTest extends BaseParseTestcase {
|
||||
myFixture.testHighlighting(test.showWarnings, true, test.showInfo, name);
|
||||
|
||||
if (test.expectedResult == Result.ERR) {
|
||||
System.out.println(" FAILED. Expression incorrectly parsed OK: " + FileUtil.loadTextAndClose(new FileReader(new File(
|
||||
getTestDataPath(), name))));
|
||||
System.out.println(" FAILED. Expression incorrectly parsed OK: " + FileUtil.loadFile(new File(getTestDataPath(), name)));
|
||||
failed++;
|
||||
} else {
|
||||
System.out.println(" OK");
|
||||
@@ -185,7 +185,7 @@ public class MainParseTest extends BaseParseTestcase {
|
||||
System.out.println(" OK");
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
System.out.println(" FAILED. Expression = " + FileUtil.loadTextAndClose(new FileReader(new File(getTestDataPath(), name))));
|
||||
System.out.println(" FAILED. Expression = " + FileUtil.loadFile(new File(getTestDataPath(), name)));
|
||||
if (myOut.size() > 0) {
|
||||
String line;
|
||||
final BufferedReader reader = new BufferedReader(new StringReader(myOut.toString()));
|
||||
|
||||
@@ -34,7 +34,7 @@ class JavaIoFile extends SimpleJavaFileObject {
|
||||
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
|
||||
return new String(FileUtil.loadFileText(myFile));
|
||||
return FileUtil.loadFile(myFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+51
-20
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.generation.PsiMethodMember;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElementDecorator;
|
||||
import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.util.MemberChooser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -16,6 +17,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
@@ -63,38 +65,67 @@ class ConstructorInsertHandler implements InsertHandler<LookupElementDecorator<L
|
||||
}
|
||||
}
|
||||
|
||||
OffsetKey insideRef = context.trackOffset(context.getTailOffset(), false);
|
||||
|
||||
insertParentheses(context, delegate, delegate.getObject(), withTail && isAbstract);
|
||||
|
||||
DefaultInsertHandler.addImportForItem(context, delegate);
|
||||
|
||||
|
||||
if (withTail) {
|
||||
if (isAbstract) {
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.AFTER_NEW_ANONYMOUS);
|
||||
}
|
||||
if (!withTail) {
|
||||
return;
|
||||
}
|
||||
|
||||
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
|
||||
|
||||
final Editor editor = context.getEditor();
|
||||
final int offset = context.getTailOffset();
|
||||
editor.getDocument().insertString(offset, " {}");
|
||||
editor.getCaretModel().moveToOffset(offset + 2);
|
||||
context.setLaterRunnable(generateAnonymousBody(editor, context.getFile()));
|
||||
if (isAbstract) {
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.AFTER_NEW_ANONYMOUS);
|
||||
}
|
||||
else {
|
||||
final PsiNewExpression newExpression =
|
||||
PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiNewExpression.class, false);
|
||||
if (newExpression != null) {
|
||||
final PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null) {
|
||||
CodeStyleManager.getInstance(context.getProject()).reformat(classReference);
|
||||
|
||||
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(context.getFile().getViewProvider());
|
||||
|
||||
final Editor editor = context.getEditor();
|
||||
final int offset = context.getTailOffset();
|
||||
editor.getDocument().insertString(offset, " {}");
|
||||
editor.getCaretModel().moveToOffset(offset + 2);
|
||||
|
||||
if (delegate instanceof PsiTypeLookupItem) {
|
||||
PsiType type = JavaCompletionUtil.getLookupElementType(delegate);
|
||||
if (type instanceof PsiClassType) {
|
||||
PsiClassType.ClassResolveResult result = ((PsiClassType)type).resolveGenerics();
|
||||
PsiClass psiClass = result.getElement();
|
||||
if (psiClass != null) {
|
||||
for (PsiTypeParameter parameter : psiClass.getTypeParameters()) {
|
||||
PsiType substitution = result.getSubstitutor().substitute(parameter);
|
||||
if (substitution instanceof PsiClassType && parameter.equals(((PsiClassType)substitution).resolve())) {
|
||||
PsiReferenceParameterList paramList = PsiTreeUtil
|
||||
.findElementOfClassAtOffset(context.getFile(), context.getOffset(insideRef) - 1, PsiReferenceParameterList.class, false);
|
||||
if (paramList != null && paramList.getTextLength() > 0) {
|
||||
TextRange range = paramList.getTextRange();
|
||||
context.getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), "<>");
|
||||
editor.getCaretModel().moveToOffset(range.getStartOffset() + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.AFTER_NEW);
|
||||
}
|
||||
|
||||
context.setLaterRunnable(generateAnonymousBody(editor, context.getFile()));
|
||||
}
|
||||
else {
|
||||
final PsiNewExpression newExpression =
|
||||
PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiNewExpression.class, false);
|
||||
if (newExpression != null) {
|
||||
final PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null) {
|
||||
CodeStyleManager.getInstance(context.getProject()).reformat(classReference);
|
||||
}
|
||||
}
|
||||
if (mySmart) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.AFTER_NEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -37,6 +37,7 @@ import com.intellij.find.impl.FindManagerImpl;
|
||||
import com.intellij.ide.util.SuperMethodWarningUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.undo.UndoUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -68,6 +69,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction {
|
||||
private final boolean myChangeAllUsages;
|
||||
private final int myMinUsagesNumberToShowDialog;
|
||||
private ParameterInfoImpl[] myNewParametersInfo;
|
||||
private static final Logger LOG = Logger.getInstance("#" + ChangeMethodSignatureFromUsageFix.class.getName());
|
||||
|
||||
ChangeMethodSignatureFromUsageFix(@NotNull PsiMethod targetMethod,
|
||||
@NotNull PsiExpression[] expressions,
|
||||
@@ -99,6 +101,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction {
|
||||
if (result.length() != 0) {
|
||||
result += ", ";
|
||||
}
|
||||
LOG.assertTrue(type != null, "old idx: " + info.getOldIndex() + "; " + info.getClass().getName());
|
||||
result += type.getPresentableText();
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -678,9 +678,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
PsiParameter[] parameters = list.getParameters();
|
||||
|
||||
final JavaParameterInfo[] parameterInfos = changeInfo.getNewParameters();
|
||||
PsiParameter[] newParms = new PsiParameter[parameterInfos.length -
|
||||
(baseMethod != null ? baseMethod.getParameterList().getParametersCount() -
|
||||
method.getParameterList().getParametersCount() : 0)];
|
||||
final int delta = baseMethod != null ? baseMethod.getParameterList().getParametersCount() - method.getParameterList().getParametersCount() : 0;
|
||||
PsiParameter[] newParms = new PsiParameter[Math.max(parameterInfos.length - delta, 0)];
|
||||
final String[] oldParameterNames = changeInfo.getOldParameterNames();
|
||||
final String[] oldParameterTypes = changeInfo.getOldParameterTypes();
|
||||
for (int i = 0; i < newParms.length; i++) {
|
||||
@@ -865,6 +864,20 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
}
|
||||
|
||||
for (UsageInfo usageInfo : usagesSet) {
|
||||
if (usageInfo instanceof OverriderUsageInfo) {
|
||||
final PsiMethod method = (PsiMethod)usageInfo.getElement();
|
||||
final PsiMethod baseMethod = ((OverriderUsageInfo)usageInfo).getBaseMethod();
|
||||
final int delta = baseMethod.getParameterList().getParametersCount() - method.getParameterList().getParametersCount();
|
||||
if (delta > 0) {
|
||||
final boolean[] toRemove = myChangeInfo.toRemoveParm();
|
||||
if (toRemove[toRemove.length - 1]) { //todo check if implicit parameter is not the last one
|
||||
conflictDescriptions.putValue(baseMethod, "Implicit last parameter should not be deleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return conflictDescriptions;
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -89,7 +89,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
myMethodToSearchFor = methodToSearchFor;
|
||||
myOccurrences = occurrences;
|
||||
myMustBeFinal = mustBeFinal;
|
||||
myExprMarker = expr != null ? myEditor.getDocument().createRangeMarker(expr.getTextRange()) : null;
|
||||
myExprMarker = expr != null && expr.isPhysical() ? myEditor.getDocument().createRangeMarker(expr.getTextRange()) : null;
|
||||
myExprText = myExpr != null ? myExpr.getText() : null;
|
||||
|
||||
myWholePanel = new JPanel(new GridBagLayout());
|
||||
@@ -202,7 +202,7 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
|
||||
@Override
|
||||
protected PsiExpression getExpr() {
|
||||
return myExpr;
|
||||
return myExpr != null && myExpr.isValid() && myExpr.isPhysical() ? myExpr : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -301,9 +301,11 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI {
|
||||
public void run() {
|
||||
final PsiFile containingFile = myMethod.getContainingFile();
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
|
||||
myExpr = restoreExpression(containingFile, psiParameter, elementFactory, myExprMarker, myExprText);
|
||||
if (myExpr != null) {
|
||||
myExprMarker = myEditor.getDocument().createRangeMarker(myExpr.getTextRange());
|
||||
if (myExprMarker != null) {
|
||||
myExpr = restoreExpression(containingFile, psiParameter, elementFactory, myExprMarker, myExprText);
|
||||
if (myExpr != null) {
|
||||
myExprMarker = myEditor.getDocument().createRangeMarker(myExpr.getTextRange());
|
||||
}
|
||||
}
|
||||
final List<RangeMarker> occurrenceMarkers = getOccurrenceMarkers();
|
||||
for (int i = 0, occurrenceMarkersSize = occurrenceMarkers.size(); i < occurrenceMarkersSize; i++) {
|
||||
|
||||
+5
-4
@@ -75,7 +75,7 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
private final SmartPsiElementPointer<PsiDeclarationStatement> myPointer;
|
||||
private final RangeMarker myExprMarker;
|
||||
private final List<RangeMarker> myOccurrenceMarkers;
|
||||
private final PsiType myDefaultType;
|
||||
private final SmartTypePointer myDefaultType;
|
||||
|
||||
protected JCheckBox myCanBeFinal;
|
||||
private Balloon myBalloon;
|
||||
@@ -97,14 +97,15 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
myExprMarker = exprMarker;
|
||||
myOccurrenceMarkers = occurrenceMarkers;
|
||||
|
||||
myDefaultType = elementToRename.getType();
|
||||
final PsiType defaultType = elementToRename.getType();
|
||||
myDefaultType = SmartTypePointerManager.getInstance(project).createSmartTypePointer(defaultType);
|
||||
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(elementToRename, PsiDeclarationStatement.class);
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(project).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
editor.putUserData(ReassignVariableUtil.OCCURRENCES_KEY,
|
||||
occurrenceMarkers.toArray(new RangeMarker[occurrenceMarkers.size()]));
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, myDefaultType, hasTypeSuggestion));
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, defaultType, hasTypeSuggestion));
|
||||
if (!cantChangeFinalModifier) {
|
||||
myCanBeFinal = new NonFocusableCheckBox("Declare final");
|
||||
myCanBeFinal.setSelected(createFinals());
|
||||
@@ -221,7 +222,7 @@ public class VariableInplaceIntroducer extends VariableInplaceRenamer {
|
||||
|
||||
protected void saveSettings(PsiVariable psiVariable) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = psiVariable.hasModifierProperty(PsiModifier.FINAL);
|
||||
TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), myDefaultType);
|
||||
TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), myDefaultType.getType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -38,6 +39,7 @@ public class CanonicalTypes {
|
||||
private CanonicalTypes() { }
|
||||
|
||||
public abstract static class Type {
|
||||
@NotNull
|
||||
public abstract PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException;
|
||||
|
||||
@NonNls
|
||||
@@ -53,6 +55,7 @@ public class CanonicalTypes {
|
||||
myType = type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) {
|
||||
return myType;
|
||||
}
|
||||
@@ -71,6 +74,7 @@ public class CanonicalTypes {
|
||||
myComponentType = componentType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
return myComponentType.getType(context, manager).createArrayType();
|
||||
}
|
||||
@@ -91,6 +95,7 @@ public class CanonicalTypes {
|
||||
myComponentType = componentType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
return new PsiEllipsisType(myComponentType.getType(context, manager));
|
||||
}
|
||||
@@ -113,6 +118,7 @@ public class CanonicalTypes {
|
||||
myBound = bound;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
if(myBound == null) return PsiWildcardType.createUnbounded(context.getManager());
|
||||
if (myIsExtending) {
|
||||
@@ -140,6 +146,7 @@ public class CanonicalTypes {
|
||||
myText = text;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
return JavaPsiFacade.getInstance(context.getProject()).getElementFactory().createTypeFromText(myText, context);
|
||||
}
|
||||
@@ -162,6 +169,7 @@ public class CanonicalTypes {
|
||||
mySubstitutor = substitutor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType getType(PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
|
||||
final PsiElementFactory factory = facade.getElementFactory();
|
||||
@@ -205,6 +213,7 @@ public class CanonicalTypes {
|
||||
myTypes = types;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiType getType(final PsiElement context, final PsiManager manager) throws IncorrectOperationException {
|
||||
final List<PsiType> types = ContainerUtil.map(myTypes, new Function<Type, PsiType>() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
interface Foo {}
|
||||
interface FooEx<T> extends Foo {
|
||||
T foo();
|
||||
}
|
||||
|
||||
class Bar {
|
||||
{
|
||||
Foo f = new FooEx<<caret>>() {};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
interface Foo {}
|
||||
interface FooEx<T> extends Foo {
|
||||
T foo();
|
||||
}
|
||||
|
||||
class Bar {
|
||||
{
|
||||
Foo f = new FE<caret>
|
||||
}
|
||||
}
|
||||
+2
@@ -861,6 +861,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnboundTypeArgs() throws Exception { doTest(); }
|
||||
|
||||
public void testIDEADEV2668() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
|
||||
private void verifyJavaDoc(final PsiElement field) throws IOException {
|
||||
final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
|
||||
String htmlText = new String(FileUtil.loadFileText(htmlPath));
|
||||
String htmlText = FileUtil.loadFile(htmlPath);
|
||||
String docInfo = new JavaDocInfoGenerator(getProject(), field).generateDocInfo(null);
|
||||
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
|
||||
PsiTestUtil.createTestProjectStructure(myProject, myModule, path, myFilesToDelete);
|
||||
final String info =
|
||||
new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null);
|
||||
String htmlText = new String(FileUtil.loadFileText(new File(packageInfo + File.separator + "packageInfo.html")));
|
||||
String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html"));
|
||||
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(info.trim()));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ public class FileTemplatesTest extends IdeaTestCase {
|
||||
File propFile = new File(resultFile.getParent(), base + ".prop" + txt);
|
||||
File inFile = new File(resultFile.getParent(), base + txt);
|
||||
|
||||
String inputText = new String(FileUtil.loadFileText(inFile, FileTemplate.ourEncoding));
|
||||
String outputText = new String(FileUtil.loadFileText(resultFile, FileTemplate.ourEncoding));
|
||||
String inputText = FileUtil.loadFile(inFile, FileTemplate.ourEncoding);
|
||||
String outputText = FileUtil.loadFile(resultFile, FileTemplate.ourEncoding);
|
||||
|
||||
EncodingAwareProperties properties = new EncodingAwareProperties();
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ClsBuilderTest extends LightIdeaTestCase {
|
||||
final String goldFilePath = JavaTestUtil.getJavaTestDataPath() + "/psi/cls/stubBuilder/" + goldFile;
|
||||
String expected = "";
|
||||
try {
|
||||
expected = new String(FileUtil.loadFileText(new File(goldFilePath)));
|
||||
expected = FileUtil.loadFile(new File(goldFilePath));
|
||||
expected = StringUtil.convertLineSeparators(expected);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
|
||||
@@ -359,10 +359,10 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
|
||||
|
||||
public void testPerformance() throws Exception {
|
||||
final String path = PathManagerEx.getTestDataPath() + "/psi/stub/StubPerformanceTest.java";
|
||||
final char[] source = FileUtil.loadFileText(new File(path));
|
||||
final PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", new String(source));
|
||||
String text = FileUtil.loadFile(new File(path));
|
||||
final PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", text);
|
||||
|
||||
IdeaTestUtil.assertTiming("Source file size: " + source.length, 2000, new Runnable() {
|
||||
IdeaTestUtil.assertTiming("Source file size: " + text.length(), 2000, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NEW_BUILDER.buildStubTree(file);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class NormalizeDeclarationTest extends PsiTestCase{
|
||||
|
||||
private static String loadFile(String name) throws Exception {
|
||||
String fullName = BASE_PATH + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName)));
|
||||
String text = FileUtil.loadFile(new File(fullName));
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class OptimizeImportsTest extends PsiTestCase{
|
||||
|
||||
private static String loadFile(String name) throws Exception {
|
||||
String fullName = BASE_PATH + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName)));
|
||||
String text = FileUtil.loadFile(new File(fullName));
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase {
|
||||
|
||||
private static String loadFile(String name) throws Exception {
|
||||
String fullName = BASE_PATH + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName)));
|
||||
String text = FileUtil.loadFile(new File(fullName));
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class ShortenClassReferencesTest extends PsiTestCase {
|
||||
|
||||
private String loadFile(String name) throws Exception {
|
||||
String fullName = BASE_PATH + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName)));
|
||||
String text = FileUtil.loadFile(new File(fullName));
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String contents = StringUtil.convertLineSeparators(new String(FileUtil.loadFileText(testFile, CharsetToolkit.UTF8)));
|
||||
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8));
|
||||
quickFixTestCase.configureFromFileText(testFile.getName(), contents);
|
||||
quickFixTestCase.bringRealEditorBack();
|
||||
final Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
|
||||
|
||||
@@ -141,8 +141,8 @@ public class IdeaTestUtil extends PlatformTestUtil {
|
||||
jarFile2 = new JarFile(file2);
|
||||
}
|
||||
catch (IOException e) {
|
||||
String textAfter = String.valueOf(FileUtil.loadFileText(file1));
|
||||
String textBefore = String.valueOf(FileUtil.loadFileText(file2));
|
||||
String textAfter = FileUtil.loadFile(file1);
|
||||
String textBefore = FileUtil.loadFile(file2);
|
||||
textAfter = StringUtil.convertLineSeparators(textAfter);
|
||||
textBefore = StringUtil.convertLineSeparators(textBefore);
|
||||
Assert.assertEquals(file1.getPath(), textAfter, textBefore);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PsiTestData implements JDOMExternalizable {
|
||||
|
||||
public void loadText(String root) throws IOException{
|
||||
String fileName = root + "/" + TEXT_FILE;
|
||||
myText = new String(FileUtil.loadFileText(new File(fileName)));
|
||||
myText = FileUtil.loadFile(new File(fileName));
|
||||
myText = StringUtil.convertLineSeparators(myText);
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -27,6 +27,7 @@ import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -135,6 +136,7 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
|
||||
|
||||
public static boolean chooseActionAndInvoke(PsiFile hostFile, final Editor hostEditor, final IntentionAction action, final String text) {
|
||||
final Project project = hostFile.getProject();
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.quickFix");
|
||||
|
||||
Pair<PsiFile, Editor> pair = chooseBetweenHostAndInjected(hostFile, hostEditor, new PairProcessor<PsiFile, Editor>() {
|
||||
public boolean process(PsiFile psiFile, Editor editor) {
|
||||
|
||||
@@ -669,6 +669,9 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
finally {
|
||||
myChangeGuard = false;
|
||||
}
|
||||
if (isVisible()) {
|
||||
updateLookupBounds();
|
||||
}
|
||||
LOG.assertTrue(!myDisposed, disposeTrace);
|
||||
}
|
||||
|
||||
@@ -1135,8 +1138,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
|
||||
updateScrollbarVisibility();
|
||||
HintManagerImpl.adjustEditorHintPosition(this, myEditor, calculatePosition(getComponent()));
|
||||
layoutStatusIcons();
|
||||
updateLookupBounds();
|
||||
|
||||
if (reused) {
|
||||
ensureSelectionVisible();
|
||||
@@ -1144,6 +1146,11 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLookupBounds() {
|
||||
HintManagerImpl.adjustEditorHintPosition(this, myEditor, calculatePosition(getComponent()));
|
||||
layoutStatusIcons();
|
||||
}
|
||||
|
||||
private void layoutStatusIcons() {
|
||||
final JLayeredPane layeredPane = getComponent().getRootPane().getLayeredPane();
|
||||
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -135,6 +136,7 @@ public class ListTemplatesHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
|
||||
public void itemSelected(LookupEvent event) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.liveTemplates");
|
||||
LookupElement item = event.getItem();
|
||||
if (item != null) {
|
||||
final TemplateImpl template = (TemplateImpl)item.getObject();
|
||||
|
||||
@@ -295,11 +295,12 @@ class RunConfigurable extends BaseConfigurable {
|
||||
public void stateChanged(final SettingsEditor<RunnerAndConfigurationSettings> editor) {
|
||||
update();
|
||||
final RunConfiguration configuration = info.getConfiguration();
|
||||
if (configuration instanceof RuntimeConfiguration) {
|
||||
final RuntimeConfiguration runtimeConfiguration = (RuntimeConfiguration)configuration;
|
||||
if (configuration instanceof LocatableConfiguration) {
|
||||
final LocatableConfiguration runtimeConfiguration = (LocatableConfiguration)configuration;
|
||||
if (runtimeConfiguration.isGeneratedName()) {
|
||||
try {
|
||||
final String generatedName = ((RuntimeConfiguration)editor.getSnapshot().getConfiguration()).getGeneratedName();
|
||||
final LocatableConfiguration snapshot = (LocatableConfiguration)editor.getSnapshot().getConfiguration();
|
||||
final String generatedName = snapshot instanceof RuntimeConfiguration? ((RuntimeConfiguration)snapshot).getGeneratedName() : snapshot.suggestedName();
|
||||
if (generatedName != null && generatedName.length() > 0) {
|
||||
info.setNameText(generatedName);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -38,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class FormatterImpl extends FormatterEx
|
||||
implements ApplicationComponent,
|
||||
@@ -51,7 +53,7 @@ public class FormatterImpl extends FormatterEx
|
||||
|
||||
private FormattingProgressIndicatorImpl myProgressIndicator;
|
||||
|
||||
private int myIsDisabledCount = 0;
|
||||
private final AtomicInteger myIsDisabledCount = new AtomicInteger();
|
||||
private final IndentImpl NONE_INDENT = new IndentImpl(Indent.Type.NONE, false, false);
|
||||
private final IndentImpl myAbsoluteNoneIndent = new IndentImpl(Indent.Type.NONE, true, false);
|
||||
private final IndentImpl myLabelIndent = new IndentImpl(Indent.Type.LABEL, false, false);
|
||||
@@ -263,10 +265,10 @@ public class FormatterImpl extends FormatterEx
|
||||
whiteSpace.setReadOnly(false);
|
||||
processor.formatWithoutRealModifications();
|
||||
return new IndentInfo(whiteSpace.getLineFeeds(), whiteSpace.getIndentOffset(), whiteSpace.getSpaces());
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void adjustLineIndentsForRange(final FormattingModel model,
|
||||
@@ -295,7 +297,6 @@ public class FormatterImpl extends FormatterEx
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void formatAroundRange(final FormattingModel model,
|
||||
@@ -329,8 +330,8 @@ public class FormatterImpl extends FormatterEx
|
||||
}
|
||||
processor.formatWithoutRealModifications();
|
||||
processor.performModifications(model);
|
||||
|
||||
} finally{
|
||||
}
|
||||
finally{
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
@@ -357,12 +358,10 @@ public class FormatterImpl extends FormatterEx
|
||||
return offset;
|
||||
}
|
||||
|
||||
if (blockAfterOffset != null) {
|
||||
return adjustLineIndent(offset, documentModel, processor, indentOptions, model, blockAfterOffset.getWhiteSpace());
|
||||
} else {
|
||||
return adjustLineIndent(offset, documentModel, processor, indentOptions, model, processor.getLastWhiteSpace());
|
||||
}
|
||||
} finally {
|
||||
WhiteSpace whiteSpace = blockAfterOffset != null ? blockAfterOffset.getWhiteSpace() : processor.getLastWhiteSpace();
|
||||
return adjustLineIndent(offset, documentModel, processor, indentOptions, model, whiteSpace);
|
||||
}
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
@@ -549,13 +548,16 @@ public class FormatterImpl extends FormatterEx
|
||||
if (whiteSpace.containsLineFeeds() && indentInfoStorage != null) {
|
||||
whiteSpace.setLineFeedsAreReadOnly(true);
|
||||
current.setIndentFromParent(indentInfoStorage.getIndentInfo(current.getStartOffset()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
whiteSpace.setReadOnly(true);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!changeWSBeforeFirstElement) {
|
||||
whiteSpace.setReadOnly(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!changeLineFeedsBeforeFirstElement) {
|
||||
whiteSpace.setLineFeedsAreReadOnly(true);
|
||||
}
|
||||
@@ -578,7 +580,8 @@ public class FormatterImpl extends FormatterEx
|
||||
assert !(spaceProperty instanceof DependantSpacingImpl);
|
||||
current.setSpaceProperty(
|
||||
getSpacingImpl(
|
||||
spaceProperty.getMinSpaces(), spaceProperty.getMaxSpaces(), spaceProperty.getMinLineFeeds(), spaceProperty.isReadOnly(),
|
||||
spaceProperty.getMinSpaces(), spaceProperty.getMaxSpaces(), spaceProperty.getMinLineFeeds(),
|
||||
spaceProperty.isReadOnly(),
|
||||
spaceProperty.isSafe(), newKeepLineBreaksFlag, newKeepLineBreaks, false, spaceProperty.getPrefLineFeeds()
|
||||
)
|
||||
);
|
||||
@@ -590,10 +593,10 @@ public class FormatterImpl extends FormatterEx
|
||||
current = current.getNextBlock();
|
||||
}
|
||||
processor.format(model);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void adjustTextRange(final FormattingModel model,
|
||||
@@ -612,17 +615,18 @@ public class FormatterImpl extends FormatterEx
|
||||
if (!whiteSpace.isReadOnly()) {
|
||||
if (whiteSpace.getStartOffset() > affectedRange.getStartOffset()) {
|
||||
whiteSpace.setReadOnly(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
whiteSpace.setReadOnly(false);
|
||||
}
|
||||
}
|
||||
current = current.getNextBlock();
|
||||
}
|
||||
processor.format(model);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveIndents(final FormattingModel model, final TextRange affectedRange,
|
||||
@@ -722,36 +726,37 @@ public class FormatterImpl extends FormatterEx
|
||||
return relative ? myContinuationIndentRelativeToDirectParent : myContinuationIndentNotRelativeToDirectParent;
|
||||
}
|
||||
|
||||
public Indent getContinuationWithoutFirstIndent(boolean relative)//is default
|
||||
{
|
||||
//is default
|
||||
public Indent getContinuationWithoutFirstIndent(boolean relative) {
|
||||
return relative ? myContinuationWithoutFirstIndentRelativeToDirectParent : myContinuationWithoutFirstIndentNotRelativeToDirectParent;
|
||||
}
|
||||
|
||||
private final Object DISABLING_LOCK = new Object();
|
||||
|
||||
public boolean isDisabled() {
|
||||
synchronized (DISABLING_LOCK) {
|
||||
return myIsDisabledCount > 0;
|
||||
return myIsDisabledCount.get() > 0;
|
||||
}
|
||||
|
||||
private void disableFormatting() {
|
||||
myIsDisabledCount.incrementAndGet();
|
||||
}
|
||||
|
||||
private void enableFormatting() {
|
||||
int old = myIsDisabledCount.getAndDecrement();
|
||||
if (old <= 0) {
|
||||
LOG.error("enableFormatting()/disableFormatting() not paired. DisabledLevel = " + old);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableFormatting() {
|
||||
synchronized (DISABLING_LOCK) {
|
||||
myIsDisabledCount++;
|
||||
public <T> T runWithFormattingDisabled(@NotNull Computable<T> runnable) {
|
||||
disableFormatting();
|
||||
try {
|
||||
return runnable.compute();
|
||||
}
|
||||
}
|
||||
|
||||
public void enableFormatting() {
|
||||
synchronized (DISABLING_LOCK) {
|
||||
if (myIsDisabledCount <= 0) {
|
||||
LOG.error("enableFormatting()/disableFormatting() not paired. DisabledLevel = " + myIsDisabledCount);
|
||||
}
|
||||
myIsDisabledCount--;
|
||||
finally {
|
||||
enableFormatting();
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class MyFormattingTask implements SequentialTask {
|
||||
|
||||
private FormatProcessor myProcessor;
|
||||
private boolean myDone;
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ public class FileTemplateImpl implements FileTemplate, Cloneable{
|
||||
|
||||
/** Read template from file. */
|
||||
private static String readExternal(File file) throws IOException{
|
||||
return new String(FileUtil.loadFileText(file, ourEncoding));
|
||||
return FileUtil.loadFile(file, ourEncoding);
|
||||
}
|
||||
|
||||
/** Read template from URL. */
|
||||
|
||||
@@ -148,7 +148,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
worker.execute();
|
||||
}
|
||||
};
|
||||
final boolean completed = ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "", true, myProject);
|
||||
final boolean completed = ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Looking for new and edited TODO items...", true, myProject);
|
||||
if (! completed || (worker.getAddedOrEditedTodos().isEmpty() && worker.getInChangedTodos().isEmpty() &&
|
||||
worker.getSkipped().isEmpty())) return ReturnResult.COMMIT;
|
||||
|
||||
|
||||
@@ -72,8 +72,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.intellij.psi.impl.PsiTreeChangeEventImpl.PsiEventType.*;
|
||||
|
||||
public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiManagerImpl");
|
||||
|
||||
@@ -113,7 +111,8 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
StartupManager startupManager,
|
||||
FileTypeManager fileTypeManager,
|
||||
FileDocumentManager fileDocumentManager,
|
||||
PsiBuilderFactory psiBuilderFactory, MessageBus messageBus) {
|
||||
PsiBuilderFactory psiBuilderFactory,
|
||||
MessageBus messageBus) {
|
||||
myProject = project;
|
||||
myMessageBus = messageBus;
|
||||
|
||||
@@ -208,56 +207,45 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void performActionWithFormatterDisabled(final Runnable r) {
|
||||
final PostprocessReformattingAspect component = getProject().getComponent(PostprocessReformattingAspect.class);
|
||||
try {
|
||||
((FormatterImpl)FormatterEx.getInstance()).disableFormatting();
|
||||
component.disablePostprocessFormattingInside(new Computable<Object>() {
|
||||
public Object compute() {
|
||||
r.run();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
((FormatterImpl)FormatterEx.getInstance()).enableFormatting();
|
||||
}
|
||||
performActionWithFormatterDisabled(new Computable<Object>() {
|
||||
@Override
|
||||
public Object compute() {
|
||||
r.run();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public <T extends Throwable> void performActionWithFormatterDisabled(final ThrowableRunnable<T> r) throws T {
|
||||
final Throwable[] throwable = new Throwable[1];
|
||||
|
||||
final PostprocessReformattingAspect component = getProject().getComponent(PostprocessReformattingAspect.class);
|
||||
try {
|
||||
((FormatterImpl)FormatterEx.getInstance()).disableFormatting();
|
||||
component.disablePostprocessFormattingInside(new Computable<Object>() {
|
||||
public Object compute() {
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throwable[0] = t;
|
||||
}
|
||||
return null;
|
||||
performActionWithFormatterDisabled(new Computable<Object>() {
|
||||
@Override
|
||||
public Object compute() {
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
((FormatterImpl)FormatterEx.getInstance()).enableFormatting();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throwable[0] = t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if (throwable[0] != null) //noinspection unchecked
|
||||
if (throwable[0] != null) {
|
||||
//noinspection unchecked
|
||||
throw (T)throwable[0];
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T performActionWithFormatterDisabled(Computable<T> r) {
|
||||
try {
|
||||
final PostprocessReformattingAspect component = PostprocessReformattingAspect.getInstance(getProject());
|
||||
((FormatterImpl)FormatterEx.getInstance()).disableFormatting();
|
||||
return component.disablePostprocessFormattingInside(r);
|
||||
}
|
||||
finally {
|
||||
((FormatterImpl)FormatterEx.getInstance()).enableFormatting();
|
||||
}
|
||||
public <T> T performActionWithFormatterDisabled(final Computable<T> r) {
|
||||
return ((FormatterImpl)FormatterEx.getInstance()).runWithFormattingDisabled(new Computable<T>() {
|
||||
@Override
|
||||
public T compute() {
|
||||
final PostprocessReformattingAspect component = PostprocessReformattingAspect.getInstance(getProject());
|
||||
return component.disablePostprocessFormattingInside(r);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -436,7 +424,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforeChildAddition(PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_CHILD_ADDITION);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_CHILD_ADDITION);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"beforeChildAddition: parent = " + event.getParent()
|
||||
@@ -446,7 +434,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforeChildRemoval(@NotNull PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_CHILD_REMOVAL);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_CHILD_REMOVAL);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"beforeChildRemoval: child = " + event.getChild()
|
||||
@@ -457,7 +445,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforeChildReplacement(@NotNull PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_CHILD_REPLACEMENT);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_CHILD_REPLACEMENT);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"beforeChildReplacement: oldChild = " + event.getOldChild()
|
||||
@@ -468,7 +456,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforeChildrenChange(PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_CHILDREN_CHANGE);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_CHILDREN_CHANGE);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("beforeChildrenChange: parent = " + event.getParent());
|
||||
}
|
||||
@@ -476,7 +464,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforeChildMovement(PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_CHILD_MOVEMENT);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_CHILD_MOVEMENT);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"beforeChildMovement: child = " + event.getChild()
|
||||
@@ -488,7 +476,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void beforePropertyChange(PsiTreeChangeEventImpl event) {
|
||||
event.setCode(BEFORE_PROPERTY_CHANGE);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.BEFORE_PROPERTY_CHANGE);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"beforePropertyChange: element = " + event.getElement()
|
||||
@@ -501,7 +489,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void childAdded(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(CHILD_ADDED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.CHILD_ADDED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"childAdded: child = " + event.getChild()
|
||||
@@ -514,7 +502,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void childRemoved(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(CHILD_REMOVED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.CHILD_REMOVED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"childRemoved: child = " + event.getChild() + ", parent = " + event.getParent()
|
||||
@@ -526,7 +514,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void childReplaced(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(CHILD_REPLACED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.CHILD_REPLACED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"childReplaced: oldChild = " + event.getOldChild()
|
||||
@@ -540,7 +528,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void childMoved(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(CHILD_MOVED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.CHILD_MOVED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"childMoved: child = " + event.getChild()
|
||||
@@ -554,7 +542,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void childrenChanged(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(CHILDREN_CHANGED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.CHILDREN_CHANGED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"childrenChanged: parent = " + event.getParent()
|
||||
@@ -566,7 +554,7 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
|
||||
public void propertyChanged(PsiTreeChangeEventImpl event) {
|
||||
beforeChange(true);
|
||||
event.setCode(PROPERTY_CHANGED);
|
||||
event.setCode(PsiTreeChangeEventImpl.PsiEventType.PROPERTY_CHANGED);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(
|
||||
"propertyChanged: element = " + event.getElement()
|
||||
@@ -584,7 +572,8 @@ public class PsiManagerImpl extends PsiManagerEx implements ProjectComponent {
|
||||
}
|
||||
|
||||
private void fireEvent(PsiTreeChangeEventImpl event) {
|
||||
boolean isRealTreeChange = event.getCode() != PROPERTY_CHANGED && event.getCode() != BEFORE_PROPERTY_CHANGE;
|
||||
boolean isRealTreeChange = event.getCode() != PsiTreeChangeEventImpl.PsiEventType.PROPERTY_CHANGED
|
||||
&& event.getCode() != PsiTreeChangeEventImpl.PsiEventType.BEFORE_PROPERTY_CHANGE;
|
||||
|
||||
PsiFile file = event.getFile();
|
||||
if (file == null || file.isPhysical()) {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.source.tree.injected;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
class Places extends SmartList<Place> {
|
||||
public boolean isValid() {
|
||||
for (Place place : this) {
|
||||
if (!place.isValid()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class BrowserUtil {
|
||||
|
||||
String previousTimestamp = null;
|
||||
if (timestampFile.exists()) {
|
||||
previousTimestamp = new String(FileUtil.loadFileText(timestampFile));
|
||||
previousTimestamp = FileUtil.loadFile(timestampFile);
|
||||
}
|
||||
|
||||
if (!currentTimestamp.equals(previousTimestamp)) {
|
||||
|
||||
@@ -757,7 +757,7 @@ public class PluginManager {
|
||||
FileUtil.findFirstThatExist(PathManager.getHomePath() + "/build.txt", PathManager.getHomePath() + "/community/build.txt");
|
||||
|
||||
if (buildTxtFile != null) {
|
||||
ourBuildNumber = BuildNumber.fromString(new String(FileUtil.loadFileText(buildTxtFile)).trim());
|
||||
ourBuildNumber = BuildNumber.fromString(FileUtil.loadFile(buildTxtFile).trim());
|
||||
}
|
||||
else {
|
||||
ourBuildNumber = BuildNumber.fromString("106.SNAPSHOT");
|
||||
|
||||
@@ -3338,11 +3338,6 @@ public class AbstractTreeUi {
|
||||
notified = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!notified) {
|
||||
myTreeModel.nodeChanged(node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DefaultTreeModel getTreeModel() {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class VMOptions {
|
||||
|
||||
private static int readOption(Pattern pattern) {
|
||||
try {
|
||||
String content = new String(FileUtil.loadFileText(getFile()));
|
||||
String content = FileUtil.loadFile(getFile());
|
||||
|
||||
if (isMacOs()) {
|
||||
content = extractMacOsVMOptionsSection(content);
|
||||
@@ -115,7 +115,7 @@ public class VMOptions {
|
||||
private static void writeOption(String option, int value, Pattern pattern) {
|
||||
try {
|
||||
String optionValue = option + value + "m";
|
||||
String content = new String(FileUtil.loadFileText(getFile()));
|
||||
String content = FileUtil.loadFile(getFile());
|
||||
String vmOptions;
|
||||
|
||||
if (isMacOs()) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LoggerFactory implements Logger.Factory {
|
||||
throw new RuntimeException("log.xml file does not exist! Path: [ $home/bin/log.xml]");
|
||||
}
|
||||
|
||||
String text = new String(FileUtil.loadFileText(logXmlFile));
|
||||
String text = FileUtil.loadFile(logXmlFile);
|
||||
text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\"));
|
||||
text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\"));
|
||||
text = StringUtil.replace(text, LOGDIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\"));
|
||||
|
||||
+1
-1
@@ -521,7 +521,7 @@ public final class UpdateChecker {
|
||||
try {
|
||||
final File file = new File(PathManager.getConfigPath(), DISABLED_UPDATE);
|
||||
if (file.isFile()) {
|
||||
final String[] ids = new String(FileUtil.loadFileText(file)).split("[\\s]");
|
||||
final String[] ids = FileUtil.loadFile(file).split("[\\s]");
|
||||
for (String id : ids) {
|
||||
if (id != null && id.trim().length() > 0) {
|
||||
ourDisabledToUpdatePlugins.add(id.trim());
|
||||
|
||||
@@ -87,6 +87,8 @@
|
||||
<editorSmartKeysConfigurable instance="com.intellij.application.options.editor.WebEditorOptionsProvider"/>
|
||||
<editorAppearanceConfigurable instance="com.intellij.application.options.editor.WebEditorAppearanceConfigurable"/>
|
||||
|
||||
<editorAppearanceConfigurable instance="com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.HtmlTagTreeHighlightingConfigurable"/>
|
||||
|
||||
<autoImportOptionsProvider instance="com.intellij.application.options.XmlAutoImportOptionsProvider"/>
|
||||
|
||||
<highlightErrorFilter implementation="com.intellij.codeInsight.highlighting.HtmlClosingTagErrorFilter"/>
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class FileSetTestCase extends TestSuite {
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
String content = new String(FileUtil.loadFileText(myTestFile));
|
||||
String content = FileUtil.loadFile(myTestFile);
|
||||
assertNotNull(content);
|
||||
|
||||
List<String> input = new ArrayList<String>();
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class LexerTestCase extends UsefulTestCase {
|
||||
String fileName = PathManager.getHomePath() + "/" + getDirPath() + "/" + getTestName(true) + "." + fileExt;
|
||||
String text = "";
|
||||
try {
|
||||
text = StringUtil.convertLineSeparators(new String(FileUtil.loadFileText(new File(fileName))).trim());
|
||||
text = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(fileName)).trim());
|
||||
}
|
||||
catch (IOException e) {
|
||||
fail("can't load file " + fileName + ": " + e.getMessage());
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
String fullPath = getTestDataPath() + filePath;
|
||||
|
||||
final File ioFile = new File(fullPath);
|
||||
String fileText = new String(FileUtil.loadFileText(ioFile, CharsetToolkit.UTF8));
|
||||
String fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
fileText = StringUtil.convertLineSeparators(fileText);
|
||||
|
||||
configureFromFileText(ioFile.getName(), fileText);
|
||||
@@ -280,7 +280,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
assertTrue(getMessage("Cannot find file " + fullPath, message), ioFile.exists());
|
||||
String fileText = null;
|
||||
try {
|
||||
fileText = new String(FileUtil.loadFileText(ioFile, CharsetToolkit.UTF8));
|
||||
fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
} catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public abstract class ParsingTestCase extends LightPlatformTestCase {
|
||||
|
||||
private static String doLoadFile(String myFullDataPath, String name) throws IOException {
|
||||
String fullName = myFullDataPath + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName))).trim();
|
||||
String text = FileUtil.loadFile(new File(fullName)).trim();
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TestLoggerFactory implements Logger.Factory {
|
||||
}
|
||||
|
||||
final String logDir = PathManager.getSystemPath() + "/" + LOG_DIR;
|
||||
String text = new String(FileUtil.loadFileText(logXmlFile));
|
||||
String text = FileUtil.loadFile(logXmlFile);
|
||||
text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\"));
|
||||
text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\"));
|
||||
text = StringUtil.replace(text, LOG_DIR_MACRO, StringUtil.replace(logDir, "\\", "\\\\"));
|
||||
|
||||
@@ -506,8 +506,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
protected static void assertSameLinesWithFile(final String filePath, final String actualText) {
|
||||
String fileText;
|
||||
try {
|
||||
final FileReader reader = new FileReader(filePath);
|
||||
fileText = FileUtil.loadTextAndClose(reader);
|
||||
fileText = FileUtil.loadFile(new File(filePath));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -168,12 +168,20 @@ public class FileUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] loadFileText(File file) throws IOException {
|
||||
public static String loadFile(@NotNull File file) throws IOException {
|
||||
return loadFile(file, null);
|
||||
}
|
||||
@NotNull
|
||||
public static String loadFile(@NotNull File file, String encoding) throws IOException {
|
||||
return new String(loadFileText(file, encoding));
|
||||
}
|
||||
@NotNull
|
||||
public static char[] loadFileText(@NotNull File file) throws IOException {
|
||||
return loadFileText(file, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static char[] loadFileText(File file, @NonNls String encoding) throws IOException{
|
||||
public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException{
|
||||
InputStream stream = new FileInputStream(file);
|
||||
Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding);
|
||||
try{
|
||||
|
||||
@@ -91,13 +91,13 @@ public class ReorderJarsMain {
|
||||
private static Set<String> loadIgnoredJars(String libPath) throws IOException {
|
||||
final File ignoredJarsFile = new File(libPath, "required_for_dist.txt");
|
||||
final Set<String> ignoredJars = new HashSet<String>();
|
||||
ContainerUtil.addAll(ignoredJars, new String(FileUtil.loadFileText(ignoredJarsFile)).split("\r\n"));
|
||||
ContainerUtil.addAll(ignoredJars, FileUtil.loadFile(ignoredJarsFile).split("\r\n"));
|
||||
return ignoredJars;
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> getOrder(final File loadingFile) throws IOException {
|
||||
final Map<String, List<String>> entriesOrder = new HashMap<String, List<String>>();
|
||||
final String[] lines = new String(FileUtil.loadFileText(loadingFile)).split("\r\n");
|
||||
final String[] lines = FileUtil.loadFile(loadingFile).split("\r\n");
|
||||
for (String line : lines) {
|
||||
final int i = line.indexOf(":");
|
||||
if (i != -1) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.io.IOException;
|
||||
*/
|
||||
public class EncodingAwareProperties extends java.util.Properties{
|
||||
public void load(File file, String encoding) throws IOException{
|
||||
String propText = new String(FileUtil.loadFileText(file, encoding));
|
||||
String propText = FileUtil.loadFile(file, encoding);
|
||||
propText = StringUtil.convertLineSeparators(propText);
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(propText, "\n");
|
||||
while (stringTokenizer.hasMoreElements()){
|
||||
|
||||
@@ -279,7 +279,8 @@ class BeanBinding implements Binding {
|
||||
return new AccessorBindingWrapper(accessor, binding);
|
||||
}
|
||||
|
||||
return new OptionTagBinding(accessor, xmlSerializer);
|
||||
OptionTag optionTag = XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), OptionTag.class);
|
||||
return new OptionTagBinding(accessor, xmlSerializer, optionTag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,42 +19,57 @@ package com.intellij.util.xmlb;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Content;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Text;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//todo: use TagBinding
|
||||
class OptionTagBinding implements Binding {
|
||||
|
||||
private final static Logger LOG = Logger.getInstance("#" + OptionTagBinding.class.getName());
|
||||
|
||||
private final Accessor accessor;
|
||||
private final String myName;
|
||||
private final Binding myBinding;
|
||||
private final String myTagName;
|
||||
private final String myNameAttribute;
|
||||
private final String myValueAttribute;
|
||||
|
||||
public OptionTagBinding(Accessor accessor, XmlSerializerImpl xmlSerializer) {
|
||||
public OptionTagBinding(Accessor accessor, XmlSerializerImpl xmlSerializer, @Nullable OptionTag optionTag) {
|
||||
this.accessor = accessor;
|
||||
myName = accessor.getName();
|
||||
myBinding = xmlSerializer.getBinding(accessor);
|
||||
if (optionTag != null) {
|
||||
String name = optionTag.value();
|
||||
myName = name.isEmpty() ? accessor.getName() : name;
|
||||
myTagName = optionTag.tag();
|
||||
myNameAttribute = optionTag.nameAttribute();
|
||||
myValueAttribute = optionTag.valueAttribute();
|
||||
}
|
||||
else {
|
||||
myName = accessor.getName();
|
||||
myTagName = Constants.OPTION;
|
||||
myNameAttribute = Constants.NAME;
|
||||
myValueAttribute = Constants.VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public Object serialize(Object o, Object context) {
|
||||
Element targetElement = new Element(Constants.OPTION);
|
||||
Element targetElement = new Element(myTagName);
|
||||
Object value = accessor.read(o);
|
||||
|
||||
targetElement.setAttribute(Constants.NAME, myName);
|
||||
targetElement.setAttribute(myNameAttribute, myName);
|
||||
|
||||
if (value == null) return targetElement;
|
||||
|
||||
Object node = myBinding.serialize(value, targetElement);
|
||||
if (node instanceof Text) {
|
||||
Text text = (Text)node;
|
||||
targetElement.setAttribute(Constants.VALUE, text.getText());
|
||||
targetElement.setAttribute(myValueAttribute, text.getText());
|
||||
}
|
||||
else {
|
||||
if (targetElement != node) {
|
||||
@@ -72,7 +87,7 @@ class OptionTagBinding implements Binding {
|
||||
assert nodes.length != 0 : "Empty nodes passed to: " + this;
|
||||
|
||||
Element element = ((Element)nodes[0]);
|
||||
Attribute valueAttr = element.getAttribute(Constants.VALUE);
|
||||
Attribute valueAttr = element.getAttribute(myValueAttribute);
|
||||
|
||||
if (valueAttr != null) {
|
||||
Object value = myBinding.deserialize(o, valueAttr);
|
||||
@@ -102,8 +117,8 @@ class OptionTagBinding implements Binding {
|
||||
public boolean isBoundTo(Object node) {
|
||||
if (!(node instanceof Element)) return false;
|
||||
Element e = (Element)node;
|
||||
if (!e.getName().equals(Constants.OPTION)) return false;
|
||||
String name = e.getAttributeValue(Constants.NAME);
|
||||
if (!e.getName().equals(myTagName)) return false;
|
||||
String name = e.getAttributeValue(myNameAttribute);
|
||||
return name != null && name.equals(myName);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.util.xmlb.annotations;
|
||||
|
||||
import com.intellij.util.xmlb.Constants;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Store value in tag like <option name="optionName" value="optionValue"/>
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD})
|
||||
public @interface OptionTag {
|
||||
String value() default "";
|
||||
String tag() default Constants.OPTION;
|
||||
String nameAttribute() default Constants.NAME;
|
||||
String valueAttribute() default Constants.VALUE;
|
||||
}
|
||||
@@ -21,9 +21,6 @@ import com.intellij.util.xmlb.annotations.*;
|
||||
import junit.framework.TestCase;
|
||||
import org.jdom.Element;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -36,7 +33,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public static class EmptyBean {
|
||||
}
|
||||
|
||||
public void testEmptyBeanSerialization() throws Exception {
|
||||
public void testEmptyBeanSerialization() {
|
||||
doSerializerTest("<EmptyBean />", new EmptyBean());
|
||||
}
|
||||
|
||||
@@ -44,7 +41,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public static class EmptyBeanWithCustomName {
|
||||
}
|
||||
|
||||
public void testEmptyBeanSerializationWithCustomName() throws Exception {
|
||||
public void testEmptyBeanSerializationWithCustomName() {
|
||||
doSerializerTest("<Bean />", new EmptyBeanWithCustomName());
|
||||
}
|
||||
|
||||
@@ -67,7 +64,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testPublicFieldSerialization() throws Exception {
|
||||
public void testPublicFieldSerialization() {
|
||||
BeanWithPublicFields bean = new BeanWithPublicFields();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -91,7 +88,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public String NEW_S = "foo";
|
||||
}
|
||||
|
||||
public void testPublicFieldSerializationWithInheritance() throws Exception {
|
||||
public void testPublicFieldSerializationWithInheritance() {
|
||||
BeanWithPublicFieldsDescendant bean = new BeanWithPublicFieldsDescendant();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -120,7 +117,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public BeanWithPublicFields BEAN2 = new BeanWithPublicFields();
|
||||
}
|
||||
|
||||
public void testSubBeanSerialization() throws Exception {
|
||||
public void testSubBeanSerialization() {
|
||||
BeanWithSubBean bean = new BeanWithSubBean();
|
||||
doSerializerTest(
|
||||
"<BeanWithSubBean>\n" +
|
||||
@@ -153,7 +150,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
bean);
|
||||
}
|
||||
|
||||
public void testNullFieldValue() throws Exception {
|
||||
public void testNullFieldValue() {
|
||||
BeanWithPublicFields bean1 = new BeanWithPublicFields();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -187,7 +184,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public List<String> VALUES = new ArrayList<String>(Arrays.asList("a", "b", "c"));
|
||||
}
|
||||
|
||||
public void testListSerialization() throws Exception {
|
||||
public void testListSerialization() {
|
||||
BeanWithList bean = new BeanWithList();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -221,7 +218,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public Set<String> VALUES = new LinkedHashSet<String>(Arrays.asList("a", "b", "w"));
|
||||
}
|
||||
|
||||
public void testSetSerialization() throws Exception {
|
||||
public void testSetSerialization() {
|
||||
BeanWithSet bean = new BeanWithSet();
|
||||
doSerializerTest(
|
||||
"<BeanWithSet>\n" +
|
||||
@@ -259,7 +256,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testMapSerialization() throws Exception {
|
||||
public void testMapSerialization() {
|
||||
BeanWithMap bean = new BeanWithMap();
|
||||
doSerializerTest(
|
||||
"<BeanWithMap>\n" +
|
||||
@@ -307,7 +304,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testMapSerializationWithAnnotations() throws Exception {
|
||||
public void testMapSerializationWithAnnotations() {
|
||||
BeanWithMapWithAnnotations bean = new BeanWithMapWithAnnotations();
|
||||
doSerializerTest(
|
||||
"<BeanWithMapWithAnnotations>\n" +
|
||||
@@ -335,7 +332,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public Map<String, BeanWithProperty> VALUES = new HashMap<String, BeanWithProperty>();
|
||||
|
||||
}
|
||||
public void testMapWithBeanValue() throws Exception {
|
||||
public void testMapWithBeanValue() {
|
||||
BeanWithMapWithBeanValue bean = new BeanWithMapWithBeanValue();
|
||||
|
||||
bean.VALUES.put("a", new BeanWithProperty("James"));
|
||||
@@ -372,6 +369,33 @@ public class XmlSerializerTest extends TestCase {
|
||||
"</BeanWithMapWithBeanValue>",
|
||||
bean);
|
||||
}
|
||||
|
||||
public static class BeanWithOption {
|
||||
@OptionTag("path")
|
||||
public String PATH;
|
||||
}
|
||||
|
||||
public void testOptionTag() {
|
||||
BeanWithOption bean = new BeanWithOption();
|
||||
bean.PATH = "123";
|
||||
doSerializerTest("<BeanWithOption>\n" +
|
||||
" <option name=\"path\" value=\"123\" />\n" +
|
||||
"</BeanWithOption>", bean);
|
||||
}
|
||||
|
||||
public static class BeanWithCustomizedOption {
|
||||
@OptionTag(tag = "setting", nameAttribute = "key", valueAttribute = "saved")
|
||||
public String PATH;
|
||||
}
|
||||
|
||||
public void testCustomizedOptionTag() {
|
||||
BeanWithCustomizedOption bean = new BeanWithCustomizedOption();
|
||||
bean.PATH = "123";
|
||||
doSerializerTest("<BeanWithCustomizedOption>\n" +
|
||||
" <setting key=\"PATH\" saved=\"123\" />\n" +
|
||||
"</BeanWithCustomizedOption>", bean);
|
||||
}
|
||||
|
||||
public static class BeanWithProperty {
|
||||
private String name = "James";
|
||||
|
||||
@@ -392,7 +416,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testPropertySerialization() throws Exception {
|
||||
public void testPropertySerialization() {
|
||||
BeanWithProperty bean = new BeanWithProperty();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -414,7 +438,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public String STRING_V = "hello";
|
||||
}
|
||||
|
||||
public void testFieldWithTagAnnotation() throws Exception {
|
||||
public void testFieldWithTagAnnotation() {
|
||||
BeanWithFieldWithTagAnnotation bean = new BeanWithFieldWithTagAnnotation();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -431,7 +455,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
"</BeanWithFieldWithTagAnnotation>", bean);
|
||||
}
|
||||
|
||||
public void testShuffledDeserialize() throws Exception {
|
||||
public void testShuffledDeserialize() {
|
||||
BeanWithPublicFields bean = new BeanWithPublicFields();
|
||||
bean.INT_V = 987;
|
||||
bean.STRING_V = "1234";
|
||||
@@ -448,7 +472,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
assertEquals("1234", bean.STRING_V);
|
||||
}
|
||||
|
||||
public void testFilterSerializer() throws Exception {
|
||||
public void testFilterSerializer() {
|
||||
BeanWithPublicFields bean = new BeanWithPublicFields();
|
||||
assertSerializer(bean,
|
||||
"<BeanWithPublicFields>\n" +
|
||||
@@ -465,7 +489,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public static class BeanWithArray {
|
||||
public String[] ARRAY_V = new String[] {"a", "b"};
|
||||
}
|
||||
public void testArray() throws Exception {
|
||||
public void testArray() {
|
||||
final BeanWithArray bean = new BeanWithArray();
|
||||
doSerializerTest(
|
||||
"<BeanWithArray>\n" +
|
||||
@@ -498,7 +522,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
return "foo";
|
||||
}
|
||||
}
|
||||
public void testTransient() throws Exception {
|
||||
public void testTransient() {
|
||||
final BeanWithTransient bean = new BeanWithTransient();
|
||||
doSerializerTest("<BeanWithTransient />", bean);
|
||||
}
|
||||
@@ -507,7 +531,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
@com.intellij.util.xmlb.annotations.AbstractCollection(surroundWithTag = false)
|
||||
public String[] V = new String[]{"a"};
|
||||
}
|
||||
public void testArrayAnnotationWithoutTagNAmeGivesError() throws Exception {
|
||||
public void testArrayAnnotationWithoutTagNAmeGivesError() {
|
||||
final BeanWithArrayWithoutTagName bean = new BeanWithArrayWithoutTagName();
|
||||
|
||||
try {
|
||||
@@ -524,7 +548,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
@com.intellij.util.xmlb.annotations.AbstractCollection(elementTag = "vvalue", elementValueAttribute = "v")
|
||||
public String[] V = new String[]{"a", "b"};
|
||||
}
|
||||
public void testArrayAnnotationWithElementTag() throws Exception {
|
||||
public void testArrayAnnotationWithElementTag() {
|
||||
final BeanWithArrayWithElementTagName bean = new BeanWithArrayWithElementTagName();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -557,7 +581,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public String[] V = new String[]{"a", "b"};
|
||||
public int INT_V = 1;
|
||||
}
|
||||
public void testArrayWithoutTag() throws Exception {
|
||||
public void testArrayWithoutTag() {
|
||||
final BeanWithArrayWithoutTag bean = new BeanWithArrayWithoutTag();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -587,7 +611,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
@Property(surroundWithTag = false)
|
||||
public int INT_V = 1;
|
||||
}
|
||||
public void testPropertyWithoutTagWithPrimitiveType() throws Exception {
|
||||
public void testPropertyWithoutTagWithPrimitiveType() {
|
||||
final BeanWithPropertyWithoutTagOnPrimitiveValue bean = new BeanWithPropertyWithoutTagOnPrimitiveValue();
|
||||
|
||||
try {
|
||||
@@ -605,7 +629,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public BeanWithPublicFields BEAN1 = new BeanWithPublicFields();
|
||||
public int INT_V = 1;
|
||||
}
|
||||
public void testPropertyWithoutTag() throws Exception {
|
||||
public void testPropertyWithoutTag() {
|
||||
final BeanWithPropertyWithoutTag bean = new BeanWithPropertyWithoutTag();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -638,7 +662,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public String[] V = new String[]{"a", "b"};
|
||||
public int INT_V = 1;
|
||||
}
|
||||
public void testArrayWithoutAllTags() throws Exception {
|
||||
public void testArrayWithoutAllTags() {
|
||||
final BeanWithArrayWithoutAllsTag bean = new BeanWithArrayWithoutAllsTag();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -666,7 +690,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public String[] V = new String[]{"a", "b"};
|
||||
public int INT_V = 1;
|
||||
}
|
||||
public void testArrayWithoutAllTags2() throws Exception {
|
||||
public void testArrayWithoutAllTags2() {
|
||||
final BeanWithArrayWithoutAllsTag2 bean = new BeanWithArrayWithoutAllsTag2();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -706,7 +730,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public BeanWithPublicFields[] V = new BeanWithPublicFields[] {};
|
||||
}
|
||||
|
||||
public void testPolymorphicArray() throws Exception {
|
||||
public void testPolymorphicArray() {
|
||||
final BeanWithPolymorphicArray bean = new BeanWithPolymorphicArray();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -747,7 +771,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
@Attribute("name")
|
||||
public String name = "James";
|
||||
}
|
||||
public void testBeanWithPrimitivePropertyBoundToAttribute() throws Exception {
|
||||
public void testBeanWithPrimitivePropertyBoundToAttribute() {
|
||||
final BeanWithPropertiesBoundToAttribute bean = new BeanWithPropertiesBoundToAttribute();
|
||||
|
||||
doSerializerTest("<BeanWithPropertiesBoundToAttribute count=\"3\" name=\"James\" />", bean);
|
||||
@@ -771,7 +795,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
return !accessor.read(bean).equals("skip");
|
||||
}
|
||||
}
|
||||
public void testPropertyFilter() throws Exception {
|
||||
public void testPropertyFilter() {
|
||||
BeanWithPropertyFilter bean = new BeanWithPropertyFilter();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -797,7 +821,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public org.jdom.Element actions;
|
||||
}
|
||||
|
||||
public void testSerializeJDOMElementField() throws Exception {
|
||||
public void testSerializeJDOMElementField() {
|
||||
BeanWithJDOMElement element = new BeanWithJDOMElement();
|
||||
element.STRING_V = "a";
|
||||
element.actions = new Element("x").addContent(new Element("a")).addContent(new Element("b"));
|
||||
@@ -881,7 +905,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testTextAnnotation() throws Exception {
|
||||
public void testTextAnnotation() {
|
||||
BeanWithTextAnnotation bean = new BeanWithTextAnnotation();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -911,7 +935,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public TestEnum FLD = TestEnum.VALUE_1;
|
||||
}
|
||||
|
||||
public void testEnums() throws Exception {
|
||||
public void testEnums() {
|
||||
BeanWithEnum bean = new BeanWithEnum();
|
||||
|
||||
doSerializerTest(
|
||||
@@ -927,7 +951,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public Map<Collection<String>, String> myMap = new HashMap<Collection<String>, String>();
|
||||
}
|
||||
|
||||
public void testSetKeysInMap() throws Exception {
|
||||
public void testSetKeysInMap() {
|
||||
final BeanWithSetKeysInMap bean = new BeanWithSetKeysInMap();
|
||||
bean.myMap.put(new HashSet<String>(Arrays.asList("1", "2", "3")), "numbers");
|
||||
bean.myMap.put(new HashSet<String>(Arrays.asList("a", "b", "c")), "letters");
|
||||
@@ -982,7 +1006,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
public Map<BeanWithPublicFields, BeanWithTextAnnotation> MAP = new HashMap<BeanWithPublicFields, BeanWithTextAnnotation>();
|
||||
}
|
||||
|
||||
public void testMapWithNotSurroundingKeyAndValue() throws Exception {
|
||||
public void testMapWithNotSurroundingKeyAndValue() {
|
||||
BeanWithMapWithoutSurround bean = new BeanWithMapWithoutSurround();
|
||||
|
||||
bean.MAP.put(new BeanWithPublicFields(1, "a"), new BeanWithTextAnnotation(2, "b"));
|
||||
@@ -1028,24 +1052,29 @@ public class XmlSerializerTest extends TestCase {
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
private void assertSerializer(Object bean, String expected, SerializationFilter filter)
|
||||
throws TransformerException, ParserConfigurationException, IOException {
|
||||
private static void assertSerializer(Object bean, String expected, SerializationFilter filter) {
|
||||
assertSerializer(bean, expected, "Serialization failure", filter);
|
||||
}
|
||||
|
||||
private Object doSerializerTest(String expectedText, Object bean)
|
||||
throws ParserConfigurationException, TransformerException, XmlSerializationException, IOException {
|
||||
Element element = assertSerializer(bean, expectedText, "Serialization failure", null);
|
||||
private static Object doSerializerTest(String expectedText, Object bean) {
|
||||
try {
|
||||
Element element = assertSerializer(bean, expectedText, "Serialization failure", null);
|
||||
|
||||
//test deserializer
|
||||
//test deserializer
|
||||
|
||||
Object o = XmlSerializer.deserialize(element, bean.getClass());
|
||||
assertSerializer(o, expectedText, "Deserialization failure", null);
|
||||
return o;
|
||||
Object o = XmlSerializer.deserialize(element, bean.getClass());
|
||||
assertSerializer(o, expectedText, "Deserialization failure", null);
|
||||
return o;
|
||||
}
|
||||
catch (XmlSerializationException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Element assertSerializer(Object bean, String expectedText, String message, SerializationFilter filter)
|
||||
throws ParserConfigurationException, XmlSerializationException, TransformerException, IOException {
|
||||
private static Element assertSerializer(Object bean, String expectedText, String message, SerializationFilter filter) throws XmlSerializationException {
|
||||
Element element = serialize(bean, filter);
|
||||
|
||||
|
||||
@@ -1060,7 +1089,7 @@ public class XmlSerializerTest extends TestCase {
|
||||
return element;
|
||||
}
|
||||
|
||||
private Element serialize(Object bean, SerializationFilter filter) throws ParserConfigurationException {
|
||||
private static Element serialize(Object bean, SerializationFilter filter) {
|
||||
return XmlSerializer.serialize(bean, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class AndroidUtils {
|
||||
public static final String EXT_NATIVE_LIB = "so";
|
||||
@NonNls public static final String RES_OVERLAY_DIR_NAME = "res-overlay";
|
||||
|
||||
public static final int TIMEOUT = 60000;
|
||||
public static final int TIMEOUT = 300000;
|
||||
|
||||
private AndroidUtils() {
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CustomTypesTest extends ParsingTestCase {
|
||||
@Override
|
||||
protected String loadFile(String name) throws IOException {
|
||||
String fullName = getTestDataPath() + File.separatorChar + name;
|
||||
String text = new String(FileUtil.loadFileText(new File(fullName))).trim();
|
||||
String text = FileUtil.loadFile(new File(fullName)).trim();
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
final String root = PathUtil.getJarPathForClass(this.getClass());
|
||||
final String placeholder = "<_classpath_>";
|
||||
|
||||
+4
-2
@@ -17,6 +17,7 @@
|
||||
package com.maddyhome.idea.copyright.options;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.maddyhome.idea.copyright.CopyrightProfile;
|
||||
import org.jdom.Document;
|
||||
@@ -54,10 +55,11 @@ public class ExternalOptionHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
return profiles.isEmpty() ? null : profiles;
|
||||
return profiles;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.info(e);
|
||||
Messages.showErrorDialog(e.getMessage(), "Import Failure");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,8 @@ public class CopyrightProfilesPanel extends MasterDetailsComponent implements Se
|
||||
if (files.length != 1) return;
|
||||
|
||||
final List<CopyrightProfile> copyrightProfiles = ExternalOptionHelper.loadOptions(VfsUtil.virtualToIoFile(files[0]));
|
||||
if (copyrightProfiles != null) {
|
||||
if (copyrightProfiles == null) return;
|
||||
if (!copyrightProfiles.isEmpty()) {
|
||||
if (copyrightProfiles.size() == 1) {
|
||||
importProfile(copyrightProfiles.get(0));
|
||||
} else {
|
||||
@@ -224,7 +225,7 @@ public class CopyrightProfilesPanel extends MasterDetailsComponent implements Se
|
||||
}
|
||||
}
|
||||
else {
|
||||
Messages.showWarningDialog(myProject, "The selected file did not contain any copyright settings.", "Import Failure");
|
||||
Messages.showWarningDialog(myProject, "The selected file does not contain any copyright settings.", "Import Failure");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public class CvsUtil {
|
||||
File file = getFileInTheAdminDir(directory, fileName);
|
||||
if (!file.isFile()) return null;
|
||||
try {
|
||||
String result = new String(FileUtil.loadFileText(file));
|
||||
String result = FileUtil.loadFile(file);
|
||||
if (trimContent) {
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class IdeaJdk extends SdkType implements JavaSdkType {
|
||||
private static String getBuildNumber(String ideaHome) {
|
||||
try {
|
||||
@NonNls final String buildTxt = "/build.txt";
|
||||
return new String(FileUtil.loadFileText(new File(ideaHome + buildTxt))).trim();
|
||||
return FileUtil.loadFile(new File(ideaHome + buildTxt)).trim();
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class EclipseClasspathTest extends IdeaTestCase {
|
||||
|
||||
static Module setUpModule(final String path, final Project project) throws IOException, JDOMException, ConversionException {
|
||||
final File classpathFile = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
|
||||
String fileText = new String(FileUtil.loadFileText(classpathFile)).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
String fileText = FileUtil.loadFile(classpathFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
if (!SystemInfo.isWindows) {
|
||||
fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class EclipseClasspathTest extends IdeaTestCase {
|
||||
static void checkModule(String path, Module module) throws IOException, JDOMException, ConversionException {
|
||||
final File classpathFile1 = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
|
||||
if (!classpathFile1.exists()) return;
|
||||
String fileText1 = new String(FileUtil.loadFileText(classpathFile1)).replaceAll("\\$ROOT\\$", module.getProject().getBaseDir().getPath());
|
||||
String fileText1 = FileUtil.loadFile(classpathFile1).replaceAll("\\$ROOT\\$", module.getProject().getBaseDir().getPath());
|
||||
if (!SystemInfo.isWindows) {
|
||||
fileText1 = fileText1.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class EclipseEmlTest extends IdeaTestCase {
|
||||
new EclipseClasspathStorageProvider.EclipseClasspathConverter(module);
|
||||
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
|
||||
final Element classpathElement = JDOMUtil.loadDocument(new String(FileUtil.loadFileText(new File(path, EclipseXml.DOT_CLASSPATH_EXT)))).getRootElement();
|
||||
final Element classpathElement = JDOMUtil.loadDocument(FileUtil.loadFile(new File(path, EclipseXml.DOT_CLASSPATH_EXT))).getRootElement();
|
||||
converter.getClasspath(rootModel, classpathElement);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
@@ -103,12 +103,12 @@ public class EclipseEmlTest extends IdeaTestCase {
|
||||
|
||||
final File emlFile = new File(path, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX);
|
||||
Assert.assertTrue(resulted.replaceAll(StringUtil.escapeToRegexp(module.getProject().getBaseDir().getPath()), "\\$ROOT\\$"),
|
||||
JDOMUtil.areElementsEqual(root, JDOMUtil.loadDocument(new String(FileUtil.loadFileText(emlFile))).getRootElement()));
|
||||
JDOMUtil.areElementsEqual(root, JDOMUtil.loadDocument(FileUtil.loadFile(emlFile)).getRootElement()));
|
||||
}
|
||||
|
||||
private static void replaceRoot(String path, final String child, final Project project) throws IOException, JDOMException {
|
||||
final File emlFile = new File(path, child);
|
||||
String fileText = new String(FileUtil.loadFileText(emlFile)).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
String fileText = FileUtil.loadFile(emlFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
if (!SystemInfo.isWindows) {
|
||||
fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class EclipseImlTest extends IdeaTestCase {
|
||||
final String path = project.getBaseDir().getPath() + relativePath;
|
||||
|
||||
final File classpathFile = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
|
||||
String fileText = new String(FileUtil.loadFileText(classpathFile)).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
String fileText = FileUtil.loadFile(classpathFile).replaceAll("\\$ROOT\\$", project.getBaseDir().getPath());
|
||||
if (!SystemInfo.isWindows) {
|
||||
fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class GitBranch extends GitReference {
|
||||
// the case after git init and before first commit - there is no branch and no output, and we'll take refs/heads/master
|
||||
String head;
|
||||
try {
|
||||
head = new String(FileUtil.loadFileText(new File(root.getPath(), ".git/HEAD"), GitUtil.UTF8_ENCODING)).trim();
|
||||
head = FileUtil.loadFile(new File(root.getPath(), ".git/HEAD"), GitUtil.UTF8_ENCODING).trim();
|
||||
final String prefix = "ref: refs/heads/";
|
||||
return head.startsWith(prefix) ? new GitBranch(head.substring(prefix.length()), true, false) : null;
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -31,9 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -363,7 +361,7 @@ public final class GitRemote {
|
||||
// try remotes file
|
||||
try {
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
String text = FileUtil.loadTextAndClose(new InputStreamReader(new FileInputStream(remotesFile), US_ASCII_ENCODING));
|
||||
String text = FileUtil.loadFile(remotesFile, US_ASCII_ENCODING);
|
||||
@NonNls String pullPrefix = "Pull:";
|
||||
for (StringScanner s = new StringScanner(text); s.hasMoreData();) {
|
||||
String line = s.line();
|
||||
|
||||
@@ -198,7 +198,7 @@ public class GitPushRebaseProcess extends GitBaseRebaseProcess {
|
||||
}
|
||||
try {
|
||||
TreeMap<String, String> pickLines = new TreeMap<String, String>();
|
||||
StringScanner s = new StringScanner(new String(FileUtil.loadFileText(new File(path), GitUtil.UTF8_ENCODING)));
|
||||
StringScanner s = new StringScanner(FileUtil.loadFile(new File(path), GitUtil.UTF8_ENCODING));
|
||||
while (s.hasMoreData()) {
|
||||
if (!s.tryConsume("pick ")) {
|
||||
s.line();
|
||||
|
||||
@@ -476,7 +476,7 @@ public class GitSwitchBranchesDialog extends DialogWrapper {
|
||||
String newRef;
|
||||
try {
|
||||
final String refText =
|
||||
new String(FileUtil.loadFileText(new File(rootPath, ".git/refs/" + value), GitUtil.UTF8_ENCODING)).trim();
|
||||
FileUtil.loadFile(new File(rootPath, ".git/refs/" + value), GitUtil.UTF8_ENCODING).trim();
|
||||
String refsPrefix = "ref: refs/";
|
||||
if (refText.endsWith("/HEAD") || !refText.startsWith(refsPrefix)) {
|
||||
newRef = null;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class MergeChangeCollector {
|
||||
File mergeHeadsFile = new File(root, ".git/MERGE_HEAD");
|
||||
try {
|
||||
if (mergeHeadsFile.exists()) {
|
||||
String mergeHeads = new String(FileUtil.loadFileText(mergeHeadsFile, GitUtil.UTF8_ENCODING));
|
||||
String mergeHeads = FileUtil.loadFile(mergeHeadsFile, GitUtil.UTF8_ENCODING);
|
||||
for (StringScanner s = new StringScanner(mergeHeads); s.hasMoreData();) {
|
||||
String head = s.line();
|
||||
if (head.length() == 0) {
|
||||
|
||||
@@ -338,7 +338,7 @@ public class GitRebaseEditor extends DialogWrapper {
|
||||
*/
|
||||
public void load(final String file) throws IOException {
|
||||
String encoding = GitConfigUtil.getLogEncoding(myProject, myGitRoot);
|
||||
final StringScanner s = new StringScanner(new String(FileUtil.loadFileText(new File(file), encoding)));
|
||||
final StringScanner s = new StringScanner(FileUtil.loadFile(new File(file), encoding));
|
||||
while (s.hasMoreData()) {
|
||||
if (s.isEol() || s.startsWith('#') || s.startsWith("noop")) {
|
||||
s.nextLine();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class GitRebaseUnstructuredEditor extends DialogWrapper {
|
||||
myGitRootLabel.setText(root.getPresentableUrl());
|
||||
encoding = GitConfigUtil.getCommitEncoding(project, root);
|
||||
myFile = new File(path);
|
||||
myTextArea.setText(new String(FileUtil.loadFileText(myFile, encoding)));
|
||||
myTextArea.setText(FileUtil.loadFile(myFile, encoding));
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class GitRebaseUtils {
|
||||
File nextFile = new File(rebaseDir, "next");
|
||||
int next;
|
||||
try {
|
||||
next = Integer.parseInt(new String(FileUtil.loadFileText(nextFile, GitUtil.UTF8_ENCODING)).trim());
|
||||
next = Integer.parseInt(FileUtil.loadFile(nextFile, GitUtil.UTF8_ENCODING).trim());
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
@@ -72,6 +87,7 @@ public class GithubCheckoutProvider implements CheckoutProvider {
|
||||
if (!writeAccessAllowed){
|
||||
Messages.showErrorDialog(project, "It seems that you have only read access to the selected repository.\n" +
|
||||
"GitHub supports only https protocol for readonly access, which is not supported yet.\n" +
|
||||
"As a workaround, please fork it and clone your forked repository instead.\n" +
|
||||
"More details are available here: http://youtrack.jetbrains.net/issue/IDEA-55298", "Cannot clone this repository");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafeException;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.util.PasswordUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -24,13 +41,14 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
|
||||
private static final String GITHUB_SETTINGS_TAG = "GithubSettings";
|
||||
private static final String LOGIN = "Login";
|
||||
private static final String PASSWORD = "Password";
|
||||
private static final String HOST = "Host";
|
||||
private static final String GITHUB = "github.com";
|
||||
private static final String GITHUB_SETTINGS_PASSWORD_KEY = "GITHUB_SETTINGS_PASSWORD_KEY";
|
||||
|
||||
private String myLogin;
|
||||
private String myPassword;
|
||||
private String myHost;
|
||||
private static final Logger LOG = Logger.getInstance(GithubSettings.class.getName());
|
||||
|
||||
public static GithubSettings getInstance(){
|
||||
return ServiceManager.getService(GithubSettings.class);
|
||||
@@ -40,31 +58,23 @@ public class GithubSettings implements PersistentStateComponent<Element> {
|
||||
if (StringUtil.isEmptyOrSpaces(myLogin) && StringUtil.isEmptyOrSpaces(myPassword) && StringUtil.isEmptyOrSpaces(myHost)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, myPassword);
|
||||
}
|
||||
catch (PasswordSafeException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
final Element element = new Element(GITHUB_SETTINGS_TAG);
|
||||
element.setAttribute(LOGIN, getLogin());
|
||||
element.setAttribute(PASSWORD, getEncodedPassword());
|
||||
element.setAttribute(HOST, getHost());
|
||||
return element;
|
||||
}
|
||||
|
||||
public String getEncodedPassword() {
|
||||
return PasswordUtil.encodePassword(getPassword());
|
||||
}
|
||||
|
||||
public void setEncodedPassword(final String password) {
|
||||
try {
|
||||
setPassword(PasswordUtil.decodePassword(password));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
public void loadState(@NotNull final Element element) {
|
||||
try {
|
||||
setLogin(element.getAttributeValue(LOGIN));
|
||||
setEncodedPassword(element.getAttributeValue(PASSWORD));
|
||||
setHost(element.getAttributeValue(HOST));
|
||||
setPassword(PasswordSafe.getInstance().getPassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.github;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -141,6 +156,10 @@ public class GithubUtil {
|
||||
|
||||
public static boolean isPushableRepo(final String url, final String login, final String password, final RepositoryInfo repositoryInfo) {
|
||||
try {
|
||||
// Github API doesn't list your own repos among pushable repos. Fail!
|
||||
if (login.equals(repositoryInfo.getOwner())){
|
||||
return true;
|
||||
}
|
||||
final HttpMethod method = doREST(url, login, password, "/repos/pushable", false);
|
||||
final InputStream stream = method.getResponseBodyAsStream();
|
||||
final Element element = new SAXBuilder(false).build(stream).getRootElement();
|
||||
|
||||
+7
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.extensions;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
@@ -48,6 +49,12 @@ public abstract class GroovyNamedArgumentProvider {
|
||||
return namedArguments;
|
||||
}
|
||||
|
||||
public static final StringTypeCondition TYPE_STRING = new StringTypeCondition(CommonClassNames.JAVA_LANG_STRING);
|
||||
public static final StringTypeCondition TYPE_MAP = new StringTypeCondition(CommonClassNames.JAVA_UTIL_MAP);
|
||||
public static final StringTypeCondition TYPE_BOOL = new StringTypeCondition(CommonClassNames.JAVA_LANG_BOOLEAN);
|
||||
public static final StringTypeCondition TYPE_INTEGER = new StringTypeCondition(CommonClassNames.JAVA_LANG_INTEGER);
|
||||
public static final Condition<PsiType> TYPE_ANY = Condition.TRUE;
|
||||
|
||||
protected static class StringTypeCondition implements Condition<PsiType> {
|
||||
private final String myTypeName;
|
||||
|
||||
|
||||
+1
-2
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.lang;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider;
|
||||
@@ -35,7 +34,7 @@ public class GroovySourceCodeNamedArgumentProvider extends GroovyNamedArgumentPr
|
||||
public void getNamedArguments(@Nullable GrCall call, @NotNull PsiMethod method, Map<String, Condition<PsiType>> result) {
|
||||
if (method instanceof GrMethod) {
|
||||
for (String parameter : ((GrMethod)method).getNamedParametersArray()) {
|
||||
result.put(parameter, Condition.TRUE);
|
||||
result.put(parameter, TYPE_ANY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class TestUtils {
|
||||
public static List<String> readInput(String filePath) {
|
||||
String content;
|
||||
try {
|
||||
content = new String(FileUtil.loadFileText(new File(filePath)));
|
||||
content = FileUtil.loadFile(new File(filePath));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -310,8 +310,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
|
||||
myAuthenticationManager.addListener(savedOnceListener);
|
||||
|
||||
final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
|
||||
final char[] chars = FileUtil.loadFileText(config);
|
||||
final String contents = String.valueOf(chars);
|
||||
final String contents = FileUtil.loadFile(config);
|
||||
final String auth = "[auth]";
|
||||
final int idx = contents.indexOf(auth);
|
||||
Assert.assertTrue(idx != -1);
|
||||
@@ -439,8 +438,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
|
||||
myAuthenticationManager.addListener(savedOnceListener);
|
||||
|
||||
final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
|
||||
final char[] chars = FileUtil.loadFileText(config);
|
||||
final String contents = String.valueOf(chars);
|
||||
final String contents = FileUtil.loadFile(config);
|
||||
final String auth = "[auth]";
|
||||
final int idx = contents.indexOf(auth);
|
||||
Assert.assertTrue(idx != -1);
|
||||
@@ -572,8 +570,7 @@ public class SvnAuthenticationTest extends PlatformTestCase {
|
||||
myAuthenticationManager.addListener(savedOnceListener);
|
||||
|
||||
final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
|
||||
final char[] chars = FileUtil.loadFileText(servers);
|
||||
final String contents = String.valueOf(chars);
|
||||
final String contents = FileUtil.loadFile(servers);
|
||||
final String groups = "[groups]";
|
||||
final int idx = contents.indexOf(groups);
|
||||
Assert.assertTrue(idx != -1);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class AsmCodeGeneratorTest extends TestCase {
|
||||
}
|
||||
|
||||
private LwRootContainer loadFormData(final String formPath) throws Exception {
|
||||
String formData = new String(FileUtil.loadFileText(new File(formPath)));
|
||||
String formData = FileUtil.loadFile(new File(formPath));
|
||||
final CompiledClassPropertiesProvider provider = new CompiledClassPropertiesProvider(getClass().getClassLoader());
|
||||
return Utils.getRootContainer(formData, provider);
|
||||
}
|
||||
|
||||
-1
@@ -28,6 +28,5 @@ public class WebEditorAppearanceConfigurable extends BeanConfigurable<WebEditorO
|
||||
checkBox("breadcrumbsEnabled", XmlBundle.message("xml.editor.options.breadcrumbs.title"));
|
||||
checkBox("breadcrumbsEnabledInXml", XmlBundle.message("xml.editor.options.breadcrumbs.for.xml.title"));
|
||||
checkBox("showCssColorPreviewInGutter", "Show CSS Color preview icon in gutter");
|
||||
checkBox("tagTreeHighlightingEnabled", "Enable HTML tag tree highlighting");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
package com.intellij.application.options.editor;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.xml.XmlBundle;
|
||||
@@ -47,12 +49,18 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
|
||||
private boolean myAutomaticallyStartAttribute = true;
|
||||
private boolean myZenCodingEnabled = true;
|
||||
private int myZenCodingExpandShortcut = TemplateSettings.TAB_CHAR;
|
||||
|
||||
private boolean myTagTreeHighlightingEnabled = true;
|
||||
private int myTagTreeHighlightingLevelCount = 6;
|
||||
|
||||
public static WebEditorOptions getInstance() {
|
||||
return ServiceManager.getService(WebEditorOptions.class);
|
||||
}
|
||||
|
||||
public WebEditorOptions() {
|
||||
setTagTreeHighlightingEnabled(!ApplicationManager.getApplication().isUnitTestMode());
|
||||
}
|
||||
|
||||
public void setBreadcrumbsEnabled(boolean b) {
|
||||
myBreadcrumbsEnabled = b;
|
||||
}
|
||||
@@ -125,6 +133,14 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
|
||||
myAutomaticallyInsertRequiredSubTags = automaticallyInsertRequiredSubTags;
|
||||
}
|
||||
|
||||
public void setTagTreeHighlightingLevelCount(int tagTreeHighlightingLevelCount) {
|
||||
myTagTreeHighlightingLevelCount = tagTreeHighlightingLevelCount;
|
||||
}
|
||||
|
||||
public int getTagTreeHighlightingLevelCount() {
|
||||
return myTagTreeHighlightingLevelCount;
|
||||
}
|
||||
|
||||
public void setTagTreeHighlightingEnabled(boolean tagTreeHighlightingEnabled) {
|
||||
myTagTreeHighlightingEnabled = tagTreeHighlightingEnabled;
|
||||
}
|
||||
|
||||
+19
-8
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.tagTreeHighlighting;
|
||||
|
||||
import com.intellij.application.options.editor.WebEditorOptions;
|
||||
import com.intellij.openapi.editor.colors.ColorKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -23,16 +25,25 @@ import java.awt.*;
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class HtmlTagTreeHighlightingColors {
|
||||
public static final ColorKey[] COLOR_KEYS = new ColorKey[20];
|
||||
private static ColorKey[] ourColorKeys = null;
|
||||
|
||||
static {
|
||||
final Color[] baseColors = new Color[]{Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA};
|
||||
|
||||
for (int i = 0; i < COLOR_KEYS.length; i++) {
|
||||
COLOR_KEYS[i] = ColorKey.createColorKey("HTML_TAG_TREE_LEVEL" + i, baseColors[i % baseColors.length]);
|
||||
}
|
||||
}
|
||||
private static final Color[] DEFAULT_COLORS = new Color[]{Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA};
|
||||
|
||||
private HtmlTagTreeHighlightingColors() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ColorKey[] getColorKeys() {
|
||||
final int levelCount = WebEditorOptions.getInstance().getTagTreeHighlightingLevelCount();
|
||||
|
||||
if (ourColorKeys == null || ourColorKeys.length != levelCount) {
|
||||
ourColorKeys = new ColorKey[levelCount];
|
||||
|
||||
for (int i = 0; i < ourColorKeys.length; i++) {
|
||||
ourColorKeys[i] = ColorKey.createColorKey("HTML_TAG_TREE_LEVEL" + i, DEFAULT_COLORS[i % DEFAULT_COLORS.length]);
|
||||
}
|
||||
}
|
||||
|
||||
return ourColorKeys;
|
||||
}
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.HtmlTagTreeHighlightingConfigurable">
|
||||
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="422" height="55"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b5068" class="javax.swing.JCheckBox" binding="myEnableTagTreeHighlightingCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Enable HTML tag tree highlighting"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="30544" binding="myLevelsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="84b2a" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Levels to highlight:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f41b2" class="javax.swing.JSpinner" binding="myLevelsSpinner">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
<maximum-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<hspacer id="dd839">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.codeInsight.daemon.impl.tagTreeHighlighting;
|
||||
|
||||
import com.intellij.application.options.editor.WebEditorOptions;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class HtmlTagTreeHighlightingConfigurable implements UnnamedConfigurable {
|
||||
private JCheckBox myEnableTagTreeHighlightingCheckBox;
|
||||
private JSpinner myLevelsSpinner;
|
||||
private JPanel myLevelsPanel;
|
||||
private JPanel myContentPanel;
|
||||
|
||||
public HtmlTagTreeHighlightingConfigurable() {
|
||||
myLevelsSpinner.setModel(new SpinnerNumberModel(1, 1, 50, 1));
|
||||
|
||||
myEnableTagTreeHighlightingCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final boolean enabled = myEnableTagTreeHighlightingCheckBox.isSelected();
|
||||
UIUtil.setEnabled(myLevelsPanel, enabled, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myContentPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
final WebEditorOptions options = WebEditorOptions.getInstance();
|
||||
|
||||
if (myEnableTagTreeHighlightingCheckBox.isSelected() != options.isTagTreeHighlightingEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getLevelCount() != options.getTagTreeHighlightingLevelCount()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
final WebEditorOptions options = WebEditorOptions.getInstance();
|
||||
|
||||
options.setTagTreeHighlightingEnabled(myEnableTagTreeHighlightingCheckBox.isSelected());
|
||||
options.setTagTreeHighlightingLevelCount(getLevelCount());
|
||||
|
||||
clearTagTreeHighlighting();
|
||||
}
|
||||
|
||||
private int getLevelCount() {
|
||||
return ((Integer)myLevelsSpinner.getValue()).intValue();
|
||||
}
|
||||
|
||||
private static void clearTagTreeHighlighting() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
final Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
HtmlTagTreeHighlightingPass.clearHighlightingAndLineMarkers(editor, project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
final WebEditorOptions options = WebEditorOptions.getInstance();
|
||||
final boolean enabled = options.isTagTreeHighlightingEnabled();
|
||||
|
||||
myEnableTagTreeHighlightingCheckBox.setSelected(enabled);
|
||||
myLevelsSpinner.setValue(options.getTagTreeHighlightingLevelCount());
|
||||
UIUtil.setEnabled(myLevelsPanel, enabled, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
}
|
||||
+112
-15
@@ -31,8 +31,11 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
@@ -52,6 +55,8 @@ import java.util.List;
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
private static final Key<List<RangeHighlighter>> TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY = Key.create("TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY");
|
||||
|
||||
private static final HighlightInfoType TYPE = new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, TextAttributesKey
|
||||
.createTextAttributesKey("TAG_TREE_HIGHLIGHTING_KEY"));
|
||||
|
||||
@@ -154,24 +159,28 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
public List<HighlightInfo> getHighlights() {
|
||||
clearLineMarkers(myEditor);
|
||||
|
||||
final int count = myPairsToHighlight.size();
|
||||
final List<HighlightInfo> highlightInfos = new ArrayList<HighlightInfo>(count * 2);
|
||||
final MarkupModel markupModel = myEditor.getMarkupModel();
|
||||
|
||||
final Color[] colors = getColors();
|
||||
final Color[] baseColors = getBaseColors();
|
||||
final Color[] colorsForEditor = toColorsForEditor(baseColors);
|
||||
final Color[] colorsForLineMarkers = toColorsForLineMarkers(baseColors);
|
||||
|
||||
assert colors.length > 0;
|
||||
final List<RangeHighlighter> newHighlighters = new ArrayList<RangeHighlighter>();
|
||||
|
||||
int colorIndex = 0;
|
||||
assert colorsForEditor.length > 0;
|
||||
|
||||
for (int i = 0, n = myPairsToHighlight.size(); i < n && i < baseColors.length; i++) {
|
||||
Pair<TextRange, TextRange> pair = myPairsToHighlight.get(i);
|
||||
|
||||
for (Pair<TextRange, TextRange> pair : myPairsToHighlight) {
|
||||
if (pair == null || (pair.first == null && pair.second == null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (colorIndex >= colors.length) {
|
||||
colorIndex = 0;
|
||||
}
|
||||
Color color = colors[colorIndex];
|
||||
Color color = colorsForEditor[i];
|
||||
|
||||
if (pair.first != null) {
|
||||
highlightInfos.add(createHighlightInfo(color, pair.first));
|
||||
@@ -181,30 +190,100 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
highlightInfos.add(createHighlightInfo(color, pair.second));
|
||||
}
|
||||
|
||||
colorIndex++;
|
||||
final int start = pair.first != null ? pair.first.getStartOffset() : pair.second.getStartOffset();
|
||||
final int end = pair.second != null ? pair.second.getEndOffset() : pair.first.getEndOffset();
|
||||
|
||||
final RangeHighlighter highlighter = createHighlighter(markupModel, new TextRange(start, end), colorsForLineMarkers[i]);
|
||||
newHighlighters.add(highlighter);
|
||||
}
|
||||
|
||||
myEditor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, newHighlighters);
|
||||
|
||||
return highlightInfos;
|
||||
}
|
||||
|
||||
private static void clearLineMarkers(Editor editor) {
|
||||
final List<RangeHighlighter> oldHighlighters = editor.getUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY);
|
||||
|
||||
if (oldHighlighters != null) {
|
||||
final MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
|
||||
|
||||
for (RangeHighlighter highlighter : oldHighlighters) {
|
||||
if (markupModel.containsHighlighter(highlighter)) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
editor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, null);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static HighlightInfo createHighlightInfo(Color color, @NotNull TextRange range) {
|
||||
return new HighlightInfo(new TextAttributes(null, color, null, null, Font.PLAIN), TYPE, range.getStartOffset(),
|
||||
range.getEndOffset(), null, null, HighlightSeverity.INFORMATION, false, null, false);
|
||||
}
|
||||
|
||||
private Color[] getColors() {
|
||||
final ColorKey[] colorKeys = HtmlTagTreeHighlightingColors.COLOR_KEYS;
|
||||
@NotNull
|
||||
private static RangeHighlighter createHighlighter(final MarkupModel mm, final @NotNull TextRange range, final Color color) {
|
||||
final RangeHighlighter highlighter =
|
||||
mm.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), 0, null, HighlighterTargetArea.LINES_IN_RANGE);
|
||||
|
||||
highlighter.setLineMarkerRenderer(new LineMarkerRenderer() {
|
||||
public void paint(Editor editor, Graphics g, Rectangle r) {
|
||||
int height = r.height + editor.getLineHeight();
|
||||
g.setColor(color);
|
||||
g.fillRect(r.x, r.y, 2, height);
|
||||
}
|
||||
});
|
||||
return highlighter;
|
||||
}
|
||||
|
||||
|
||||
private static Color[] getBaseColors() {
|
||||
final ColorKey[] colorKeys = HtmlTagTreeHighlightingColors.getColorKeys();
|
||||
final Color[] colors = new Color[colorKeys.length];
|
||||
|
||||
final EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
colors[i] = colorsScheme.getColor(colorKeys[i]);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
private static Color[] toColorsForLineMarkers(Color[] baseColors) {
|
||||
final Color[] colors = new Color[baseColors.length];
|
||||
final Color tagBackground = new Color(239, 239, 239);
|
||||
final double transparency = 0.4;
|
||||
final double factor = 0.8;
|
||||
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
final Color color = baseColors[i];
|
||||
|
||||
int r = (int)(color.getRed() * factor);
|
||||
int g = (int)(color.getGreen() * factor);
|
||||
int b = (int)(color.getBlue() * factor);
|
||||
|
||||
r = (int)(tagBackground.getRed() * (1 - transparency) + r * transparency);
|
||||
g = (int)(tagBackground.getGreen() * (1 - transparency) + g * transparency);
|
||||
b = (int)(tagBackground.getBlue() * (1 - transparency) + b * transparency);
|
||||
|
||||
colors[i] = new Color(r, g, b);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
private Color[] toColorsForEditor(Color[] baseColors) {
|
||||
final Color[] colors = new Color[baseColors.length];
|
||||
final Color tagBackground = myEditor instanceof EditorEx ? ((EditorEx)myEditor).getBackgroundColor() : null;
|
||||
|
||||
// todo: make configurable
|
||||
final double transparency = 0.1;
|
||||
|
||||
final EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
Color color = colorsScheme.getColor(colorKeys[i]);
|
||||
final Color color = baseColors[i];
|
||||
|
||||
if (tagBackground == null) {
|
||||
colors[i] = color;
|
||||
@@ -220,4 +299,22 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
public static void clearHighlightingAndLineMarkers(final Editor editor, @NotNull Project project) {
|
||||
final MarkupModel markupModel = editor.getDocument().getMarkupModel(project);
|
||||
|
||||
for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
|
||||
Object tooltip = highlighter.getErrorStripeTooltip();
|
||||
|
||||
if (!(tooltip instanceof HighlightInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((HighlightInfo)tooltip).type == TYPE) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
clearLineMarkers(editor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -29,32 +30,51 @@ import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlUnwrapDescriptor implements UnwrapDescriptor {
|
||||
public List<Pair<PsiElement, Unwrapper>> collectUnwrappers(Project project, Editor editor, PsiFile file) {
|
||||
List<Pair<PsiElement, Unwrapper>> result = new ArrayList<Pair<PsiElement, Unwrapper>>();
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
PsiElement e1 = file.findElementAt(offset);
|
||||
if (e1 != null) {
|
||||
Language language = e1.getParent().getLanguage();
|
||||
if (language != file.getLanguage()) {
|
||||
UnwrapDescriptor unwrapDescriptor = LanguageUnwrappers.INSTANCE.forLanguage(language);
|
||||
if (unwrapDescriptor != null && !(unwrapDescriptor instanceof XmlUnwrapDescriptor)) {
|
||||
result.addAll(unwrapDescriptor.collectUnwrappers(project, editor, file));
|
||||
return unwrapDescriptor.collectUnwrappers(project, editor, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PsiElement tag = PsiTreeUtil.getParentOfType(e1, XmlTag.class);
|
||||
while (tag != null) {
|
||||
if (XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()) != null) { // Exclude implicit tags suck as 'jsp:root'
|
||||
result.add(new Pair<PsiElement, Unwrapper>(tag, new XmlEnclosingTagUnwrapper()));
|
||||
List<Pair<PsiElement, Unwrapper>> result = new ArrayList<Pair<PsiElement, Unwrapper>>();
|
||||
|
||||
FileViewProvider viewProvider = file.getViewProvider();
|
||||
|
||||
for (Language language : viewProvider.getLanguages()) {
|
||||
UnwrapDescriptor unwrapDescriptor = LanguageUnwrappers.INSTANCE.forLanguage(language);
|
||||
if (unwrapDescriptor instanceof XmlUnwrapDescriptor) {
|
||||
PsiElement e = viewProvider.findElementAt(offset, language);
|
||||
|
||||
PsiElement tag = PsiTreeUtil.getParentOfType(e, XmlTag.class);
|
||||
while (tag != null) {
|
||||
if (XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()) != null) { // Exclude implicit tags suck as 'jsp:root'
|
||||
result.add(new Pair<PsiElement, Unwrapper>(tag, new XmlEnclosingTagUnwrapper()));
|
||||
}
|
||||
tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class);
|
||||
}
|
||||
}
|
||||
tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class);
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<Pair<PsiElement, Unwrapper>>() {
|
||||
@Override
|
||||
public int compare(Pair<PsiElement, Unwrapper> o1, Pair<PsiElement, Unwrapper> o2) {
|
||||
return o2.first.getTextOffset() - o1.first.getTextOffset();
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.HtmlTagTreeHighl
|
||||
import com.intellij.ide.highlighter.HtmlFileHighlighter;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.editor.XmlHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.ColorKey;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
@@ -42,19 +43,6 @@ public class HTMLColorsPage implements ColorSettingsPage {
|
||||
};
|
||||
private static final String FULL_PRODUCT_NAME = ApplicationNamesInfo.getInstance().getFullProductName();
|
||||
|
||||
private static final ColorDescriptor[] COLOR_DESCRIPTORS;
|
||||
|
||||
static {
|
||||
COLOR_DESCRIPTORS = new ColorDescriptor[HtmlTagTreeHighlightingColors.COLOR_KEYS.length];
|
||||
|
||||
for (int i = 0; i < COLOR_DESCRIPTORS.length; i++) {
|
||||
COLOR_DESCRIPTORS[i] = new ColorDescriptor(OptionsBundle.message("options.html.attribute.descriptor.tag.tree", i + 1),
|
||||
HtmlTagTreeHighlightingColors.COLOR_KEYS[i], ColorDescriptor.Kind.BACKGROUND);
|
||||
}
|
||||
|
||||
// todo: make preview for it
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return OptionsBundle.message("options.html.display.name");
|
||||
@@ -71,7 +59,17 @@ public class HTMLColorsPage implements ColorSettingsPage {
|
||||
|
||||
@NotNull
|
||||
public ColorDescriptor[] getColorDescriptors() {
|
||||
return COLOR_DESCRIPTORS;
|
||||
// todo: make preview for it
|
||||
|
||||
final ColorKey[] colorKeys = HtmlTagTreeHighlightingColors.getColorKeys();
|
||||
final ColorDescriptor[] colorDescriptors = new ColorDescriptor[colorKeys.length];
|
||||
|
||||
for (int i = 0; i < colorDescriptors.length; i++) {
|
||||
colorDescriptors[i] = new ColorDescriptor(OptionsBundle.message("options.html.attribute.descriptor.tag.tree", i + 1),
|
||||
colorKeys[i], ColorDescriptor.Kind.BACKGROUND);
|
||||
}
|
||||
|
||||
return colorDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -471,4 +471,52 @@
|
||||
type = "string"
|
||||
default = "true"
|
||||
/>
|
||||
<tag name = "bdi"
|
||||
helpref = "text-level-semantics.html#the-bdi-element"
|
||||
description = "represents a span of text that is to be isolated from its surroundings for the purposes of bidirectional text formatting"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "false"
|
||||
dtd = ""
|
||||
/>
|
||||
<tag name = "details"
|
||||
helpref = "interactive-elements.html#the-details-element"
|
||||
description = "represents a disclosure widget from which the user can obtain additional information or controls"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "false"
|
||||
dtd = ""
|
||||
/>
|
||||
<tag name = "source"
|
||||
helpref = "video.html#the-source-element"
|
||||
description = "allows authors to specify multiple alternative media resources for media elements. It does not represent anything on its own"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "true"
|
||||
dtd = ""
|
||||
/>
|
||||
<tag name = "summary"
|
||||
helpref = "interactive-elements.html#the-summary-element"
|
||||
description = "represents a summary, caption, or legend for the rest of the contents of the summary element's parent details element, if any"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "false"
|
||||
dtd = ""
|
||||
/>
|
||||
<tag name = "track"
|
||||
helpref = "video.html#the-track-element"
|
||||
description = "allows authors to specify explicit external timed text tracks for media elements. It does not represent anything on its own"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "true"
|
||||
dtd = ""
|
||||
/>
|
||||
<tag name = "wbr"
|
||||
helpref = "text-level-semantics.html#the-wbr-element"
|
||||
description = "represents a line break opportunity"
|
||||
startTag = "true"
|
||||
endTag = "true"
|
||||
empty = "true"
|
||||
dtd = ""
|
||||
/>
|
||||
</html-property-table>
|
||||
Reference in New Issue
Block a user