plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 02 Sep 2010 15:18:58 -0700
changeset 484 f5df819c1852
parent 483 109da596fa9d
child 490 17d65127bce4
permissions -rw-r--r--
Checkstyle was used to review coding conventions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
package org.symbian.tools.wrttools.core.internal.validation;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
import java.io.IOException;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
import java.text.MessageFormat;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
import java.util.Set;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
import java.util.TreeSet;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
import java.util.regex.Matcher;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
import java.util.regex.Pattern;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
import org.eclipse.core.resources.IContainer;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
import org.eclipse.core.resources.IFile;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
import org.eclipse.core.resources.IMarker;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
import org.eclipse.core.resources.IProject;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
import org.eclipse.core.resources.IResource;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
import org.eclipse.core.runtime.CoreException;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
import org.eclipse.core.runtime.IPath;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
import org.eclipse.core.runtime.IProgressMonitor;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
import org.eclipse.core.runtime.Path;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
import org.eclipse.jface.text.IRegion;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
import org.eclipse.wst.sse.core.StructuredModelManager;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import org.eclipse.wst.validation.AbstractValidator;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import org.eclipse.wst.validation.ValidationResult;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.wst.validation.ValidationState;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.wst.validation.ValidatorMessage;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.symbian.tools.wrttools.Activator;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.symbian.tools.wrttools.util.CoreUtil;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.symbian.tools.wrttools.util.ProjectUtils;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
import org.symbian.tools.wrttools.util.Util;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
import org.w3c.dom.Element;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
import org.w3c.dom.Node;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
import org.w3c.dom.NodeList;
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
@SuppressWarnings("restriction")
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
public class WrtApplicationValidator extends AbstractValidator {
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    39
    @Override
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    40
    public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    41
        if (ProjectUtils.isPlist(resource)) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    42
            return validatePlist((IFile) resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    43
        } else if (isProject(resource)) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    44
            return validateProject((IProject) resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    45
        } else {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    46
            return null;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    47
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    48
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    50
    private ValidationResult validateProject(IProject resource) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    51
        ValidationResult result = new ValidationResult();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    52
        try {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    53
            isPlistPresent(resource, result);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    54
        } catch (CoreException e) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    55
            Activator.log(e);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    56
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    57
        return result;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    58
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    59
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    60
    private boolean isProject(IResource resource) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    61
        return resource.getType() == IResource.PROJECT && ProjectUtils.hasWrtNature(resource.getProject());
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    62
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    64
    private ValidationResult validatePlist(IFile resource) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    65
        ValidationResult result = new ValidationResult();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    66
        IStructuredModel structuredModel;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    67
        try {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    68
            structuredModel = StructuredModelManager.getModelManager().getModelForRead(resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    69
            try {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    70
                if (structuredModel instanceof IDOMModel) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    71
                    IDOMModel model = (IDOMModel) structuredModel;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    72
                    validateElement((IDOMElement) model.getDocument().getDocumentElement(), result, resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    73
                    checkHtml(model, resource, result);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    74
                    checkPlistValues(model, resource, result);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    75
                }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    76
            } finally {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    77
                if (structuredModel != null) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    78
                    structuredModel.releaseFromRead();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    79
                }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    80
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    81
        } catch (IOException e) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    82
            Activator.log(e);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    83
        } catch (CoreException e) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    84
            Activator.log(e);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    85
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    86
        return result;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    87
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 482
diff changeset
    89
    private static enum PListElements {
482
2973198ae2a9 Cleaned up unused code
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    90
        plist, array, data, date, dict, real, integer, string, FALSE, TRUE, key, xml
2973198ae2a9 Cleaned up unused code
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    91
    };
2973198ae2a9 Cleaned up unused code
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    92
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    93
    private void validateElement(IDOMElement element, ValidationResult result, IResource resource) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    94
        // showData("");
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 482
diff changeset
    95
        PListElements[] values = PListElements.values();
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    96
        boolean isValidElement = false;
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 482
diff changeset
    97
        for (PListElements validElement : values) {
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    98
            if (validElement.toString().equalsIgnoreCase(element.getNodeName().trim())) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
    99
                isValidElement = true;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   100
                break;
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   102
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   103
            continue;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   104
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   105
        if (!isValidElement) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   106
            Object[] arguments = { "   ", element.getNodeName().trim() };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   107
            String message = MessageFormat.format(ValidatorPropMessages.getString("plist.element.not.supported")
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   108
                    + "{0}" + "{1}", arguments);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   109
            result.add(createMessage(resource, message, element.getStartOffset(), element.getEndOffset()));
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   110
        }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   112
        NodeList childNodes = element.getChildNodes();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   113
        for (int i = 0; i < childNodes.getLength(); i++) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   114
            Node item = childNodes.item(i);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   115
            if (item.getNodeType() == Node.ELEMENT_NODE) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   116
                validateElement((IDOMElement) item, result, resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   117
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   118
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   119
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   120
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   121
    private ValidatorMessage createMessage(IResource resource, String message, int startOffset, int endOffset) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   122
        ValidatorMessage msg = ValidatorMessage.create(message, resource);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   123
        msg.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   124
        msg.setAttribute(IMarker.CHAR_START, startOffset);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   125
        msg.setAttribute(IMarker.CHAR_END, endOffset);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   126
        return msg;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   127
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   129
    private boolean checkHtml(IDOMModel model, IFile plist, ValidationResult result) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   130
        String text = model.getStructuredDocument().get();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   131
        IRegion region = CoreUtil.getIndexFileNameRegion(text);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   132
        boolean checkHtml = false;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   133
        if (region != null) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   134
            String htmlName = text.substring(region.getOffset(), region.getOffset() + region.getLength());
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   135
            IFile htmlFile = null;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   136
            try {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   137
                htmlFile = getFile(plist.getProject(), new Path(htmlName), 0, "html", "htm");
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   138
            } catch (CoreException e) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   139
                Activator.log(e);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   140
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   141
            if (htmlFile == null) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   142
                Object[] arguments = { htmlName, "<>", htmlName };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   143
                String message = MessageFormat.format(ValidatorPropMessages.getString("plist.html.element.mismatch")
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   144
                        + "{0}" + "{1}" + "{2}", arguments);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   145
                result.add(createMessage(plist, message, region.getOffset(), region.getOffset() + region.getLength()));
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   146
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   147
        } else {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   148
            String message = ValidatorPropMessages.getString("plist.html.element.mailHtml.missing");
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   149
            ValidatorMessage msg = createMessage(plist, message, 0, 0);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   150
            setMessageOnRootElement(msg, model);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   151
            result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   152
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   153
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   154
        return checkHtml;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   155
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   157
    private void setMessageOnRootElement(ValidatorMessage msg, IDOMModel model) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   158
        Element element = model.getDocument().getDocumentElement();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   159
        int begin = 0, end = 0;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   160
        if (element instanceof IDOMNode) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   161
            IDOMNode node = (IDOMNode) element;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   162
            begin = node.getStartOffset();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   163
            end = node.getFirstStructuredDocumentRegion().getEnd();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   164
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   165
        msg.setAttribute(IMarker.CHAR_START, begin);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   166
        msg.setAttribute(IMarker.CHAR_END, end);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   167
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   169
    private IFile getFile(IContainer container, IPath path, int segment, String... extensions) throws CoreException {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   170
        if (segment + 1 == path.segmentCount()) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   171
            return getFile(container, path.lastSegment(), extensions);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   172
        } else {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   173
            String name = path.segment(segment).toLowerCase();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   174
            IResource[] members = container.members();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   175
            for (IResource resource : members) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   176
                if (resource.getName().toLowerCase().equals(name)) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   177
                    if (resource.getType() == IResource.FOLDER) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   178
                        return getFile((IContainer) resource, path, segment + 1, extensions);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   179
                    }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   180
                }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   181
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   182
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   183
        return null;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   184
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   185
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   186
    private IFile getFile(IContainer container, String lastSegment, String[] extensions) throws CoreException {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   187
        final Set<String> names = new TreeSet<String>();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   188
        names.add(lastSegment.toLowerCase());
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   189
        for (String extension : extensions) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   190
            names.add(lastSegment.concat(".").concat(extension).toLowerCase());
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   191
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   192
        IResource[] members = container.members();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   193
        for (IResource resource : members) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   194
            if (resource.getType() == IResource.FILE && names.contains(resource.getName().toLowerCase())
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   195
                    && resource.isAccessible()) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   196
                return (IFile) resource;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   197
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   198
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   199
        return null;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   200
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   201
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   202
    private void checkPlistValues(IDOMModel model, IResource plist, ValidationResult result) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   203
        String source = model.getStructuredDocument().get();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   204
        if (!hasAttributeValue(source, "DisplayName")) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   205
            Object[] arguments = { " 'Display Name'  ", ValidatorPropMessages.getString("not.in.plist.file") };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   206
            String message = MessageFormat.format(ValidatorPropMessages.getString("plist.mankey.mising") + "{0}"
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   207
                    + "{1}", arguments);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   208
            ValidatorMessage msg = createMessage(plist, message, 0, 0);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   209
            setMessageOnRootElement(msg, model);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   210
            result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   211
        } else { /* validating Widget name (Display name) */
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   212
            Matcher matcher = CoreUtil.getPropertyLookupPattern("DisplayName").matcher(source);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   213
            if (matcher.find()) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   214
                String strError = Util.validateWidgetName(matcher.group(1));
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   215
                if (strError != null) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   216
                    Object[] arguments = { " 'Display Name'  ",
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   217
                            ValidatorPropMessages.getString("contains.invalid.character") };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   218
                    String message = MessageFormat.format(ValidatorPropMessages.getString("plist.mankey.mising")
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   219
                            + "{0}" + "{1}", arguments);
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   220
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   221
                    ValidatorMessage msg = createMessage(plist, message, matcher.start(), matcher.end());
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   222
                    result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   223
                }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   224
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   225
        }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   226
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   227
        if (!hasAttributeValue(source, "MainHTML")) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   228
            Object[] arguments = { " 'MainHTML '  ", ValidatorPropMessages.getString("not.in.plist.file") };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   229
            String message = MessageFormat.format(ValidatorPropMessages.getString("plist.mankey.mising") + "{0}"
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   230
                    + "{1}", arguments);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   231
            ValidatorMessage msg = createMessage(plist, message, 0, 0);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   232
            setMessageOnRootElement(msg, model);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   233
            result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   234
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   235
        if (!hasAttributeValue(source, "Identifier")) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   236
            Object[] arguments = { " 'Identifier '  ", ValidatorPropMessages.getString("not.in.plist.file") };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   237
            String message = MessageFormat.format(ValidatorPropMessages.getString("plist.mankey.mising") + "{0}"
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   238
                    + "{1}", arguments);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   239
            ValidatorMessage msg = createMessage(plist, message, 0, 0);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   240
            setMessageOnRootElement(msg, model);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   241
            result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   242
        } else { /* validating Widget Idenfier (UID) */
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   243
            Matcher matcher = CoreUtil.getPropertyLookupPattern("Identifier").matcher(source);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   244
            if (matcher.find()) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   245
                String strError = Util.validateWidgetID(matcher.group(1));
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   246
                if (strError != null) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   247
                    Object[] arguments = { " 'Identifier'  ",
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   248
                            ValidatorPropMessages.getString("contains.invalid.character") };
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   249
                    String message = MessageFormat.format(ValidatorPropMessages.getString("plist.mankey.mising")
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   250
                            + "{0}" + "{1}", arguments);
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   251
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   252
                    ValidatorMessage msg = createMessage(plist, message, matcher.start(1), matcher.end(1));
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   253
                    result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   254
                }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   255
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   256
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   257
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   258
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   259
    private boolean hasAttributeValue(String source, String propertyName) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   260
        Pattern pattern = CoreUtil.getPropertyLookupPattern(propertyName);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   261
        boolean hasAttr = true;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   262
        Matcher matcher = pattern.matcher(source);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   263
        if (!matcher.find()) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   264
            hasAttr = false;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   265
        } else {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   266
            hasAttr = matcher.group(1).trim().length() > 0;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   267
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   268
        return hasAttr;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   269
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   270
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   271
    private void isPlistPresent(IProject project, ValidationResult result) throws CoreException {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   272
        IResource[] members = project.members();
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   273
        for (IResource resource : members) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   274
            if (ProjectUtils.isPlist(resource)) {
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   275
                return;
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   276
            }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   277
        }
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   278
        ValidatorMessage msg = ValidatorMessage.create(ValidatorPropMessages.getString("plist.File.Not.Present"),
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   279
                project);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   280
        msg.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   281
484
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   282
        result.add(msg);
f5df819c1852 Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 483
diff changeset
   283
    }
99
2196d1511a17 Heads were merged
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   284
}