use of com.intellij.psi.PsiCodeFragment in project intellij-community by JetBrains.
the class PyParameterTableModel method createRowItem.
@Override
protected PyParameterTableModelItem createRowItem(@Nullable PyParameterInfo parameterInfo) {
if (parameterInfo == null) {
parameterInfo = new PyParameterInfo(-1);
}
final String defaultValue = parameterInfo.getDefaultValue();
final PsiCodeFragment defaultValueFragment = new PyExpressionCodeFragment(myProject, StringUtil.notNullize(defaultValue), StringUtil.notNullize(defaultValue));
final boolean defaultInSignature = parameterInfo.getDefaultInSignature();
return new PyParameterTableModelItem(parameterInfo, defaultValueFragment, defaultValueFragment, defaultInSignature);
}
use of com.intellij.psi.PsiCodeFragment in project intellij-community by JetBrains.
the class ProjectRootsUtil method isOutsideSourceRoot.
public static boolean isOutsideSourceRoot(@Nullable PsiFile psiFile) {
if (psiFile == null)
return false;
if (psiFile instanceof PsiCodeFragment)
return false;
final VirtualFile file = psiFile.getVirtualFile();
if (file == null)
return false;
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(psiFile.getProject()).getFileIndex();
return !projectFileIndex.isInSource(file) && !projectFileIndex.isInLibraryClasses(file);
}
use of com.intellij.psi.PsiCodeFragment in project intellij-community by JetBrains.
the class UserExpressionDescriptorImpl method getEvaluationCode.
protected PsiCodeFragment getEvaluationCode(final StackFrameContext context) throws EvaluateException {
Pair<PsiElement, PsiType> psiClassAndType = DebuggerUtilsImpl.getPsiClassAndType(myTypeName, myProject);
if (psiClassAndType.first == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.type.name", myTypeName));
}
PsiCodeFragment fragment = createCodeFragment(psiClassAndType.first);
if (fragment instanceof JavaCodeFragment) {
((JavaCodeFragment) fragment).setThisType(psiClassAndType.second);
}
return fragment;
}
use of com.intellij.psi.PsiCodeFragment in project intellij-community by JetBrains.
the class CodeFragmentTableCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, final boolean hasFocus, int row, int column) {
PsiCodeFragment codeFragment = (PsiCodeFragment) value;
final EditorTextField editorTextField;
Document document = null;
if (codeFragment != null) {
document = PsiDocumentManager.getInstance(myProject).getDocument(codeFragment);
editorTextField = new EditorTextField(document, myProject, myFileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
} else {
editorTextField = new EditorTextField("", myProject, myFileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
}
if (!table.isShowing()) {
editorTextField.ensureWillComputePreferredSize();
}
editorTextField.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
editorTextField.setBorder((hasFocus || isSelected) ? BorderFactory.createLineBorder(table.getSelectionBackground()) : IdeBorderFactory.createEmptyBorder(1));
if (isSelected && document != null) {
final Color bg = table.getSelectionBackground();
final Color fg = table.getSelectionForeground();
editorTextField.setBackground(bg);
editorTextField.setForeground(fg);
editorTextField.setAsRendererWithSelection(bg, fg);
}
return editorTextField;
}
use of com.intellij.psi.PsiCodeFragment in project intellij-community by JetBrains.
the class JavaProjectRootsUtil method isOutsideJavaSourceRoot.
public static boolean isOutsideJavaSourceRoot(@Nullable PsiFile psiFile) {
if (psiFile == null)
return false;
if (psiFile instanceof PsiCodeFragment)
return false;
final VirtualFile file = psiFile.getVirtualFile();
if (file == null)
return false;
if (file.getFileSystem() instanceof NonPhysicalFileSystem)
return false;
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(psiFile.getProject()).getFileIndex();
return !projectFileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) && !projectFileIndex.isInLibrarySource(file) && !projectFileIndex.isInLibraryClasses(file);
}
Aggregations