Inspections

This commit is contained in:
Alexander Lobas
2012-05-27 18:25:58 +04:00
parent 4ba87d496b
commit 01723d7ee6
6 changed files with 113 additions and 3 deletions
@@ -16,6 +16,7 @@
package com.intellij.android.designer;
import com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel;
import com.intellij.android.designer.inspection.AndroidBackgroundEditorHighlighter;
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
import com.intellij.designer.DesignerEditor;
import com.intellij.designer.designSurface.DesignerEditorPanel;
@@ -28,6 +29,8 @@ import org.jetbrains.annotations.NotNull;
* @author Alexander Lobas
*/
public final class AndroidDesignerEditor extends DesignerEditor {
private BackgroundEditorHighlighter myHighlighter;
public AndroidDesignerEditor(Project project, VirtualFile file) {
super(project, file);
}
@@ -46,6 +49,9 @@ public final class AndroidDesignerEditor extends DesignerEditor {
@Override
public BackgroundEditorHighlighter getBackgroundHighlighter() {
return null; // TODO: Auto-generated method stub
if (myHighlighter == null) {
myHighlighter = new AndroidBackgroundEditorHighlighter((AndroidDesignerEditorPanel)getDesignerPanel());
}
return myHighlighter;
}
}
@@ -45,6 +45,9 @@ 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;
@@ -112,6 +115,21 @@ 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();
@@ -0,0 +1,44 @@
/*
* 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.android.designer.designSurface.AndroidDesignerEditorPanel;
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
import com.intellij.codeHighlighting.HighlightingPass;
import org.jetbrains.annotations.NotNull;
/**
* @author Alexander Lobas
*/
public class AndroidBackgroundEditorHighlighter implements BackgroundEditorHighlighter {
private final HighlightingPass[] myHighlightingPasses;
public AndroidBackgroundEditorHighlighter(AndroidDesignerEditorPanel designer) {
myHighlightingPasses = new HighlightingPass[]{new AndroidHighlightingPass(designer)};
}
@NotNull
@Override
public HighlightingPass[] createPassesForEditor() {
return myHighlightingPasses;
}
@NotNull
@Override
public HighlightingPass[] createPassesForVisibleArea() {
return HighlightingPass.EMPTY_ARRAY;
}
}
@@ -0,0 +1,42 @@
/*
* 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.android.designer.designSurface.AndroidDesignerEditorPanel;
import com.intellij.codeHighlighting.HighlightingPass;
import com.intellij.openapi.progress.ProgressIndicator;
/**
* @author Alexander Lobas
*/
public class AndroidHighlightingPass implements HighlightingPass {
private final AndroidDesignerEditorPanel myDesigner;
public AndroidHighlightingPass(AndroidDesignerEditorPanel designer) {
myDesigner = designer;
}
@Override
public void collectInformation(ProgressIndicator progress) {
myDesigner.loadInspections();
// TODO: Auto-generated method stub
}
@Override
public void applyInformationToEditor() {
// TODO: Auto-generated method stub
}
}
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
/**
* @author Eugene.Kudelevsky
*/
class ProblemData {
public class ProblemData {
private final Issue myIssue;
private final String myMessage;
private final TextRange myTextRange;
@@ -11,7 +11,7 @@ import java.util.List;
/**
* @author Eugene.Kudelevsky
*/
class State {
public class State {
private final Module myModule;
private final VirtualFile myMainFile;