本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
}
示例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());
}
示例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;
}
示例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 );
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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));
}
}