当前位置: 首页>>代码示例>>Java>>正文


Java IncorrectOperationException类代码示例

本文整理汇总了Java中com.intellij.util.IncorrectOperationException的典型用法代码示例。如果您正苦于以下问题:Java IncorrectOperationException类的具体用法?Java IncorrectOperationException怎么用?Java IncorrectOperationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IncorrectOperationException类属于com.intellij.util包,在下文中一共展示了IncorrectOperationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unquoteValue

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
public static void unquoteValue(@NotNull Project project, @NotNull PsiElement element) {
    try {
        Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
        List<Integer> quotePositions = new ArrayList<>();

        element = getParentFieldElement(element);
        if (getElementType(element.getFirstChild()) == CsvTypes.QUOTE) {
            quotePositions.add(element.getFirstChild().getTextOffset());
        }
        if (getElementType(element.getLastChild()) == CsvTypes.QUOTE) {
            quotePositions.add(element.getLastChild().getTextOffset());
        }
        String text = removeQuotes(document.getText(), quotePositions);
        document.setText(text);
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    }
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:19,代码来源:CsvIntentionHelper.java

示例2: handleElementRename

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
  //todo implement this via rename refactor: RenamePsiElementProcessor & RenameHandler for each distinct selector
  final int mySelectorParts = getArguments().size();
  final String[] newSelectorParts = newElementName.split(":");
  if (newSelectorParts.length == mySelectorParts) {
    for (int index = 0; index < mySelectorParts; index++) {
      final AppleScriptIdentifier myId = getArguments().get(index).getArgumentSelector().getSelectorIdentifier();
      final AppleScriptIdentifier newId = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(),
              newSelectorParts[index]);
      if (newId != null && myId != null) {
        myId.replace(newId);
      }
    }
  } else {
    final AppleScriptIdentifier myIdentifier = getArguments().get(0).getArgumentSelector().getSelectorIdentifier();
    final AppleScriptIdentifier identifierNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(),
            newElementName);
    if (identifierNew != null && myIdentifier != null) {
      myIdentifier.replace(identifierNew);
    }
  }
  return AbstractAppleScriptHandlerCall.this;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:25,代码来源:AbstractAppleScriptHandlerCall.java

示例3: setName

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public PsiElement setName(@NonNls @NotNull String newElementName) throws IncorrectOperationException {
  //todo implement this via rename refactor: RenamePsiElementProcessor & RenameHandler for each distinct selector
  final int selectors = getParameters().size();
  final String[] selectorNames = newElementName.split(":");
  if (selectorNames.length == selectors) {
    for (int index = 0; index < selectors; index++) {
      AppleScriptIdentifier myId = getParameters().get(index).getSelectorNameIdentifier();
      final AppleScriptIdentifier idNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), selectorNames[index]);
      if (idNew != null) {
        myId.replace(idNew);
      }
    }
  } else {
    AppleScriptIdentifier myIdentifier = getParameters().get(0).getSelectorNameIdentifier();
    final AppleScriptIdentifier identifierNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), newElementName);
    if (identifierNew != null) {
      myIdentifier.replace(identifierNew);
    }
  }
  return this;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:23,代码来源:AppleScriptHandlerInterleavedParameters.java

示例4: makePsiMethod

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
private PsiMethod makePsiMethod( AbstractSrcMethod method, PsiClass psiClass )
{
  PsiElementFactory elementFactory = JavaPsiFacade.getInstance( psiClass.getProject() ).getElementFactory();
  StringBuilder sb = new StringBuilder();
  method.render( sb, 0 );
  try
  {
    return elementFactory.createMethodFromText( sb.toString(), psiClass );
  }
  catch( IncorrectOperationException ioe )
  {
    // the text of the method does not conform to method grammar, probably being edited in an IJ editor,
    // ignore these since the editor provides error information
    return null;
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:17,代码来源:ManAugmentProvider.java

示例5: createJavaFile

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
private PsiClass createJavaFile(String javaFileName, @NonNls String text) {
    PsiJavaFile psiJavaFile = (PsiJavaFile) PsiFileFactory.getInstance(mPsiClass.getProject()).createFileFromText(
            javaFileName + "." + JavaFileType.INSTANCE.getDefaultExtension(),
            JavaFileType.INSTANCE, text);
    PsiClass[] classes = psiJavaFile.getClasses();
    if (classes.length != 1) {
        throw new IncorrectOperationException("Incorrect class '" + text + "'");
    } else {
        PsiClass pc = classes[0];
        if (pc == null) {
            throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null",
                    "com/intellij/psi/impl/PsiJavaParserFacadeImpl", "createJavaFile"));
        } else {
            return pc;
        }
    }
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:18,代码来源:PropertyProcessor.java

示例6: doCreate

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Nullable
@Override
protected PsiElement doCreate(PsiDirectory psiDirectory, String parameterName, String typeName) throws IncorrectOperationException {
    GCMTemplatesFactory.Template template = GCMTemplatesFactory.Template.GreyCatModel;
    String fileName = fileNameFromTypeName(typeName, parameterName);
    StringBuilder sample = new StringBuilder();
    sample.append("class Cloud {\n");
    sample.append("    att name : String\n");
    sample.append("    rel nodes : Node\n");
    sample.append("}\n");
    sample.append("class Node {\n");
    sample.append("    att name : String\n");
    sample.append("    rel softwares : Software\n");
    sample.append("    index indexedSoftware : Software using name\n");
    sample.append("}\n");
    sample.append("class Software {\n");
    sample.append("    att name : String\n");
    sample.append("    att size : Integer\n");
    sample.append("}\n");
    sample.append("index softwares : Software using name\n");
    return GCMTemplatesFactory.createFromTemplate(psiDirectory, fileName, template, sample.toString());
}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:23,代码来源:GCMNewFileAction.java

示例7: replace

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public PsiElement replace( PsiElement newElement ) throws IncorrectOperationException
{
  // just add new element to the containing class
  final PsiClass containingClass = getContainingClass();
  if( null != containingClass )
  {
    CheckUtil.checkWritable( containingClass );
    return containingClass.add( newElement );
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:13,代码来源:ManLightMethodImpl.java

示例8: setModifierProperty

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
public void setModifierProperty( @PsiModifier.ModifierConstant String name, boolean value ) throws IncorrectOperationException
{
  if( value )
  {
    addModifier( name );
  }
  else
  {
    if( hasModifierProperty( name ) )
    {
      removeModifier( name );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:15,代码来源:ManLightModifierListImpl.java

示例9: handleContentChange

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
public YAMLKeyValueImpl handleContentChange(@NotNull YAMLKeyValueImpl element, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String oldText = element.getText();
    String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
    YAMLValue value = element.getValue();
    Project project = element.getProject();
    if (value instanceof YAMLPlainTextImpl) {
        return (YAMLKeyValueImpl) element.replace(createYamlPlainText(project, element.getKeyText(), newText.substring(element.getTextLength() - element.getValueText().length())));
    }
    if (value instanceof YAMLQuotedTextImpl) {
        return (YAMLKeyValueImpl) element.replace(createYamlDoubleQuotedString(project, element.getKeyText(), newText.substring(element.getTextLength() - element.getValueText().length())));
    }
    return null;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:14,代码来源:CoffigYamlKeyValueManipulator.java

示例10: invoke

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
    String text = "{{ url(\"theme://" + element.getText() + "\") }}";
    PsiElement psiElement = TwigElementFactory.createPsiElement(project, text, TwigElementTypes.PRINT_BLOCK);
    if (psiElement != null)
        element.replace(psiElement);
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:8,代码来源:ConvertTwigResource.java

示例11: handleElementRename

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
  PsiElement element = this;
  final AppleScriptIdentifier identifier = PsiTreeUtil.getChildOfType(element, AppleScriptIdentifier.class);
  final AppleScriptIdentifier identifierNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), newElementName);
  if (identifierNew != null && identifier != null) {
    element.getNode().replaceChild(identifier.getNode(), identifierNew.getNode());
  }
  return this;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:11,代码来源:AppleScriptReferenceElementImpl.java

示例12: invoke

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) throws IncorrectOperationException {
    PsiElement context = getTestContextElement(psiElement);
    if(context != null) {
        BehatPluginUtil.executeDebugRunner(psiElement);
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-behat-plugin,代码行数:8,代码来源:TestRunIntentionAction.java

示例13: handleElementRename

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Override
public PsiElement handleElementRename(String newName) throws IncorrectOperationException {
    PsiElement newNameIdentifier = RmlElementFactory.createTypeName(myElement.getProject(), newName);
    ASTNode newNameNode = newNameIdentifier.getFirstChild().getNode();

    PsiElement nameIdentifier = myElement.getNameIdentifier();
    if (nameIdentifier == null) {
        myElement.getNode().addChild(newNameNode);
    } else {
        ASTNode oldNameNode = nameIdentifier.getNode();
        myElement.getNode().replaceChild(oldNameNode, newNameNode);
    }

    return myElement;
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:16,代码来源:PsiTypeReference.java

示例14: applyFix

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    try {
        PsiElement element = descriptor.getPsiElement();
        Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
        document.setText(document.getText() + "\"");
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    }
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:10,代码来源:CsvValidationInspection.java

示例15: createFile

import com.intellij.util.IncorrectOperationException; //导入依赖的package包/类
@Nullable
@Override
protected PsiElement createFile(String name, String templateName, PsiDirectory dir) {
    try {
        return FileCreateUtil.createFile(name, dir, templateName, this);
    } catch (Exception e) {
        throw new IncorrectOperationException(e.getMessage(), new Throwable(e));
    }
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:10,代码来源:NewThemeConfigurationFileAction.java


注:本文中的com.intellij.util.IncorrectOperationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。