Examples of PdttFile


Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new MarkOccurrenceTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
                pdttFile.applyPreferences();
              }

              protected void tearDown() throws Exception {
                if (testFile != null) {
                  testFile.delete(true, null);
                  testFile = null;
                }
              }

              protected void runTest() throws Throwable {
                // OccurrenceLocation[] proposals =
                // getProposals(pdttFile
                // .getFile());
                compareProposals(pdttFile.getFile());
              }
            });
          } catch (final Exception e) {
            phpVerSuite.addTest(new TestCase(fileName) { // dummy
                  // test
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new CompilerParserTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {

                ByteArrayInputStream inputStream = new ByteArrayInputStream(
                    pdttFile.getFile().trim().getBytes());
                ModuleDeclaration moduleDeclaration = (ModuleDeclaration) parser
                    .parse(new InputStreamReader(
                        inputStream),
                        null,
                        ProjectOptions
                            .useShortTags((IProject) null));

                String namespace = pdttFile.getConfig().get(
                    "namespace");
                int offset = Integer.parseInt(pdttFile
                    .getConfig().get("offset"));

                UsePart usePart = ASTUtils
                    .findUseStatementByNamespace(
                        moduleDeclaration, namespace,
                        offset);

                String actual = (usePart == null) ? "null"
                    : usePart.toString();
                assertContents(pdttFile.getExpected(), actual);
              }
            });
          } catch (final Exception e) {
            // dummy test indicating PDTT file parsing failure
            phpVerSuite.addTest(new TestCase(fileName) {
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            final String pruner = getPrunerType(pdttFile);

            phpVerSuite.addTest(new TypeInferenceTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void tearDown() throws Exception {
              }

              protected void runTest() throws Throwable {
                String criteriaFunction = new File(fileName)
                    .getName().replaceAll("\\.pdtt", "");
                String code = pdttFile.getFile();

                IEvaluatedType evaluatedType = findEvaluatedType(
                    code, criteriaFunction, pruner);

                Assert.assertNotNull(
                    "Can't evaluate type for: " + code,
                    evaluatedType);
                Assert.assertEquals(pdttFile.getExpected()
                    .trim(), evaluatedType.getTypeName()
                    .trim());
              }
            });
          } catch (final Exception e) {
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory)) {
          try {
            final PdttFile pdttFile = new PdttFile(fileName);
            phpVerSuite.addTest(new CompilerParserTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void runTest() throws Throwable {

                ByteArrayInputStream inputStream = new ByteArrayInputStream(
                    pdttFile.getFile().trim().getBytes());
                ModuleDeclaration moduleDeclaration = (ModuleDeclaration) parser
                    .parse(new InputStreamReader(
                        inputStream),
                        null,
                        ProjectOptions
                            .useShortTags((IProject) null));

                String alias = pdttFile.getConfig()
                    .get("alias");
                int offset = Integer.parseInt(pdttFile
                    .getConfig().get("offset"));

                UsePart usePart = ASTUtils
                    .findUseStatementByAlias(
                        moduleDeclaration, alias,
                        offset);

                String actual = (usePart == null) ? "null"
                    : usePart.toString();
                assertContents(pdttFile.getExpected(), actual);
              }
            });
          } catch (final Exception e) {
            // dummy test indicating PDTT file parsing failure
            phpVerSuite.addTest(new TestCase(fileName) {
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory,
            Activator.getDefault().getBundle())) {
          try {
            final PdttFile pdttFile = new PdttFile(Activator
                .getDefault().getBundle(), fileName);
            filesMap.put(pdttFile, null);

            phpVerSuite.addTest(new FormatterLinuxAutoEditTests("Linux" + " - /"
                + phpVersion
                .getAlias() + " - /"
                + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void runTest() throws Throwable {

                IFile file = filesMap.get(pdttFile);
                ISourceModule modelElement = (ISourceModule) DLTKCore
                    .create(file);
                if (ScriptModelUtil.isPrimary(modelElement))
                  modelElement.becomeWorkingCopy(
                      new IProblemRequestor() {

                        public void acceptProblem(
                            IProblem problem) {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void beginReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void endReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public boolean isActive() {
                          // TODO Auto-generated
                          // method stub
                          return false;
                        }
                      }, null);
                IStructuredModel modelForEdit = StructuredModelManager
                    .getModelManager()
                    .getModelForEdit(file);
                try {
                  IDocument document = modelForEdit
                      .getStructuredDocument();
                  String beforeFormat = document.get();
                  String data = document.get();
                  int offset = data.lastIndexOf(OFFSET_CHAR);
                  if (offset == -1) {
                    throw new IllegalArgumentException(
                        data+",offset character is not set");
                  }

                  // replace the offset character
                  data = data.substring(0, offset)
                      + data.substring(offset + 1);

                  document.set(data);

                  MainAutoEditStrategy indentLineAutoEditStrategy = new MainAutoEditStrategy();

                  DocumentCommand cmd = new DocumentCommand() {

                  };

                  cmd.offset = offset;
                  cmd.length = 0;
                  if (pdttFile.getOther() != null) {
                    cmd.text = pdttFile.getOther().replaceAll("\r\n", "\n");
                  } else {
                    cmd.text = "\n";
                  }

                  cmd.doit = true;
                  cmd.shiftsCaret = true;
                  cmd.caretOffset = -1;

                  indentLineAutoEditStrategy
                      .customizeDocumentCommand(document,
                          cmd);
                  document.replace(cmd.offset, cmd.length,
                      cmd.text);

                  assertContents(pdttFile.getExpected().replaceAll("\r\n", "\n"),
                      document.get());

                  // change the document text as was before
                  // the formatting
                  document.set(beforeFormat);
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory,
            Activator.getDefault().getBundle())) {
          try {
            final PdttFile pdttFile = new PdttFile(Activator
                .getDefault().getBundle(), fileName);
            filesMap.put(pdttFile, null);

            phpVerSuite.addTest(new FormatterAutoEditTests("Windows" + " - /"
                + phpVersion
                .getAlias() + " - /"
                + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void runTest() throws Throwable {

                IFile file = filesMap.get(pdttFile);
                ISourceModule modelElement = (ISourceModule) DLTKCore
                    .create(file);
                if (ScriptModelUtil.isPrimary(modelElement))
                  modelElement.becomeWorkingCopy(
                      new IProblemRequestor() {

                        public void acceptProblem(
                            IProblem problem) {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void beginReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void endReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public boolean isActive() {
                          // TODO Auto-generated
                          // method stub
                          return false;
                        }
                      }, null);
                IStructuredModel modelForEdit = StructuredModelManager
                    .getModelManager()
                    .getModelForEdit(file);
                try {
                  IDocument document = modelForEdit
                      .getStructuredDocument();
                  String beforeFormat = document.get();
                  String data = document.get();
                  int offset = data.lastIndexOf(OFFSET_CHAR);
                  if (offset == -1) {
                    throw new IllegalArgumentException(
                        data+",offset character is not set");
                  }

                  // replace the offset character
                  data = data.substring(0, offset)
                      + data.substring(offset + 1);

                  document.set(data);

                  MainAutoEditStrategy indentLineAutoEditStrategy = new MainAutoEditStrategy();

                  DocumentCommand cmd = new DocumentCommand() {

                  };

                  cmd.offset = offset;
                  cmd.length = 0;
                  if (pdttFile.getOther() != null) {
                    cmd.text = pdttFile.getOther();
                  } else {
                    cmd.text = "\n";
                  }

                  cmd.doit = true;
                  cmd.shiftsCaret = true;
                  cmd.caretOffset = -1;

                  indentLineAutoEditStrategy
                      .customizeDocumentCommand(document,
                          cmd);
                  document.replace(cmd.offset, cmd.length,
                      cmd.text);

                  assertContents(pdttFile.getExpected(),
                      document.get());

                  // change the document text as was before
                  // the formatting
                  document.set(beforeFormat);
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      String[] files = getPDTTFiles(pair.getValue(), PHPUiTests
          .getDefault().getBundle());

      for (final String fileName : files) {
        try {
          final PdttFile pdttFile = new PdttFile(PHPUiTests
              .getDefault().getBundle(), fileName);
          phpVerSuite.addTest(new SemanticHighlightingTests(
              phpVersion.getAlias() + " - /" + fileName) {

            protected void setUp() throws Exception {
              PHPCoreTests.setProjectPhpVersion(project,
                  PHPVersion.PHP5_3);
            }

            protected void tearDown() throws Exception {
              if (testFile != null) {
                testFile.delete(true, null);
                testFile = null;
              }
            }

            protected void runTest() throws Throwable {
              ;
              String result = "";
              createFile(new ByteArrayInputStream(pdttFile
                  .getFile().getBytes()));
              ISourceModule module = getSourceModule();
              assertNotNull(module);
              String index = fileName.substring(fileName
                  .lastIndexOf('/') + 1, fileName
                  .indexOf('.'));
              // System.err.println(index);
              AbstractSemanticHighlighting highlighter = highlighters
                  .get(index);
              assertNotNull(highlighter);
              Program program = getProgram(module);
              highlighter.initDefaultPreferences();
              Position[] positions = highlighter
                  .consumes(program);
              assertNoDuplicates(highlighter.getDisplayName(),
                  positions);
              result += highlighter.getClass().getName() + ":\n";
              for (Position position : positions) {
                result += "highlight("
                    + pdttFile.getFile().substring(
                        position.getOffset(),
                        position.getOffset()
                            + position.getLength())
                    + ")\n";
              }
              assertEquals(pdttFile.getExpected(), result);
              // We check the other highlighters for failure
              for (AbstractSemanticHighlighting h : highlighters
                  .values()) {
                if (h != highlighter) {
                  h.initDefaultPreferences();
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

          boolean filesFound = false;
          for (final String fileName : getPDTTFiles(testsDirectory,
              bundle)) {
            filesFound = true;
            try {
              final PdttFile pdttFile = new PdttFile(Activator.getDefault().getBundle(), fileName);
              filesMap.put(pdttFile, null);

              formatterConfigurationSuite
                  .addTest(new FormatterTests(phpVersion
                      .getAlias() + " - /" + fileName) {

                    protected void setUp() throws Exception {
                      PHPCoreTests.setProjectPhpVersion(
                          project, phpVersion);
                    }

                    protected void runTest()
                        throws Throwable {

                      IFile file = filesMap.get(pdttFile);

                      IStructuredModel modelForEdit = StructuredModelManager
                          .getModelManager()
                          .getModelForEdit(file);
                      try {
                        IDocument document = modelForEdit
                            .getStructuredDocument();
                        String beforeFormat = document
                            .get();

                        IRegion region = new Region(0,
                            document.getLength());

                        PHPFormatProcessorProxy formatter = new PHPFormatProcessorProxy();
                        formatter.formatDocument(document, 0, document.getLength());

                        assertContents(pdttFile
                            .getExpected(),
                            document.get());

                        // change the document text as
                        // was
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

      for (String testsDirectory : TESTS.get(phpVersion)) {

        for (final String fileName : getPDTTFiles(testsDirectory,
            PHPUiTests.getDefault().getBundle())) {
          try {
            final PdttFile pdttFile = new PdttFile(PHPUiTests
                .getDefault().getBundle(), fileName);
            filesMap.put(pdttFile, null);

            phpVerSuite.addTest(new FormatterAutoEditTests("/"
                + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
              }

              protected void runTest() throws Throwable {

                IFile file = filesMap.get(pdttFile);
                ISourceModule modelElement = (ISourceModule) DLTKCore
                    .create(file);
                if (ScriptModelUtil.isPrimary(modelElement))
                  modelElement.becomeWorkingCopy(
                      new IProblemRequestor() {

                        public void acceptProblem(
                            IProblem problem) {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void beginReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public void endReporting() {
                          // TODO Auto-generated
                          // method stub

                        }

                        public boolean isActive() {
                          // TODO Auto-generated
                          // method stub
                          return false;
                        }
                      }, null);
                IStructuredModel modelForEdit = StructuredModelManager
                    .getModelManager()
                    .getModelForEdit(file);
                try {
                  IDocument document = modelForEdit
                      .getStructuredDocument();
                  String beforeFormat = document.get();
                  String data = document.get();
                  int offset = data.lastIndexOf(OFFSET_CHAR);
                  if (offset == -1) {
                    throw new IllegalArgumentException(
                        "Offset character is not set");
                  }

                  // replace the offset character
                  data = data.substring(0, offset)
                      + data.substring(offset + 1);

                  document.set(data);

                  IAutoEditStrategy indentLineAutoEditStrategy = new MainAutoEditStrategy();

                  DocumentCommand cmd = new DocumentCommand() {

                  };

                  cmd.offset = offset;
                  cmd.length = 0;
                  if (pdttFile.getOther() != null) {
                    cmd.text = pdttFile.getOther();
                  } else {
                    cmd.text = "\n";
                  }

                  cmd.doit = true;
                  cmd.shiftsCaret = true;
                  cmd.caretOffset = -1;

                  indentLineAutoEditStrategy
                      .customizeDocumentCommand(document,
                          cmd);
                  document.replace(cmd.offset, cmd.length,
                      cmd.text);

                  assertContents(pdttFile.getExpected(),
                      document.get());

                  // change the document text as was before
                  // the formatting
                  document.set(beforeFormat);
View Full Code Here

Examples of org.eclipse.php.core.tests.PdttFile

        String[] files = getPDTTFiles(pair.getValue()[i], PHPUiTests
            .getDefault().getBundle());

        for (final String fileName : files) {
          try {
            final PdttFile pdttFile = new PdttFile(PHPUiTests
                .getDefault().getBundle(), fileName);
            phpVerSuite.addTest(new ContentAssistTests(phpVersion
                .getAlias() + " - /" + fileName) {

              protected void setUp() throws Exception {
                PHPCoreTests.setProjectPhpVersion(project,
                    phpVersion);
                pdttFile.applyPreferences();
              }

              protected void tearDown() throws Exception {
                if (testFile != null) {
                  testFile.delete(true, null);
                  testFile = null;
                }
              }

              protected void runTest() throws Throwable {
                String data = pdttFile.getFile();
                int offset = data.lastIndexOf(OFFSET_CHAR);

                // replace the offset character
                data = data.substring(0, offset)
                    + data.substring(offset + 1);

                createFile(
                    new ByteArrayInputStream(data
                        .getBytes()), Long
                        .toString(System
                            .currentTimeMillis()));
                String result = executeAutoInsert(offset);
                closeEditor();
                if (!pdttFile.getExpected().trim()
                    .equals(result.trim())) {
                  StringBuilder errorBuf = new StringBuilder();
                  errorBuf.append("\nEXPECTED COMPLETIONS LIST:\n-----------------------------\n");
                  errorBuf.append(pdttFile.getExpected());
                  errorBuf.append("\nACTUAL COMPLETIONS LIST:\n-----------------------------\n");
                  errorBuf.append(result);
                  fail(errorBuf.toString());
                }
              }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.