use of com.intellij.codeInsight.CodeInsightSettings in project intellij-community by JetBrains.
the class CodeCompletionPanel method reset.
public void reset() {
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
final String value;
switch(codeInsightSettings.COMPLETION_CASE_SENSITIVE) {
case CodeInsightSettings.ALL:
value = CASE_SENSITIVE_ALL;
break;
case CodeInsightSettings.NONE:
value = CASE_SENSITIVE_NONE;
break;
default:
value = CASE_SENSITIVE_FIRST_LETTER;
break;
}
myCaseSensitiveCombo.setSelectedItem(value);
myCbSelectByChars.setSelected(codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS);
myCbOnCodeCompletion.setSelected(codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION);
myCbOnSmartTypeCompletion.setSelected(codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION);
myCbAutocompletion.setSelected(codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP);
myCbAutopopupJavaDoc.setSelected(codeInsightSettings.AUTO_POPUP_JAVADOC_INFO);
myAutopopupJavaDocField.setEnabled(codeInsightSettings.AUTO_POPUP_JAVADOC_INFO);
myAutopopupJavaDocField.setText(String.valueOf(codeInsightSettings.JAVADOC_INFO_DELAY));
myCbParameterInfoPopup.setSelected(codeInsightSettings.AUTO_POPUP_PARAMETER_INFO);
myParameterInfoDelayField.setEnabled(codeInsightSettings.AUTO_POPUP_PARAMETER_INFO);
myParameterInfoDelayField.setText(String.valueOf(codeInsightSettings.PARAMETER_INFO_DELAY));
myCbShowFullParameterSignatures.setSelected(codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO);
myCbAutocompletion.setSelected(codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP);
myCbSorting.setSelected(UISettings.getInstance().getSortLookupElementsLexicographically());
myCbAutocompletion.setText("Autopopup code completion" + (PowerSaveMode.isEnabled() ? " (not available in Power Save mode)" : ""));
}
use of com.intellij.codeInsight.CodeInsightSettings in project intellij-community by JetBrains.
the class CodeCompletionPanel method isModified.
public boolean isModified() {
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
boolean isModified = false;
//noinspection ConstantConditions
isModified |= getCaseSensitiveValue() != codeInsightSettings.COMPLETION_CASE_SENSITIVE;
isModified |= isModified(myCbOnCodeCompletion, codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION);
isModified |= isModified(myCbSelectByChars, codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS);
isModified |= isModified(myCbOnSmartTypeCompletion, codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION);
isModified |= isModified(myCbShowFullParameterSignatures, codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO);
isModified |= isModified(myCbParameterInfoPopup, codeInsightSettings.AUTO_POPUP_PARAMETER_INFO);
isModified |= isModified(myCbAutocompletion, codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP);
isModified |= isModified(myCbAutopopupJavaDoc, codeInsightSettings.AUTO_POPUP_JAVADOC_INFO);
isModified |= isModified(myParameterInfoDelayField, codeInsightSettings.PARAMETER_INFO_DELAY, 0);
isModified |= isModified(myAutopopupJavaDocField, codeInsightSettings.JAVADOC_INFO_DELAY, 0);
isModified |= isModified(myCbSorting, UISettings.getInstance().getSortLookupElementsLexicographically());
return isModified;
}
use of com.intellij.codeInsight.CodeInsightSettings in project intellij-community by JetBrains.
the class CodeCompletionPanel method apply.
public void apply() {
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
codeInsightSettings.COMPLETION_CASE_SENSITIVE = getCaseSensitiveValue();
codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = myCbSelectByChars.isSelected();
codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION = myCbOnCodeCompletion.isSelected();
codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = myCbOnSmartTypeCompletion.isSelected();
codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = myCbShowFullParameterSignatures.isSelected();
codeInsightSettings.AUTO_POPUP_PARAMETER_INFO = myCbParameterInfoPopup.isSelected();
codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP = myCbAutocompletion.isSelected();
codeInsightSettings.AUTO_POPUP_JAVADOC_INFO = myCbAutopopupJavaDoc.isSelected();
codeInsightSettings.PARAMETER_INFO_DELAY = getIntegerValue(myParameterInfoDelayField.getText(), 0);
codeInsightSettings.JAVADOC_INFO_DELAY = getIntegerValue(myAutopopupJavaDocField.getText(), 0);
UISettings.getInstance().setSortLookupElementsLexicographically(myCbSorting.isSelected());
final Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
if (project != null) {
DaemonCodeAnalyzer.getInstance(project).settingsChanged();
}
}
use of com.intellij.codeInsight.CodeInsightSettings in project intellij-community by JetBrains.
the class LookupManagerImpl method createLookup.
@NotNull
@Override
public LookupImpl createLookup(@NotNull final Editor editor, @NotNull LookupElement[] items, @NotNull final String prefix, @NotNull final LookupArranger arranger) {
hideActiveLookup();
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
final LookupImpl lookup = createLookup(editor, arranger, myProject);
final Alarm alarm = new Alarm();
final Runnable request = () -> {
if (myActiveLookup != lookup)
return;
LookupElement currentItem = lookup.getCurrentItem();
if (currentItem != null && currentItem.isValid() && isAutoPopupJavadocSupportedBy(currentItem)) {
final CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion();
if (completion != null && !completion.isAutopopupCompletion()) {
try {
DocumentationManager.getInstance(myProject).showJavaDocInfo(editor, psiFile, false);
} catch (IndexNotReadyException ignored) {
}
}
}
};
if (settings.AUTO_POPUP_JAVADOC_INFO) {
alarm.addRequest(request, settings.JAVADOC_INFO_DELAY);
}
ApplicationManager.getApplication().assertIsDispatchThread();
myActiveLookup = lookup;
myActiveLookupEditor = editor;
myActiveLookup.addLookupListener(new LookupAdapter() {
@Override
public void itemSelected(LookupEvent event) {
lookupClosed();
}
@Override
public void lookupCanceled(LookupEvent event) {
lookupClosed();
}
@Override
public void currentItemChanged(LookupEvent event) {
alarm.cancelAllRequests();
if (settings.AUTO_POPUP_JAVADOC_INFO && DocumentationManager.getInstance(myProject).getDocInfoHint() == null) {
alarm.addRequest(request, settings.JAVADOC_INFO_DELAY);
}
}
private void lookupClosed() {
ApplicationManager.getApplication().assertIsDispatchThread();
alarm.cancelAllRequests();
lookup.removeLookupListener(this);
}
});
Disposer.register(lookup, new Disposable() {
@Override
public void dispose() {
myActiveLookup = null;
myActiveLookupEditor = null;
myPropertyChangeSupport.firePropertyChange(PROP_ACTIVE_LOOKUP, lookup, null);
}
});
CamelHumpMatcher matcher = new CamelHumpMatcher(prefix);
if (items.length > 0) {
for (final LookupElement item : items) {
myActiveLookup.addItem(item, matcher);
}
myActiveLookup.refreshUi(true, true);
} else {
// no items -> no doc
alarm.cancelAllRequests();
}
myPropertyChangeSupport.firePropertyChange(PROP_ACTIVE_LOOKUP, null, myActiveLookup);
return lookup;
}
use of com.intellij.codeInsight.CodeInsightSettings in project intellij-community by JetBrains.
the class GroovyParameterInfoHandler method updateUI.
@Override
public void updateUI(Object o, @NotNull ParameterInfoUIContext context) {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
if (o == null)
return;
Object element;
if (o instanceof GroovyResolveResult) {
element = ((GroovyResolveResult) o).getElement();
if (element == null || !((PsiElement) element).isValid()) {
context.setUIComponentEnabled(false);
return;
}
} else if (o instanceof GrClosureSignature) {
if (!((GrClosureSignature) o).isValid()) {
context.setUIComponentEnabled(false);
return;
}
element = o;
} else {
return;
}
int highlightStartOffset = -1;
int highlightEndOffset = -1;
final int currentParameter = context.getCurrentParameterIndex();
StringBuilder buffer = new StringBuilder();
if (element instanceof PsiMethod) {
PsiMethod method = (PsiMethod) element;
if (method instanceof GrReflectedMethod)
method = ((GrReflectedMethod) method).getBaseMethod();
if (settings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO) {
if (!method.isConstructor()) {
PsiType returnType = PsiUtil.getSmartReturnType(method);
if (returnType != null) {
buffer.append(returnType.getPresentableText());
buffer.append(' ');
}
}
buffer.append(method.getName());
buffer.append('(');
}
PsiParameter[] params = method.getParameterList().getParameters();
params = updateConstructorParams(method, params, context.getParameterOwner());
int numParams = params.length;
if (numParams > 0) {
LOG.assertTrue(o instanceof GroovyResolveResult, o.getClass());
final PsiSubstitutor substitutor = ((GroovyResolveResult) o).getSubstitutor();
for (int j = 0; j < numParams; j++) {
PsiParameter param = params[j];
int startOffset = buffer.length();
appendParameterText(param, substitutor, buffer);
int endOffset = buffer.length();
if (j < numParams - 1) {
buffer.append(", ");
}
if (context.isUIComponentEnabled() && (j == currentParameter || (j == numParams - 1 && param.isVarArgs() && currentParameter >= numParams))) {
highlightStartOffset = startOffset;
highlightEndOffset = endOffset;
}
}
} else {
buffer.append("no parameters");
}
if (settings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO) {
buffer.append(")");
}
} else if (element instanceof PsiClass) {
buffer.append("no parameters");
} else if (element instanceof GrClosureSignature) {
GrClosureParameter[] parameters = ((GrClosureSignature) element).getParameters();
if (parameters.length > 0) {
for (int i = 0; i < parameters.length; i++) {
if (i > 0)
buffer.append(", ");
int startOffset = buffer.length();
final PsiType psiType = parameters[i].getType();
if (psiType == null) {
buffer.append("def");
} else {
buffer.append(psiType.getPresentableText());
}
buffer.append(' ').append(parameters[i].getName() != null ? parameters[i].getName() : "<unknown>");
int endOffset = buffer.length();
if (context.isUIComponentEnabled() && (i == currentParameter || (i == parameters.length - 1 && ((GrClosureSignature) element).isVarargs() && currentParameter >= parameters.length))) {
highlightStartOffset = startOffset;
highlightEndOffset = endOffset;
}
final GrExpression initializer = parameters[i].getDefaultInitializer();
if (initializer != null) {
buffer.append(" = ").append(initializer.getText());
}
}
} else {
buffer.append("no parameters");
}
}
final boolean isDeprecated = o instanceof PsiDocCommentOwner && ((PsiDocCommentOwner) o).isDeprecated();
context.setupUIComponentPresentation(buffer.toString(), highlightStartOffset, highlightEndOffset, !context.isUIComponentEnabled(), isDeprecated, false, context.getDefaultParameterColor());
}
Aggregations