mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Inspections
This commit is contained in:
+2
-2
@@ -16,7 +16,7 @@
|
||||
package com.intellij.android.designer;
|
||||
|
||||
import com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel;
|
||||
import com.intellij.android.designer.inspection.AndroidBackgroundEditorHighlighter;
|
||||
import com.intellij.designer.inspection.DesignerBackgroundEditorHighlighter;
|
||||
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
|
||||
import com.intellij.designer.DesignerEditor;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
@@ -50,7 +50,7 @@ public final class AndroidDesignerEditor extends DesignerEditor {
|
||||
@Override
|
||||
public BackgroundEditorHighlighter getBackgroundHighlighter() {
|
||||
if (myHighlighter == null) {
|
||||
myHighlighter = new AndroidBackgroundEditorHighlighter((AndroidDesignerEditorPanel)getDesignerPanel());
|
||||
myHighlighter = new DesignerBackgroundEditorHighlighter(getDesignerPanel());
|
||||
}
|
||||
return myHighlighter;
|
||||
}
|
||||
|
||||
+22
-19
@@ -20,7 +20,11 @@ import com.android.ide.common.resources.configuration.*;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.intellij.android.designer.actions.ProfileAction;
|
||||
import com.intellij.android.designer.componentTree.AndroidTreeDecorator;
|
||||
import com.intellij.android.designer.model.*;
|
||||
import com.intellij.android.designer.inspection.ErrorAnalyzer;
|
||||
import com.intellij.android.designer.model.IConfigurableComponent;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.PropertyParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.profile.ProfileManager;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
@@ -36,6 +40,7 @@ import com.intellij.designer.palette.Item;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -45,9 +50,6 @@ import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintExternalAnnotator;
|
||||
import org.jetbrains.android.inspections.lint.ProblemData;
|
||||
import org.jetbrains.android.inspections.lint.State;
|
||||
import org.jetbrains.android.maven.AndroidMavenUtil;
|
||||
import org.jetbrains.android.sdk.AndroidPlatform;
|
||||
import org.jetbrains.android.sdk.AndroidSdkUtils;
|
||||
@@ -115,21 +117,6 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public void loadInspections() {
|
||||
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
|
||||
State state = annotator.collectionInformation(myXmlFile);
|
||||
if (state == null) {
|
||||
System.out.println("No inspections");
|
||||
}
|
||||
else {
|
||||
state = annotator.doAnnotate(state);
|
||||
System.out.println("==== Problems ====");
|
||||
for (ProblemData problem : state.getProblems()) {
|
||||
System.out.println(problem.getIssue() + " | " + problem.getMessage() + " | " + problem.getTextRange());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void reparseFile() {
|
||||
try {
|
||||
storeState();
|
||||
@@ -518,4 +505,20 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
myPSIChangeListener.start();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inspections
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void loadInspections(ProgressIndicator progress) {
|
||||
ErrorAnalyzer.load(myXmlFile, myRootComponent, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInspections() {
|
||||
// TODO: Auto-generated method stub
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.inspection;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintExternalAnnotator;
|
||||
import org.jetbrains.android.inspections.lint.ProblemData;
|
||||
import org.jetbrains.android.inspections.lint.State;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ErrorAnalyzer {
|
||||
public static void load(XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) {
|
||||
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
|
||||
State state = annotator.collectionInformation(xmlFile);
|
||||
if (state == null) {
|
||||
System.out.println("==== No inspections(" + rootComponent + ") ====");
|
||||
}
|
||||
else {
|
||||
state = annotator.doAnnotate(state);
|
||||
System.out.println("==== Problems(" + rootComponent + ") ====");
|
||||
for (ProblemData problem : state.getProblems()) {
|
||||
System.out.println(problem.getIssue() + " | " + problem.getMessage() + " | " + problem.getTextRange());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-6
@@ -17,7 +17,6 @@ package com.intellij.designer;
|
||||
|
||||
import com.intellij.designer.componentTree.ComponentTree;
|
||||
import com.intellij.designer.componentTree.ComponentTreeBuilder;
|
||||
import com.intellij.designer.componentTree.TreeEditableArea;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.propertyTable.PropertyTablePanel;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -135,11 +134,6 @@ public final class DesignerToolWindowManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TreeEditableArea getTreeArea() {
|
||||
return myTreeBuilder == null ? null : myTreeBuilder.getTreeArea();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static DesignerEditorPanel getDesigner(FileEditor editor) {
|
||||
if (editor instanceof DesignerEditor) {
|
||||
|
||||
+16
-7
@@ -19,7 +19,6 @@ import com.intellij.designer.DesignerEditorState;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.actions.DesignerActionPanel;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.componentTree.TreeEditableArea;
|
||||
import com.intellij.designer.designSurface.tools.*;
|
||||
import com.intellij.designer.model.FindComponentVisitor;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
@@ -29,10 +28,13 @@ import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.diagnostic.errordialog.Attachment;
|
||||
import com.intellij.ide.palette.impl.PaletteManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
@@ -510,11 +512,6 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
return mySurfaceArea;
|
||||
}
|
||||
|
||||
public EditableArea getActionsArea() {
|
||||
TreeEditableArea treeArea = DesignerToolWindowManager.getInstance(getProject()).getTreeArea();
|
||||
return treeArea == null ? mySurfaceArea : treeArea;
|
||||
}
|
||||
|
||||
public ToolProvider getToolProvider() {
|
||||
return myToolProvider;
|
||||
}
|
||||
@@ -713,6 +710,18 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
|
||||
public abstract TreeComponentDecorator getTreeDecorator();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inspection
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void loadInspections(ProgressIndicator progress) {
|
||||
}
|
||||
|
||||
public void updateInspections() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
+5
-5
@@ -13,21 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.inspection;
|
||||
package com.intellij.designer.inspection;
|
||||
|
||||
import com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel;
|
||||
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
|
||||
import com.intellij.codeHighlighting.HighlightingPass;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class AndroidBackgroundEditorHighlighter implements BackgroundEditorHighlighter {
|
||||
public final class DesignerBackgroundEditorHighlighter implements BackgroundEditorHighlighter {
|
||||
private final HighlightingPass[] myHighlightingPasses;
|
||||
|
||||
public AndroidBackgroundEditorHighlighter(AndroidDesignerEditorPanel designer) {
|
||||
myHighlightingPasses = new HighlightingPass[]{new AndroidHighlightingPass(designer)};
|
||||
public DesignerBackgroundEditorHighlighter(DesignerEditorPanel designer) {
|
||||
myHighlightingPasses = new HighlightingPass[]{new DesignerHighlightingPass(designer)};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+7
-8
@@ -13,30 +13,29 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.inspection;
|
||||
package com.intellij.designer.inspection;
|
||||
|
||||
import com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel;
|
||||
import com.intellij.codeHighlighting.HighlightingPass;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class AndroidHighlightingPass implements HighlightingPass {
|
||||
private final AndroidDesignerEditorPanel myDesigner;
|
||||
public final class DesignerHighlightingPass implements HighlightingPass {
|
||||
private final DesignerEditorPanel myDesigner;
|
||||
|
||||
public AndroidHighlightingPass(AndroidDesignerEditorPanel designer) {
|
||||
public DesignerHighlightingPass(DesignerEditorPanel designer) {
|
||||
myDesigner = designer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectInformation(ProgressIndicator progress) {
|
||||
myDesigner.loadInspections();
|
||||
// TODO: Auto-generated method stub
|
||||
myDesigner.loadInspections(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformationToEditor() {
|
||||
// TODO: Auto-generated method stub
|
||||
myDesigner.updateInspections();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user