Search in sources :

Example 1 with JDOMExternalizableStringList

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

the class HtmlUnknownElementInspection method reparseProperties.

protected static JDOMExternalizableStringList reparseProperties(@NotNull final String properties) {
    final JDOMExternalizableStringList result = new JDOMExternalizableStringList();
    final StringTokenizer tokenizer = new StringTokenizer(properties, ",");
    while (tokenizer.hasMoreTokens()) {
        result.add(tokenizer.nextToken().toLowerCase().trim());
    }
    return result;
}
Also used : StringTokenizer(java.util.StringTokenizer) JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList)

Example 2 with JDOMExternalizableStringList

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

the class PyCompatibilityInspectionAdvertiser method getLatestConfiguredCompatiblePythonVersion.

@Nullable
private static LanguageLevel getLatestConfiguredCompatiblePythonVersion(@NotNull PsiElement anchor) {
    final InspectionProfile profile = InspectionProfileManager.getInstance(anchor.getProject()).getCurrentProfile();
    final PyCompatibilityInspection inspection = (PyCompatibilityInspection) profile.getUnwrappedTool(getCompatibilityInspectionShortName(), anchor);
    final JDOMExternalizableStringList versions = inspection.ourVersions;
    if (versions.isEmpty()) {
        return null;
    }
    final String maxVersion = Collections.max(versions);
    return LanguageLevel.fromPythonVersion(maxVersion);
}
Also used : JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList) InspectionProfile(com.intellij.codeInspection.InspectionProfile) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with JDOMExternalizableStringList

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

the class SeverityRegistrar method readExternal.

public void readExternal(@NotNull Element element) {
    myMap.clear();
    myRendererColors.clear();
    for (Element infoElement : element.getChildren(INFO_TAG)) {
        SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes(infoElement);
        String colorStr = infoElement.getAttributeValue(COLOR_ATTRIBUTE);
        @SuppressWarnings("UseJBColor") Color color = colorStr == null ? null : new Color(Integer.parseInt(colorStr, 16));
        registerSeverity(highlightInfo, color);
    }
    myReadOrder = new JDOMExternalizableStringList();
    myReadOrder.readExternal(element);
    List<HighlightSeverity> read = new ArrayList<>(myReadOrder.size());
    final List<HighlightSeverity> knownSeverities = getDefaultOrder();
    for (String name : myReadOrder) {
        HighlightSeverity severity = getSeverity(name);
        if (severity != null && knownSeverities.contains(severity)) {
            read.add(severity);
        }
    }
    myOrderMap = ensureAllStandardIncluded(read, knownSeverities);
    severitiesChanged();
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList) Element(org.jdom.Element)

Example 4 with JDOMExternalizableStringList

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

the class EntryPointsConverterTest method doTest.

private static void doTest(String type, String fqName, String expectedFQName) throws Exception {
    final Element entryPoints = setUpEntryPoint(type, fqName);
    final HashMap<String, SmartRefElementPointer> persistentEntryPoints = new HashMap<>();
    EntryPointsManagerBase.convert(entryPoints, persistentEntryPoints);
    final Element testElement = new Element("comp");
    EntryPointsManagerBase.writeExternal(testElement, persistentEntryPoints, new JDOMExternalizableStringList());
    final Element expectedEntryPoints = setUpEntryPoint(type, expectedFQName);
    expectedEntryPoints.setAttribute("version", "2.0");
    final Element expected = new Element("comp");
    expected.addContent(expectedEntryPoints);
    assertTrue(JDOMUtil.areElementsEqual(testElement, expected));
}
Also used : JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList) HashMap(com.intellij.util.containers.HashMap) Element(org.jdom.Element) SmartRefElementPointer(com.intellij.codeInspection.reference.SmartRefElementPointer)

Example 5 with JDOMExternalizableStringList

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

the class SeverityRegistrar method writeExternal.

public void writeExternal(Element element) {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
        Element info = new Element(INFO_TAG);
        String severityName = severity.getName();
        final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
        if (infoType != null) {
            infoType.writeExternal(info);
            final Color color = myRendererColors.get(severityName);
            if (color != null) {
                info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
            }
            element.addContent(info);
        }
    }
    if (myReadOrder != null && !myReadOrder.isEmpty()) {
        myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
        final JDOMExternalizableStringList ext = new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
        getOrderMap().forEachEntry(new TObjectIntProcedure<HighlightSeverity>() {

            @Override
            public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                ext.set(oIdx, orderSeverity.getName());
                return true;
            }
        });
        ext.writeExternal(element);
    }
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList) Element(org.jdom.Element) TObjectIntProcedure(gnu.trove.TObjectIntProcedure)

Aggregations

JDOMExternalizableStringList (com.intellij.openapi.util.JDOMExternalizableStringList)6 Element (org.jdom.Element)3 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)2 InspectionProfile (com.intellij.codeInspection.InspectionProfile)1 SmartRefElementPointer (com.intellij.codeInspection.reference.SmartRefElementPointer)1 HashMap (com.intellij.util.containers.HashMap)1 TObjectIntProcedure (gnu.trove.TObjectIntProcedure)1 StringTokenizer (java.util.StringTokenizer)1 IllegalDataException (org.jdom.IllegalDataException)1 Nullable (org.jetbrains.annotations.Nullable)1