<commit_before>/*
 * Copyright 2014 Guidewire Software, Inc.
 */

package gw.internal.gosu.parser;

import gw.config.CommonServices;
import gw.internal.gosu.parser.java.classinfo.CompileTimeExpressionParser;
import gw.internal.gosu.parser.java.classinfo.JavaSourceEnumConstant;
import gw.internal.gosu.parser.java.classinfo.JavaSourceField;
import gw.lang.Deprecated;
import gw.lang.GosuShop;
import gw.lang.javadoc.IClassDocNode;
import gw.lang.javadoc.IDocRef;
import gw.lang.javadoc.IVarNode;
import gw.lang.parser.EvaluationException;
import gw.lang.parser.IExpression;
import gw.lang.reflect.FeatureManager;
import gw.lang.reflect.IAnnotationInfo;
import gw.lang.reflect.IFeatureInfo;
import gw.lang.reflect.IPresentationInfo;
import gw.lang.reflect.IPropertyAccessor;
import gw.lang.reflect.IRelativeTypeInfo;
import gw.lang.reflect.IScriptabilityModifier;
import gw.lang.reflect.IType;
import gw.lang.reflect.java.IJavaAnnotatedElement;
import gw.lang.reflect.java.IJavaClassField;
import gw.lang.reflect.java.IJavaFieldPropertyInfo;
import gw.lang.reflect.java.IJavaType;
import gw.util.GosuExceptionUtil;

import java.lang.reflect.Modifier;
import java.util.List;

/**
 */
public class JavaFieldPropertyInfo extends JavaBaseFeatureInfo implements IJavaFieldPropertyInfo
{
  private IJavaClassField _field;
  private boolean _isStatic;
  private IType _type;
  private IPropertyAccessor _accessor;
  private String _strName;
  private IDocRef<IVarNode> _docs = new IDocRef<IVarNode>() {
    @Override
    public IVarNode get() {
      if (getContainer() instanceof JavaTypeInfo) {
        IClassDocNode classDocs = ((JavaTypeInfo) getContainer()).getDocNode().get();
        @SuppressWarnings({"UnnecessaryLocalVariable"})
        IVarNode varDoc = classDocs == null ? null : classDocs.getVar( _field.getName() );
        return varDoc;
      } else {
        return null;
      }
    }
  };

  JavaFieldPropertyInfo(IFeatureInfo container, IType type, IJavaClassField field, boolean isStatic, boolean simplePropertyProcessing)
  {
    super( container );
    if (type == null) {
      throw new IllegalArgumentException("Feature type cannot be null");
    }
    type = TypeLord.replaceRawGenericTypesWithDefaultParameterizedTypes( type );
    _type = type;
    _field = field;
    if (_field instanceof FieldJavaClassField) {
      ((FieldJavaClassField)_field).setAccessible( true );
    }
    _isStatic = isStatic;
    //_strName = NewIntrospector.capitalizeFirstChar( _field.getName() ).replace( '$', '_' );
    _strName = simplePropertyProcessing ? _field.getName() : _field.getName().replace( '$', '_' );
    if( _isStatic )
    {
      _accessor = new StaticAccessor();
    }
    else
    {
      _accessor = new NonStaticAccessor();
    }
  }

  @Override
  public String getName()
  {
    return _strName;
  }

  void changeNameForNonStaticCollision()
  {
    _strName += "_";<commit_msg>Revert "IDE-2609.  Fix field-based properties to use a default generic type where a raw generic type is used, basically this follows a general Gosu typeinfo rule where no raw generic type can be used as a return type, a param type, or a property type."<commit_after>/*
 * Copyright 2014 Guidewire Software, Inc.
 */

package gw.internal.gosu.parser;

import gw.config.CommonServices;
import gw.internal.gosu.parser.java.classinfo.CompileTimeExpressionParser;
import gw.internal.gosu.parser.java.classinfo.JavaSourceEnumConstant;
import gw.internal.gosu.parser.java.classinfo.JavaSourceField;
import gw.lang.Deprecated;
import gw.lang.GosuShop;
import gw.lang.javadoc.IClassDocNode;
import gw.lang.javadoc.IDocRef;
import gw.lang.javadoc.IVarNode;
import gw.lang.parser.EvaluationException;
import gw.lang.parser.IExpression;
import gw.lang.reflect.FeatureManager;
import gw.lang.reflect.IAnnotationInfo;
import gw.lang.reflect.IFeatureInfo;
import gw.lang.reflect.IPresentationInfo;
import gw.lang.reflect.IPropertyAccessor;
import gw.lang.reflect.IRelativeTypeInfo;
import gw.lang.reflect.IScriptabilityModifier;
import gw.lang.reflect.IType;
import gw.lang.reflect.java.IJavaAnnotatedElement;
import gw.lang.reflect.java.IJavaClassField;
import gw.lang.reflect.java.IJavaFieldPropertyInfo;
import gw.lang.reflect.java.IJavaType;
import gw.util.GosuExceptionUtil;

import java.lang.reflect.Modifier;
import java.util.List;

/**
 */
public class JavaFieldPropertyInfo extends JavaBaseFeatureInfo implements IJavaFieldPropertyInfo
{
  private IJavaClassField _field;
  private boolean _isStatic;
  private IType _type;
  private IPropertyAccessor _accessor;
  private String _strName;
  private IDocRef<IVarNode> _docs = new IDocRef<IVarNode>() {
    @Override
    public IVarNode get() {
      if (getContainer() instanceof JavaTypeInfo) {
        IClassDocNode classDocs = ((JavaTypeInfo) getContainer()).getDocNode().get();
        @SuppressWarnings({"UnnecessaryLocalVariable"})
        IVarNode varDoc = classDocs == null ? null : classDocs.getVar( _field.getName() );
        return varDoc;
      } else {
        return null;
      }
    }
  };

  JavaFieldPropertyInfo(IFeatureInfo container, IType type, IJavaClassField field, boolean isStatic, boolean simplePropertyProcessing)
  {
    super( container );
    if (type == null) {
      throw new IllegalArgumentException("Feature type cannot be null");
    }
    _type = type;
    _field = field;
    if (_field instanceof FieldJavaClassField) {
      ((FieldJavaClassField)_field).setAccessible( true );
    }
    _isStatic = isStatic;
    //_strName = NewIntrospector.capitalizeFirstChar( _field.getName() ).replace( '$', '_' );
    _strName = simplePropertyProcessing ? _field.getName() : _field.getName().replace( '$', '_' );
    if( _isStatic )
    {
      _accessor = new StaticAccessor();
    }
    else
    {
      _accessor = new NonStaticAccessor();
    }
  }

  @Override
  public String getName()
  {
    return _strName;
  }

  void changeNameForNonStaticCollision()
  {
    _strName += "_";
{'fraction_non_alphanumeric': 0.1032171581769437, 'fraction_numerical': 0.0020107238605898124, 'mean_word_length': 4.235964912280702, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2771683', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1853, 'n_words': 393}