Package org.netbeans.modules.php.editor.parser.astnodes

Examples of org.netbeans.modules.php.editor.parser.astnodes.Scalar


    public void testGetStringValue() {
        Expression e = null;
        String result = YiiCodeUtils.getStringValue(e);
        assertEquals("", result);

        Scalar scalar = new Scalar(0, 0, "1", Scalar.Type.INT);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "test", Scalar.Type.REAL);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "test", Scalar.Type.UNKNOWN);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "test", Scalar.Type.SYSTEM);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "'test'", Scalar.Type.STRING);
        assertEquals("test", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "\"test\"", Scalar.Type.STRING);
        assertEquals("test", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "'\"test\"'", Scalar.Type.STRING);
        assertEquals("\"test\"", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "'tes\"t'", Scalar.Type.STRING);
        assertEquals("tes\"t", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "\"t'est\"", Scalar.Type.STRING);
        assertEquals("t'est", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "''", Scalar.Type.STRING);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "\"\"", Scalar.Type.STRING);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "'", Scalar.Type.STRING);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));

        scalar = new Scalar(5, 5, "", Scalar.Type.STRING);
        assertEquals("", YiiCodeUtils.getStringValue(scalar));
    }
View Full Code Here


     * @return string name | empty string
     */
    public static String getStringValue(Expression e) {
        String name = ""; // NOI18N
        if (e instanceof Scalar) {
            Scalar s = (Scalar) e;
            if (s.getScalarType() == Scalar.Type.STRING) {
                name = s.getStringValue();
            }
            if (name.length() > 2) {
                name = name.substring(1, name.length() - 1);
            } else {
                name = ""; // NOI18N
View Full Code Here

                for (ArrayElement element : elements) {
                    Expression key = element.getKey();
                    if (!(key instanceof Scalar)) {
                        continue;
                    }
                    Scalar s = (Scalar) key;
                    String varName = ""; // NOI18N
                    if (s.getScalarType() == Scalar.Type.STRING) {
                        varName = prepareViewVar(s.getStringValue());
                    }
                    if (varName.isEmpty()) {
                        continue;
                    }
                    varName = "$" + varName; // NOI18N
View Full Code Here

        @Override
        public void visit(ArrayElement node) {
            super.visit(node);
            Expression key = node.getKey();
            if (key instanceof Scalar) {
                Scalar s = (Scalar) key;
                if (s.getScalarType() == Scalar.Type.STRING) {
                    String keyValue = s.getStringValue();
                    keyValue = keyValue.substring(1, keyValue.length() - 1);
                    if (keyValue.equals(message)) {
                        offset = node.getStartOffset();
                    }
                }
View Full Code Here

        if (!parameters.isEmpty()) {
            e = parameters.get(0);
        }
        String path = ""; // NOI18N
        if (e instanceof Scalar) {
            Scalar s = (Scalar) e;
            if (s.getScalarType() == Scalar.Type.STRING) {
                String value = s.getStringValue();
                path = value.substring(1, value.length() - 1);
            }
        }
        if (!path.isEmpty() && actionName != null) {
            if (methodName.equals(actionName)) {
View Full Code Here

TOP

Related Classes of org.netbeans.modules.php.editor.parser.astnodes.Scalar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.