當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。