You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/01 16:38:36 UTC
svn commit: r1152804 [14/15] - in /uima/sandbox/trunk/TextMarker:
org.apache.uima.tm.dltk.debug.ui/ org.apache.uima.tm.dltk.debug.ui/META-INF/
org.apache.uima.tm.dltk.debug.ui/bin/
org.apache.uima.tm.dltk.debug.ui/icons/ org.apache.uima.tm.dltk.debug.u...
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,301 @@
+package org.apache.uima.tm.dltk.ui;
+
+import org.apache.uima.tm.dltk.internal.ui.text.TextMarkerColorConstants;
+import org.eclipse.dltk.ui.CodeFormatterConstants;
+import org.eclipse.dltk.ui.PreferenceConstants;
+import org.eclipse.dltk.ui.preferences.NewScriptProjectPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.graphics.RGB;
+
+
+public class TextMarkerPreferenceConstants extends PreferenceConstants {
+
+ public static final String EDITOR_FOLDING_IMPORTS = "editor_folding_default_imports"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_BLOCKS = "editor_folding_blocks"; //$NON-NLS-1$
+
+ public static final int EDITOR_FOLDING_BLOCKS_OFF = 0;
+
+ public static final int EDITOR_FOLDING_BLOCKS_INCLUDE = 1;
+
+ public static final int EDITOR_FOLDING_BLOCKS_EXCLUDE = 2;
+
+ public static final String EDITOR_FOLDING_INCLUDE_LIST = "editor_folding_include_list"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_EXCLUDE_LIST = "editor_folding_exclude_list"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_COMMENTS = "editor_folding_init_comments"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_NAMESPACES = "editor_folding_init_namespaces"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_INIT_BLOCKS = "editor_folding_init_blocks"; //$NON-NLS-1$
+
+ public static final String EDITOR_FOLDING_COMMENTS_WITH_NEWLINES = "editor_folding_comments_lines"; //$NON-NLS-1$
+
+ public static final String DOC_MAN_PAGES_LOCATIONS = "doc_man_pages_locations";
+
+ public static final String EDITOR_FOLDING_COMMENTS_FOLDING = "editor_folding_comments";
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR = TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD = TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC = TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH = TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_SINGLE_LINE_COMMENT_UNDERLINE = TextMarkerColorConstants.TM_SINGLE_LINE_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_NUMBER_COLOR = TextMarkerColorConstants.TM_NUMBER;
+
+ public final static String EDITOR_NUMBER_BOLD = TextMarkerColorConstants.TM_NUMBER
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_NUMBER_ITALIC = TextMarkerColorConstants.TM_NUMBER
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_NUMBER_STRIKETHROUGH = TextMarkerColorConstants.TM_NUMBER
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_NUMBER_UNDERLINE = TextMarkerColorConstants.TM_NUMBER
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_STRING_COLOR = TextMarkerColorConstants.TM_STRING;
+
+ public final static String EDITOR_STRING_BOLD = TextMarkerColorConstants.TM_STRING
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_STRING_ITALIC = TextMarkerColorConstants.TM_STRING
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_STRING_STRIKETHROUGH = TextMarkerColorConstants.TM_STRING
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_STRING_UNDERLINE = TextMarkerColorConstants.TM_STRING
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR = TextMarkerColorConstants.TM_FUNCTION;
+
+ public final static String EDITOR_FUNCTION_COLOR_BOLD = TextMarkerColorConstants.TM_FUNCTION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_ITALIC = TextMarkerColorConstants.TM_FUNCTION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_FUNCTION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_FUNCTION_COLOR_UNDERLINE = TextMarkerColorConstants.TM_FUNCTION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR = TextMarkerColorConstants.TM_CONDITION;
+
+ public final static String EDITOR_CONDITION_COLOR_BOLD = TextMarkerColorConstants.TM_CONDITION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_ITALIC = TextMarkerColorConstants.TM_CONDITION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_CONDITION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_CONDITION_COLOR_UNDERLINE = TextMarkerColorConstants.TM_CONDITION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR = TextMarkerColorConstants.TM_ACTION;
+
+ public final static String EDITOR_ACTION_COLOR_BOLD = TextMarkerColorConstants.TM_ACTION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_ITALIC = TextMarkerColorConstants.TM_ACTION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_ACTION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_ACTION_COLOR_UNDERLINE = TextMarkerColorConstants.TM_ACTION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR = TextMarkerColorConstants.TM_THEN;
+
+ public final static String EDITOR_THEN_COLOR_BOLD = TextMarkerColorConstants.TM_THEN
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_ITALIC = TextMarkerColorConstants.TM_THEN
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_THEN
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_THEN_COLOR_UNDERLINE = TextMarkerColorConstants.TM_THEN
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR = TextMarkerColorConstants.TM_DECLARATION;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_BOLD = TextMarkerColorConstants.TM_DECLARATION
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_ITALIC = TextMarkerColorConstants.TM_DECLARATION
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_DECLARATION
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_DECLARATION_DEFINITION_COLOR_UNDERLINE = TextMarkerColorConstants.TM_DECLARATION
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR = TextMarkerColorConstants.TM_BASICSYMBOL;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_BOLD = TextMarkerColorConstants.TM_BASICSYMBOL
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_ITALIC = TextMarkerColorConstants.TM_BASICSYMBOL
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_BASICSYMBOL
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_BASICSYMBOL_DEFINITION_COLOR_UNDERLINE = TextMarkerColorConstants.TM_BASICSYMBOL
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR = TextMarkerColorConstants.TM_DOC_COMMENT;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_BOLD = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_ITALIC = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_DOC_COMMENT_COLOR_UNDERLINE = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR = TextMarkerColorConstants.TM_DOC_COMMENT;
+
+ public final static String EDITOR_VARIABLE_COLOR_BOLD = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_BOLD_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_ITALIC = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_ITALIC_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_STRIKETHROUGH = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_STRIKETHROUGH_SUFFIX;
+
+ public final static String EDITOR_VARIABLE_COLOR_UNDERLINE = TextMarkerColorConstants.TM_DOC_COMMENT
+ + EDITOR_UNDERLINE_SUFFIX;
+
+ public final static String EDITOR_SMART_PASTE_MODE = "smartPasteMode"; //$NON-NLS-1$
+
+ public final static int EDITOR_SMART_PASTE_MODE_SIMPLE = 1;
+
+ public final static int EDITOR_SMART_PASTE_MODE_FULL = 2;
+
+ public static final String DOC_TM_PAGES_LOCATIONS = "doc_tm_pages_location";
+
+ public static final String COMMENT_TASK_TAGS = TextMarkerColorConstants.TM_TODO_TAG;// TextMarkerColorConstants
+
+ public static final String COMMENT_TASK_TAGS_BOLD = COMMENT_TASK_TAGS + EDITOR_BOLD_SUFFIX;
+
+ /**
+ * A preference that controls the selected formatter.
+ */
+ public static final String FORMATTER_ID = "formatterId"; //$NON-NLS-1$
+
+ public static void initializeDefaultValues(IPreferenceStore store) {
+ PreferenceConstants.initializeDefaultValues(store);
+
+ PreferenceConverter.setDefault(store, COMMENT_TASK_TAGS, new RGB(127, 159, 191));
+ store.setDefault(COMMENT_TASK_TAGS_BOLD, true);
+
+ PreferenceConverter.setDefault(store,
+ TextMarkerPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD, false);
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC, false);
+
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_DOC_COMMENT_COLOR,
+ new RGB(63, 127, 95));
+
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_STRING_COLOR,
+ new RGB(42, 0, 255));
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_NUMBER_COLOR,
+ new RGB(128, 0, 0));
+
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_VARIABLE_COLOR,
+ new RGB(200, 0, 0));
+
+ // Functions
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_FUNCTION_COLOR,
+ new RGB(50, 50, 200));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FUNCTION_COLOR_BOLD, true);
+
+ // Conditions
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_CONDITION_COLOR,
+ new RGB(0, 128, 0));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_CONDITION_COLOR_BOLD, true);
+
+ // Actions
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_ACTION_COLOR,
+ new RGB(0, 0, 128));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_ACTION_COLOR_BOLD, true);
+
+ // Then
+ PreferenceConverter.setDefault(store, TextMarkerPreferenceConstants.EDITOR_THEN_COLOR, new RGB(
+ 0, 0, 0));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_THEN_COLOR_BOLD, true);
+
+ // Declarations
+ PreferenceConverter.setDefault(store,
+ TextMarkerPreferenceConstants.EDITOR_DECLARATION_DEFINITION_COLOR, new RGB(128, 0, 0));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_DECLARATION_DEFINITION_COLOR_BOLD, true);
+
+ // basic tokens
+ PreferenceConverter.setDefault(store,
+ TextMarkerPreferenceConstants.EDITOR_BASICSYMBOL_DEFINITION_COLOR, new RGB(128, 128,
+ 128));
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_BASICSYMBOL_DEFINITION_COLOR_BOLD, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, false);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_TAB, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true);
+ store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true);
+ store.setDefault(PreferenceConstants.EDITOR_TAB_WIDTH, 4);
+ store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true);
+
+ // folding
+ store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, true);
+ store.setDefault(PreferenceConstants.EDITOR_COMMENTS_FOLDING_ENABLED, true);
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS,
+ TextMarkerPreferenceConstants.EDITOR_FOLDING_BLOCKS_EXCLUDE);
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FOLDING_INCLUDE_LIST, "BLOCK");
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FOLDING_EXCLUDE_LIST, "");
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FOLDING_COMMENTS_WITH_NEWLINES, true);
+ store.setDefault(TextMarkerPreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS, true);
+ store.setDefault(PreferenceConstants.EDITOR_FOLDING_LINES_LIMIT, 5);
+
+ store.setDefault(CodeFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.SPACE);
+ store.setDefault(CodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
+ store.setDefault(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "4");
+
+ NewScriptProjectPreferencePage.initDefaults(store);
+
+ store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_METHOD_TYPEPARAMETERS, true);
+ store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$
+
+ store.setDefault(PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN, true);
+
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS, ".");
+
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/TextMarkerPreferenceConstants.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,13 @@
+package org.apache.uima.tm.dltk.ui.semantichighlighting;
+
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ui.editor.highlighting.ISemanticHighlightingRequestor;
+import org.eclipse.dltk.ui.editor.highlighting.SemanticHighlighting;
+
+public interface ISemanticHighlightingExtension {
+
+ SemanticHighlighting[] getHighlightings();
+
+ void processNode(ASTNode node, ISemanticHighlightingRequestor requestor);
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/semantichighlighting/ISemanticHighlightingExtension.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,19 @@
+package org.apache.uima.tm.dltk.ui.text;
+
+import org.apache.uima.tm.dltk.core.TextMarkerConstants;
+import org.eclipse.jface.text.IDocument;
+
+
+public interface TextMarkerPartitions {
+
+ public final static String TM_PARTITIONING = TextMarkerConstants.TM_PARTITIONING;
+
+ public final static String TM_COMMENT = "__textmarker_comment";
+
+ public final static String TM_STRING = "__textmarker_string";
+
+ public static final String TM_INNER_CODE = "__tm_inner_code";
+
+ public final static String[] TM_PARTITION_TYPES = new String[] { TextMarkerPartitions.TM_STRING,
+ TextMarkerPartitions.TM_COMMENT, IDocument.DEFAULT_CONTENT_TYPE };
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/src/main/java/org/apache/uima/tm/dltk/ui/text/TextMarkerPartitions.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml Mon Aug 1 14:37:34 2011
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<templates>
+ <template id="org.apache.uima.tm.textmarker.editor.template.RECA"
+ context="tmUniversalTemplateContextType" name="RECA"
+ description="Rule element with condition and action" icon="icons/obj16/tm_obj.png"
+ autoinsert="true">${cursor}Type{C() -> A()};</template>
+ <template id="org.apache.uima.tm.textmarker.editor.template.CALL"
+ context="tmUniversalTemplateContextType" name="CALL" description="Simple CALL rule"
+ icon="icons/obj16/tm_obj.png" autoinsert="true">Document{->CALL(${cursor})};
+ </template>
+ <template id="org.apache.uima.tm.textmarker.editor.template.EXEC"
+ context="tmUniversalTemplateContextType" name="EXEC" description="Simple EXEC rule"
+ icon="icons/obj16/tm_obj.png" autoinsert="true">Document{->EXEC(${cursor})};</template>
+ <template id="org.apache.uima.tm.textmarker.editor.template.BLOCK"
+ context="tmUniversalTemplateContextType" name="BLOCK" description="Simple BLOCK"
+ icon="icons/obj16/tm_obj.png" autoinsert="true">BLOCK(${cursor}Name)
+ Document{} { };</template>
+ <template id="org.apache.uima.tm.textmarker.editor.template.MF"
+ context="tmUniversalTemplateContextType" name="MF" description="Common MARKFAST rule"
+ icon="icons/obj16/tm_obj.png" autoinsert="true">Document{->MARKFAST(${cursor}Type, List)};</template>
+
+</templates>
\ No newline at end of file
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.ui/templates/templates.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Aug 1 14:37:34 2011
@@ -0,0 +1 @@
+.settings
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath Mon Aug 1 14:37:34 2011
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.classpath
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project Mon Aug 1 14:37:34 2011
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.uima.tm.dltk.validator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/.project
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF Mon Aug 1 14:37:34 2011
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TextMarker DLTK Validator Plugin
+Bundle-SymbolicName: org.apache.uima.tm.dltk.validator;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.apache.uima.tm.dltk.validator.ValidatorPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.dltk.validators.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.dltk.core;bundle-version="[1.0.0,2.0.0)",
+ org.apache.uima.tm.dltk.core,
+ org.eclipse.dltk.launching;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.core.resources,
+ org.apache.uima.runtime;bundle-version="2.3.0",
+ org.apache.uima.tm.textmarker.engine
+Bundle-ActivationPolicy: lazy
+Export-Package: org.apache.uima.tm.dltk.validator
+Bundle-Vendor: University of Würzburg
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties Mon Aug 1 14:37:34 2011
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/build.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml Mon Aug 1 14:37:34 2011
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.dltk.validators.core.validator">
+ <validatorType
+ class="org.apache.uima.tm.dltk.validator.CheckValidator"
+ id="org.apache.uima.tm.dltk.validator.checkvalidator"
+ nature="org.apache.uima.tm.dltk.core.nature">
+ </validatorType>
+ </extension>
+ <extension
+ point="org.eclipse.dltk.core.buildParticipant">
+ <buildParticipant
+ class="org.apache.uima.tm.dltk.validator.CheckValidator"
+ id="org.apache.uima.tm.dltk.validator.Checker"
+ name="TextMarker Validator"
+ nature="org.apache.uima.tm.dltk.core.nature">
+ </buildParticipant>
+ </extension>
+
+</plugin>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/plugin.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,19 @@
+package org.apache.uima.tm.dltk.validator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.builder.AbstractBuildParticipantType;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+
+public class CheckValidator extends AbstractBuildParticipantType {
+
+ private static final String ID = "org.apache.uima.tm.dltk.validator.checkvalidator"; //$NON-NLS-1$
+
+ private static final String NAME = "TextMarker Checker"; //$NON-NLS-1$
+
+ @Override
+ public IBuildParticipant createBuildParticipant(IScriptProject project) throws CoreException {
+ return new TextMarkerChecker(project);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/CheckValidator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,77 @@
+/**
+ *
+ */
+package org.apache.uima.tm.dltk.validator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.SourceParserUtil;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+
+/**
+ * @author Martin Toepfer
+ *
+ */
+public class TextMarkerChecker implements IBuildParticipant, IBuildParticipantExtension {
+ List<IBuildParticipant> buildParticipants = null;
+
+ public TextMarkerChecker(IScriptProject project) {
+ buildParticipants = new ArrayList<IBuildParticipant>();
+ try {
+ buildParticipants.add(new TextMarkerTypeChecker(project));
+ buildParticipants.add(new TextMarkerVarRefChecker());
+ buildParticipants.add(new TextMarkerEngineAndCallChecker(project));
+ buildParticipants.add(new TextMarkerRessourceChecker(project));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.dltk.core.builder.IBuildParticipant#build(org.eclipse.dltk
+ * .core.builder.IBuildContext)
+ */
+ public void build(IBuildContext context) throws CoreException {
+ // if ast not declared in context ..
+ Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+ if (!(mdObj instanceof ModuleDeclaration)) {
+ // ...temporary inefficient hack to get live error msgs
+ // TODO refactor
+ ISourceModule sourceModule = context.getSourceModule();
+ ModuleDeclaration md = SourceParserUtil.getModuleDeclaration(sourceModule, null);
+ context.set(IBuildContext.ATTR_MODULE_DECLARATION, md);
+ }
+ for (IBuildParticipant buildP : buildParticipants) {
+ buildP.build(context);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.dltk.core.builder.IBuildParticipantExtension#beginBuild(int)
+ */
+ public boolean beginBuild(int buildType) {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.dltk.core.builder.IBuildParticipantExtension#endBuild(org
+ * .eclipse.core.runtime.IProgressMonitor)
+ */
+ public void endBuild(IProgressMonitor monitor) {
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerChecker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package org.apache.uima.tm.dltk.validator;
+
+import org.apache.uima.tm.dltk.parser.ast.declarations.TextMarkerAbstractDeclaration;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.compiler.problem.DefaultProblem;
+import org.eclipse.dltk.compiler.problem.ProblemSeverities;
+
+
+/**
+ * @author Martin Toepfer
+ *
+ */
+public class TextMarkerCheckerDefaultProblem extends DefaultProblem {
+ public static final int WARNING = ProblemSeverities.Warning;
+
+ public static final int ERROR = ProblemSeverities.Error;
+
+ // public TextMarkerCheckerDefaultProblem(String message, int id, String[]
+ // stringArguments,
+ // int severity, int start, int end) {
+ // super(message, id, stringArguments, severity, start,
+ // end, 10);
+ // }
+
+ public TextMarkerCheckerDefaultProblem(String fileName, String message,
+ TextMarkerAbstractDeclaration node, int line, int severity) {
+ super(fileName, message, 0, new String[] {}, severity, node.getNameStart(), node.getNameEnd(),
+ line);
+ }
+
+ public TextMarkerCheckerDefaultProblem(String fileName, String message,
+ TextMarkerAbstractDeclaration node, int line) {
+ super(fileName, message, 0, new String[] {}, ERROR, node.getNameStart(), node.getNameEnd(),
+ line);
+ }
+
+ public TextMarkerCheckerDefaultProblem(String fileName, String message, ASTNode node, int line) {
+ this(fileName, message, node, line, ERROR);
+ }
+
+ public TextMarkerCheckerDefaultProblem(String fileName, String message, ASTNode node, int line,
+ int severity) {
+ super(fileName, message, 0, new String[] {}, severity, node.sourceStart(), node.sourceEnd(),
+ line);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerDefaultProblem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,150 @@
+/**
+ *
+ */
+package org.apache.uima.tm.dltk.validator;
+
+import java.util.List;
+
+import org.apache.uima.tm.dltk.parser.ast.declarations.TextMarkerAbstractDeclaration;
+import org.apache.uima.tm.dltk.parser.ast.declarations.TextMarkerFeatureDeclaration;
+import org.apache.uima.tm.dltk.parser.ast.expressions.TextMarkerVariableReference;
+import org.eclipse.dltk.ast.ASTListNode;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.expressions.StringLiteral;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+
+/**
+ * @author Martin Toepfer
+ *
+ */
+public class TextMarkerCheckerProblemFactory {
+ // private static final String errMsgHead = "Type \"";
+ // private static final String errMsgTailDefault =
+ // " \" not defined in this script!";
+
+ private ISourceLineTracker linetracker;
+
+ private String fileName;
+
+ public TextMarkerCheckerProblemFactory(String fileName, ISourceLineTracker linetracker) {
+ this.fileName = fileName;
+ this.linetracker = linetracker;
+ }
+
+ public IProblem createIdConflictsWithVariableProblem(TextMarkerAbstractDeclaration varRef) {
+ String message = generateVarAlreadyDeclaredProblemMsg(varRef);
+ return new TextMarkerCheckerDefaultProblem(this.fileName, message, varRef, getLine(varRef));
+ }
+
+ public IProblem createIdConflictsWithTypeProblem(TextMarkerAbstractDeclaration varRef) {
+ String message = generateVarConflictsWithTypeProblem(varRef);
+ return new TextMarkerCheckerDefaultProblem(this.fileName, message, varRef, getLine(varRef));
+ }
+
+ public IProblem createFileNotFoundProblem(ASTNode node, String localPath) {
+ return new TextMarkerCheckerDefaultProblem(this.fileName,
+ generateFileNotFoundProblemMsg(localPath), node, getLine(node));
+ }
+
+ public IProblem createFileNotFoundProblem(ASTNode fileNode) {
+ return createFileNotFoundProblem(fileNode, fileNode.toString());
+ // generateFileNotFoundProblemMsg(fileNode));
+ }
+
+ public IProblem createDuplicateShortNameInImported(ASTNode node, String localPath,
+ List<String> checkDuplicateShortNames, int severity) {
+ StringBuilder sb = new StringBuilder();
+ for (String string : checkDuplicateShortNames) {
+ sb.append(string);
+ sb.append(", ");
+ }
+
+ return new TextMarkerCheckerDefaultProblem(this.fileName, "Types in " + localPath
+ + " share same short name, but with different namespaces: " + sb.toString(), node,
+ getLine(node), severity);
+ }
+
+ public IProblem createDuplicateShortName(TextMarkerAbstractDeclaration var, int severity) {
+ return new TextMarkerCheckerDefaultProblem(this.fileName, "The type " + var.getName()
+ + " conflicts with other types with same short name, but different namespace.", var,
+ getLine(var), severity);
+ }
+
+ public IProblem createXMLProblem(ASTNode node, String localPath) {
+ return new TextMarkerCheckerDefaultProblem(this.fileName, generateXMLProblemMsg(localPath),
+ node, getLine(node));
+ }
+
+ public IProblem createTypeProblem(TextMarkerVariableReference ref, ISourceModule currentFile) {
+
+ String errMsgHead = "Type \"";
+
+ String errMsgTailDefault = " \" not defined in this script/block!";
+ String errMsg = errMsgHead + ref.getName() + errMsgTailDefault;
+ IProblem problem = new TextMarkerCheckerDefaultProblem(currentFile.getElementName(), errMsg,
+ ref, linetracker.getLineNumberOfOffset(ref.sourceStart()));
+ return problem;
+ }
+
+ private String generateFileNotFoundProblemMsg(ASTNode node) {
+ return generateFileNotFoundProblemMsg(node.toString());
+ }
+
+ private String generateFileNotFoundProblemMsg(String fileName) {
+ return "error: \"" + fileName + "\" not found.";
+ }
+
+ private String generateXMLProblemMsg(String fileName) {
+ return "error: " + fileName + " causes xml problem.";
+ }
+
+ private int getLine(ASTNode varRef) {
+ return this.linetracker.getLineNumberOfOffset(varRef.sourceStart());
+ }
+
+ private String generateVarAlreadyDeclaredProblemMsg(TextMarkerAbstractDeclaration var) {
+ return "error: Id \"" + var.getName() + "\" conflicts with already declared variable.";
+ }
+
+ private String generateVarConflictsWithTypeProblem(TextMarkerAbstractDeclaration var) {
+ return "error: Identifier \"" + var.getName()
+ + "\" conflicts with already declared annotation type.";
+ }
+
+ public IProblem createUnknownFeatureTypeProblem(TextMarkerFeatureDeclaration var) {
+ String message = "error: Type \"" + var.getType() + "\" of Feature \"" + var.getName()
+ + "\" is not defined.";
+ return new TextMarkerCheckerDefaultProblem(this.fileName, message, var, getLine(var));
+ }
+
+ public IProblem createUnknownFeatureProblem(Expression var) {
+ // TODO refactor and find better solution
+ String feat = var.toString();
+ List childs = var.getChilds();
+ if (childs != null && !childs.isEmpty()) {
+ Object object = childs.get(0);
+ if (object instanceof ASTListNode) {
+ List childs2 = ((ASTListNode) object).getChilds();
+ if (childs2 != null && !childs2.isEmpty()) {
+ Object object2 = childs2.get(0);
+ if (object2 instanceof StringLiteral) {
+ StringLiteral sl = (StringLiteral) object2;
+ feat = sl.getValue().replaceAll("\"", "");
+ }
+ }
+ }
+ }
+ String message = "error: Feature \"" + feat + "\" is not defined.";
+ return new TextMarkerCheckerDefaultProblem(this.fileName, message, var, getLine(var));
+ }
+
+ public IProblem createInheritenceFinalProblem(TextMarkerVariableReference parent) {
+ String message = "Type \"" + parent.getName()
+ + "\" is final and cannot be used as a parent type.";
+ return new TextMarkerCheckerDefaultProblem(this.fileName, message, parent, getLine(parent));
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerProblemFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,257 @@
+/**
+ *
+ */
+package org.apache.uima.tm.dltk.validator;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.resource.metadata.ConfigurationParameterSettings;
+import org.apache.uima.tm.dltk.internal.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.tm.textmarker.engine.TextMarkerEngine;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IMethod;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+
+
+/**
+ * @author Martin Toepfer
+ *
+ */
+public class TextMarkerCheckerUtils {
+
+ public static Set<String> importScript(String path, int type, IScriptProject project)
+ throws InvalidXMLException, IOException, ModelException {
+ return importScript(path, type, project, false);
+ }
+
+ /**
+ * @param path
+ * relative to script folder of the project.<br>
+ * i.e.: "org.apache.uima.tm.MyScript"
+ * @param type
+ * i.e. IModelElement.FIELD for fields to be collected and returned
+ * @return
+ * @throws InvalidXMLException
+ * @throws IOException
+ * @throws ModelException
+ */
+ public static Set<String> importScript(String path, int type, IScriptProject project,
+ boolean appendPath) throws InvalidXMLException, IOException, ModelException {
+ Stack<String> namespaceStack = new Stack<String>();
+
+ final Set<String> imports = new HashSet<String>();
+ List<IFolder> scriptFolders = null;
+ try {
+ scriptFolders = TextMarkerProjectUtils.getAllScriptFolders(project);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ String fileNameWithoutExtension = path.substring(path.lastIndexOf('.') + 1);
+ String fileNameWithExtension = fileNameWithoutExtension + ".tm";
+ ISourceModule sourceModule = null;
+ boolean found = false;
+ for (IFolder eachFolder : scriptFolders) {
+
+ IScriptProject sp = DLTKCore.create(eachFolder.getProject());
+ IScriptFolder[] scriptFolders2 = sp.getScriptFolders();
+ for (IScriptFolder iScriptFolder : scriptFolders2) {
+ sourceModule = iScriptFolder.getSourceModule(fileNameWithExtension);
+ if (sourceModule.exists() && sourceModule.getResource() != null
+ && sourceModule.getResource().exists()) {
+ found = true;
+ break;
+ }
+ if (found)
+ break;
+ }
+ }
+ IModelElement elements[] = null;
+ namespaceStack.push(fileNameWithoutExtension);
+ try {
+ elements = sourceModule.getChildren();
+ for (int i = 0; i < elements.length; i++) {
+ IModelElement modelElement = elements[i];
+ int elementType = modelElement.getElementType();
+ if (elementType == type) {
+ if (elementType == IModelElement.METHOD) {
+ imports.add(namespaceStack.peek() + "." + modelElement.getElementName());
+ } else if (appendPath) {
+ imports.add(path + "." + modelElement.getElementName());
+ } else {
+ imports.add(modelElement.getElementName());
+ }
+ }
+ if (elementType == IModelElement.METHOD) {
+ String nSpace = namespaceStack.empty() ? modelElement.getElementName() : namespaceStack
+ .peek()
+ + "." + modelElement.getElementName();
+ namespaceStack.push(nSpace);
+ imports.addAll(collectElements((IMethod) modelElement, type, namespaceStack));
+ namespaceStack.pop();
+ }
+ }
+ } catch (ModelException e) {
+ throw new FileNotFoundException();
+ }
+ return imports;
+ }
+
+ private static Set<String> collectElements(IMethod element, int type, Stack stack)
+ throws ModelException {
+ Set<String> fieldsCollection = new HashSet<String>();
+ IModelElement elements[] = element.getChildren();
+ if (elements == null) {
+ return fieldsCollection;
+ }
+ for (int i = 0; i < elements.length; i++) {
+ IModelElement modelElement = elements[i];
+ int elementType = modelElement.getElementType();
+ if (elementType == type) {
+ if (elementType == IModelElement.FIELD) {
+ fieldsCollection.add(modelElement.getElementName());
+ }
+ fieldsCollection.add(stack.peek() + "." + modelElement.getElementName());
+ }
+ if (elementType == IModelElement.METHOD) {
+ stack.push(stack.peek() + "." + modelElement.getElementName());
+ fieldsCollection.addAll(collectElements((IMethod) modelElement, type, stack));
+ stack.pop();
+ }
+ }
+ return fieldsCollection;
+ }
+
+ public static IFile getFile(IFolder folder, String filePath) {
+ int lastDot = filePath.lastIndexOf('.');
+ int sndLastDot = filePath.lastIndexOf('.', lastDot - 1);
+ String fName = filePath;
+ if (sndLastDot >= 0) {
+ String subFolder = filePath.substring(0, sndLastDot);
+ folder = folder.getFolder(subFolder);
+ fName = filePath.substring(sndLastDot + 1);
+ }
+ return folder.getFile(fName);
+ }
+
+ /**
+ * @param xmlFilePath
+ * absolute full path. i.e.: "de.uniwue.myengine" ".xml" will be added.
+ * @return file.exists
+ */
+ public static boolean checkEngineImport(String xmlFilePath, IScriptProject project) {
+ boolean result = false;
+ List<IFolder> allDescriptorFolders;
+ try {
+ allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
+ } catch (CoreException e) {
+ return false;
+ }
+ for (IFolder folder : allDescriptorFolders) {
+ String fileExtended = xmlFilePath.replaceAll("[.]", "/") + ".xml";
+ IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+ result |= iFile.exists();
+ }
+ return result;
+ }
+
+ public static boolean checkScriptImport(String xmlFilePath, IScriptProject project) {
+ boolean result = false;
+ List<IFolder> allDescriptorFolders;
+ try {
+ allDescriptorFolders = TextMarkerProjectUtils.getAllScriptFolders(project);
+ } catch (CoreException e) {
+ return false;
+ }
+ for (IFolder folder : allDescriptorFolders) {
+ String fileExtended = xmlFilePath.replaceAll("[.]", "/") + ".tm";
+ IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+ result |= iFile.exists();
+ }
+ return result;
+ }
+
+ /**
+ * @param resourceFilePath
+ * absolute full path. i.e.: "de.uniwue.TestList.txt"
+ * @return file.exists
+ */
+ public static boolean checkRessourceExistence(String resourceFilePath, IScriptProject project) {
+ IFolder ddlFolder = project.getProject().getFolder(
+ TextMarkerProjectUtils.getDefaultDescriptorLocation());
+ final String basicXML = "BasicEngine.xml";
+ IFile file = getFile(ddlFolder, basicXML);
+ AnalysisEngineDescription aed;
+ try {
+ URL url = file.getLocationURI().toURL();
+ aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(url));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ ConfigurationParameterSettings configurationParameterSettings = aed.getAnalysisEngineMetaData()
+ .getConfigurationParameterSettings();
+ String[] paths = (String[]) configurationParameterSettings
+ .getParameterValue(TextMarkerEngine.RESOURCE_PATHS);
+ if (paths == null) {
+ IFolder folder = project.getProject().getFolder(
+ TextMarkerProjectUtils.getDefaultResourcesLocation());
+ String defaultPath = folder.getLocation().toPortableString();
+ paths = new String[] { defaultPath };
+ }
+ for (String string : paths) {
+ File iFile = new File(string, resourceFilePath);
+ // IFile iFile = getFile(folder, ressourceFilePath);
+ if (iFile.exists()) {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ /**
+ * @param xmlFilePath
+ * absolute full path. i.e.: "de.uniwue.myengine" ".xml" will be added.
+ * @return file.exists
+ */
+ public static IFile getEngine(String xmlFilePath, IScriptProject project) {
+ IFolder folder = project.getProject().getFolder(
+ TextMarkerProjectUtils.getDefaultDescriptorLocation());
+ String fileExtended = xmlFilePath + ".xml";
+ return getFile(folder, fileExtended);
+ }
+
+ public static boolean checkTypeSystemImport(String localPath, IScriptProject project) {
+ boolean result = false;
+ List<IFolder> allDescriptorFolders;
+ try {
+ allDescriptorFolders = TextMarkerProjectUtils.getAllDescriptorFolders(project.getProject());
+ } catch (CoreException e) {
+ return false;
+ }
+ for (IFolder folder : allDescriptorFolders) {
+ String fileExtended = localPath.replaceAll("[.]", "/") + ".xml";
+ IFile iFile = TextMarkerCheckerUtils.getFile(folder, fileExtended);
+ result |= iFile.exists();
+ }
+ return result;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerCheckerUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,218 @@
+package org.apache.uima.tm.dltk.validator;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.uima.tm.dltk.parser.ast.TMActionConstants;
+import org.apache.uima.tm.dltk.parser.ast.TMStatementConstants;
+import org.apache.uima.tm.dltk.parser.ast.TextMarkerImportStatement;
+import org.apache.uima.tm.dltk.parser.ast.actions.TextMarkerAction;
+import org.apache.uima.util.InvalidXMLException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.statements.Statement;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemReporter;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+
+public class TextMarkerEngineAndCallChecker implements IBuildParticipant,
+ IBuildParticipantExtension {
+
+ /**
+ * @author Martin Toepfer
+ *
+ */
+ private class EngineAndCallCheckerVisitor extends ASTVisitor {
+ private IProblemReporter rep;
+
+ private TextMarkerCheckerProblemFactory problemFactory;
+
+ private Set<String> engines;
+
+ private Set<String> scripts;
+
+ private String curFile;
+
+ private HashSet<String> scriptsInnerBlocks;
+
+ public EngineAndCallCheckerVisitor(IProblemReporter rep, ISourceLineTracker linetracker,
+ String curFile) {
+ this.problemFactory = new TextMarkerCheckerProblemFactory(curFile, linetracker);
+ this.rep = rep;
+ this.engines = new HashSet<String>();
+ this.scripts = new HashSet<String>();
+ this.scriptsInnerBlocks = new HashSet<String>();
+ this.curFile = curFile;
+
+ if (curFile != null && curFile.endsWith(".tm")) {
+ scripts.add(curFile.substring(0, curFile.length() - 3));
+ }
+ try {
+ String fnwe = curFile.substring(0, curFile.length() - 3);
+ scriptsInnerBlocks.addAll(TextMarkerCheckerUtils.importScript(fnwe, IModelElement.METHOD,
+ project));
+ } catch (InvalidXMLException e) {
+ } catch (IOException e) {
+ } catch (ModelException e) {
+ }
+ }
+
+ @Override
+ public boolean visit(Statement s) throws Exception {
+ if (s instanceof TextMarkerImportStatement) {
+ // handle engine imports
+ if (((TextMarkerImportStatement) s).getType() == TMStatementConstants.S_IMPORT_ENGINE) {
+ SimpleReference sRef = (SimpleReference) ((TextMarkerImportStatement) s).getExpression();
+ if (TextMarkerCheckerUtils.checkEngineImport(sRef.getName(), project)) {
+ importEngine(sRef.getName());
+ } else {
+ IProblem problem = problemFactory.createFileNotFoundProblem(sRef);
+ rep.reportProblem(problem);
+ }
+ }
+ // handle script imports
+ if (((TextMarkerImportStatement) s).getType() == TMStatementConstants.S_IMPORT_SCRIPT) {
+ SimpleReference stRef = (SimpleReference) ((TextMarkerImportStatement) s).getExpression();
+ String sRefName = stRef.getName();
+ try {
+ Set<String> blocks = TextMarkerCheckerUtils.importScript(sRefName,
+ IModelElement.METHOD, project);
+ scripts.add(sRefName);
+ if (!blocks.isEmpty()) {
+ scriptsInnerBlocks.addAll(blocks);
+ }
+ } catch (Exception e) {
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ private void importEngine(String name) {
+ engines.add(name);
+ int i = name.lastIndexOf('.');
+ if (i > 1) {
+ // TODO emit errors for doublettes (names in scripts and
+ // engines)
+ String lastPart = name.substring(i + 1);
+ if (lastPart != null && lastPart.length() != 0) {
+ engines.add(lastPart);
+ }
+ }
+ }
+
+ @Override
+ public boolean visit(Expression s) throws Exception {
+ if (s instanceof TextMarkerAction) {
+ TextMarkerAction action = (TextMarkerAction) s;
+ if (action.getKind() == TMActionConstants.A_CALL) {
+ // TODO see antlr grammar: no viable child defined!
+ if (action.getChilds().size() > 0) {
+ SimpleReference ref = (SimpleReference) action.getChilds().get(0);
+ if (ref != null && !engines.contains(ref.getName())) {
+ String required = ref.getName();
+ for (String script : scripts) {
+ // check direct script-call
+ boolean a = script.endsWith(required);
+ if (a) {
+ return false;
+ }
+ }
+ for (String block : scriptsInnerBlocks) {
+ boolean b = block.equals(required);
+ if (b) {
+ return false;
+ }
+ }
+ IProblem problem = problemFactory.createFileNotFoundProblem(ref);
+ rep.reportProblem(problem);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean visit(MethodDeclaration s) throws Exception {
+ return true;
+ }
+
+ @Override
+ public boolean visit(TypeDeclaration s) throws Exception {
+ return false;
+ }
+ }
+
+ public TextMarkerEngineAndCallChecker(IScriptProject project) throws CoreException {
+ this.project = project;
+ }
+
+ private IScriptProject project;
+
+ public boolean beginBuild(int buildType) {
+ return true;
+ }
+
+ public void endBuild(IProgressMonitor monitor) {
+ }
+
+ public void build(IBuildContext context) throws CoreException {
+ // getAST:
+ Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+ if (!(mdObj instanceof ModuleDeclaration)) {
+ return;
+ }
+ ModuleDeclaration md = (ModuleDeclaration) mdObj;
+ IProblemReporter problemReporter = context.getProblemReporter();
+ ISourceModule smod = context.getSourceModule();
+
+ // traverse:
+ ISourceLineTracker linetracker = context.getLineTracker();
+ String fileName = smod.getElementName();
+ try {
+ ASTVisitor visitor = new EngineAndCallCheckerVisitor(problemReporter, linetracker, fileName);
+ md.traverse(visitor);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // /**
+ // * @param filePath
+ // * absolute full path. i.e.: "de.uniwue.myengine" ".xml" will be
+ // * added.
+ // * @return file.exists
+ // */
+ // private boolean checkBlockCall(String filePath) {
+ // // try engine
+ // if (checkEngineImport(filePath)) {
+ // return true;
+ // }
+ // String fileExtended = filePath + ".tm";
+ // IFolder scriptFolder = project.getProject().getFolder(
+ // TextMarkerLanguageToolkit.getDefault()
+ // .getDefaultDescriptorLocation());
+ // IFile iFile = getFile(scriptFolder, fileExtended);
+ // return iFile.exists();
+ // }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerEngineAndCallChecker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java?rev=1152804&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java Mon Aug 1 14:37:34 2011
@@ -0,0 +1,206 @@
+package org.apache.uima.tm.dltk.validator;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.tm.dltk.internal.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.tm.dltk.parser.ast.expressions.TextMarkerRessourceReference;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemReporter;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+import org.eclipse.dltk.core.builder.ISourceLineTracker;
+
+
+public class TextMarkerRessourceChecker implements IBuildParticipant, IBuildParticipantExtension {
+
+ /**
+ * @author Martin Toepfer
+ *
+ */
+ private class TypeCheckerVisitor extends ASTVisitor {
+ private IProblemReporter rep;
+
+ private String currentFile;
+
+ private ISourceLineTracker linetracker;
+
+ private Set<String> types;
+
+ private TextMarkerCheckerProblemFactory problemFactory;
+
+ private String packageName;
+
+ private static final String errMsgHead = "Cannot find resource \"";
+
+ private static final String errMsgTailDefault = " \" in resource location.";
+
+ public TypeCheckerVisitor(IProblemReporter rep, ISourceLineTracker linetracker, String curFile,
+ Set<String> types) {
+ this.problemFactory = new TextMarkerCheckerProblemFactory(curFile, linetracker);
+ this.linetracker = linetracker;
+ this.rep = rep;
+ this.packageName = "";
+ this.currentFile = curFile;
+ this.types = types;
+ }
+
+ @Override
+ public boolean visit(Expression s) throws Exception {
+ // traverse everything but RessourceReference
+ if (!(s instanceof TextMarkerRessourceReference)) {
+ return true;
+ }
+ TextMarkerRessourceReference resRef = (TextMarkerRessourceReference) s;
+ if (TextMarkerCheckerUtils.checkRessourceExistence(resRef.getValue(), project)) {
+ return false;
+ }
+ // ressource not valid
+ String errMsg = errMsgHead + resRef.getValue() + errMsgTailDefault;
+ IProblem problem = new TextMarkerCheckerDefaultProblem(currentFile, errMsg, resRef,
+ linetracker.getLineNumberOfOffset(resRef.sourceStart()));
+ rep.reportProblem(problem);
+ return false;
+ }
+ }
+
+ public TextMarkerRessourceChecker(IScriptProject project) throws CoreException {
+ this.project = project;
+ }
+
+ private IScriptProject project;
+
+ public boolean beginBuild(int buildType) {
+ return true;
+ }
+
+ public void endBuild(IProgressMonitor monitor) {
+ }
+
+ public void build(IBuildContext context) throws CoreException {
+ // getAST:
+ Object mdObj = context.get(IBuildContext.ATTR_MODULE_DECLARATION);
+ if (!(mdObj instanceof ModuleDeclaration)) {
+ return;
+ }
+ ModuleDeclaration md = (ModuleDeclaration) mdObj;
+ IProblemReporter problemReporter = context.getProblemReporter();
+ ISourceModule smod = context.getSourceModule();
+
+ // get Types:
+ Set<String> types = null;
+ try {
+ types = importBasicTypeSystem();
+ } catch (InvalidXMLException e1) {
+ System.err.println("ERROR: Failed to get BasicTypeSystem!! " + this.toString());
+ // problemReporter.reportProblem(problem)
+ } catch (IOException e1) {
+ System.err.println("ERROR: Failed to get BasicTypeSystem!! " + this.toString());
+ }
+ if (types == null) {
+ types = new HashSet<String>();
+ }
+
+ // traverse:
+ ISourceLineTracker linetracker = context.getLineTracker();
+ String fileName = smod.getElementName();
+ try {
+ ASTVisitor visitor = new TypeCheckerVisitor(problemReporter, linetracker, fileName, types);
+ md.traverse(visitor);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private Set<String> importBasicTypeSystem() throws InvalidXMLException, IOException {
+ final String basicXmlFile = "BasicTypeSystem";
+ Set<String> types = importTypeSystem(basicXmlFile);
+ types.add("Annotation");
+ types.add("DocumentAnnotation");
+ return types;
+ }
+
+ /**
+ * @param xmlFilePath
+ * absolute full path. i.e.: "de.uniwue.mytypes" ".xml" will be added.
+ * @return
+ * @throws InvalidXMLException
+ * @throws IOException
+ * when file not found
+ */
+ private Set<String> importTypeSystem(String xmlFilePath) throws InvalidXMLException, IOException {
+ IFolder folder = project.getProject().getFolder(
+ TextMarkerProjectUtils.getDefaultDescriptorLocation());
+ String fileExtended = xmlFilePath + ".xml";
+ return getTypes(folder, fileExtended);
+ }
+
+ private Set<String> getTypes(IFolder folder, String filePath) throws InvalidXMLException,
+ IOException {
+ Set<String> types = new HashSet<String>();
+ IFile iFile = getFile(folder, filePath);
+ URL url;
+ try {
+ url = iFile.getLocationURI().toURL();
+ types = getTypes(url);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return types;
+ }
+
+ private IFile getFile(IFolder folder, String filePath) {
+ int lastDot = filePath.lastIndexOf('.');
+ int sndLastDot = filePath.lastIndexOf('.', lastDot - 1);
+ String fName = filePath;
+ if (sndLastDot >= 0) {
+ String subFolder = filePath.substring(0, sndLastDot);
+ folder = folder.getFolder(subFolder);
+ fName = filePath.substring(sndLastDot + 1);
+ }
+ return folder.getFile(fName);
+ }
+
+ private Set<String> getTypes(URL resource) throws IOException, InvalidXMLException {
+ Set<String> types = new HashSet<String>();
+ TypeSystemDescription typeSysDescr = null;
+ typeSysDescr = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+ new XMLInputSource(resource));
+ for (TypeDescription each : typeSysDescr.getTypes()) {
+ String name = each.getName();
+ String[] nameSpace = name.split("[.]");
+ types.add(nameSpace[nameSpace.length - 1]);
+ StringBuffer fullName = new StringBuffer();
+ if (nameSpace.length > 0) {
+ fullName.append(nameSpace[0]);
+ }
+ for (int i = 1; i < nameSpace.length; i++) {
+ // TODO fix workaround
+ if (!nameSpace[i].equals("type")) {
+ fullName.append('.');
+ fullName.append(nameSpace[i]);
+ }
+ }
+ types.add(fullName.toString());
+ }
+ return types;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.dltk.validator/src/main/java/org/apache/uima/tm/dltk/validator/TextMarkerRessourceChecker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain