Search in sources :

Example 1 with PsiCodeFragment

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);
}
Also used : PsiCodeFragment(com.intellij.psi.PsiCodeFragment)

Example 2 with PsiCodeFragment

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiCodeFragment(com.intellij.psi.PsiCodeFragment)

Example 3 with PsiCodeFragment

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;
}
Also used : PsiCodeFragment(com.intellij.psi.PsiCodeFragment) JavaCodeFragment(com.intellij.psi.JavaCodeFragment) PsiElement(com.intellij.psi.PsiElement) PsiType(com.intellij.psi.PsiType)

Example 4 with PsiCodeFragment

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;
}
Also used : EditorTextField(com.intellij.ui.EditorTextField) PsiCodeFragment(com.intellij.psi.PsiCodeFragment) Document(com.intellij.openapi.editor.Document)

Example 5 with PsiCodeFragment

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiCodeFragment(com.intellij.psi.PsiCodeFragment) NonPhysicalFileSystem(com.intellij.openapi.vfs.NonPhysicalFileSystem)

Aggregations

PsiCodeFragment (com.intellij.psi.PsiCodeFragment)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiElement (com.intellij.psi.PsiElement)3 Document (com.intellij.openapi.editor.Document)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 JSEditorTextField (com.intellij.lang.javascript.refactoring.ui.JSEditorTextField)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 NonPhysicalFileSystem (com.intellij.openapi.vfs.NonPhysicalFileSystem)1 JavaCodeFragment (com.intellij.psi.JavaCodeFragment)1 JavaCodeFragmentFactory (com.intellij.psi.JavaCodeFragmentFactory)1 PsiFile (com.intellij.psi.PsiFile)1 PsiType (com.intellij.psi.PsiType)1 ParameterTableModelItemBase (com.intellij.refactoring.changeSignature.ParameterTableModelItemBase)1 EditorTextField (com.intellij.ui.EditorTextField)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 NotNull (org.jetbrains.annotations.NotNull)1 KtExpression (org.jetbrains.kotlin.psi.KtExpression)1 KtPsiFactory (org.jetbrains.kotlin.psi.KtPsiFactory)1