<commit_before>// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.lightEdit.project;

import com.intellij.ide.lightEdit.LightEditServiceImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.util.TimeoutUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class LightEditProjectManager {
  private static final Logger LOG = Logger.getInstance(LightEditServiceImpl.class);
  private static final Object LOCK = new Object();

  private volatile LightEditProjectImpl myProject;

  @Nullable
  public Project getProject() {
    return myProject;
  }

  public @NotNull Project getOrCreateProject() {
    if (myProject != null) {
      return myProject;
    }
    synchronized (LOCK) {
      long start = System.nanoTime();
      LightEditProjectImpl project = new LightEditProjectImpl();
      myProject = project;
      LOG.info(LightEditProjectImpl.class.getSimpleName() + " loaded in " + TimeoutUtil.getDurationMillis(start) + " ms");
      return project;
    }
  }

  public void close() {
    Project project = myProject;
    if (project != null) {
      ProjectManagerEx.getInstanceEx().forceCloseProject(project);
    }
    myProject = null;
  }

}<commit_msg>light edit: save project components / project services<commit_after>// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.lightEdit.project;

import com.intellij.ide.SaveAndSyncHandler;
import com.intellij.ide.lightEdit.LightEditServiceImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.util.TimeoutUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class LightEditProjectManager {
  private static final Logger LOG = Logger.getInstance(LightEditServiceImpl.class);
  private static final Object LOCK = new Object();

  private volatile LightEditProjectImpl myProject;

  @Nullable
  public Project getProject() {
    return myProject;
  }

  public @NotNull Project getOrCreateProject() {
    if (myProject != null) {
      return myProject;
    }
    synchronized (LOCK) {
      long start = System.nanoTime();
      LightEditProjectImpl project = new LightEditProjectImpl();
      myProject = project;
      LOG.info(LightEditProjectImpl.class.getSimpleName() + " loaded in " + TimeoutUtil.getDurationMillis(start) + " ms");
      return project;
    }
  }

  public void close() {
    Project project = myProject;
    if (project != null) {
      SaveAndSyncHandler.getInstance().saveSettingsUnderModalProgress(project);
      ProjectManagerEx.getInstanceEx().forceCloseProject(project);
    }
    myProject = null;
  }

}
{'fraction_non_alphanumeric': 0.09227257906749266, 'fraction_numerical': 0.006521030322791001, 'mean_word_length': 4.139028475711893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4560075', 'n_tokens_mistral': 889, 'n_tokens_neox': 865, 'n_words': 223}