com.intellij.psi.PsiCodeFragment Java Examples

The following examples show how to use com.intellij.psi.PsiCodeFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeFragmentTableCellEditorBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  myCodeFragment = (PsiCodeFragment)value;

  myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myCodeFragment);
  myEditorTextField = createEditorField(myDocument);
  if (myEditorTextField != null) {
    for (DocumentListener listener : myListeners) {
      myEditorTextField.addDocumentListener(listener);
    }
    myEditorTextField.setDocument(myDocument);
    myEditorTextField.setBorder(new LineBorder(table.getSelectionBackground()));
  }

  return myEditorTextField;
}
 
Example #2
Source File: MatchNamespaceInspection.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public PsiElementVisitor buildVisitor(@Nonnull ProblemsHolder holder, boolean isOnTheFly, @Nonnull LocalInspectionToolSession session)
{
	PsiFile file = holder.getFile();
	if(!(file instanceof CSharpFile))
	{
		return PsiElementVisitor.EMPTY_VISITOR;
	}

	if(file instanceof PsiCodeFragment)
	{
		return PsiElementVisitor.EMPTY_VISITOR;
	}

	DotNetSimpleModuleExtension extension = ModuleUtilCore.getExtension(file, DotNetSimpleModuleExtension.class);
	if(extension == null)
	{
		return PsiElementVisitor.EMPTY_VISITOR;
	}

	MatchNamespaceVisitor visitor = session.getUserData(KEY);
	if(visitor == null)
	{
		session.putUserData(KEY, visitor = new MatchNamespaceVisitor(holder, extension));
	}
	return visitor;
}
 
Example #3
Source File: CSharpProblemHighlightFilter.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldHighlight(@Nonnull PsiFile psiFile)
{
	if(psiFile instanceof CSharpFile)
	{
		if(psiFile instanceof PsiCodeFragment)
		{
			return true;
		}
		return CSharpLocationUtil.isValidLocation(psiFile.getProject(), psiFile.getVirtualFile());
	}
	return true;
}
 
Example #4
Source File: CSharpParameterTableModel.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
protected CSharpParameterTableModelItem createRowItem(@Nullable CSharpParameterInfo parameterInfo)
{
	Project project = myMethodDescriptor.getMethod().getProject();

	if(parameterInfo == null)
	{
		parameterInfo = new CSharpParameterInfo("", null, new CSharpTypeRefByQName(myDefaultValueContext, DotNetTypes.System.Object), getRowCount());
	}
	PsiCodeFragment fragment = CSharpFragmentFactory.createTypeFragment(project, parameterInfo.getTypeText(), myDefaultValueContext);

	PsiCodeFragment defaultValue = CSharpFragmentFactory.createExpressionFragment(project, "", myDefaultValueContext);
	return new CSharpParameterTableModelItem(parameterInfo, fragment, defaultValue);
}
 
Example #5
Source File: CSharpChangeSignatureDialog.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
protected PsiCodeFragment createReturnTypeCodeFragment()
{
	String text = CSharpTypeRefPresentationUtil.buildShortText(myMethod.getMethod().getReturnTypeRef(), myDefaultValueContext);
	CSharpFragmentFileImpl typeFragment = CSharpFragmentFactory.createTypeFragment(getProject(), text, myDefaultValueContext);
	typeFragment.putUserData(CS1547.ourReturnTypeFlag, Boolean.TRUE);
	return typeFragment;
}
 
Example #6
Source File: ProjectRootsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #7
Source File: OnEventChangeSignatureDialog.java    From litho with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
protected PsiCodeFragment createReturnTypeCodeFragment() {
  return null;
}
 
Example #8
Source File: CSharpParameterTableModelItem.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public CSharpParameterTableModelItem(CSharpParameterInfo parameter, PsiCodeFragment typeCodeFragment, PsiCodeFragment defaultValueCodeFragment)
{
	super(parameter, typeCodeFragment, defaultValueCodeFragment);
}
 
Example #9
Source File: ParameterTableModelBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiCodeFragment valueOf(TableItem item) {
  return item.typeCodeFragment;
}
 
Example #10
Source File: ParameterTableModelBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiCodeFragment valueOf(TableItem item) {
  return item.defaultValueCodeFragment;
}
 
Example #11
Source File: ParameterTableModelItemBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ParameterTableModelItemBase(P parameter, PsiCodeFragment typeCodeFragment, PsiCodeFragment defaultValueCodeFragment) {
  this.parameter = parameter;
  this.typeCodeFragment = typeCodeFragment;
  this.defaultValueCodeFragment = defaultValueCodeFragment;
}
 
Example #12
Source File: CodeFragmentTableCellEditorBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiCodeFragment getCellEditorValue() {
  return myCodeFragment;
}
 
Example #13
Source File: ChangeSignatureDialogBase.java    From consulo with Apache License 2.0 votes vote down vote up
protected abstract PsiCodeFragment createReturnTypeCodeFragment();