<commit_before>/*
 * Copyright 2000-2009 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.facet;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.module.Module;
import org.jetbrains.annotations.NotNull;

/**
 * Represents a specific instance of facet
 *
 * @see FacetType
 *
 * @author nik
 */
public class Facet<C extends FacetConfiguration> extends UserDataHolderBase implements UserDataHolder, Disposable {
  public static final Facet[] EMPTY_ARRAY = new Facet[0];
  @NotNull private final FacetType myFacetType;
  @NotNull private final Module myModule;
  @NotNull private final C myConfiguration;
  private final Facet myUnderlyingFacet;
  private String myName;
  private boolean myImplicit;
  private boolean isDisposed;

  public Facet(@NotNull final FacetType facetType, @NotNull final Module module, @NotNull final String name, @NotNull final C configuration, Facet underlyingFacet) {
    myName = name;
    myFacetType = facetType;
    myModule = module;
    myConfiguration = configuration;
    myUnderlyingFacet = underlyingFacet;
    Disposer.register(myModule, this);
  }

  @NotNull
  public final FacetType getType() {
    return myFacetType;
  }

  public final FacetTypeId getTypeId() {
    return myFacetType.getId();
  }

  public final Facet getUnderlyingFacet() {
    return myUnderlyingFacet;
  }

  @NotNull
  public final C getConfiguration() {
    return myConfiguration;
  }

  @NotNull
  public final Module getModule() {
    return myModule;
  }

  @Deprecated
  public final boolean isImplicit() {
    return myImplicit;
  }

  @Deprecated
  public final void setImplicit(final boolean implicit) {
    myImplicit = implicit;
  }

  /**
   * Called when the module containing this facet is initialized
   */
  public void initFacet() {
  }

  /**
   * Called when the module containing this facet is disposed
   */
  public void disposeFacet() {
  }

  public final void dispose() {
    assert !isDisposed;
    isDisposed = true;
    disposeFacet();
  }

  public final int hashCode() {
    return super.hashCode();
  }

  @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
  public final boolean equals(Object obj) {
    return super.equals(obj);
  }

  @NotNull
  public final String getName() {
    return myName;
  }

  /**
   * Use {@link com.intellij.facet.ModifiableFacetModel#rename} to rename facets
   */
  final void setName(@NotNull final String name) {
    myName = name;
  }

}
<commit_msg>Module already disposed AE fix<commit_after>/*
 * Copyright 2000-2009 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.facet;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.module.Module;
import org.jetbrains.annotations.NotNull;

/**
 * Represents a specific instance of facet
 *
 * @see FacetType
 *
 * @author nik
 */
public class Facet<C extends FacetConfiguration> extends UserDataHolderBase implements UserDataHolder, Disposable {
  public static final Facet[] EMPTY_ARRAY = new Facet[0];
  @NotNull private final FacetType myFacetType;
  @NotNull private final Module myModule;
  @NotNull private final C myConfiguration;
  private final Facet myUnderlyingFacet;
  private String myName;
  private boolean myImplicit;
  private boolean isDisposed;

  public Facet(@NotNull final FacetType facetType, @NotNull final Module module, @NotNull final String name, @NotNull final C configuration, Facet underlyingFacet) {
    myName = name;
    myFacetType = facetType;
    myModule = module;
    myConfiguration = configuration;
    myUnderlyingFacet = underlyingFacet;
    Disposer.register(myModule, this);
  }

  @NotNull
  public final FacetType getType() {
    return myFacetType;
  }

  public final FacetTypeId getTypeId() {
    return myFacetType.getId();
  }

  public final Facet getUnderlyingFacet() {
    return myUnderlyingFacet;
  }

  @NotNull
  public final C getConfiguration() {
    return myConfiguration;
  }

  @NotNull
  public final Module getModule() {
    return myModule;
  }

  public boolean isDisposed() {
    return isDisposed;
  }

  @Deprecated
  public final boolean isImplicit() {
    return myImplicit;
  }

  @Deprecated
  public final void setImplicit(final boolean implicit) {
    myImplicit = implicit;
  }

  /**
   * Called when the module containing this facet is initialized
   */
  public void initFacet() {
  }

  /**
   * Called when the module containing this facet is disposed
   */
  public void disposeFacet() {
  }

  public final void dispose() {
    assert !isDisposed;
    isDisposed = true;
    disposeFacet();
  }

  public final int hashCode() {
    return super.hashCode();
  }

  @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
  public final boolean equals(Object obj) {
    return super.equals(obj);
  }

  @NotNull
  public final String getName() {
    return myName;
  }

  /**
   * Use {@link com.intellij.facet.ModifiableFacetModel#rename} to rename facets
   */
  final void setName(@NotNull final String name) {
    myName = name;
  }

}

{'fraction_non_alphanumeric': 0.08311159805916418, 'fraction_numerical': 0.004069494443574895, 'mean_word_length': 3.7580044676098288, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '130301', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1849, 'n_words': 609}