void () { XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText(XMLLanguage.INSTANCE, """ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.amirsh.myapplication"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest>"""); XmlTag subtag = createTag("<b/>"); try { file.getRootTag().addSubTag(subtag, true); fail(); } catch (IncorrectOperationException e) { assertTrue(e.getMessage().startsWith("Must not change PSI outside command or undo-transparent action.")); } }