/*
 * Copyright 2000-2014 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.codeInspection.ui;

import com.intellij.codeInspection.InspectionProfileEntry;

import java.lang.reflect.Field;

/**
 * @author Dmitry Batkovich
 */
public interface OptionAccessor {

  boolean getOption(String optionName);

  void setOption(String optionName, boolean optionValue);

  class Default implements OptionAccessor {
    private final InspectionProfileEntry myInspection;

    public Default(final InspectionProfileEntry inspection) {
      myInspection = inspection;
    }

    @Override
    public boolean getOption(final String optionName) {
      try {
        final Class<? extends InspectionProfileEntry> aClass = myInspection.getClass();
        final Field field = aClass.getField(optionName);
        return field.getBoolean(myInspection);
      } catch (IllegalAccessException ignored) {
        return false;
      } catch (NoSuchFieldException ignored) {
        return false;
      }
    }

    @Override
    public void setOption(final String optionName, boolean optionValue) {
      try {
        final Class<? extends InspectionProfileEntry> aClass = myInspection.getClass();
        final Field field = aClass.getField(optionName);
        field.setBoolean(myInspection, optionValue);
      } catch (IllegalAccessException ignored) {
        // nothing
      } catch (NoSuchFieldException ignored) {
        // nothing
      }
    }
  }

}

@@ -698,39 +698,94 @@
 ry;%0A
-%0A
 import 
-java.lang.reflect.Field
+com.intellij.openapi.diagnostic.Logger;%0Aimport com.intellij.util.ReflectionUtil
 ;%0A%0A/
@@ -998,16 +998,124 @@
 essor %7B%0A
+    private static final Logger LOG = Logger.getInstance(%22#com.intellij.codeInspection.ui.OptionAccessor%22);%0A
     priv
@@ -1344,619 +1344,297 @@
     
-try %7B%0A        final Class%3C? extends InspectionProfileEntry%3E aClass = myInspection.getClass();%0A        final Field field = aClass.getField(optionName);%0A        return field.getBoolean(myInspection);%0A      %7D catch (IllegalAccessException ignored) %7B%0A        return false;%0A      %7D catch (NoSuchFieldException ignored) %7B%0A        return false;%0A      %7D%0A    %7D%0A%0A    @Override%0A    public void setOption(final String optionName, boolean optionValue) %7B%0A      try %7B%0A        final Class%3C? extends InspectionProfileEntry%3E aClass = myInspection.getClass();%0A        final Field field = aClass.getField(optionName);%0A        field
+return ReflectionUtil.getField(myInspection.getClass(), myInspection, boolean.class, optionName);%0A    %7D%0A%0A    @Override%0A    public void setOption(final String optionName, boolean optionValue) %7B%0A      try %7B%0A        ReflectionUtil.findField(myInspection.getClass(), boolean.class, optionName)
 .set
@@ -1668,32 +1668,38 @@
 nValue);%0A      %7D
+%0A     
  catch (IllegalA
@@ -1705,39 +1705,33 @@
 AccessException 
-ignored
+e
 ) %7B%0A        // n
@@ -1726,34 +1726,36 @@
         
-// nothing
+LOG.warn(e);
 %0A      %7D
  catch (
@@ -1746,16 +1746,22 @@
 %0A      %7D
+%0A     
  catch (
@@ -1785,15 +1785,9 @@
 ion 
-ignored
+e
 ) %7B%0A
@@ -1798,18 +1798,20 @@
     
-// nothing
+LOG.warn(e);
 %0A   
@@ -1825,11 +1825,10 @@
   %7D%0A  %7D%0A
-%0A
 %7D%0A

fix for private fields