Search in sources :

Example 51 with Nullable

use of org.jetbrains.annotations.Nullable in project folding-plugin by dmytrodanylyk.

the class SettingConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    useCustomPatternCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            boolean selected = getCheckBoxStatus(actionEvent);
            customPattern.setEnabled(selected);
            isModified = true;
        }
    });
    customPattern.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            isModified = true;
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            isModified = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            isModified = true;
        }
    });
    hideFoldingPrefix.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            isModified = true;
        }
    });
    reset();
    return mPanel;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with Nullable

use of org.jetbrains.annotations.Nullable in project midpoint by Evolveum.

the class DataModelUtil method resolvePath.

// null means not supported yet
@Nullable
@SuppressWarnings("unchecked")
public static PathResolutionResult resolvePath(@NotNull ItemPath path, @NotNull PathResolutionContext context) {
    if (!(path.first() instanceof NameItemPathSegment)) {
        return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_DOES_NOT_START_WITH_NAME, "Path does not start with a name: '" + path + "'", null, null));
    }
    QName varName;
    ItemPath itemPath;
    NameItemPathSegment firstNameSegment = (NameItemPathSegment) path.first();
    if (firstNameSegment.isVariable()) {
        varName = firstNameSegment.getName();
        itemPath = path.tail();
    } else {
        if (context.defaultVariable == null) {
            return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_NO_DEFAULT_VARIABLE, "No default variable for item path: '" + path + "'", null, null));
        }
        varName = context.defaultVariable;
        itemPath = path;
    }
    if (QNameUtil.match(ExpressionConstants.VAR_ACCOUNT, varName)) {
        if (!(context instanceof ResourceResolutionContext)) {
            return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_ILLEGAL_USE_OF_ACCOUNT_VARIABLE, "Illegal use of 'account' variable: '" + path + "'", null, null));
        } else {
            // TODO implement checking of $account-based paths
            return null;
        }
    } else if (QNameUtil.match(ExpressionConstants.VAR_USER, varName) || QNameUtil.match(ExpressionConstants.VAR_FOCUS, varName)) {
        Class<? extends FocusType> clazz = FocusType.class;
        if (context instanceof ResourceResolutionContext) {
            ResourceResolutionContext rctx = (ResourceResolutionContext) context;
            ObjectSynchronizationType def = ResourceTypeUtil.findObjectSynchronization(rctx.resource, rctx.kind, rctx.intent);
            if (def != null) {
                QName focusType = def.getFocusType() != null ? def.getFocusType() : UserType.COMPLEX_TYPE;
                PrismObjectDefinition<Objectable> objdef = rctx.prismContext.getSchemaRegistry().findObjectDefinitionByType(focusType);
                if (objdef != null && objdef.getCompileTimeClass() != null && FocusType.class.isAssignableFrom(objdef.getCompileTimeClass())) {
                    clazz = (Class) objdef.getCompileTimeClass();
                }
            } else {
                // the default (MID-3307)
                clazz = UserType.class;
            }
        }
        return resolvePathForType(clazz, itemPath, context);
    } else if (QNameUtil.match(ExpressionConstants.VAR_ACTOR, varName)) {
        return resolvePathForType(UserType.class, itemPath, context);
    } else if (QNameUtil.match(ExpressionConstants.VAR_INPUT, varName)) {
        return null;
    } else {
        // TODO list all possible variables here and issue a warning if no one matches
        return null;
    }
}
Also used : Issue(com.evolveum.midpoint.model.api.validator.Issue) QName(javax.xml.namespace.QName) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Nullable(org.jetbrains.annotations.Nullable)

Example 53 with Nullable

use of org.jetbrains.annotations.Nullable in project midpoint by Evolveum.

the class DataModelUtil method resolvePathForType.

// null means not supported yet
@Nullable
public static PathResolutionResult resolvePathForType(@NotNull Class<? extends ObjectType> clazz, @NotNull ItemPath path, @NotNull PathResolutionContext context) {
    PrismObjectDefinition<?> def = context.prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz);
    if (def == null) {
        return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION, "No definition for " + clazz + " in item path: '" + path + "'", null, null));
    }
    ItemDefinition<?> itemDef = def.findItemDefinition(path);
    if (itemDef != null) {
        return new PathResolutionResult(itemDef);
    } else {
        if (FocusType.class.equals(clazz) && context instanceof ResourceResolutionContext) {
            ResourceResolutionContext rctx = (ResourceResolutionContext) context;
            return new PathResolutionResult(new Issue(Issue.Severity.INFO, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION, "Couldn't verify item path '" + path + "' because specific focus type (user, role, org, ...) is not defined for kind=" + rctx.kind + ", intent=" + rctx.intent, null, null));
        } else {
            return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION, "No definition for '" + path + "' in " + def.getName().getLocalPart(), null, null));
        }
    }
}
Also used : Issue(com.evolveum.midpoint.model.api.validator.Issue) Nullable(org.jetbrains.annotations.Nullable)

Example 54 with Nullable

use of org.jetbrains.annotations.Nullable in project pysonar2 by yinwang0.

the class Analyzer method loadFile.

@Nullable
public Type loadFile(String path) {
    path = $.unifyPath(path);
    File f = new File(path);
    if (!f.canRead()) {
        return null;
    }
    Type module = getCachedModule(path);
    if (module != null) {
        return module;
    }
    // detect circular import
    if (inImportStack(path)) {
        return null;
    }
    // set new CWD and save the old one on stack
    String oldcwd = cwd;
    setCWD(f.getParent());
    pushImportStack(path);
    Type type = parseAndResolve(path);
    popImportStack(path);
    // restore old CWD
    setCWD(oldcwd);
    return type;
}
Also used : ClassType(org.yinwang.pysonar.types.ClassType) Type(org.yinwang.pysonar.types.Type) UnionType(org.yinwang.pysonar.types.UnionType) FunType(org.yinwang.pysonar.types.FunType) ModuleType(org.yinwang.pysonar.types.ModuleType) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 55 with Nullable

use of org.jetbrains.annotations.Nullable in project pysonar2 by yinwang0.

the class Analyzer method parseAndResolve.

@Nullable
private Type parseAndResolve(String file) {
    loadingProgress.tick();
    Node ast = getAstForFile(file);
    if (ast == null) {
        failedToParse.add(file);
        return null;
    } else {
        Type type = inferencer.visit(ast, moduleTable);
        loadedFiles.add(file);
        return type;
    }
}
Also used : ClassType(org.yinwang.pysonar.types.ClassType) Type(org.yinwang.pysonar.types.Type) UnionType(org.yinwang.pysonar.types.UnionType) FunType(org.yinwang.pysonar.types.FunType) ModuleType(org.yinwang.pysonar.types.ModuleType) Node(org.yinwang.pysonar.ast.Node) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)4694 VirtualFile (com.intellij.openapi.vfs.VirtualFile)812 PsiElement (com.intellij.psi.PsiElement)485 File (java.io.File)405 Project (com.intellij.openapi.project.Project)396 PsiFile (com.intellij.psi.PsiFile)320 NotNull (org.jetbrains.annotations.NotNull)259 IOException (java.io.IOException)247 Module (com.intellij.openapi.module.Module)227 ArrayList (java.util.ArrayList)178 TextRange (com.intellij.openapi.util.TextRange)156 Document (com.intellij.openapi.editor.Document)124 List (java.util.List)116 ASTNode (com.intellij.lang.ASTNode)105 IElementType (com.intellij.psi.tree.IElementType)103 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)102 XmlTag (com.intellij.psi.xml.XmlTag)96 Editor (com.intellij.openapi.editor.Editor)94 Element (org.jdom.Element)93 XmlFile (com.intellij.psi.xml.XmlFile)78