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:
@@ -306,7 +306,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
@Nullable
|
||||
@TestOnly
|
||||
public static String getInfo(PsiElement element, PsiElement atPointer) {
|
||||
return generateInfo(element, atPointer).text;
|
||||
return generateInfo(element, atPointer, true).text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -321,22 +321,17 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DocInfo generateInfo(PsiElement element, PsiElement atPointer) {
|
||||
private static DocInfo generateInfo(PsiElement element, PsiElement atPointer, boolean fallbackToBasicInfo) {
|
||||
final DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(element, atPointer);
|
||||
String result = doGenerateInfo(element, atPointer, documentationProvider);
|
||||
String result = documentationProvider.getQuickNavigateInfo(element, atPointer);
|
||||
if (result == null && fallbackToBasicInfo) {
|
||||
result = doGenerateInfo(element);
|
||||
}
|
||||
return result == null ? DocInfo.EMPTY : new DocInfo(result, documentationProvider, element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String doGenerateInfo(@NotNull PsiElement element,
|
||||
@NotNull PsiElement atPointer,
|
||||
@NotNull DocumentationProvider documentationProvider)
|
||||
{
|
||||
String info = documentationProvider.getQuickNavigateInfo(element, atPointer);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
|
||||
private static String doGenerateInfo(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiFile) {
|
||||
final VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
@@ -344,7 +339,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
info = getQuickNavigateInfo(element);
|
||||
String info = getQuickNavigateInfo(element);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
@@ -454,7 +449,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
@Override
|
||||
public DocInfo compute() {
|
||||
try {
|
||||
return generateInfo(myTargetElement, myElementAtPointer);
|
||||
return generateInfo(myTargetElement, myElementAtPointer, isNavigatable());
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
showDumbModeNotification(myTargetElement.getProject());
|
||||
@@ -893,7 +888,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if (!info.isValid(myEditor.getDocument())) {
|
||||
if (!info.isValid(myEditor.getDocument()) || !info.isNavigatable() && docInfo.text == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -61,6 +61,6 @@ public class JavaFxRedundantPropertyValueInspectionTest extends AbstractJavaFXQu
|
||||
if (getTestName(false).endsWith("Attribute")) {
|
||||
return "Remove attribute " + tagName;
|
||||
}
|
||||
return "Remove tag '" + tagName + "'";
|
||||
return "Remove tag " + tagName;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.inspections;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.RemoveAttributeIntentionFix;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.RemoveTagIntentionFix;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.XmlSuppressableInspectionTool;
|
||||
@@ -83,7 +84,7 @@ public class JavaFxRedundantPropertyValueInspection extends XmlSuppressableInspe
|
||||
return;
|
||||
}
|
||||
if (tag.getSubTags().length != 0) return;
|
||||
final String tagText = tag.getValue().getText().trim();
|
||||
final String tagText = tag.getValue().getTrimmedText();
|
||||
if (tagText.startsWith("$") ||
|
||||
tagText.startsWith("#") ||
|
||||
tagText.startsWith("%")) {
|
||||
@@ -97,7 +98,7 @@ public class JavaFxRedundantPropertyValueInspection extends XmlSuppressableInspe
|
||||
if (isEqualValue(tagClass, tagText, defaultValue, descriptor.getDeclaration())) {
|
||||
holder.registerProblem(tag, "Tag is redundant because it contains default value",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new RemoveTagFix(tag.getName()));
|
||||
new RemoveTagIntentionFix(tag.getName(), tag));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.inspections;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class RemoveTagFix implements LocalQuickFix {
|
||||
private static final Logger LOG = Logger.getInstance("#" + RemoveTagFix.class.getName());
|
||||
|
||||
private final String myTagName;
|
||||
|
||||
public RemoveTagFix(String name) {
|
||||
myTagName = name;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Remove tag '" + myTagName + "'";
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove tag";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
if (element != null) {
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
LOG.assertTrue(containingFile != null && JavaFxFileTypeFactory.isFxml(containingFile),
|
||||
containingFile == null ? "no containing file found" : "containing file: " + containingFile.getName());
|
||||
final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
|
||||
if (xmlTag != null) {
|
||||
final XmlTag parentTag = xmlTag.getParentTag();
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
|
||||
xmlTag.delete();
|
||||
if (parentTag != null) {
|
||||
CodeStyleManager.getInstance(project).reformat(parentTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
minHeight="-Infinity"
|
||||
prefHeight="400.0"
|
||||
prefWidth="600.0">
|
||||
<alignm<caret>ent>TOP_LEFT</alignment>
|
||||
<Label text="Hi">
|
||||
<alignment>TOP_LEFT</alignment>
|
||||
</Label>
|
||||
<alignm<caret>ent>TOP_LEFT</alignment>
|
||||
<Label text="Hi">
|
||||
<alignment>TOP_LEFT</alignment>
|
||||
</Label>
|
||||
</GridPane>
|
||||
@@ -3,10 +3,10 @@
|
||||
<hgap>1</hgap>
|
||||
<vgap>0</vgap>
|
||||
<minWidth>
|
||||
100
|
||||
100
|
||||
</minWidth>
|
||||
<minHeight>
|
||||
-1
|
||||
-1
|
||||
</minHeight>
|
||||
<maxWidth>500</maxWidth>
|
||||
<maxHe<caret>ight>-1</maxHeight>
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.analysis;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.XmlErrorMessages;
|
||||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class RemoveTagIntentionFix extends LocalQuickFixAndIntentionActionOnPsiElement {
|
||||
private final String myTagName;
|
||||
|
||||
public RemoveTagIntentionFix(final String name, @NotNull final XmlTag tag) {
|
||||
super(tag);
|
||||
myTagName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return XmlErrorMessages.message("remove.tag.quickfix.text", myTagName);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return XmlErrorMessages.message("remove.tag.quickfix.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project,
|
||||
@NotNull PsiFile file,
|
||||
@Nullable("is null when called from inspection") Editor editor,
|
||||
@NotNull PsiElement startElement,
|
||||
@NotNull PsiElement endElement) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
|
||||
final XmlTag next = editor != null ? PsiTreeUtil.getNextSiblingOfType(startElement, XmlTag.class) : null;
|
||||
final XmlTag prev = editor != null ? PsiTreeUtil.getPrevSiblingOfType(startElement, XmlTag.class) : null;
|
||||
|
||||
startElement.delete();
|
||||
|
||||
if (editor != null) {
|
||||
if (next != null) {
|
||||
editor.getCaretModel().moveToOffset(next.getTextRange().getStartOffset());
|
||||
}
|
||||
else if (prev != null) {
|
||||
editor.getCaretModel().moveToOffset(prev.getTextRange().getEndOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ insert.required.attribute.quickfix.text=Insert required attribute {0}
|
||||
insert.required.attribute.quickfix.family=Insert required attribute
|
||||
remove.attribute.quickfix.text=Remove attribute {0}
|
||||
remove.attribute.quickfix.family=Remove attribute
|
||||
remove.tag.quickfix.text=Remove tag {0}
|
||||
remove.tag.quickfix.family=Remove tag
|
||||
add.attribute.value.quickfix.text=Add attribute value
|
||||
remove.extra.closing.tag.quickfix=Remove extra closing tag
|
||||
create.namespace.declaration.quickfix=Create {0} declaration
|
||||
|
||||
Reference in New Issue
Block a user