<commit_before>package org.nextras.orm.intellij.completion;

import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocPropertyTagParser;
import com.jetbrains.php.lang.psi.PhpFile;


public class ModifierInsertHandler implements InsertHandler<LookupElement>
{
	private boolean insertSpace;


	public ModifierInsertHandler(boolean insertSpace)
	{
		this.insertSpace = insertSpace;
	}

	@Override
	public void handleInsert(InsertionContext context, LookupElement element)
	{
		Editor editor = context.getEditor();
		CaretModel caretModel = editor.getCaretModel();
		Document document = context.getEditor().getDocument();
		PhpFile file = (PhpFile) context.getFile();

		PsiElement currElement = file.findElementAt(editor.getCaretModel().getOffset());

		StringBuilder buffer = new StringBuilder();
		int newOffset = caretModel.getOffset();
		if (insertSpace) {
			buffer.append(' ');
			newOffset++;
		}

		if (currElement != null && !(currElement.getNode().getElementType().equals(PhpDocPropertyTagParser.DOC_RBRACE))) {
			buffer.append('}');
		}

		document.insertString(caretModel.getOffset(), buffer.toString());
		caretModel.moveToOffset(newOffset);
	}
}<commit_msg>completion contributor: skip space in RBRACE detection<commit_after>package org.nextras.orm.intellij.completion;

import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocPropertyTagParser;
import com.jetbrains.php.lang.psi.PhpFile;


public class ModifierInsertHandler implements InsertHandler<LookupElement>
{
	private boolean insertSpace;


	public ModifierInsertHandler(boolean insertSpace)
	{
		this.insertSpace = insertSpace;
	}

	@Override
	public void handleInsert(InsertionContext context, LookupElement element)
	{
		Editor editor = context.getEditor();
		CaretModel caretModel = editor.getCaretModel();
		Document document = context.getEditor().getDocument();
		PhpFile file = (PhpFile) context.getFile();

		PsiElement currElement = file.findElementAt(editor.getCaretModel().getOffset());

		StringBuilder buffer = new StringBuilder();
		int newOffset = caretModel.getOffset();
		if (insertSpace) {
			buffer.append(' ');
			newOffset++;
		}

		PsiElement testElement = currElement;
		if (testElement!= null && !(testElement.getNode().getElementType().equals(PhpDocPropertyTagParser.DOC_WHITESPACE))) {
			testElement = testElement.getNextSibling();
		}

		if (testElement != null && !(testElement.getNode().getElementType().equals(PhpDocPropertyTagParser.DOC_RBRACE))) {
			buffer.append('}');
		}

		document.insertString(caretModel.getOffset(), buffer.toString());
		caretModel.moveToOffset(newOffset);
	}
}
{'fraction_non_alphanumeric': 0.11534968210717529, 'fraction_numerical': 0.0, 'mean_word_length': 6.120689655172414, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6440267', 'n_tokens_mistral': 1068, 'n_tokens_neox': 997, 'n_words': 165}