highlight globally unused groovy properties (IDEA-75803)

This commit is contained in:
peter
2012-01-31 18:30:25 +01:00
parent 9dfa66531e
commit ea7151df75
4 changed files with 43 additions and 6 deletions
@@ -447,15 +447,22 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
else if (isImplicitUsage(field, progress)) {
return null;
}
else if (!myRefCountHolder.isReferenced(field) && weAreSureThereAreNoUsages(field, progress, helper)) {
if (field instanceof PsiEnumConstant && isEnumValuesMethodUsed(field, progress, helper)) {
return null;
}
else if (isFieldUnused(field, progress, helper)) {
return formatUnusedSymbolHighlightInfo("field.is.not.used", field, "fields", myDeadCodeKey, myDeadCodeInfoType);
}
return null;
}
public static boolean isFieldUnused(PsiField field, ProgressIndicator progress, GlobalUsageHelper helper) {
if (helper.isLocallyUsed(field) || !weAreSureThereAreNoUsages(field, progress, helper)) {
return false;
}
if (field instanceof PsiEnumConstant && isEnumValuesMethodUsed(field, progress, helper)) {
return false;
}
return true;
}
private HighlightInfo suggestionsToMakeFieldUsed(final PsiField field, final PsiIdentifier identifier, final String message) {
HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message, HighlightInfoType.UNUSED_SYMBOL);
QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveUnusedVariableFix(field), myUnusedSymbolKey);