use of com.intellij.codeInspection.reference.EntryPoint in project intellij-community by JetBrains.
the class InspectionTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.DEAD_CODE_TOOL);
myUnusedCodeExtension = new EntryPoint() {
@NotNull
@Override
public String getDisplayName() {
return "duh";
}
@Override
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return isEntryPoint(psiElement);
}
@Override
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
return ext_src != null && VfsUtilCore.isAncestor(ext_src, PsiUtilCore.getVirtualFile(psiElement), false);
}
@Override
public boolean isSelected() {
return true;
}
@Override
public void setSelected(boolean selected) {
}
@Override
public void readExternal(Element element) {
}
@Override
public void writeExternal(Element element) {
}
};
point.registerExtension(myUnusedCodeExtension);
}
use of com.intellij.codeInspection.reference.EntryPoint in project intellij-community by JetBrains.
the class LightAdvHighlightingJdk7Test method testDynamicallyAddIgnoredAnnotations.
public void testDynamicallyAddIgnoredAnnotations() {
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.DEAD_CODE_TOOL);
EntryPoint extension = new EntryPoint() {
@NotNull
@Override
public String getDisplayName() {
return "duh";
}
@Override
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return false;
}
@Override
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
return false;
}
@Override
public boolean isSelected() {
return false;
}
@Override
public void setSelected(boolean selected) {
}
@Override
public void readExternal(Element element) {
}
@Override
public void writeExternal(Element element) {
}
@Override
public String[] getIgnoreAnnotations() {
return new String[] { "MyAnno" };
}
};
enableInspectionTool(new UnusedDeclarationInspectionBase(true));
doTest(true, false);
List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING);
// unused class and unused method
assertEquals(2, infos.size());
try {
point.registerExtension(extension);
infos = doHighlighting(HighlightSeverity.WARNING);
HighlightInfo info = assertOneElement(infos);
assertEquals("Class 'WithMain' is never used", info.getDescription());
} finally {
point.unregisterExtension(extension);
}
}
use of com.intellij.codeInspection.reference.EntryPoint in project intellij-community by JetBrains.
the class LightAdvHighlightingTest method testUnusedNonPrivateMembers2.
public void testUnusedNonPrivateMembers2() {
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.DEAD_CODE_TOOL);
EntryPoint extension = new EntryPoint() {
@NotNull
@Override
public String getDisplayName() {
return "duh";
}
@Override
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return false;
}
@Override
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
return psiElement instanceof PsiMethod && ((PsiMethod) psiElement).getName().equals("myTestMethod");
}
@Override
public boolean isSelected() {
return false;
}
@Override
public void setSelected(boolean selected) {
}
@Override
public void readExternal(Element element) {
}
@Override
public void writeExternal(Element element) {
}
};
point.registerExtension(extension);
try {
myUnusedDeclarationInspection = new UnusedDeclarationInspectionBase(true);
doTest(true);
} finally {
point.unregisterExtension(extension);
myUnusedDeclarationInspection = new UnusedDeclarationInspectionBase();
}
}
use of com.intellij.codeInspection.reference.EntryPoint in project android by JetBrains.
the class AndroidInspectionsTest method getAndroidEntryPoint.
@NotNull
private AndroidComponentEntryPoint getAndroidEntryPoint() {
AndroidComponentEntryPoint result = null;
for (EntryPoint entryPoint : ((UnusedDeclarationInspection) myUnusedDeclarationToolWrapper.getTool()).getExtensions()) {
if (entryPoint instanceof AndroidComponentEntryPoint) {
try {
result = (AndroidComponentEntryPoint) entryPoint;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
assertNotNull(result);
return result;
}
Aggregations