Search in sources :

Example 56 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class MarkupLanguageProviderTest method getMarkupLanguagesDuplicatedNames.

@Test
public void getMarkupLanguagesDuplicatedNames() {
    MarkupLanguageProvider provider = new MarkupLanguageProvider() {

        @Override
        protected Set<MarkupLanguage> loadMarkupLanguages() {
            return ImmutableSet.<MarkupLanguage>of(new MockMarkupLanguage("Test"), new MockMarkupLanguage("Test"));
        }
    };
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Language name 'Test' must not be provided more than once");
    provider.getMarkupLanguages();
}
Also used : MockMarkupLanguage(org.eclipse.mylyn.internal.wikitext.MockMarkupLanguage) MockMarkupLanguage(org.eclipse.mylyn.internal.wikitext.MockMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) MarkupLanguageProvider(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguageProvider) Test(org.junit.Test)

Example 57 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class WikiTextExtensionPointReader method getMarkupLanguageForFilename.

/**
 * Get a markup language for a file. A markup language is selected based on the registered languages and their
 * expected file extensions.
 *
 * @param name
 *            the name of the file for which a markup language is desired
 * @return the markup language, or null if no markup language is registered for the specified file name
 * @see #getMarkupLanguageForFilename(String)
 */
public MarkupLanguage getMarkupLanguageForFilename(String name) {
    if (languageByFileExtension == null) {
        initializeMarkupLanguages();
    }
    int lastIndexOfDot = name.lastIndexOf('.');
    String extension = lastIndexOfDot == -1 ? name : name.substring(lastIndexOfDot + 1);
    Class<? extends MarkupLanguage> languageClass = languageByFileExtension.get(extension);
    if (languageClass != null) {
        String languageName = null;
        for (Map.Entry<String, Class<? extends MarkupLanguage>> ent : languageByName.entrySet()) {
            if (ent.getValue() == languageClass) {
                languageName = ent.getKey();
                break;
            }
        }
        return instantiateMarkupLanguage(languageName, languageClass);
    }
    return null;
}
Also used : MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 58 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testDiscoverable.

@Test
public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("MediaWiki");
    assertNotNull(language);
    assertTrue(language instanceof MediaWikiLanguage);
}
Also used : MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 59 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class MarkdownLanguageTest method testDiscoverable.

public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("Markdown");
    assertNotNull(language);
    assertTrue(language instanceof MarkdownLanguage);
}
Also used : MarkdownLanguage(org.eclipse.mylyn.wikitext.markdown.MarkdownLanguage) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)

Example 60 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class TextileLanguageTest method testDiscoverable.

@Test
public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("Textile");
    assertNotNull(language);
    assertTrue(language instanceof TextileLanguage);
}
Also used : MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Aggregations

MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)60 Test (org.junit.Test)18 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)15 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)8 File (java.io.File)7 BuildException (org.apache.tools.ant.BuildException)7 CoreException (org.eclipse.core.runtime.CoreException)7 MockMarkupLanguage (org.eclipse.mylyn.internal.wikitext.MockMarkupLanguage)7 StringWriter (java.io.StringWriter)6 HashMap (java.util.HashMap)5 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)5 FileSet (org.apache.tools.ant.types.FileSet)5 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)5 Point (org.eclipse.swt.graphics.Point)5 IOException (java.io.IOException)4 IFile (org.eclipse.core.resources.IFile)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)4 TreeMap (java.util.TreeMap)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3