Search in sources :

Example 21 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class VirtualFilePointerContainerImpl method readExternal.

@Override
public void readExternal(@NotNull final Element rootChild, @NotNull final String childElements) throws InvalidDataException {
    final List<Element> urls = rootChild.getChildren(childElements);
    for (Element url : urls) {
        final String urlAttribute = url.getAttributeValue(URL_ATTR);
        if (urlAttribute == null)
            throw new InvalidDataException("path element without url");
        add(urlAttribute);
    }
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 22 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class ProjectFacetManagerImpl method createDefaultConfiguration.

@Override
public <C extends FacetConfiguration> C createDefaultConfiguration(@NotNull final FacetType<?, C> facetType) {
    C configuration = facetType.createDefaultConfiguration();
    DefaultFacetConfigurationState state = myState.getDefaultConfigurations().get(facetType.getStringId());
    if (state != null) {
        Element defaultConfiguration = state.getDefaultConfiguration();
        try {
            FacetUtil.loadFacetConfiguration(configuration, defaultConfiguration);
        } catch (InvalidDataException e) {
            LOG.info(e);
        }
    }
    return configuration;
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 23 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class BreakpointManager method doRead.

private void doRead(@NotNull final Element parentNode) {
    ApplicationManager.getApplication().runReadAction(() -> {
        final Map<String, Breakpoint> nameToBreakpointMap = new THashMap<>();
        try {
            final List groups = parentNode.getChildren();
            for (final Object group1 : groups) {
                final Element group = (Element) group1;
                if (group.getName().equals(RULES_GROUP_NAME)) {
                    continue;
                }
                // skip already converted
                if (group.getAttribute(CONVERTED_PARAM) != null) {
                    continue;
                }
                final String categoryName = group.getName();
                final Key<Breakpoint> breakpointCategory = BreakpointCategory.lookup(categoryName);
                final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME);
                final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true"));
                setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled));
                Element anyExceptionBreakpointGroup;
                if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) {
                    // for compatibility with previous format
                    anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString());
                    //if (factory != null) {
                    for (Element breakpointNode : group.getChildren("breakpoint")) {
                        //Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
                        Breakpoint breakpoint = createBreakpoint(categoryName, breakpointNode);
                        breakpoint.readExternal(breakpointNode);
                        nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint);
                    }
                //}
                } else {
                    anyExceptionBreakpointGroup = group;
                }
                if (anyExceptionBreakpointGroup != null) {
                    final Element breakpointElement = group.getChild("breakpoint");
                    if (breakpointElement != null) {
                        XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
                        JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
                        XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = manager.getDefaultBreakpoint(type);
                        Breakpoint breakpoint = getJavaBreakpoint(xBreakpoint);
                        if (breakpoint != null) {
                            breakpoint.readExternal(breakpointElement);
                            addBreakpoint(breakpoint);
                        }
                    }
                }
            }
        } catch (InvalidDataException ignored) {
        }
        final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
        if (rulesGroup != null) {
            final List<Element> rules = rulesGroup.getChildren("rule");
            for (Element rule : rules) {
                // skip already converted
                if (rule.getAttribute(CONVERTED_PARAM) != null) {
                    continue;
                }
                final Element master = rule.getChild(MASTER_BREAKPOINT_TAG_NAME);
                if (master == null) {
                    continue;
                }
                final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAG_NAME);
                if (slave == null) {
                    continue;
                }
                final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name"));
                if (masterBreakpoint == null) {
                    continue;
                }
                final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name"));
                if (slaveBreakpoint == null) {
                    continue;
                }
                boolean leaveEnabled = "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"));
                XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl) getXBreakpointManager()).getDependentBreakpointManager();
                dependentBreakpointManager.setMasterBreakpoint(slaveBreakpoint.myXBreakpoint, masterBreakpoint.myXBreakpoint, leaveEnabled);
            //addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, leaveEnabled));
            }
        }
        DebuggerInvocationUtil.invokeLater(myProject, this::updateBreakpointsUI);
    });
    myUIProperties.clear();
    final Element props = parentNode.getChild("ui_properties");
    if (props != null) {
        final List children = props.getChildren("property");
        for (Object child : children) {
            Element property = (Element) child;
            final String name = property.getAttributeValue("name");
            final String value = property.getAttributeValue("value");
            if (name != null && value != null) {
                myUIProperties.put(name, value);
            }
        }
    }
}
Also used : XDependentBreakpointManager(com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager) JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) Element(org.jdom.Element) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl) THashMap(gnu.trove.THashMap) InvalidDataException(com.intellij.openapi.util.InvalidDataException) List(java.util.List)

Example 24 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class DebuggerSettings method loadState.

@Override
public void loadState(Element state) {
    XmlSerializer.deserializeInto(this, state);
    try {
        setSteppingFilters(DebuggerUtilsEx.readFilters(state.getChildren("filter")));
    } catch (InvalidDataException e) {
        LOG.error(e);
    }
    myContentStates.clear();
    for (Element content : state.getChildren("content")) {
        ContentState contentState = new ContentState(content);
        myContentStates.put(contentState.getType(), contentState);
    }
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 25 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class MigrationMapSet method readMap.

private static MigrationMap readMap(File file) throws JDOMException, InvalidDataException, IOException {
    if (!file.exists()) {
        return null;
    }
    Element root = JDOMUtil.load(file);
    if (!MIGRATION_MAP.equals(root.getName())) {
        throw new InvalidDataException();
    }
    MigrationMap map = new MigrationMap();
    for (Iterator i = root.getChildren().iterator(); i.hasNext(); ) {
        Element node = (Element) i.next();
        if (NAME.equals(node.getName())) {
            String name = node.getAttributeValue(VALUE);
            map.setName(name);
        }
        if (DESCRIPTION.equals(node.getName())) {
            String description = node.getAttributeValue(VALUE);
            map.setDescription(description);
        }
        if (ENTRY.equals(node.getName())) {
            MigrationMapEntry entry = new MigrationMapEntry();
            String oldName = node.getAttributeValue(OLD_NAME);
            if (oldName == null) {
                throw new InvalidDataException();
            }
            entry.setOldName(oldName);
            String newName = node.getAttributeValue(NEW_NAME);
            if (newName == null) {
                throw new InvalidDataException();
            }
            entry.setNewName(newName);
            String typeStr = node.getAttributeValue(TYPE);
            if (typeStr == null) {
                throw new InvalidDataException();
            }
            entry.setType(MigrationMapEntry.CLASS);
            if (typeStr.equals(PACKAGE_TYPE)) {
                entry.setType(MigrationMapEntry.PACKAGE);
                @NonNls String isRecursiveStr = node.getAttributeValue(RECURSIVE);
                if (isRecursiveStr != null && isRecursiveStr.equals("true")) {
                    entry.setRecursive(true);
                } else {
                    entry.setRecursive(false);
                }
            }
            map.addEntry(entry);
        }
    }
    return map;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Aggregations

InvalidDataException (com.intellij.openapi.util.InvalidDataException)36 Element (org.jdom.Element)24 WriteExternalException (com.intellij.openapi.util.WriteExternalException)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 JDOMException (org.jdom.JDOMException)5 NotNull (org.jetbrains.annotations.NotNull)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 List (java.util.List)4 TreeState (com.intellij.ide.util.treeView.TreeState)3 Nullable (org.jetbrains.annotations.Nullable)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 DescriptionAwareSchemeActions (com.intellij.application.options.schemes.DescriptionAwareSchemeActions)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionProfileModifiableModel (com.intellij.codeInspection.ex.InspectionProfileModifiableModel)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 UnsupportedExpressionException (com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException)1 ExecutionException (com.intellij.execution.ExecutionException)1